init
This commit is contained in:
11
node_modules/@dcloudio/uni-h5/src/platforms/mp-xhs/runtime/api/index.js
generated
vendored
Normal file
11
node_modules/@dcloudio/uni-h5/src/platforms/mp-xhs/runtime/api/index.js
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
export {
|
||||
getPushClientId,
|
||||
onPushMessage,
|
||||
offPushMessage,
|
||||
invokePushCallback
|
||||
}
|
||||
from 'uni-core/service/api/plugin/push'
|
||||
export {
|
||||
__f__
|
||||
}
|
||||
from 'uni-core/service/api/plugin/__f__'
|
||||
24
node_modules/@dcloudio/uni-h5/src/platforms/mp-xhs/runtime/api/protocols.js
generated
vendored
Normal file
24
node_modules/@dcloudio/uni-h5/src/platforms/mp-xhs/runtime/api/protocols.js
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
// import navigateTo from 'uni-helpers/navigate-to'
|
||||
// import redirectTo from '../../../mp-weixin/helpers/redirect-to'
|
||||
// import previewImage from '../../../mp-weixin/helpers/normalize-preview-image'
|
||||
import getSystemInfo from '../../../mp-weixin/helpers/system-info'
|
||||
// import getUserProfile from '../../../mp-weixin/helpers/get-user-profile'
|
||||
|
||||
// 需要做转换的 API 列表
|
||||
export const protocols = {
|
||||
// navigateTo,
|
||||
// redirectTo,
|
||||
// previewImage,
|
||||
getSystemInfo,
|
||||
getSystemInfoSync: getSystemInfo
|
||||
// getUserProfile
|
||||
}
|
||||
|
||||
// 不支持的 API 列表
|
||||
// TODO: 补充
|
||||
export const todos = [
|
||||
'getSelectedTextRange'
|
||||
]
|
||||
|
||||
// 存在兼容性的 API 列表
|
||||
export const canIUses = []
|
||||
6
node_modules/@dcloudio/uni-h5/src/platforms/mp-xhs/runtime/api/providers.js
generated
vendored
Normal file
6
node_modules/@dcloudio/uni-h5/src/platforms/mp-xhs/runtime/api/providers.js
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
export default {
|
||||
oauth: ['xhs'],
|
||||
share: ['xhs'],
|
||||
payment: ['xhs'],
|
||||
push: ['xhs']
|
||||
}
|
||||
1
node_modules/@dcloudio/uni-h5/src/platforms/mp-xhs/runtime/index.js
generated
vendored
Normal file
1
node_modules/@dcloudio/uni-h5/src/platforms/mp-xhs/runtime/index.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
import '../../mp-weixin/runtime/index'
|
||||
17
node_modules/@dcloudio/uni-h5/src/platforms/mp-xhs/runtime/web-view.js
generated
vendored
Normal file
17
node_modules/@dcloudio/uni-h5/src/platforms/mp-xhs/runtime/web-view.js
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
const isXhs = window.xhs &&
|
||||
window.xhs.miniProgram &&
|
||||
/xhsminiapp/i.test(navigator.userAgent)
|
||||
|
||||
export function initWebviewApi (readyCallback) {
|
||||
if (!isXhs) {
|
||||
return
|
||||
}
|
||||
// todo 没有 XhsJSBridgeReady
|
||||
// if (window.XhsJSBridgeReady && window.XhsJSBridgeReady.invoke) {
|
||||
// setTimeout(readyCallback, 0)
|
||||
// } else {
|
||||
// document.addEventListener('XhsJSBridgeReady', readyCallback)
|
||||
// }
|
||||
|
||||
return window.xhs.miniProgram
|
||||
}
|
||||
5
node_modules/@dcloudio/uni-h5/src/platforms/mp-xhs/runtime/wrapper/app-parser.js
generated
vendored
Normal file
5
node_modules/@dcloudio/uni-h5/src/platforms/mp-xhs/runtime/wrapper/app-parser.js
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
import parseBaseApp from '../../../mp-weixin/runtime/wrapper/app-parser'
|
||||
|
||||
export default function parseApp (vm) {
|
||||
return parseBaseApp(vm)
|
||||
}
|
||||
36
node_modules/@dcloudio/uni-h5/src/platforms/mp-xhs/runtime/wrapper/component-parser.js
generated
vendored
Normal file
36
node_modules/@dcloudio/uni-h5/src/platforms/mp-xhs/runtime/wrapper/component-parser.js
generated
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
// import parseBaseComponent from '../../../mp-weixin/runtime/wrapper/component-parser'
|
||||
|
||||
// export default function parseComponent (vueComponentOptions) {
|
||||
// const componentOptions = parseBaseComponent(vueComponentOptions)
|
||||
// // 小红书小程序 lifetimes 存在兼容问题
|
||||
// const lifetimes = componentOptions.lifetimes
|
||||
// Object.keys(lifetimes).forEach(key => {
|
||||
// componentOptions[key] = lifetimes[key]
|
||||
// })
|
||||
// return componentOptions
|
||||
// }
|
||||
|
||||
import parseBaseComponent from '../../../mp-weixin/runtime/wrapper/component-parser'
|
||||
|
||||
import { isPage } from '../../../mp-weixin/runtime/wrapper/util'
|
||||
|
||||
import {
|
||||
fixSetDataStart,
|
||||
fixSetDataEnd
|
||||
} from '../../../mp-weixin/runtime/wrapper/fix-set-data'
|
||||
|
||||
export default function parseComponent (vueComponentOptions, needVueOptions) {
|
||||
const [componentOptions, vueOptions] = parseBaseComponent(vueComponentOptions, true)
|
||||
const oldAttached = componentOptions.lifetimes.attached
|
||||
componentOptions.lifetimes.attached = function attached () {
|
||||
// 暂不区分版本
|
||||
if (isPage.call(this)) {
|
||||
fixSetDataStart(this)
|
||||
setTimeout(() => {
|
||||
fixSetDataEnd(this)
|
||||
}, 0)
|
||||
}
|
||||
oldAttached.call(this)
|
||||
}
|
||||
return needVueOptions ? [componentOptions, vueOptions] : componentOptions
|
||||
}
|
||||
98
node_modules/@dcloudio/uni-h5/src/platforms/mp-xhs/runtime/wrapper/page-parser.js
generated
vendored
Normal file
98
node_modules/@dcloudio/uni-h5/src/platforms/mp-xhs/runtime/wrapper/page-parser.js
generated
vendored
Normal file
@@ -0,0 +1,98 @@
|
||||
import Vue from 'vue'
|
||||
|
||||
import {
|
||||
stringifyQuery
|
||||
} from 'uni-shared/query'
|
||||
|
||||
import {
|
||||
initData,
|
||||
initHooks,
|
||||
initUnknownHooks,
|
||||
handleEvent,
|
||||
initBehaviors,
|
||||
initVueComponent,
|
||||
PAGE_EVENT_HOOKS
|
||||
} from 'uni-wrapper/util'
|
||||
|
||||
import { handleLink, initBehavior } from '../../../mp-weixin/runtime/wrapper/util'
|
||||
|
||||
import {
|
||||
handleWrap,
|
||||
initSpecialMethods
|
||||
} from './util'
|
||||
|
||||
const hooks = [
|
||||
'onShow',
|
||||
'onHide',
|
||||
'onUnload'
|
||||
]
|
||||
|
||||
hooks.push(...PAGE_EVENT_HOOKS)
|
||||
|
||||
export default function parsePage (vuePageOptions) {
|
||||
const [VueComponent, vueOptions] = initVueComponent(Vue, vuePageOptions)
|
||||
|
||||
const pageOptions = {
|
||||
mixins: initBehaviors(vueOptions, initBehavior),
|
||||
data: initData(vueOptions, Vue.prototype),
|
||||
onLoad (query) {
|
||||
const properties = this.props
|
||||
|
||||
this.__query = query
|
||||
this.__options = {
|
||||
mpType: 'page',
|
||||
mpInstance: this,
|
||||
propsData: properties
|
||||
}
|
||||
},
|
||||
onReady () {
|
||||
// initChildVues(this)
|
||||
// 初始化 vue 实例
|
||||
this.$vm = new VueComponent(this.__options)
|
||||
|
||||
// 触发首次 setData
|
||||
this.$vm.$mount()
|
||||
|
||||
initSpecialMethods(this)
|
||||
this.$vm._isMounted = true
|
||||
this.$vm.__call_hook('mounted')
|
||||
|
||||
// mounted => onLoad
|
||||
this.options = this.__query
|
||||
this.$vm.$mp.query = this.__query // 兼容 mpvue
|
||||
const copyQuery = Object.assign({}, this.__query)
|
||||
delete copyQuery.__id__
|
||||
this.$page = {
|
||||
fullPath: '/' + this.route + stringifyQuery(copyQuery)
|
||||
}
|
||||
|
||||
this.$vm.__call_hook('onLoad', this.__query)
|
||||
this.$vm.__call_hook('onShow')
|
||||
setTimeout(() => {
|
||||
this.$vm.__call_hook('onReady')
|
||||
})
|
||||
},
|
||||
onUnload () {
|
||||
this.$vm.__call_hook('onUnload')
|
||||
this.$vm.$destroy()
|
||||
},
|
||||
// __r: handleRef,
|
||||
__e: handleEvent,
|
||||
__l: handleLink,
|
||||
__w: handleWrap,
|
||||
triggerEvent: function noop () {}
|
||||
}
|
||||
|
||||
initHooks(pageOptions, hooks, vueOptions)
|
||||
initUnknownHooks(pageOptions, vueOptions, ['onReady'])
|
||||
|
||||
if (Array.isArray(vueOptions.wxsCallMethods)) {
|
||||
vueOptions.wxsCallMethods.forEach(callMethod => {
|
||||
pageOptions[callMethod] = function (args) {
|
||||
return this.$vm[callMethod](args)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
return pageOptions
|
||||
}
|
||||
52
node_modules/@dcloudio/uni-h5/src/platforms/mp-xhs/runtime/wrapper/util.js
generated
vendored
Normal file
52
node_modules/@dcloudio/uni-h5/src/platforms/mp-xhs/runtime/wrapper/util.js
generated
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
import {
|
||||
isFn,
|
||||
hasOwn
|
||||
} from 'uni-shared'
|
||||
|
||||
export const isComponent2 = xhs.canIUse('component2')
|
||||
|
||||
export const mocks = ['$id']
|
||||
|
||||
export function initSpecialMethods (mpInstance) {
|
||||
if (!mpInstance.$vm) {
|
||||
return
|
||||
}
|
||||
let path = mpInstance.is || mpInstance.route
|
||||
if (!path) {
|
||||
return
|
||||
}
|
||||
if (path.indexOf('/') === 0) {
|
||||
path = path.substr(1)
|
||||
}
|
||||
const specialMethods = xhs.specialMethods && xhs.specialMethods[path]
|
||||
if (specialMethods) {
|
||||
specialMethods.forEach(method => {
|
||||
if (isFn(mpInstance.$vm[method])) {
|
||||
mpInstance[method] = function (event) {
|
||||
if (hasOwn(event, 'markerId')) {
|
||||
event.detail = typeof event.detail === 'object' ? event.detail : {}
|
||||
event.detail.markerId = event.markerId
|
||||
}
|
||||
// TODO normalizeEvent
|
||||
mpInstance.$vm[method](event)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
export const handleWrap = function (mp, destory) {
|
||||
const vueId = mp.props.vueId
|
||||
const list = (mp.props['data-event-list'] || '').split(',')
|
||||
list.forEach(eventName => {
|
||||
const key = `${eventName}${vueId}`
|
||||
if (destory) {
|
||||
delete this[key]
|
||||
} else {
|
||||
// TODO remove handleRef
|
||||
this[key] = function () {
|
||||
mp.props[eventName].apply(this, arguments)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user