@mpxjs/store 2.9.1 → 2.9.11-test.0

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 CHANGED
@@ -6,7 +6,6 @@ type UnboxDepField<D, F> = F extends keyof D ? D[F] : {}
6
6
  type GetReturnOrSelf<T> = T extends (...args: any)=> infer R ? R : T
7
7
 
8
8
  interface compContext {
9
- __mpxProxy: object;
10
9
  [key: string]: any
11
10
  }
12
11
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mpxjs/store",
3
- "version": "2.9.1",
3
+ "version": "2.9.11-test.0",
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.1"
29
+ "@mpxjs/utils": "^2.8.40-test.2"
30
30
  },
31
31
  "peerDependencies": {
32
32
  "@mpxjs/core": "^2.9.0"
33
33
  },
34
- "gitHead": "5460efb7afae97e321ff608258a8c0ad0b366f4c"
34
+ "gitHead": "d244d661acb081b709fc99ca8f6add541f793877"
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
- context.__mpxProxy.options.computed = context.__mpxProxy.options.computed || {}
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
- context.__mpxProxy.options.computed = context.__mpxProxy.options.computed || {}
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)