-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from aotianwinter/test
update v0.1.2
- Loading branch information
Showing
10 changed files
with
184 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { mapState, mapActions } from 'vuex' | ||
|
||
const appMixin = { | ||
computed: { | ||
...mapState({ | ||
setting: state => state.app.setting | ||
}) | ||
}, | ||
methods: { | ||
...mapActions([ | ||
'getSetting', | ||
'initSetting', | ||
'updateSetting' | ||
]) | ||
} | ||
} | ||
|
||
export default appMixin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import { appDB } from '@/core/datastore' | ||
|
||
const state = { | ||
setting: {} // app setting | ||
} | ||
|
||
const mutations = { | ||
GET_SETTING (state, obj) { | ||
state.setting = obj | ||
} | ||
} | ||
|
||
const actions = { | ||
getSetting ({ commit }) { | ||
return new Promise((resolve, reject) => { | ||
appDB.findOne({}, (err, docs) => { | ||
if (err) { | ||
reject(err) | ||
} else { | ||
console.log() | ||
if (docs) commit('GET_SETTING', docs) | ||
resolve(docs) | ||
} | ||
}) | ||
}) | ||
}, | ||
initSetting ({ commit }, val) { | ||
if (val.logs) delete val.logs | ||
return new Promise((resolve, reject) => { | ||
appDB.insert({ ...val }, (err, docs) => { | ||
if (err) { | ||
reject(err) | ||
} else { | ||
console.log(docs) | ||
resolve() | ||
} | ||
}) | ||
}) | ||
}, | ||
updateSetting ({ commit }, val) { | ||
if (val.logs) delete val.logs | ||
return new Promise((resolve, reject) => { | ||
appDB.update({ _id: val._id }, { ...val }, (err, numReplaced) => { | ||
if (err) { | ||
reject(err) | ||
} else { | ||
console.log(numReplaced) | ||
resolve() | ||
} | ||
}) | ||
}) | ||
} | ||
} | ||
|
||
export default { | ||
state, | ||
mutations, | ||
actions | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// el is the document node need to bottom | ||
function toBottom (el) { | ||
const cubic = value => Math.pow(value, 3) | ||
const easeInOutCubic = value => value < 0.5 | ||
? cubic(value * 2) / 2 | ||
: 1 - cubic((1 - value) * 2) / 2 | ||
const beginTime = Date.now() | ||
const bottomValue = el.scrollHeight | ||
const rAF = window.requestAnimationFrame || (func => setTimeout(func, 16)) | ||
const frameFunc = () => { | ||
const progress = (Date.now() - beginTime) / 500 | ||
if (progress < 1) { | ||
el.scrollTop += bottomValue * easeInOutCubic(progress) | ||
rAF(frameFunc) | ||
} else { | ||
el.scrollTop = bottomValue | ||
} | ||
} | ||
rAF(frameFunc) | ||
} | ||
|
||
export default toBottom |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters