2019-10-24 16:01:11 +08:00
|
|
|
/*
|
|
|
|
* @Author: Volankey@gmail.com
|
|
|
|
* @Company: Tusimple
|
2019-10-25 19:28:04 +08:00
|
|
|
* @Date: 2019-10-25 11:31:12
|
2019-10-24 16:01:11 +08:00
|
|
|
* @LastEditors: Jiwen.bai
|
2019-10-25 19:28:04 +08:00
|
|
|
* @LastEditTime: 2019-10-25 11:33:00
|
2019-10-24 16:01:11 +08:00
|
|
|
*/
|
2019-10-25 19:28:04 +08:00
|
|
|
let Vue = null
|
|
|
|
export class Store {
|
|
|
|
constructor (options = {}) {
|
|
|
|
const store = this
|
|
|
|
store._vm = new Vue({
|
|
|
|
data: {
|
|
|
|
$$state: {
|
|
|
|
currentHoverRow: 1
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
get state () {
|
|
|
|
return this._vm._data.$$state
|
|
|
|
}
|
|
|
|
commit (type, payload) {
|
|
|
|
Vue.set(this._vm._data.$$state, type, payload)
|
|
|
|
// this.state[type] = payload
|
|
|
|
}
|
|
|
|
}
|
2019-10-24 16:01:11 +08:00
|
|
|
|
2019-10-25 19:28:04 +08:00
|
|
|
function vuexInit () {
|
|
|
|
const options = this.$options
|
|
|
|
const _Vue = options.Vue
|
|
|
|
if (_Vue) {
|
|
|
|
Vue = _Vue
|
|
|
|
}
|
|
|
|
// store injection
|
|
|
|
if (options.store) {
|
|
|
|
this.$store =
|
|
|
|
typeof options.store === 'function' ? options.store() : options.store
|
|
|
|
} else if (options.parent && options.parent.$store) {
|
|
|
|
this.$store = options.parent.$store
|
2019-10-24 16:01:11 +08:00
|
|
|
}
|
|
|
|
}
|
2019-10-25 19:28:04 +08:00
|
|
|
export const storageMixin = {
|
|
|
|
beforeCreate: vuexInit
|
|
|
|
}
|