@mpxjs/core 2.10.6-beta.5 → 2.10.7-beta.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mpxjs/core",
3
- "version": "2.10.6-beta.5",
3
+ "version": "2.10.7-beta.1",
4
4
  "description": "mpx runtime core",
5
5
  "keywords": [
6
6
  "miniprogram",
@@ -19,7 +19,7 @@
19
19
  ],
20
20
  "main": "src/index.js",
21
21
  "dependencies": {
22
- "@mpxjs/utils": "^2.10.6 | ^2.10.6-beta.1",
22
+ "@mpxjs/utils": "^2.10.7 | ^2.10.7-beta.1",
23
23
  "lodash": "^4.1.1",
24
24
  "miniprogram-api-typings": "^3.10.0"
25
25
  },
@@ -25,7 +25,8 @@ export default function getBuiltInMixins ({ type, rawOptions = {} }) {
25
25
  styleHelperMixin(),
26
26
  refsMixin(),
27
27
  i18nMixin(),
28
- relationsMixin(type)
28
+ relationsMixin(type),
29
+ pageRouteMixin(type)
29
30
  ]
30
31
  } else if (isWeb) {
31
32
  bulitInMixins = [
@@ -0,0 +1,27 @@
1
+ import { BEFORECREATE } from '../../core/innerLifecycle'
2
+ import { EventChannel } from '@mpxjs/api-proxy/src/platform/api/event-channel/index'
3
+ export default function pageRouteMixin (mixinType) {
4
+ if (mixinType === 'page') {
5
+ return {
6
+ [BEFORECREATE] () {
7
+ const mpxEventChannel = global.__mpxEventChannel
8
+ if (mpxEventChannel.route === this.route) {
9
+ this._eventChannel = mpxEventChannel.eventChannel
10
+ } else {
11
+ this._eventChannel = new EventChannel()
12
+ }
13
+ },
14
+ methods: {
15
+ getOpenerEventChannel () {
16
+ return this._eventChannel
17
+ }
18
+ }
19
+ }
20
+ }
21
+ return {
22
+ methods: {
23
+ getOpenerEventChannel () {
24
+ }
25
+ }
26
+ }
27
+ }
@@ -1,15 +1,20 @@
1
+ import { EventChannel } from '@mpxjs/api-proxy/src/platform/api/event-channel/index'
1
2
  // web专用mixin,在web页面上挂载route属性
2
3
  export default function pageRouteMixin (mixinType) {
3
4
  if (mixinType === 'page') {
4
5
  return {
5
6
  beforeCreate () {
6
7
  this.route = this.$options.__mpxPageRoute || ''
8
+ const mpxEventChannel = global.__mpxEventChannel || {}
9
+ if (mpxEventChannel.route === this.route) {
10
+ this._eventChannel = mpxEventChannel.eventChannel
11
+ } else {
12
+ this._eventChannel = new EventChannel()
13
+ }
7
14
  },
8
15
  methods: {
9
16
  getOpenerEventChannel () {
10
- const router = global.__mpxRouter
11
- const eventChannel = router && router.eventChannelMap[this.route]
12
- return eventChannel || {}
17
+ return this._eventChannel
13
18
  }
14
19
  }
15
20
  }
@@ -422,7 +422,7 @@ function usePageStatus (navigation, pageId) {
422
422
  function usePagePreload (route) {
423
423
  const name = route.name
424
424
  useEffect(() => {
425
- const timer = setTimeout(() => {
425
+ setTimeout(() => {
426
426
  const preloadRule = global.__preloadRule || {}
427
427
  const { packages } = preloadRule[name] || {}
428
428
  if (packages?.length > 0) {
@@ -432,10 +432,6 @@ function usePagePreload (route) {
432
432
  }
433
433
  }
434
434
  }, 800)
435
-
436
- return () => {
437
- clearTimeout(timer)
438
- }
439
435
  }, [])
440
436
  }
441
437