@mpxjs/store 2.9.0 → 2.9.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/@types/index.d.ts +0 -1
- package/package.json +4 -4
- package/src/mapStore.js +8 -4
package/@types/index.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mpxjs/store",
|
|
3
|
-
"version": "2.9.
|
|
3
|
+
"version": "2.9.9",
|
|
4
4
|
"description": "A store for mpx framework",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"types": "@types/index.d.ts",
|
|
@@ -26,10 +26,10 @@
|
|
|
26
26
|
},
|
|
27
27
|
"homepage": "https://github.com/didi/mpx#readme",
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@mpxjs/utils": "^2.9.
|
|
29
|
+
"@mpxjs/utils": "^2.9.1"
|
|
30
30
|
},
|
|
31
31
|
"peerDependencies": {
|
|
32
|
-
"@mpxjs/core": "^2.
|
|
32
|
+
"@mpxjs/core": "^2.9.0"
|
|
33
33
|
},
|
|
34
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "7ec6526f024c00f9c6b935c631bfdc61be27b69b"
|
|
35
35
|
}
|
package/src/mapStore.js
CHANGED
|
@@ -82,6 +82,12 @@ function checkMapInstance (args) {
|
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
+
function mapComputedToInstance (result, context) {
|
|
86
|
+
const options = __mpx_mode__ === 'web' ? context.$options : context.__mpxProxy.options
|
|
87
|
+
options.computed = options.computed || {}
|
|
88
|
+
Object.assign(options.computed, result)
|
|
89
|
+
}
|
|
90
|
+
|
|
85
91
|
export default function (store) {
|
|
86
92
|
const mapState = mapFactory('state', store)
|
|
87
93
|
const mapGetters = mapFactory('getters', store)
|
|
@@ -113,14 +119,12 @@ export default function (store) {
|
|
|
113
119
|
const { context, restParams } = checkMapInstance(args)
|
|
114
120
|
const result = mapState(...restParams)
|
|
115
121
|
// 将result挂载到mpxProxy实例属性上
|
|
116
|
-
|
|
117
|
-
Object.assign(context.__mpxProxy.options.computed, result)
|
|
122
|
+
mapComputedToInstance(result, context)
|
|
118
123
|
},
|
|
119
124
|
mapGettersToInstance: (...args) => {
|
|
120
125
|
const { context, restParams } = checkMapInstance(args)
|
|
121
126
|
const result = mapGetters(...restParams)
|
|
122
|
-
|
|
123
|
-
Object.assign(context.__mpxProxy.options.computed, result)
|
|
127
|
+
mapComputedToInstance(result, context)
|
|
124
128
|
},
|
|
125
129
|
mapMutationsToInstance: (...args) => {
|
|
126
130
|
const { context, restParams } = checkMapInstance(args)
|