@mpxjs/core 2.6.114-alpha.0 → 2.6.114-alpha.3

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/README.md CHANGED
@@ -1,4 +1,3 @@
1
1
  # 小程序框架 [**MPX** 介绍文档](https://didi.github.io/mpx)
2
2
 
3
3
  ## 跨平台代码编写指南
4
-
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mpxjs/core",
3
- "version": "2.6.114-alpha.0",
3
+ "version": "2.6.114-alpha.3",
4
4
  "description": "mpx runtime core",
5
5
  "keywords": [
6
6
  "miniprogram",
@@ -43,5 +43,5 @@
43
43
  "url": "https://github.com/didi/mpx/issues"
44
44
  },
45
45
  "sideEffects": false,
46
- "gitHead": "7f944d9d7fe0dd3bd0a798c6268c6d08f90d62c0"
46
+ "gitHead": "951dd877934ec6233bfb67452b790dc982317ccd"
47
47
  }
@@ -4,7 +4,7 @@ import { mergeLifecycle } from './mergeLifecycle'
4
4
  import { error } from '../helper/log'
5
5
  import { isObject, diffAndCloneA, hasOwn } from '../helper/utils'
6
6
  import { implemented } from '../core/implement'
7
- import { CREATED } from '../core/innerLifecycle'
7
+ import { CREATED, DESTROYED } from '../core/innerLifecycle'
8
8
 
9
9
  // 暂不支持的wx选项,后期需要各种花式支持
10
10
  const unsupported = [
@@ -49,7 +49,8 @@ export default {
49
49
  support: true,
50
50
  // wx输出tenon时额外将onLoad代理到CREATED
51
51
  lifecycleProxyMap: Object.assign({}, wxLifecycle.lifecycleProxyMap, {
52
- [CREATED]: ['created', 'attached', 'onLoad']
52
+ [CREATED]: ['created', 'attached', 'onLoad'],
53
+ [DESTROYED]: ['destroyed', 'detached', 'onUnload', 'unmounted']
53
54
  }),
54
55
  convert (options) {
55
56
  const props = Object.assign({}, options.properties, options.props)
@@ -208,7 +208,7 @@ class Store {
208
208
  const getter = this.__wrappedGetters[k]
209
209
  computedObj[k] = () => getter(this.state)
210
210
  Object.defineProperty(this.getters, k, {
211
- get: () => Vue.computed(() => computedObj[k]()).value,
211
+ get: () => computedObj[k](),
212
212
  enumerable: true // for local getters
213
213
  })
214
214
  })
@@ -8,9 +8,14 @@ export default function pageStatusMixin (mixinType) {
8
8
  },
9
9
  onShow () {
10
10
  this.mpxPageStatus = 'show'
11
+ this.onShow && this.onShow()
11
12
  },
12
13
  onHide () {
13
14
  this.mpxPageStatus = 'hide'
15
+ this.onHide && this.onHide()
16
+ },
17
+ onBack () {
18
+ this.onBack && this.onBack()
14
19
  }
15
20
  }
16
21
  }
@@ -26,12 +26,21 @@ export default function proxyEventMixin () {
26
26
  return {
27
27
  beforeCreate () {
28
28
  const modelEvent = this.$attrs.mpxModelEvent
29
- if (modelEvent) {
30
- this.$on(modelEvent, (e) => {
29
+ const modelEventId = this.$attrs.mpxModelEventId
30
+ if (modelEvent && modelEventId) {
31
+ Hummer.notifyCenter.addEventListener(modelEventId, (e) => {
31
32
  this.$emit('mpxModel', e)
32
33
  })
33
34
  }
34
35
  },
36
+ beforeDestroy () {
37
+ const modelEvent = this.$attrs.mpxModelEvent
38
+ const modelEventId = this.$attrs.mpxModelEventId
39
+ if (modelEvent && modelEventId) {
40
+ Hummer.notifyCenter.removeEventListener(modelEventId)
41
+ }
42
+ },
43
+
35
44
  methods
36
45
  }
37
46
  }
@@ -30,23 +30,24 @@ function initProxy (context, rawOptions) {
30
30
  // 创建proxy对象
31
31
  const mpxProxy = new MPXProxy(rawOptions, context)
32
32
  context.__mpxProxy = mpxProxy
33
- context.__mpxProxy.created()
33
+ context.__mpxProxy.created(Hummer.pageInfo && Hummer.pageInfo.params && [Hummer.pageInfo.params])
34
34
  }
35
35
 
36
- export function getDefaultOptions (type, { rawOptions = {} }) {
36
+ export function getDefaultOptions (type, { rawOptions = {}, currentInject }) {
37
+ const hookNames = type === 'page' ? ['onLoad', 'onReady', 'onUnload'] : ['created', 'mounted', 'unmounted']
37
38
  const rootMixins = [{
38
- created () {
39
+ [hookNames[0]] (...params) {
39
40
  if (!this.__mpxProxy) {
40
- initProxy(this, rawOptions)
41
+ initProxy(this, rawOptions, currentInject, params)
41
42
  }
42
43
  },
43
- mounted () {
44
- this.__mpxProxy && this.__mpxProxy.mounted()
44
+ [hookNames[1]] () {
45
+ this.__mpxProxy && this.__mpxProxy.mounted(Hummer.pageInfo && Hummer.pageInfo.params && [Hummer.pageInfo.params])
45
46
  },
46
47
  updated () {
47
48
  this.__mpxProxy && this.__mpxProxy.updated()
48
49
  },
49
- destroyed () {
50
+ [hookNames[2]] () {
50
51
  this.__mpxProxy && this.__mpxProxy.destroyed()
51
52
  }
52
53
  }]
@@ -9,7 +9,9 @@ const COMPONENT_HOOKS = [
9
9
  // 'deactivated',
10
10
  'beforeDestroy',
11
11
  'destroyed',
12
- 'errorCaptured'
12
+ 'errorCaptured',
13
+ 'beforeUnmount',
14
+ 'unmounted'
13
15
  // 'onPageNotFound'
14
16
  ]
15
17
 
@@ -20,6 +22,7 @@ const PAGE_HOOKS = [
20
22
  'onShow',
21
23
  'onHide',
22
24
  'onUnload'
25
+ // 'onBack',
23
26
  // 'onPullDownRefresh',
24
27
  // 'onReachBottom',
25
28
  // 'onPageScroll',