提交 3e11d7ba 编写于 作者: fxy060608's avatar fxy060608

feat(h5): export wx

上级 e089b89d
......@@ -19,6 +19,11 @@ const uniInjectPluginOptions: Partial<InjectOptions> = {
'@dcloudio/uni-h5',
((method: string) => apiJson.includes(method)) as any, // API白名单
],
// 兼容 wx 对象
'wx.': [
'@dcloudio/uni-h5',
((method: string) => apiJson.includes(method)) as any, // API白名单
],
getApp: ['@dcloudio/uni-h5', 'getApp'],
getCurrentPages: ['@dcloudio/uni-h5', 'getCurrentPages'],
UniServiceJSBridge: ['@dcloudio/uni-h5', 'UniServiceJSBridge'],
......
......@@ -77,12 +77,12 @@ const hmrCode = `if(import.meta.hot){
function getGlobal(ssr?: boolean) {
return ssr ? 'global' : 'window'
}
// 兼容 wx 对象
function registerGlobalCode(config: ResolvedConfig, ssr?: boolean) {
const name = getGlobal(ssr)
if (config.command === 'build' && !ssr) {
// 非SSR的发行模式,补充全局 uni 对象
return `${name}.uni = {}`
return `${name}.uni = {};${name}.wx = {}`
}
const rpx2pxCode =
......@@ -95,6 +95,7 @@ function registerGlobalCode(config: ResolvedConfig, ssr?: boolean) {
import {uni,getCurrentPages,getApp,UniServiceJSBridge,UniViewJSBridge} from '@dcloudio/uni-h5'
${name}.getApp = getApp
${name}.getCurrentPages = getCurrentPages
${name}.wx = uni
${name}.uni = uni
${name}.UniViewJSBridge = UniViewJSBridge
${name}.UniServiceJSBridge = UniServiceJSBridge
......
......@@ -40,7 +40,7 @@
"@types/sass": "^1.16.0"
},
"uni-app": {
"compilerVersion": "3.2.2"
"compilerVersion": "3.2.3"
},
"gitHead": "d5896d19315a106039411c16bbf8b804a865450d"
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册