@dcloudio/uni-h5 2.0.0 → 2.0.1-32920211122002
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/dist/automator.js +1 -1
- package/dist/index.css +1 -1
- package/dist/index.umd.min.js +1 -1
- package/lib/apis.js +14 -4
- package/lib/h5/uni.automator.js +1 -1
- package/lib/modules.json +4 -1
- package/manifest.json +49 -0
- package/package.json +2 -3
- package/src/core/helpers/api.js +1 -1
- package/src/core/helpers/constants.js +1 -0
- package/src/core/helpers/i18n/en.json +4 -2
- package/src/core/helpers/i18n/es.json +4 -1
- package/src/core/helpers/i18n/fr.json +4 -1
- package/src/core/helpers/i18n/index.js +155 -4
- package/src/core/helpers/i18n/zh-Hans.json +4 -1
- package/src/core/helpers/i18n/zh-Hant.json +4 -1
- package/src/core/helpers/index.js +1 -1
- package/src/core/helpers/interceptor.js +19 -15
- package/src/core/helpers/promise.js +1 -1
- package/src/core/helpers/protocol/device/set-clipboard-data.js +11 -2
- package/src/core/helpers/protocol/network/request.js +14 -1
- package/src/core/helpers/protocol/network/upload-file.js +1 -1
- package/src/core/helpers/protocol/ui/popup.js +2 -2
- package/src/core/runtime/base.js +2 -0
- package/src/core/runtime/locale.js +37 -0
- package/src/core/runtime/web-view/index.js +4 -0
- package/src/core/runtime/wrapper/create-subpackage-app.js +7 -6
- package/src/core/runtime/wrapper/util.js +6 -1
- package/src/core/service/api/base/interceptor.js +1 -1
- package/src/core/service/api/context/canvas.js +3 -2
- package/src/core/service/api/context/create-map-context.js +8 -1
- package/src/core/service/api/ui/locale.js +50 -0
- package/src/core/service/plugins/app/create-app.js +8 -3
- package/src/core/service/plugins/app/index.js +2 -2
- package/src/core/service/plugins/index.js +8 -2
- package/src/core/view/bridge/subscribe/api/request-component-observer.js +16 -1
- package/src/core/view/components/canvas/index.vue +3 -1
- package/src/core/view/components/editor/formats/image.js +3 -1
- package/src/core/view/components/editor/formats/index.js +3 -1
- package/src/core/view/components/editor/formats/link.js +9 -0
- package/src/core/view/components/editor/index.vue +33 -3
- package/src/core/view/components/image/index.vue +4 -5
- package/src/core/view/components/input/index.vue +53 -25
- package/src/core/view/components/picker-view-column/index.vue +1 -0
- package/src/core/view/components/progress/index.vue +20 -13
- package/src/core/view/components/rich-text/index.vue +13 -1
- package/src/core/view/components/rich-text/nodes-parser.js +23 -4
- package/src/core/view/components/scroll-view/index.vue +253 -122
- package/src/core/view/components/slider/index.vue +1 -1
- package/src/core/view/components/swiper/index.vue +3 -0
- package/src/core/view/components/textarea/index.vue +7 -3
- package/src/core/view/index.css +4 -0
- package/src/core/view/mixins/field.js +27 -9
- package/src/core/view/mixins/interact.js +13 -11
- package/src/core/view/mixins/keyboard.js +42 -26
- package/src/core/view/mixins/touchtrack.js +2 -2
- package/src/core/view/plugins/index.js +1 -1
- package/src/platforms/app-plus/constants.js +1 -0
- package/src/platforms/app-plus/helpers/get-real-path.js +7 -4
- package/src/platforms/app-plus/helpers/uuid.js +1 -1
- package/src/platforms/app-plus/service/api/ad/ad-base.js +159 -0
- package/src/platforms/app-plus/service/api/ad/ad.js +4 -8
- package/src/platforms/app-plus/service/api/ad/full-screen-video-ad.js +5 -98
- package/src/platforms/app-plus/service/api/ad/interactive-ad.js +257 -0
- package/src/platforms/app-plus/service/api/ad/interstitial-ad.js +15 -0
- package/src/platforms/app-plus/service/api/ad/rewarded-video-ad.js +15 -2
- package/src/platforms/app-plus/service/api/device/system.js +3 -2
- package/src/platforms/app-plus/service/api/file/open-document.js +7 -15
- package/src/platforms/app-plus/service/api/index.js +2 -0
- package/src/platforms/app-plus/service/api/location/get-location.js +8 -7
- package/src/platforms/app-plus/service/api/media/choose-image.js +22 -51
- package/src/platforms/app-plus/service/api/media/choose-video.js +19 -36
- package/src/platforms/app-plus/service/api/media/compress-video.js +2 -2
- package/src/platforms/app-plus/service/api/media/get-video-info.js +5 -2
- package/src/platforms/app-plus/service/api/network/request.js +27 -1
- package/src/platforms/app-plus/service/api/network/upload-file.js +1 -1
- package/src/platforms/app-plus/service/api/plugin/oauth.js +140 -8
- package/src/platforms/app-plus/service/api/storage/storage.js +1 -1
- package/src/platforms/app-plus/service/api/ui/popup.js +21 -11
- package/src/platforms/app-plus/service/api/ui/tab-bar.js +3 -2
- package/src/platforms/app-plus/service/api/util.js +5 -1
- package/src/platforms/app-plus/service/framework/app.js +21 -5
- package/src/platforms/app-plus/service/framework/config.js +1 -0
- package/src/platforms/app-plus/service/framework/plugins/index.js +8 -2
- package/src/platforms/app-plus/service/framework/plugins/lifecycle.js +2 -2
- package/src/platforms/app-plus/service/framework/subscribe-handlers/index.js +1 -1
- package/src/platforms/app-plus/service/framework/tab-bar.js +12 -2
- package/src/platforms/app-plus/service/framework/webview/index.js +2 -2
- package/src/platforms/app-plus/service/framework/webview/parser/title-nview-parser.js +73 -30
- package/src/platforms/app-plus/service/framework/webview/parser/webview-style-parser.js +16 -16
- package/src/platforms/app-plus/service/index.js +10 -3
- package/src/platforms/app-plus/service/publish-handler.js +3 -0
- package/src/platforms/app-plus/view/bridge/subscribe/index.js +5 -3
- package/src/platforms/app-plus/view/components/ad/index.vue +53 -44
- package/src/platforms/app-plus/view/components/cover-view/index.vue +13 -7
- package/src/platforms/app-plus/view/components/map/index.vue +29 -27
- package/src/platforms/app-plus/view/components/video/index.vue +40 -24
- package/src/platforms/app-plus/view/framework/plugins/gesture.js +17 -0
- package/src/platforms/app-plus/view/framework/plugins/index.js +3 -1
- package/src/platforms/app-plus/view/index.css +4 -0
- package/src/platforms/app-plus/view/mixins/cover.js +10 -15
- package/src/platforms/app-plus/view/mixins/native.js +45 -3
- package/src/platforms/app-plus-nvue/service/api/context/operate-map-player.js +3 -0
- package/src/platforms/h5/components/app/observable.js +3 -2
- package/src/platforms/h5/components/app/popup/mixins/modal.js +3 -3
- package/src/platforms/h5/components/app/popup/modal.vue +38 -2
- package/src/platforms/h5/components/app/popup/toast.vue +9 -1
- package/src/platforms/h5/components/app/tabBar.vue +39 -17
- package/src/platforms/h5/components/page/index.vue +5 -3
- package/src/platforms/h5/components/page/pageHead.vue +94 -75
- package/src/platforms/h5/components/system-routes/choose-location/index.vue +127 -66
- package/src/platforms/h5/components/system-routes/open-location/index.vue +193 -38
- package/src/platforms/h5/helpers/location.js +26 -0
- package/src/platforms/h5/helpers/todo-api.js +2 -2
- package/src/platforms/h5/service/api/device/clipboard.js +41 -0
- package/src/platforms/h5/service/api/device/get-system-info.js +75 -0
- package/src/platforms/h5/service/api/location/get-location.js +47 -18
- package/src/platforms/h5/service/api/media/MIMEType.js +53 -0
- package/src/platforms/h5/service/api/media/choose-file.js +9 -1
- package/src/platforms/h5/service/api/media/choose-image.js +9 -2
- package/src/platforms/h5/service/api/media/choose-video.js +9 -1
- package/src/platforms/h5/service/api/media/create_input.js +12 -3
- package/src/platforms/h5/service/api/ui/popup.js +3 -5
- package/src/platforms/h5/service/api/ui/tab-bar.js +1 -1
- package/src/platforms/h5/service/index.js +5 -0
- package/src/platforms/h5/view/bridge/subscribe/index.js +3 -2
- package/src/platforms/h5/view/components/ad/index.vue +112 -69
- package/src/platforms/h5/view/components/map/index.vue +96 -349
- package/src/platforms/h5/view/components/map/map-marker.js +287 -0
- package/src/platforms/h5/view/components/map/maps/callout.js +117 -0
- package/src/platforms/h5/view/components/map/maps/index.js +55 -0
- package/src/platforms/h5/view/components/video/index.vue +1 -1
- package/src/platforms/h5/view/index.css +4 -0
- package/src/platforms/mp-alipay/runtime/api/protocols.js +30 -3
- package/src/platforms/mp-baidu/runtime/api/protocols.js +5 -0
- package/src/platforms/mp-baidu/runtime/wrapper/component-parser.js +20 -18
- package/src/platforms/mp-baidu/runtime/wrapper/util.js +2 -1
- package/src/platforms/mp-kuaishou/runtime/api/protocols.js +3 -1
- package/src/platforms/mp-kuaishou/runtime/wrapper/component-parser.js +21 -1
- package/src/platforms/mp-lark/runtime/api/index.js +0 -0
- package/src/platforms/mp-lark/runtime/api/protocols.js +68 -0
- package/src/platforms/mp-lark/runtime/api/providers.js +6 -0
- package/src/platforms/mp-lark/runtime/index.js +1 -0
- package/src/platforms/mp-lark/runtime/web-view.js +11 -0
- package/src/platforms/mp-lark/runtime/wrapper/app-parser.js +33 -0
- package/src/platforms/mp-lark/runtime/wrapper/component-parser.js +50 -0
- package/src/platforms/mp-lark/runtime/wrapper/page-parser.js +39 -0
- package/src/platforms/mp-lark/runtime/wrapper/util.js +64 -0
- package/src/platforms/mp-qq/runtime/api/protocols.js +3 -1
- package/src/platforms/mp-toutiao/runtime/api/protocols.js +2 -0
- package/src/platforms/mp-toutiao/runtime/wrapper/component-parser.js +35 -19
- package/src/platforms/mp-weixin/helpers/get-user-profile.js +6 -0
- package/src/platforms/mp-weixin/runtime/index.js +6 -7
- package/src/platforms/mp-weixin/runtime/wrapper/app-base-parser.js +197 -126
- package/src/platforms/mp-weixin/runtime/wrapper/fix-set-data.js +37 -0
- package/src/shared/uni-id-mixin.js +77 -0
- package/src/shared/util.js +2 -0
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import navigateTo from 'uni-helpers/navigate-to'
|
|
2
|
+
import redirectTo from '../../../mp-weixin/helpers/redirect-to'
|
|
3
|
+
import previewImage from '../../../mp-weixin/helpers/normalize-preview-image'
|
|
4
|
+
import getSystemInfo from '../../../mp-weixin/helpers/system-info'
|
|
5
|
+
import getUserProfile from '../../../mp-weixin/helpers/get-user-profile'
|
|
6
|
+
|
|
7
|
+
// 需要做转换的 API 列表
|
|
8
|
+
export const protocols = {
|
|
9
|
+
navigateTo,
|
|
10
|
+
redirectTo,
|
|
11
|
+
previewImage,
|
|
12
|
+
getSystemInfo,
|
|
13
|
+
getSystemInfoSync: getSystemInfo,
|
|
14
|
+
getUserProfile,
|
|
15
|
+
connectSocket: {
|
|
16
|
+
args: {
|
|
17
|
+
method: false
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
chooseVideo: {
|
|
21
|
+
args: {
|
|
22
|
+
camera: false
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
scanCode: {
|
|
26
|
+
args: {
|
|
27
|
+
onlyFromCamera: false
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
startAccelerometer: {
|
|
31
|
+
args: {
|
|
32
|
+
interval: false
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
showToast: {
|
|
36
|
+
args: {
|
|
37
|
+
image: false
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
showModal: {
|
|
41
|
+
args: {
|
|
42
|
+
cancelColor: false,
|
|
43
|
+
confirmColor: false
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
showActionSheet: {
|
|
47
|
+
args: {
|
|
48
|
+
itemColor: false,
|
|
49
|
+
alertText: false
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
login: {
|
|
53
|
+
args: {
|
|
54
|
+
scopes: false,
|
|
55
|
+
timeout: false
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
getUserInfo: {
|
|
59
|
+
args: {
|
|
60
|
+
lang: false,
|
|
61
|
+
timeout: false
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export const todos = []
|
|
67
|
+
|
|
68
|
+
export const canIUses = []
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '../../mp-weixin/runtime/index'
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
const isLark = window.tt &&
|
|
2
|
+
window.tt.miniProgram &&
|
|
3
|
+
/Lark|Feishu/i.test(navigator.userAgent)
|
|
4
|
+
|
|
5
|
+
export function initWebviewApi (readyCallback) {
|
|
6
|
+
if (!isLark) {
|
|
7
|
+
return
|
|
8
|
+
}
|
|
9
|
+
document.addEventListener('DOMContentLoaded', readyCallback)
|
|
10
|
+
return window.tt.miniProgram
|
|
11
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import Vue from 'vue'
|
|
2
|
+
|
|
3
|
+
import parseBaseApp from '../../../mp-weixin/runtime/wrapper/app-base-parser'
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
mocks,
|
|
7
|
+
initRefs
|
|
8
|
+
} from './util'
|
|
9
|
+
|
|
10
|
+
export default function parseApp (vm) {
|
|
11
|
+
Vue.prototype._$fallback = true // 降级(调整原 vue 的部分生命周期,如 created,beforeMount,inject,provide)
|
|
12
|
+
|
|
13
|
+
Vue.mixin({
|
|
14
|
+
created () { // 处理 injections, triggerEvent 是异步,且触发时机很慢,故延迟 relation 设置
|
|
15
|
+
if (this.mpType !== 'app') {
|
|
16
|
+
if (this.mpType === 'page' && !this.$scope.route && this.$scope.__route__
|
|
17
|
+
) {
|
|
18
|
+
this.$scope.route = this.$scope.__route__
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
initRefs(this)
|
|
22
|
+
|
|
23
|
+
this.__init_injections(this)
|
|
24
|
+
this.__init_provide(this)
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
return parseBaseApp(vm, {
|
|
30
|
+
mocks,
|
|
31
|
+
initRefs: function () {} // attached 时,可能查询不到
|
|
32
|
+
})
|
|
33
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import {
|
|
2
|
+
isPage,
|
|
3
|
+
initRelation,
|
|
4
|
+
handleLink
|
|
5
|
+
} from './util'
|
|
6
|
+
|
|
7
|
+
import {
|
|
8
|
+
initSlots,
|
|
9
|
+
initVueIds
|
|
10
|
+
} from 'uni-wrapper/util'
|
|
11
|
+
|
|
12
|
+
import parseBaseComponent from '../../../mp-weixin/runtime/wrapper/component-base-parser'
|
|
13
|
+
|
|
14
|
+
export default function parseComponent (vueOptions) {
|
|
15
|
+
const [componentOptions, VueComponent] = parseBaseComponent(vueOptions)
|
|
16
|
+
|
|
17
|
+
componentOptions.lifetimes.attached = function attached () {
|
|
18
|
+
const properties = this.properties
|
|
19
|
+
|
|
20
|
+
const options = {
|
|
21
|
+
mpType: isPage.call(this) ? 'page' : 'component',
|
|
22
|
+
mpInstance: this,
|
|
23
|
+
propsData: properties
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
initVueIds(properties.vueId, this)
|
|
27
|
+
|
|
28
|
+
// 初始化 vue 实例
|
|
29
|
+
this.$vm = new VueComponent(options)
|
|
30
|
+
|
|
31
|
+
// 处理$slots,$scopedSlots(暂不支持动态变化$slots)
|
|
32
|
+
initSlots(this.$vm, properties.vueSlots)
|
|
33
|
+
|
|
34
|
+
// 处理父子关系
|
|
35
|
+
initRelation.call(this, {
|
|
36
|
+
vuePid: this._$vuePid,
|
|
37
|
+
mpInstance: this
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
// 触发首次 setData
|
|
41
|
+
this.$vm.$mount()
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// ready 比 handleLink 还早,初始化逻辑放到 handleLink 中
|
|
45
|
+
delete componentOptions.lifetimes.ready
|
|
46
|
+
|
|
47
|
+
componentOptions.methods.__l = handleLink
|
|
48
|
+
|
|
49
|
+
return componentOptions
|
|
50
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import {
|
|
2
|
+
isPage,
|
|
3
|
+
instances,
|
|
4
|
+
initRelation
|
|
5
|
+
} from './util'
|
|
6
|
+
|
|
7
|
+
import parseBasePage from '../../../mp-weixin/runtime/wrapper/page-base-parser'
|
|
8
|
+
|
|
9
|
+
export default function parsePage (vuePageOptions) {
|
|
10
|
+
const pageOptions = parseBasePage(vuePageOptions, {
|
|
11
|
+
isPage,
|
|
12
|
+
initRelation
|
|
13
|
+
})
|
|
14
|
+
// 页面需要在 ready 中触发,其他组件是在 handleLink 中触发
|
|
15
|
+
pageOptions.lifetimes.ready = function ready () {
|
|
16
|
+
if (this.$vm && this.$vm.mpType === 'page') {
|
|
17
|
+
this.$vm.__call_hook('created')
|
|
18
|
+
this.$vm.__call_hook('beforeMount')
|
|
19
|
+
this.$vm._isMounted = true
|
|
20
|
+
this.$vm.__call_hook('mounted')
|
|
21
|
+
this.$vm.__call_hook('onReady')
|
|
22
|
+
} else {
|
|
23
|
+
this.is && console.warn(this.is + ' is not ready')
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
pageOptions.lifetimes.detached = function detached () {
|
|
28
|
+
this.$vm && this.$vm.$destroy()
|
|
29
|
+
// 清理
|
|
30
|
+
const webviewId = this.__webviewId__
|
|
31
|
+
webviewId && Object.keys(instances).forEach(key => {
|
|
32
|
+
if (key.indexOf(webviewId + '_') === 0) {
|
|
33
|
+
delete instances[key]
|
|
34
|
+
}
|
|
35
|
+
})
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return pageOptions
|
|
39
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import {
|
|
2
|
+
findVmByVueId,
|
|
3
|
+
initRefs
|
|
4
|
+
} from '../../../mp-weixin/runtime/wrapper/util'
|
|
5
|
+
|
|
6
|
+
export { initRefs }
|
|
7
|
+
|
|
8
|
+
export const mocks = ['__route__', '__webviewId__', '__nodeid__', '__nodeId__']
|
|
9
|
+
|
|
10
|
+
export const instances = Object.create(null)
|
|
11
|
+
|
|
12
|
+
export function isPage () {
|
|
13
|
+
return this.__nodeid__ === 0 || this.__nodeId__ === 0
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function initRelation ({
|
|
17
|
+
vuePid,
|
|
18
|
+
mpInstance
|
|
19
|
+
}) {
|
|
20
|
+
// triggerEvent 后,接收事件时机特别晚,已经到了 ready 之后
|
|
21
|
+
const nodeId = (mpInstance.__nodeId__ || mpInstance.__nodeid__) + ''
|
|
22
|
+
const webviewId = mpInstance.__webviewId__ + ''
|
|
23
|
+
|
|
24
|
+
instances[webviewId + '_' + nodeId] = mpInstance.$vm
|
|
25
|
+
|
|
26
|
+
this.triggerEvent('__l', {
|
|
27
|
+
vuePid,
|
|
28
|
+
nodeId,
|
|
29
|
+
webviewId
|
|
30
|
+
})
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function handleLink ({
|
|
34
|
+
detail: {
|
|
35
|
+
vuePid,
|
|
36
|
+
nodeId,
|
|
37
|
+
webviewId
|
|
38
|
+
}
|
|
39
|
+
}) {
|
|
40
|
+
const vm = instances[webviewId + '_' + nodeId]
|
|
41
|
+
if (!vm) {
|
|
42
|
+
return
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
let parentVm
|
|
46
|
+
|
|
47
|
+
if (vuePid) {
|
|
48
|
+
parentVm = findVmByVueId(this.$vm, vuePid)
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if (!parentVm) {
|
|
52
|
+
parentVm = this.$vm
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
vm.$parent = parentVm
|
|
56
|
+
vm.$root = parentVm.$root
|
|
57
|
+
parentVm.$children.push(vm)
|
|
58
|
+
|
|
59
|
+
vm.__call_hook('created')
|
|
60
|
+
vm.__call_hook('beforeMount')
|
|
61
|
+
vm._isMounted = true
|
|
62
|
+
vm.__call_hook('mounted')
|
|
63
|
+
vm.__call_hook('onReady')
|
|
64
|
+
}
|
|
@@ -2,13 +2,15 @@ import navigateTo from 'uni-helpers/navigate-to'
|
|
|
2
2
|
import redirectTo from '../../../mp-weixin/helpers/redirect-to'
|
|
3
3
|
import previewImage from '../../../mp-weixin/helpers/normalize-preview-image'
|
|
4
4
|
import getSystemInfo from '../../../mp-weixin/helpers/system-info'
|
|
5
|
+
import getUserProfile from '../../../mp-weixin/helpers/get-user-profile'
|
|
5
6
|
|
|
6
7
|
export const protocols = {
|
|
7
8
|
navigateTo,
|
|
8
9
|
redirectTo,
|
|
9
10
|
previewImage,
|
|
10
11
|
getSystemInfo,
|
|
11
|
-
getSystemInfoSync: getSystemInfo
|
|
12
|
+
getSystemInfoSync: getSystemInfo,
|
|
13
|
+
getUserProfile
|
|
12
14
|
}
|
|
13
15
|
export const todos = [
|
|
14
16
|
'preloadPage',
|
|
@@ -2,6 +2,7 @@ import navigateTo from 'uni-helpers/navigate-to'
|
|
|
2
2
|
import redirectTo from '../../../mp-weixin/helpers/redirect-to'
|
|
3
3
|
import previewImage from '../../../mp-weixin/helpers/normalize-preview-image'
|
|
4
4
|
import getSystemInfo from '../../../mp-weixin/helpers/system-info'
|
|
5
|
+
import getUserProfile from '../../../mp-weixin/helpers/get-user-profile'
|
|
5
6
|
|
|
6
7
|
// 不支持的 API 列表
|
|
7
8
|
const todos = [
|
|
@@ -107,6 +108,7 @@ const protocols = {
|
|
|
107
108
|
previewImage,
|
|
108
109
|
getSystemInfo,
|
|
109
110
|
getSystemInfoSync: getSystemInfo,
|
|
111
|
+
getUserProfile,
|
|
110
112
|
connectSocket: {
|
|
111
113
|
args: {
|
|
112
114
|
method: false
|
|
@@ -11,34 +11,50 @@ import {
|
|
|
11
11
|
|
|
12
12
|
import parseBaseComponent from '../../../mp-weixin/runtime/wrapper/component-base-parser'
|
|
13
13
|
|
|
14
|
+
const components = []
|
|
15
|
+
|
|
14
16
|
export default function parseComponent (vueOptions) {
|
|
15
17
|
const [componentOptions, VueComponent] = parseBaseComponent(vueOptions)
|
|
16
18
|
|
|
19
|
+
// 基础库 2.0 以上 attached 顺序错乱,按照 created 顺序强制纠正
|
|
20
|
+
componentOptions.lifetimes.created = function created () {
|
|
21
|
+
components.push(this)
|
|
22
|
+
}
|
|
23
|
+
|
|
17
24
|
componentOptions.lifetimes.attached = function attached () {
|
|
18
|
-
|
|
25
|
+
this.__lifetimes_attached = function () {
|
|
26
|
+
const properties = this.properties
|
|
19
27
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
28
|
+
const options = {
|
|
29
|
+
mpType: isPage.call(this) ? 'page' : 'component',
|
|
30
|
+
mpInstance: this,
|
|
31
|
+
propsData: properties
|
|
32
|
+
}
|
|
25
33
|
|
|
26
|
-
|
|
34
|
+
initVueIds(properties.vueId, this)
|
|
27
35
|
|
|
28
|
-
|
|
29
|
-
|
|
36
|
+
// 初始化 vue 实例
|
|
37
|
+
this.$vm = new VueComponent(options)
|
|
30
38
|
|
|
31
|
-
|
|
32
|
-
|
|
39
|
+
// 处理$slots,$scopedSlots(暂不支持动态变化$slots)
|
|
40
|
+
initSlots(this.$vm, properties.vueSlots)
|
|
33
41
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
42
|
+
// 处理父子关系
|
|
43
|
+
initRelation.call(this, {
|
|
44
|
+
vuePid: this._$vuePid,
|
|
45
|
+
mpInstance: this
|
|
46
|
+
})
|
|
39
47
|
|
|
40
|
-
|
|
41
|
-
|
|
48
|
+
// 触发首次 setData
|
|
49
|
+
this.$vm.$mount()
|
|
50
|
+
}
|
|
51
|
+
let component = this
|
|
52
|
+
while (component && component.__lifetimes_attached && components[0] && component === components[0]) {
|
|
53
|
+
components.shift()
|
|
54
|
+
component.__lifetimes_attached()
|
|
55
|
+
delete component.__lifetimes_attached
|
|
56
|
+
component = components[0]
|
|
57
|
+
}
|
|
42
58
|
}
|
|
43
59
|
|
|
44
60
|
// ready 比 handleLink 还早,初始化逻辑放到 handleLink 中
|
|
@@ -47,4 +63,4 @@ export default function parseComponent (vueOptions) {
|
|
|
47
63
|
componentOptions.methods.__l = handleLink
|
|
48
64
|
|
|
49
65
|
return componentOptions
|
|
50
|
-
}
|
|
66
|
+
}
|
|
@@ -13,18 +13,17 @@ const customize = cached((str) => {
|
|
|
13
13
|
})
|
|
14
14
|
|
|
15
15
|
function initTriggerEvent (mpInstance) {
|
|
16
|
-
if (__PLATFORM__ === 'mp-weixin' || __PLATFORM__ === 'app-plus') {
|
|
17
|
-
if (!wx.canIUse || !wx.canIUse('nextTick')) {
|
|
18
|
-
return
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
16
|
const oldTriggerEvent = mpInstance.triggerEvent
|
|
22
17
|
mpInstance.triggerEvent = function (event, ...args) {
|
|
23
18
|
return oldTriggerEvent.apply(mpInstance, [customize(event), ...args])
|
|
24
19
|
}
|
|
25
20
|
}
|
|
26
21
|
|
|
27
|
-
function initHook (name, options) {
|
|
22
|
+
function initHook (name, options, isComponent) {
|
|
23
|
+
if (__PLATFORM__ === 'mp-toutiao') {
|
|
24
|
+
// fix by Lxh 字节自定义组件Component构造器文档上写有created,但是实测只触发了lifetimes上的created
|
|
25
|
+
isComponent && (options = options.lifetimes)
|
|
26
|
+
}
|
|
28
27
|
const oldHook = options[name]
|
|
29
28
|
if (!oldHook) {
|
|
30
29
|
options[name] = function () {
|
|
@@ -46,7 +45,7 @@ if (!MPPage.__$wrappered) {
|
|
|
46
45
|
Page.after = MPPage.after
|
|
47
46
|
|
|
48
47
|
Component = function (options = {}) {
|
|
49
|
-
initHook('created', options)
|
|
48
|
+
initHook('created', options, true)
|
|
50
49
|
return MPComponent(options)
|
|
51
50
|
}
|
|
52
51
|
}
|