Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
MuGuiLin
uni-app
提交
fa4a8028
U
uni-app
项目概览
MuGuiLin
/
uni-app
与 Fork 源项目一致
Fork自
DCloud / uni-app
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
fa4a8028
编写于
6月 08, 2020
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(v3): subPackages
上级
9a8202d5
变更
30
展开全部
隐藏空白更改
内联
并排
Showing
30 changed file
with
500 addition
and
154 deletion
+500
-154
lib/apis.js
lib/apis.js
+2
-1
packages/uni-app-plus/dist/index.js
packages/uni-app-plus/dist/index.js
+12
-12
packages/uni-app-plus/dist/index.v3.js
packages/uni-app-plus/dist/index.v3.js
+156
-24
packages/uni-app-plus/lib/plugin/sub-packages-plugin.js
packages/uni-app-plus/lib/plugin/sub-packages-plugin.js
+23
-0
packages/uni-app-plus/lib/uni.config.js
packages/uni-app-plus/lib/uni.config.js
+12
-2
packages/uni-h5/dist/index.umd.min.js
packages/uni-h5/dist/index.umd.min.js
+1
-1
packages/uni-mp-alipay/dist/index.js
packages/uni-mp-alipay/dist/index.js
+14
-13
packages/uni-mp-baidu/dist/index.js
packages/uni-mp-baidu/dist/index.js
+14
-14
packages/uni-mp-qq/dist/index.js
packages/uni-mp-qq/dist/index.js
+14
-13
packages/uni-mp-toutiao/dist/index.js
packages/uni-mp-toutiao/dist/index.js
+14
-13
packages/uni-mp-weixin/dist/index.js
packages/uni-mp-weixin/dist/index.js
+14
-13
packages/uni-quickapp-native/dist/vue.dev.js
packages/uni-quickapp-native/dist/vue.dev.js
+1
-1
packages/uni-quickapp-native/dist/vue.prod.js
packages/uni-quickapp-native/dist/vue.prod.js
+1
-1
packages/uni-quickapp-webview/dist/index.js
packages/uni-quickapp-webview/dist/index.js
+16
-13
packages/vue-cli-plugin-uni/lib/split-chunks.js
packages/vue-cli-plugin-uni/lib/split-chunks.js
+46
-20
packages/webpack-uni-pages-loader/lib/platforms/app-plus/index.js
.../webpack-uni-pages-loader/lib/platforms/app-plus/index.js
+7
-0
src/core/helpers/protocol/plugin/load-sub-package.js
src/core/helpers/protocol/plugin/load-sub-package.js
+15
-0
src/platforms/app-plus/service/api/index.js
src/platforms/app-plus/service/api/index.js
+1
-0
src/platforms/app-plus/service/api/network/request.js
src/platforms/app-plus/service/api/network/request.js
+1
-1
src/platforms/app-plus/service/api/plugin/load-sub-package.js
...platforms/app-plus/service/api/plugin/load-sub-package.js
+21
-0
src/platforms/app-plus/service/api/ui/popup.js
src/platforms/app-plus/service/api/ui/popup.js
+1
-1
src/platforms/app-plus/service/framework/load-sub-package.js
src/platforms/app-plus/service/framework/load-sub-package.js
+85
-0
src/platforms/app-plus/service/framework/page.js
src/platforms/app-plus/service/framework/page.js
+7
-1
src/platforms/app-plus/service/framework/plugins/lifecycle.js
...platforms/app-plus/service/framework/plugins/lifecycle.js
+6
-1
src/platforms/mp-alipay/runtime/api/protocols.js
src/platforms/mp-alipay/runtime/api/protocols.js
+2
-1
src/platforms/mp-baidu/runtime/api/protocols.js
src/platforms/mp-baidu/runtime/api/protocols.js
+3
-3
src/platforms/mp-qq/runtime/api/protocols.js
src/platforms/mp-qq/runtime/api/protocols.js
+2
-1
src/platforms/mp-toutiao/runtime/api/protocols.js
src/platforms/mp-toutiao/runtime/api/protocols.js
+2
-1
src/platforms/mp-weixin/runtime/api/protocols.js
src/platforms/mp-weixin/runtime/api/protocols.js
+2
-1
src/platforms/quickapp-webview/runtime/api/protocols.js
src/platforms/quickapp-webview/runtime/api/protocols.js
+5
-2
未找到文件。
lib/apis.js
浏览文件 @
fa4a8028
...
@@ -206,7 +206,8 @@ const third = [
...
@@ -206,7 +206,8 @@ const third = [
'
setPageMeta
'
,
'
setPageMeta
'
,
'
onNativeEventReceive
'
,
'
onNativeEventReceive
'
,
'
sendNativeEvent
'
,
'
sendNativeEvent
'
,
'
preloadPage
'
'
preloadPage
'
,
'
loadSubPackage
'
]
]
const
ad
=
[
const
ad
=
[
...
...
packages/uni-app-plus/dist/index.js
浏览文件 @
fa4a8028
...
@@ -329,18 +329,18 @@ function upx2px (number, newDeviceWidth) {
...
@@ -329,18 +329,18 @@ function upx2px (number, newDeviceWidth) {
if
(
number
===
0
)
{
if
(
number
===
0
)
{
return
0
return
0
}
}
let
result
=
(
number
/
BASE_DEVICE_WIDTH
)
*
(
newDeviceWidth
||
deviceWidth
);
let
result
=
(
number
/
BASE_DEVICE_WIDTH
)
*
(
newDeviceWidth
||
deviceWidth
);
if
(
result
<
0
)
{
if
(
result
<
0
)
{
result
=
-
result
;
result
=
-
result
;
}
}
result
=
Math
.
floor
(
result
+
EPS
);
result
=
Math
.
floor
(
result
+
EPS
);
if
(
result
===
0
)
{
if
(
result
===
0
)
{
if
(
deviceDPR
===
1
||
!
isIOS
)
{
if
(
deviceDPR
===
1
||
!
isIOS
)
{
re
turn
1
re
sult
=
1
;
}
else
{
}
else
{
re
turn
0.5
re
sult
=
0.5
;
}
}
}
}
return
number
<
0
?
-
result
:
result
return
number
<
0
?
-
result
:
result
}
}
...
...
packages/uni-app-plus/dist/index.v3.js
浏览文件 @
fa4a8028
...
@@ -217,7 +217,8 @@ var serviceContext = (function () {
...
@@ -217,7 +217,8 @@ var serviceContext = (function () {
'
setPageMeta
'
,
'
setPageMeta
'
,
'
onNativeEventReceive
'
,
'
onNativeEventReceive
'
,
'
sendNativeEvent
'
,
'
sendNativeEvent
'
,
'
preloadPage
'
'
preloadPage
'
,
'
loadSubPackage
'
];
];
const
ad
=
[
const
ad
=
[
...
@@ -1627,6 +1628,27 @@ var serviceContext = (function () {
...
@@ -1627,6 +1628,27 @@ var serviceContext = (function () {
getProvider
:
getProvider
getProvider
:
getProvider
});
});
const
loadSubPackage
=
{
root
:
{
type
:
String
,
required
:
true
,
validator
(
value
,
params
)
{
const
subPackages
=
__uniConfig
.
subPackages
;
if
(
!
Array
.
isArray
(
subPackages
)
||
subPackages
.
length
===
0
)
{
return
'
no subPackages
'
}
if
(
!
subPackages
.
find
(
subPackage
=>
subPackage
.
root
===
value
))
{
return
'
root `
'
+
value
+
'
` is not found
'
}
}
}
};
var
require_context_module_0_23
=
/*#__PURE__*/
Object
.
freeze
({
__proto__
:
null
,
loadSubPackage
:
loadSubPackage
});
function
encodeQueryString
(
url
)
{
function
encodeQueryString
(
url
)
{
if
(
typeof
url
!==
'
string
'
)
{
if
(
typeof
url
!==
'
string
'
)
{
return
url
return
url
...
@@ -1814,7 +1836,7 @@ var serviceContext = (function () {
...
@@ -1814,7 +1836,7 @@ var serviceContext = (function () {
}
}
};
};
var
require_context_module_0_2
3
=
/*#__PURE__*/
Object
.
freeze
({
var
require_context_module_0_2
4
=
/*#__PURE__*/
Object
.
freeze
({
__proto__
:
null
,
__proto__
:
null
,
redirectTo
:
redirectTo
,
redirectTo
:
redirectTo
,
reLaunch
:
reLaunch
,
reLaunch
:
reLaunch
,
...
@@ -1859,7 +1881,7 @@ var serviceContext = (function () {
...
@@ -1859,7 +1881,7 @@ var serviceContext = (function () {
const
removeStorage
=
getStorage
;
const
removeStorage
=
getStorage
;
const
removeStorageSync
=
getStorageSync
;
const
removeStorageSync
=
getStorageSync
;
var
require_context_module_0_2
4
=
/*#__PURE__*/
Object
.
freeze
({
var
require_context_module_0_2
5
=
/*#__PURE__*/
Object
.
freeze
({
__proto__
:
null
,
__proto__
:
null
,
getStorage
:
getStorage
,
getStorage
:
getStorage
,
getStorageSync
:
getStorageSync
,
getStorageSync
:
getStorageSync
,
...
@@ -1896,7 +1918,7 @@ var serviceContext = (function () {
...
@@ -1896,7 +1918,7 @@ var serviceContext = (function () {
}
}
};
};
var
require_context_module_0_2
5
=
/*#__PURE__*/
Object
.
freeze
({
var
require_context_module_0_2
6
=
/*#__PURE__*/
Object
.
freeze
({
__proto__
:
null
,
__proto__
:
null
,
loadFontFace
:
loadFontFace
loadFontFace
:
loadFontFace
});
});
...
@@ -1939,7 +1961,7 @@ var serviceContext = (function () {
...
@@ -1939,7 +1961,7 @@ var serviceContext = (function () {
}
}
};
};
var
require_context_module_0_2
6
=
/*#__PURE__*/
Object
.
freeze
({
var
require_context_module_0_2
7
=
/*#__PURE__*/
Object
.
freeze
({
__proto__
:
null
,
__proto__
:
null
,
setNavigationBarColor
:
setNavigationBarColor
,
setNavigationBarColor
:
setNavigationBarColor
,
setNavigationBarTitle
:
setNavigationBarTitle
setNavigationBarTitle
:
setNavigationBarTitle
...
@@ -1959,7 +1981,7 @@ var serviceContext = (function () {
...
@@ -1959,7 +1981,7 @@ var serviceContext = (function () {
}
}
};
};
var
require_context_module_0_2
7
=
/*#__PURE__*/
Object
.
freeze
({
var
require_context_module_0_2
8
=
/*#__PURE__*/
Object
.
freeze
({
__proto__
:
null
,
__proto__
:
null
,
pageScrollTo
:
pageScrollTo
pageScrollTo
:
pageScrollTo
});
});
...
@@ -2080,7 +2102,7 @@ var serviceContext = (function () {
...
@@ -2080,7 +2102,7 @@ var serviceContext = (function () {
}
}
};
};
var
require_context_module_0_2
8
=
/*#__PURE__*/
Object
.
freeze
({
var
require_context_module_0_2
9
=
/*#__PURE__*/
Object
.
freeze
({
__proto__
:
null
,
__proto__
:
null
,
showModal
:
showModal
,
showModal
:
showModal
,
showToast
:
showToast
,
showToast
:
showToast
,
...
@@ -2176,7 +2198,7 @@ var serviceContext = (function () {
...
@@ -2176,7 +2198,7 @@ var serviceContext = (function () {
}
}
};
};
var
require_context_module_0_
29
=
/*#__PURE__*/
Object
.
freeze
({
var
require_context_module_0_
30
=
/*#__PURE__*/
Object
.
freeze
({
__proto__
:
null
,
__proto__
:
null
,
setTabBarItem
:
setTabBarItem
,
setTabBarItem
:
setTabBarItem
,
setTabBarStyle
:
setTabBarStyle
,
setTabBarStyle
:
setTabBarStyle
,
...
@@ -2215,13 +2237,14 @@ var serviceContext = (function () {
...
@@ -2215,13 +2237,14 @@ var serviceContext = (function () {
'
./network/socket.js
'
:
require_context_module_0_20
,
'
./network/socket.js
'
:
require_context_module_0_20
,
'
./network/upload-file.js
'
:
require_context_module_0_21
,
'
./network/upload-file.js
'
:
require_context_module_0_21
,
'
./plugin/get-provider.js
'
:
require_context_module_0_22
,
'
./plugin/get-provider.js
'
:
require_context_module_0_22
,
'
./route/route.js
'
:
require_context_module_0_23
,
'
./plugin/load-sub-package.js
'
:
require_context_module_0_23
,
'
./storage/storage.js
'
:
require_context_module_0_24
,
'
./route/route.js
'
:
require_context_module_0_24
,
'
./ui/load-font-face.js
'
:
require_context_module_0_25
,
'
./storage/storage.js
'
:
require_context_module_0_25
,
'
./ui/navigation-bar.js
'
:
require_context_module_0_26
,
'
./ui/load-font-face.js
'
:
require_context_module_0_26
,
'
./ui/page-scroll-to.js
'
:
require_context_module_0_27
,
'
./ui/navigation-bar.js
'
:
require_context_module_0_27
,
'
./ui/popup.js
'
:
require_context_module_0_28
,
'
./ui/page-scroll-to.js
'
:
require_context_module_0_28
,
'
./ui/tab-bar.js
'
:
require_context_module_0_29
,
'
./ui/popup.js
'
:
require_context_module_0_29
,
'
./ui/tab-bar.js
'
:
require_context_module_0_30
,
};
};
var
req
=
function
req
(
key
)
{
var
req
=
function
req
(
key
)
{
...
@@ -6550,7 +6573,7 @@ var serviceContext = (function () {
...
@@ -6550,7 +6573,7 @@ var serviceContext = (function () {
sslVerify
:
!
sslVerify
sslVerify
:
!
sslVerify
};
};
if
(
method
!==
'
GET
'
)
{
if
(
method
!==
'
GET
'
)
{
options
.
body
=
data
;
options
.
body
=
typeof
data
===
'
string
'
?
data
:
JSON
.
stringify
(
data
)
;
}
}
try
{
try
{
stream
.
fetch
(
options
,
({
stream
.
fetch
(
options
,
({
...
@@ -7489,6 +7512,24 @@ var serviceContext = (function () {
...
@@ -7489,6 +7512,24 @@ var serviceContext = (function () {
return
weex
.
requireModule
(
'
plus
'
).
sendNativeEvent
(
event
,
data
,
callback
)
return
weex
.
requireModule
(
'
plus
'
).
sendNativeEvent
(
event
,
data
,
callback
)
}
}
const
SUB_FILENAME
=
'
app-sub-service.js
'
;
function
evaluateScriptFile
(
file
,
callback
)
{
setTimeout
(()
=>
{
callback
();
},
2000
);
}
function
loadSubPackage$1
({
root
},
callbackId
)
{
evaluateScriptFile
(
root
+
'
/
'
+
SUB_FILENAME
,
res
=>
{
invoke$1
(
callbackId
,
{
errMsg
:
'
loadSubPackage:ok
'
});
});
}
let
firstBackTime
=
0
;
let
firstBackTime
=
0
;
function
quit
()
{
function
quit
()
{
...
@@ -8374,6 +8415,92 @@ var serviceContext = (function () {
...
@@ -8374,6 +8415,92 @@ var serviceContext = (function () {
return
pageVm
return
pageVm
}
}
const
loadedSubPackages
=
[];
/**
* 指定路由 ready 后,检查是否触发分包预加载
* @param {Object} route
*/
function
preloadSubPackages
(
route
)
{
if
(
!
__uniConfig
.
preloadRule
)
{
return
}
const
options
=
__uniConfig
.
preloadRule
[
route
];
if
(
!
options
||
!
Array
.
isArray
(
options
.
packages
))
{
return
}
const
packages
=
options
.
packages
.
filter
(
root
=>
loadedSubPackages
.
indexOf
(
root
)
===
-
1
);
if
(
!
packages
.
length
)
{
return
}
const
network
=
options
.
network
||
'
wifi
'
;
if
(
network
===
'
wifi
'
)
{
uni
.
getNetworkType
({
success
(
res
)
{
if
(
process
.
env
.
NODE_ENV
!==
'
production
'
)
{
console
.
log
(
'
UNIAPP[preloadRule]:
'
+
res
.
networkType
+
'
:
'
+
JSON
.
stringify
(
options
));
}
if
(
res
.
networkType
===
'
wifi
'
)
{
loadSubPackages
(
options
.
packages
);
}
}
});
}
else
{
if
(
process
.
env
.
NODE_ENV
!==
'
production
'
)
{
console
.
log
(
'
UNIAPP[preloadRule]:
'
+
JSON
.
stringify
(
options
));
}
loadSubPackages
(
options
.
packages
);
}
}
function
loadPage
(
route
,
callback
)
{
let
isInSubPackage
=
false
;
const
subPackages
=
__uniConfig
.
subPackages
;
if
(
Array
.
isArray
(
subPackages
))
{
const
subPackage
=
subPackages
.
find
(
subPackage
=>
route
.
indexOf
(
subPackage
.
root
)
===
0
);
if
(
subPackage
)
{
isInSubPackage
=
true
;
loadSubPackage$2
(
subPackage
.
root
,
callback
);
}
}
if
(
!
isInSubPackage
)
{
callback
();
}
}
function
loadSubPackage$2
(
root
,
callback
)
{
if
(
loadedSubPackages
.
indexOf
(
root
)
!==
-
1
)
{
return
callback
()
}
loadSubPackages
([
root
],
()
=>
{
callback
();
});
}
function
loadSubPackages
(
packages
,
callback
)
{
if
(
process
.
env
.
NODE_ENV
!==
'
production
'
)
{
console
.
log
(
'
UNIAPP[loadSubPackages]:
'
+
JSON
.
stringify
(
packages
));
}
const
startTime
=
Date
.
now
();
Promise
.
all
(
packages
.
map
(
root
=>
{
// 目前阶段:假定一定会加载成功
loadedSubPackages
.
push
(
root
);
return
uni
.
loadSubPackage
({
root
})
})
).
then
(
res
=>
{
if
(
process
.
env
.
NODE_ENV
!==
'
production
'
)
{
console
.
log
(
'
UNIAPP[loadSubPackages]:
'
+
(
Date
.
now
()
-
startTime
));
}
callback
&&
callback
(
true
);
}).
catch
(
err
=>
{
console
.
log
(
err
);
callback
&&
callback
(
false
);
});
}
const
pages
=
[];
const
pages
=
[];
function
getCurrentPages$1
(
returnAll
)
{
function
getCurrentPages$1
(
returnAll
)
{
...
@@ -8512,7 +8639,9 @@ var serviceContext = (function () {
...
@@ -8512,7 +8639,9 @@ var serviceContext = (function () {
if
(
!
webview
.
nvue
)
{
if
(
!
webview
.
nvue
)
{
const
pageId
=
webview
.
id
;
const
pageId
=
webview
.
id
;
try
{
try
{
createPage
(
route
,
pageId
,
query
,
pageInstance
).
$mount
();
loadPage
(
route
,
()
=>
{
createPage
(
route
,
pageId
,
query
,
pageInstance
).
$mount
();
});
}
catch
(
e
)
{
}
catch
(
e
)
{
console
.
error
(
e
);
console
.
error
(
e
);
}
}
...
@@ -9120,10 +9249,8 @@ var serviceContext = (function () {
...
@@ -9120,10 +9249,8 @@ var serviceContext = (function () {
waiting
.
close
();
waiting
.
close
();
}
}
if
(
~
[
'
top
'
,
'
center
'
,
'
bottom
'
].
indexOf
(
position
))
{
if
(
~
[
'
top
'
,
'
center
'
,
'
bottom
'
].
indexOf
(
position
))
{
const
richText
=
`<span>
${
title
}
</span>`
;
plus
.
nativeUI
.
toast
(
title
,
{
plus
.
nativeUI
.
toast
(
richText
,
{
verticalAlign
:
position
verticalAlign
:
position
,
type
:
'
richtext
'
});
});
toast
=
true
;
toast
=
true
;
toastTimeout
=
setTimeout
(()
=>
{
toastTimeout
=
setTimeout
(()
=>
{
...
@@ -9217,7 +9344,7 @@ var serviceContext = (function () {
...
@@ -9217,7 +9344,7 @@ var serviceContext = (function () {
cancelColor
=
'
#000000
'
,
cancelColor
=
'
#000000
'
,
confirmText
=
'
确定
'
,
confirmText
=
'
确定
'
,
confirmColor
=
'
#3CC51F
'
confirmColor
=
'
#3CC51F
'
}
=
{},
callbackId
)
{
}
=
{},
callbackId
)
{
content
=
content
||
'
'
;
content
=
content
||
'
'
;
plus
.
nativeUI
.
confirm
(
content
,
(
e
)
=>
{
plus
.
nativeUI
.
confirm
(
content
,
(
e
)
=>
{
if
(
showCancel
)
{
if
(
showCancel
)
{
...
@@ -9720,6 +9847,7 @@ var serviceContext = (function () {
...
@@ -9720,6 +9847,7 @@ var serviceContext = (function () {
getCurrentSubNVue
:
getCurrentSubNVue
,
getCurrentSubNVue
:
getCurrentSubNVue
,
onNativeEventReceive
:
onNativeEventReceive
,
onNativeEventReceive
:
onNativeEventReceive
,
sendNativeEvent
:
sendNativeEvent
,
sendNativeEvent
:
sendNativeEvent
,
loadSubPackage
:
loadSubPackage$1
,
navigateBack
:
navigateBack$1
,
navigateBack
:
navigateBack$1
,
navigateTo
:
navigateTo$1
,
navigateTo
:
navigateTo$1
,
reLaunch
:
reLaunch$1
,
reLaunch
:
reLaunch$1
,
...
@@ -13363,7 +13491,10 @@ var serviceContext = (function () {
...
@@ -13363,7 +13491,10 @@ var serviceContext = (function () {
nid
=
String
(
nid
);
nid
=
String
(
nid
);
const
target
=
vd
.
elements
.
find
(
target
=>
target
.
cid
===
cid
&&
target
.
nid
===
nid
);
const
target
=
vd
.
elements
.
find
(
target
=>
target
.
cid
===
cid
&&
target
.
nid
===
nid
);
if
(
!
target
)
{
if
(
!
target
)
{
return
console
.
error
(
`event handler[
${
cid
}
][
${
nid
}
] not found`
)
if
(
process
.
env
.
NODE_ENV
!==
'
production
'
)
{
console
.
error
(
`event handler[
${
cid
}
][
${
nid
}
] not found`
);
}
return
}
}
const
type
=
event
.
type
;
const
type
=
event
.
type
;
const
mpEvent
=
wrapperEvent
(
event
);
const
mpEvent
=
wrapperEvent
(
event
);
...
@@ -13938,7 +14069,8 @@ var serviceContext = (function () {
...
@@ -13938,7 +14069,8 @@ var serviceContext = (function () {
},
},
mounted
()
{
mounted
()
{
if
(
this
.
mpType
===
'
page
'
)
{
if
(
this
.
mpType
===
'
page
'
)
{
callPageHook
(
this
.
$scope
,
'
onReady
'
);
callPageHook
(
this
.
$scope
,
'
onReady
'
);
preloadSubPackages
(
this
.
$scope
.
route
);
}
}
}
}
});
});
...
...
packages/uni-app-plus/lib/plugin/sub-packages-plugin.js
0 → 100644
浏览文件 @
fa4a8028
const
isWin
=
/^win/
.
test
(
process
.
platform
)
const
normalizePath
=
path
=>
(
isWin
?
path
.
replace
(
/
\\
/g
,
'
/
'
)
:
path
)
function
optimizeChunk
(
chunk
)
{
if
(
!
chunk
)
{
return
}
const
subPackages
=
Object
.
keys
(
process
.
UNI_SUBPACKAGES
).
map
(
root
=>
`
${
root
}
/app-sub-service`
)
const
chunks
=
Array
.
from
(
chunk
.
groupsIterable
)[
0
].
chunks
Array
.
from
(
chunk
.
groupsIterable
)[
0
].
chunks
=
chunks
.
filter
(
chunk
=>
!
subPackages
.
includes
(
normalizePath
(
chunk
.
id
)))
}
class
SubPackagesPlugin
{
apply
(
compiler
)
{
compiler
.
hooks
.
thisCompilation
.
tap
(
'
SubPackagesPlugin
'
,
compilation
=>
{
compilation
.
hooks
.
afterOptimizeChunkIds
.
tap
(
'
SubPackagesPlugin
'
,
chunks
=>
{
optimizeChunk
(
chunks
.
find
(
chunk
=>
chunk
.
id
===
'
app-service
'
))
})
})
}
}
module
.
exports
=
SubPackagesPlugin
packages/uni-app-plus/lib/uni.config.js
浏览文件 @
fa4a8028
...
@@ -23,7 +23,8 @@ module.exports = {
...
@@ -23,7 +23,8 @@ module.exports = {
template
:
'
.wxml
'
,
template
:
'
.wxml
'
,
filter
:
'
.wxs
'
filter
:
'
.wxs
'
},
},
filterTag
:
'
wxs
'
filterTag
:
'
wxs
'
,
subPackages
:
true
},
},
copyWebpackOptions
(
platformOptions
,
vueOptions
)
{
copyWebpackOptions
(
platformOptions
,
vueOptions
)
{
const
copyOptions
=
[]
const
copyOptions
=
[]
...
@@ -42,7 +43,16 @@ module.exports = {
...
@@ -42,7 +43,16 @@ module.exports = {
}
}
return
copyOptions
return
copyOptions
},
},
chainWebpack
(
config
)
{
chainWebpack
(
config
,
vueOptions
)
{
const
isAppService
=
!!
vueOptions
.
pluginOptions
[
'
uni-app-plus
'
].
service
if
(
isAppService
)
{
const
subPackages
=
Object
.
keys
(
process
.
UNI_SUBPACKAGES
)
if
(
process
.
env
.
UNI_OPT_SUBPACKAGES
&&
subPackages
.
length
)
{
config
.
plugin
(
'
uni-app-plus-subpackages
'
)
.
use
(
require
(
'
./plugin/sub-packages-plugin
'
))
}
}
if
(
process
.
env
.
NODE_ENV
===
'
production
'
)
{
if
(
process
.
env
.
NODE_ENV
===
'
production
'
)
{
config
.
optimization
.
minimizer
(
'
terser
'
).
tap
((
args
)
=>
{
config
.
optimization
.
minimizer
(
'
terser
'
).
tap
((
args
)
=>
{
if
(
!
args
[
0
].
terserOptions
.
output
)
{
if
(
!
args
[
0
].
terserOptions
.
output
)
{
...
...
packages/uni-h5/dist/index.umd.min.js
浏览文件 @
fa4a8028
此差异已折叠。
点击以展开。
packages/uni-mp-alipay/dist/index.js
浏览文件 @
fa4a8028
...
@@ -329,18 +329,18 @@ function upx2px (number, newDeviceWidth) {
...
@@ -329,18 +329,18 @@ function upx2px (number, newDeviceWidth) {
if
(
number
===
0
)
{
if
(
number
===
0
)
{
return
0
return
0
}
}
let
result
=
(
number
/
BASE_DEVICE_WIDTH
)
*
(
newDeviceWidth
||
deviceWidth
);
let
result
=
(
number
/
BASE_DEVICE_WIDTH
)
*
(
newDeviceWidth
||
deviceWidth
);
if
(
result
<
0
)
{
if
(
result
<
0
)
{
result
=
-
result
;
result
=
-
result
;
}
}
result
=
Math
.
floor
(
result
+
EPS
);
result
=
Math
.
floor
(
result
+
EPS
);
if
(
result
===
0
)
{
if
(
result
===
0
)
{
if
(
deviceDPR
===
1
||
!
isIOS
)
{
if
(
deviceDPR
===
1
||
!
isIOS
)
{
re
turn
1
re
sult
=
1
;
}
else
{
}
else
{
re
turn
0.5
re
sult
=
0.5
;
}
}
}
}
return
number
<
0
?
-
result
:
result
return
number
<
0
?
-
result
:
result
}
}
...
@@ -358,7 +358,8 @@ var baseApi = /*#__PURE__*/Object.freeze({
...
@@ -358,7 +358,8 @@ var baseApi = /*#__PURE__*/Object.freeze({
// 不支持的 API 列表
// 不支持的 API 列表
const
todos
=
[
const
todos
=
[
'
preloadPage
'
'
preloadPage
'
,
'
loadSubPackage
'
// 'getRecorderManager',
// 'getRecorderManager',
// 'getBackgroundAudioManager',
// 'getBackgroundAudioManager',
// 'createInnerAudioContext',
// 'createInnerAudioContext',
...
...
packages/uni-mp-baidu/dist/index.js
浏览文件 @
fa4a8028
...
@@ -329,18 +329,18 @@ function upx2px (number, newDeviceWidth) {
...
@@ -329,18 +329,18 @@ function upx2px (number, newDeviceWidth) {
if
(
number
===
0
)
{
if
(
number
===
0
)
{
return
0
return
0
}
}
let
result
=
(
number
/
BASE_DEVICE_WIDTH
)
*
(
newDeviceWidth
||
deviceWidth
);
let
result
=
(
number
/
BASE_DEVICE_WIDTH
)
*
(
newDeviceWidth
||
deviceWidth
);
if
(
result
<
0
)
{
if
(
result
<
0
)
{
result
=
-
result
;
result
=
-
result
;
}
}
result
=
Math
.
floor
(
result
+
EPS
);
result
=
Math
.
floor
(
result
+
EPS
);
if
(
result
===
0
)
{
if
(
result
===
0
)
{
if
(
deviceDPR
===
1
||
!
isIOS
)
{
if
(
deviceDPR
===
1
||
!
isIOS
)
{
re
turn
1
re
sult
=
1
;
}
else
{
}
else
{
re
turn
0.5
re
sult
=
0.5
;
}
}
}
}
return
number
<
0
?
-
result
:
result
return
number
<
0
?
-
result
:
result
}
}
...
@@ -391,7 +391,7 @@ var previewImage = {
...
@@ -391,7 +391,7 @@ var previewImage = {
};
};
// 不支持的 API 列表
// 不支持的 API 列表
const
todos
=
[
const
todos
=
[
'
preloadPage
'
'
preloadPage
'
// 'hideKeyboard',
// 'hideKeyboard',
// 'onGyroscopeChange',
// 'onGyroscopeChange',
...
@@ -422,7 +422,7 @@ const todos = [
...
@@ -422,7 +422,7 @@ const todos = [
// 'stopBeaconDiscovery',
// 'stopBeaconDiscovery',
// 'hideShareMenu',
// 'hideShareMenu',
// 'onWindowResize',
// 'onWindowResize',
// 'offWindowResize',
// 'offWindowResize',
// 'vibrate'
// 'vibrate'
];
];
...
...
packages/uni-mp-qq/dist/index.js
浏览文件 @
fa4a8028
...
@@ -329,18 +329,18 @@ function upx2px (number, newDeviceWidth) {
...
@@ -329,18 +329,18 @@ function upx2px (number, newDeviceWidth) {
if
(
number
===
0
)
{
if
(
number
===
0
)
{
return
0
return
0
}
}
let
result
=
(
number
/
BASE_DEVICE_WIDTH
)
*
(
newDeviceWidth
||
deviceWidth
);
let
result
=
(
number
/
BASE_DEVICE_WIDTH
)
*
(
newDeviceWidth
||
deviceWidth
);
if
(
result
<
0
)
{
if
(
result
<
0
)
{
result
=
-
result
;
result
=
-
result
;
}
}
result
=
Math
.
floor
(
result
+
EPS
);
result
=
Math
.
floor
(
result
+
EPS
);
if
(
result
===
0
)
{
if
(
result
===
0
)
{
if
(
deviceDPR
===
1
||
!
isIOS
)
{
if
(
deviceDPR
===
1
||
!
isIOS
)
{
re
turn
1
re
sult
=
1
;
}
else
{
}
else
{
re
turn
0.5
re
sult
=
0.5
;
}
}
}
}
return
number
<
0
?
-
result
:
result
return
number
<
0
?
-
result
:
result
}
}
...
@@ -394,7 +394,8 @@ const protocols = {
...
@@ -394,7 +394,8 @@ const protocols = {
previewImage
previewImage
};
};
const
todos
=
[
const
todos
=
[
'
preloadPage
'
'
preloadPage
'
,
'
loadSubPackage
'
// 'startBeaconDiscovery',
// 'startBeaconDiscovery',
// 'stopBeaconDiscovery',
// 'stopBeaconDiscovery',
// 'getBeacons',
// 'getBeacons',
...
...
packages/uni-mp-toutiao/dist/index.js
浏览文件 @
fa4a8028
...
@@ -329,18 +329,18 @@ function upx2px (number, newDeviceWidth) {
...
@@ -329,18 +329,18 @@ function upx2px (number, newDeviceWidth) {
if
(
number
===
0
)
{
if
(
number
===
0
)
{
return
0
return
0
}
}
let
result
=
(
number
/
BASE_DEVICE_WIDTH
)
*
(
newDeviceWidth
||
deviceWidth
);
let
result
=
(
number
/
BASE_DEVICE_WIDTH
)
*
(
newDeviceWidth
||
deviceWidth
);
if
(
result
<
0
)
{
if
(
result
<
0
)
{
result
=
-
result
;
result
=
-
result
;
}
}
result
=
Math
.
floor
(
result
+
EPS
);
result
=
Math
.
floor
(
result
+
EPS
);
if
(
result
===
0
)
{
if
(
result
===
0
)
{
if
(
deviceDPR
===
1
||
!
isIOS
)
{
if
(
deviceDPR
===
1
||
!
isIOS
)
{
re
turn
1
re
sult
=
1
;
}
else
{
}
else
{
re
turn
0.5
re
sult
=
0.5
;
}
}
}
}
return
number
<
0
?
-
result
:
result
return
number
<
0
?
-
result
:
result
}
}
...
@@ -392,7 +392,8 @@ var previewImage = {
...
@@ -392,7 +392,8 @@ var previewImage = {
// 不支持的 API 列表
// 不支持的 API 列表
const
todos
=
[
const
todos
=
[
'
preloadPage
'
'
preloadPage
'
,
'
loadSubPackage
'
// 'createCameraContext',
// 'createCameraContext',
// 'createLivePlayerContext',
// 'createLivePlayerContext',
// 'getSavedFileInfo',
// 'getSavedFileInfo',
...
...
packages/uni-mp-weixin/dist/index.js
浏览文件 @
fa4a8028
...
@@ -329,18 +329,18 @@ function upx2px (number, newDeviceWidth) {
...
@@ -329,18 +329,18 @@ function upx2px (number, newDeviceWidth) {
if
(
number
===
0
)
{
if
(
number
===
0
)
{
return
0
return
0
}
}
let
result
=
(
number
/
BASE_DEVICE_WIDTH
)
*
(
newDeviceWidth
||
deviceWidth
);
let
result
=
(
number
/
BASE_DEVICE_WIDTH
)
*
(
newDeviceWidth
||
deviceWidth
);
if
(
result
<
0
)
{
if
(
result
<
0
)
{
result
=
-
result
;
result
=
-
result
;
}
}
result
=
Math
.
floor
(
result
+
EPS
);
result
=
Math
.
floor
(
result
+
EPS
);
if
(
result
===
0
)
{
if
(
result
===
0
)
{
if
(
deviceDPR
===
1
||
!
isIOS
)
{
if
(
deviceDPR
===
1
||
!
isIOS
)
{
re
turn
1
re
sult
=
1
;
}
else
{
}
else
{
re
turn
0.5
re
sult
=
0.5
;
}
}
}
}
return
number
<
0
?
-
result
:
result
return
number
<
0
?
-
result
:
result
}
}
...
@@ -412,7 +412,8 @@ const protocols = {
...
@@ -412,7 +412,8 @@ const protocols = {
};
};
const
todos
=
[
const
todos
=
[
'
vibrate
'
,
'
vibrate
'
,
'
preloadPage
'
'
preloadPage
'
,
'
loadSubPackage
'
];
];
const
canIUses
=
[];
const
canIUses
=
[];
...
...
packages/uni-quickapp-native/dist/vue.dev.js
浏览文件 @
fa4a8028
此差异已折叠。
点击以展开。
packages/uni-quickapp-native/dist/vue.prod.js
浏览文件 @
fa4a8028
此差异已折叠。
点击以展开。
packages/uni-quickapp-webview/dist/index.js
浏览文件 @
fa4a8028
...
@@ -329,18 +329,18 @@ function upx2px (number, newDeviceWidth) {
...
@@ -329,18 +329,18 @@ function upx2px (number, newDeviceWidth) {
if
(
number
===
0
)
{
if
(
number
===
0
)
{
return
0
return
0
}
}
let
result
=
(
number
/
BASE_DEVICE_WIDTH
)
*
(
newDeviceWidth
||
deviceWidth
);
let
result
=
(
number
/
BASE_DEVICE_WIDTH
)
*
(
newDeviceWidth
||
deviceWidth
);
if
(
result
<
0
)
{
if
(
result
<
0
)
{
result
=
-
result
;
result
=
-
result
;
}
}
result
=
Math
.
floor
(
result
+
EPS
);
result
=
Math
.
floor
(
result
+
EPS
);
if
(
result
===
0
)
{
if
(
result
===
0
)
{
if
(
deviceDPR
===
1
||
!
isIOS
)
{
if
(
deviceDPR
===
1
||
!
isIOS
)
{
re
turn
1
re
sult
=
1
;
}
else
{
}
else
{
re
turn
0.5
re
sult
=
0.5
;
}
}
}
}
return
number
<
0
?
-
result
:
result
return
number
<
0
?
-
result
:
result
}
}
...
@@ -393,7 +393,10 @@ var previewImage = {
...
@@ -393,7 +393,10 @@ var previewImage = {
const
protocols
=
{
const
protocols
=
{
previewImage
previewImage
};
};
const
todos
=
[];
const
todos
=
[
'
preloadPage
'
,
'
loadSubPackage
'
];
const
canIUses
=
[];
const
canIUses
=
[];
const
CALLBACKS
=
[
'
success
'
,
'
fail
'
,
'
cancel
'
,
'
complete
'
];
const
CALLBACKS
=
[
'
success
'
,
'
fail
'
,
'
cancel
'
,
'
complete
'
];
...
...
packages/vue-cli-plugin-uni/lib/split-chunks.js
浏览文件 @
fa4a8028
const
path
=
require
(
'
path
'
)
const
path
=
require
(
'
path
'
)
const
{
normalizePath
}
=
require
(
'
@dcloudio/uni-cli-shared
'
)
function
createCacheGroups
()
{
const
cacheGroups
=
{}
if
(
process
.
UNI_CONFUSION
)
{
// 加密
cacheGroups
.
confusion
=
{
minSize
:
0
,
minChunks
:
1
,
test
:
function
(
module
)
{
if
(
!
module
.
resource
)
{
return
false
}
if
(
process
.
UNI_CONFUSION
.
includes
(
normalizePath
(
module
.
resource
)))
{
return
true
}
return
false
},
name
:
'
app-confusion
'
,
chunks
:
'
all
'
}
}
process
.
env
.
UNI_OPT_SUBPACKAGES
&&
Object
.
keys
(
process
.
UNI_SUBPACKAGES
).
forEach
(
root
=>
{
cacheGroups
[
root
]
=
{
minSize
:
0
,
minChunks
:
1
,
test
:
function
(
module
)
{
if
(
!
module
.
resource
)
{
return
false
}
if
(
normalizePath
(
module
.
resource
).
includes
(
root
+
'
/
'
))
{
return
true
}
return
false
},
name
:
root
+
'
/app-sub-service
'
,
chunks
:
'
all
'
}
})
return
cacheGroups
}
module
.
exports
=
function
getSplitChunks
()
{
module
.
exports
=
function
getSplitChunks
()
{
const
{
const
{
normalizePath
normalizePath
}
=
require
(
'
@dcloudio/uni-cli-shared
'
)
}
=
require
(
'
@dcloudio/uni-cli-shared
'
)
if
(
process
.
env
.
UNI_USING_V3
)
{
if
(
process
.
env
.
UNI_USING_V3
)
{
if
(
!
process
.
UNI_CONFUSION
)
{
// 无加密
return
false
}
return
{
return
{
cacheGroups
:
{
cacheGroups
:
createCacheGroups
()
vendor
:
{
minSize
:
0
,
minChunks
:
1
,
test
:
function
(
module
)
{
if
(
!
module
.
resource
)
{
return
false
}
if
(
process
.
UNI_CONFUSION
.
includes
(
normalizePath
(
module
.
resource
)))
{
return
true
}
return
false
},
name
:
'
app-confusion
'
,
chunks
:
'
all
'
}
}
}
}
}
}
if
(
!
process
.
env
.
UNI_USING_COMPONENTS
)
{
if
(
!
process
.
env
.
UNI_USING_COMPONENTS
)
{
return
{
return
{
cacheGroups
:
{
cacheGroups
:
{
...
...
packages/webpack-uni-pages-loader/lib/platforms/app-plus/index.js
浏览文件 @
fa4a8028
...
@@ -478,6 +478,7 @@ module.exports = function (pagesJson, userManifestJson) {
...
@@ -478,6 +478,7 @@ module.exports = function (pagesJson, userManifestJson) {
manifest
.
content
=
manifestJson
manifest
.
content
=
manifestJson
const
subPackages
=
[]
// 分包合并
// 分包合并
if
(
appJson
.
subPackages
&&
appJson
.
subPackages
.
length
)
{
if
(
appJson
.
subPackages
&&
appJson
.
subPackages
.
length
)
{
appJson
.
subPackages
.
forEach
(
subPackage
=>
{
appJson
.
subPackages
.
forEach
(
subPackage
=>
{
...
@@ -485,6 +486,9 @@ module.exports = function (pagesJson, userManifestJson) {
...
@@ -485,6 +486,9 @@ module.exports = function (pagesJson, userManifestJson) {
subPackage
.
pages
.
forEach
(
page
=>
{
subPackage
.
pages
.
forEach
(
page
=>
{
appJson
.
pages
.
push
(
normalizePath
(
path
.
join
(
subPackage
.
root
,
page
)))
appJson
.
pages
.
push
(
normalizePath
(
path
.
join
(
subPackage
.
root
,
page
)))
})
})
subPackages
.
push
({
root
:
subPackage
.
root
})
}
}
})
})
}
}
...
@@ -499,6 +503,9 @@ module.exports = function (pagesJson, userManifestJson) {
...
@@ -499,6 +503,9 @@ module.exports = function (pagesJson, userManifestJson) {
}
}
if
(
process
.
env
.
UNI_USING_V3
||
process
.
env
.
UNI_USING_V3_NATIVE
)
{
if
(
process
.
env
.
UNI_USING_V3
||
process
.
env
.
UNI_USING_V3_NATIVE
)
{
if
(
process
.
env
.
UNI_USING_V3
)
{
appJson
.
subPackages
=
subPackages
}
return
require
(
'
./index.v3
'
)(
appJson
,
manifestJson
,
{
return
require
(
'
./index.v3
'
)(
appJson
,
manifestJson
,
{
manifest
,
manifest
,
pagesJson
,
pagesJson
,
...
...
src/core/helpers/protocol/plugin/load-sub-package.js
0 → 100644
浏览文件 @
fa4a8028
export
const
loadSubPackage
=
{
root
:
{
type
:
String
,
required
:
true
,
validator
(
value
,
params
)
{
const
subPackages
=
__uniConfig
.
subPackages
if
(
!
Array
.
isArray
(
subPackages
)
||
subPackages
.
length
===
0
)
{
return
'
no subPackages
'
}
if
(
!
subPackages
.
find
(
subPackage
=>
subPackage
.
root
===
value
))
{
return
'
root `
'
+
value
+
'
` is not found
'
}
}
}
}
src/platforms/app-plus/service/api/index.js
浏览文件 @
fa4a8028
...
@@ -52,6 +52,7 @@ export * from './plugin/restore-global'
...
@@ -52,6 +52,7 @@ export * from './plugin/restore-global'
export
*
from
'
./plugin/sub-nvue
'
export
*
from
'
./plugin/sub-nvue
'
export
*
from
'
./plugin/on-native-event-receive
'
export
*
from
'
./plugin/on-native-event-receive
'
export
*
from
'
./plugin/send-native-event
'
export
*
from
'
./plugin/send-native-event
'
export
*
from
'
./plugin/load-sub-package
'
export
*
from
'
./route/navigate-back
'
export
*
from
'
./route/navigate-back
'
export
*
from
'
./route/navigate-to
'
export
*
from
'
./route/navigate-to
'
...
...
src/platforms/app-plus/service/api/network/request.js
浏览文件 @
fa4a8028
...
@@ -78,7 +78,7 @@ export function createRequestTaskById (requestTaskId, {
...
@@ -78,7 +78,7 @@ export function createRequestTaskById (requestTaskId, {
sslVerify
:
!
sslVerify
sslVerify
:
!
sslVerify
}
}
if
(
method
!==
'
GET
'
)
{
if
(
method
!==
'
GET
'
)
{
options
.
body
=
typeof
data
===
"
string
"
?
data
:
JSON
.
stringify
(
data
)
options
.
body
=
typeof
data
===
'
string
'
?
data
:
JSON
.
stringify
(
data
)
}
}
try
{
try
{
stream
.
fetch
(
options
,
({
stream
.
fetch
(
options
,
({
...
...
src/platforms/app-plus/service/api/plugin/load-sub-package.js
0 → 100644
浏览文件 @
fa4a8028
import
{
invoke
}
from
'
../../bridge
'
const
SUB_FILENAME
=
'
app-sub-service.js
'
function
evaluateScriptFile
(
file
,
callback
)
{
setTimeout
(()
=>
{
callback
()
},
2000
)
}
export
function
loadSubPackage
({
root
},
callbackId
)
{
evaluateScriptFile
(
root
+
'
/
'
+
SUB_FILENAME
,
res
=>
{
invoke
(
callbackId
,
{
errMsg
:
'
loadSubPackage:ok
'
})
})
}
src/platforms/app-plus/service/api/ui/popup.js
浏览文件 @
fa4a8028
...
@@ -38,7 +38,7 @@ export function showToast ({
...
@@ -38,7 +38,7 @@ export function showToast ({
}
}
if
(
~
[
'
top
'
,
'
center
'
,
'
bottom
'
].
indexOf
(
position
))
{
if
(
~
[
'
top
'
,
'
center
'
,
'
bottom
'
].
indexOf
(
position
))
{
plus
.
nativeUI
.
toast
(
title
,
{
plus
.
nativeUI
.
toast
(
title
,
{
verticalAlign
:
position
,
verticalAlign
:
position
})
})
toast
=
true
toast
=
true
toastTimeout
=
setTimeout
(()
=>
{
toastTimeout
=
setTimeout
(()
=>
{
...
...
src/platforms/app-plus/service/framework/load-sub-package.js
0 → 100644
浏览文件 @
fa4a8028
const
loadedSubPackages
=
[]
/**
* 指定路由 ready 后,检查是否触发分包预加载
* @param {Object} route
*/
export
function
preloadSubPackages
(
route
)
{
if
(
!
__uniConfig
.
preloadRule
)
{
return
}
const
options
=
__uniConfig
.
preloadRule
[
route
]
if
(
!
options
||
!
Array
.
isArray
(
options
.
packages
))
{
return
}
const
packages
=
options
.
packages
.
filter
(
root
=>
loadedSubPackages
.
indexOf
(
root
)
===
-
1
)
if
(
!
packages
.
length
)
{
return
}
const
network
=
options
.
network
||
'
wifi
'
if
(
network
===
'
wifi
'
)
{
uni
.
getNetworkType
({
success
(
res
)
{
if
(
process
.
env
.
NODE_ENV
!==
'
production
'
)
{
console
.
log
(
'
UNIAPP[preloadRule]:
'
+
res
.
networkType
+
'
:
'
+
JSON
.
stringify
(
options
))
}
if
(
res
.
networkType
===
'
wifi
'
)
{
loadSubPackages
(
options
.
packages
)
}
}
})
}
else
{
if
(
process
.
env
.
NODE_ENV
!==
'
production
'
)
{
console
.
log
(
'
UNIAPP[preloadRule]:
'
+
JSON
.
stringify
(
options
))
}
loadSubPackages
(
options
.
packages
)
}
}
export
function
loadPage
(
route
,
callback
)
{
let
isInSubPackage
=
false
const
subPackages
=
__uniConfig
.
subPackages
if
(
Array
.
isArray
(
subPackages
))
{
const
subPackage
=
subPackages
.
find
(
subPackage
=>
route
.
indexOf
(
subPackage
.
root
)
===
0
)
if
(
subPackage
)
{
isInSubPackage
=
true
loadSubPackage
(
subPackage
.
root
,
callback
)
}
}
if
(
!
isInSubPackage
)
{
callback
()
}
}
function
loadSubPackage
(
root
,
callback
)
{
if
(
loadedSubPackages
.
indexOf
(
root
)
!==
-
1
)
{
return
callback
()
}
loadSubPackages
([
root
],
()
=>
{
callback
()
})
}
function
loadSubPackages
(
packages
,
callback
)
{
if
(
process
.
env
.
NODE_ENV
!==
'
production
'
)
{
console
.
log
(
'
UNIAPP[loadSubPackages]:
'
+
JSON
.
stringify
(
packages
))
}
const
startTime
=
Date
.
now
()
Promise
.
all
(
packages
.
map
(
root
=>
{
// 目前阶段:假定一定会加载成功
loadedSubPackages
.
push
(
root
)
return
uni
.
loadSubPackage
({
root
})
})
).
then
(
res
=>
{
if
(
process
.
env
.
NODE_ENV
!==
'
production
'
)
{
console
.
log
(
'
UNIAPP[loadSubPackages]:
'
+
(
Date
.
now
()
-
startTime
))
}
callback
&&
callback
(
true
)
}).
catch
(
err
=>
{
console
.
log
(
err
)
callback
&&
callback
(
false
)
})
}
src/platforms/app-plus/service/framework/page.js
浏览文件 @
fa4a8028
...
@@ -13,6 +13,10 @@ import {
...
@@ -13,6 +13,10 @@ import {
createPage
createPage
}
from
'
../../page-factory
'
}
from
'
../../page-factory
'
import
{
loadPage
}
from
'
./load-sub-package
'
const
pages
=
[]
const
pages
=
[]
export
function
getCurrentPages
(
returnAll
)
{
export
function
getCurrentPages
(
returnAll
)
{
...
@@ -151,7 +155,9 @@ export function registerPage ({
...
@@ -151,7 +155,9 @@ export function registerPage ({
if
(
!
webview
.
nvue
)
{
if
(
!
webview
.
nvue
)
{
const
pageId
=
webview
.
id
const
pageId
=
webview
.
id
try
{
try
{
createPage
(
route
,
pageId
,
query
,
pageInstance
).
$mount
()
loadPage
(
route
,
()
=>
{
createPage
(
route
,
pageId
,
query
,
pageInstance
).
$mount
()
})
}
catch
(
e
)
{
}
catch
(
e
)
{
console
.
error
(
e
)
console
.
error
(
e
)
}
}
...
...
src/platforms/app-plus/service/framework/plugins/lifecycle.js
浏览文件 @
fa4a8028
...
@@ -32,6 +32,10 @@ import {
...
@@ -32,6 +32,10 @@ import {
getStatusbarHeight
getStatusbarHeight
}
from
'
../../api/util
'
}
from
'
../../api/util
'
import
{
preloadSubPackages
}
from
'
../load-sub-package
'
function
parsePageCreateOptions
(
vm
,
route
)
{
function
parsePageCreateOptions
(
vm
,
route
)
{
const
pagePath
=
'
/
'
+
route
const
pagePath
=
'
/
'
+
route
const
routeOptions
=
__uniRoutes
.
find
(
route
=>
route
.
path
===
pagePath
)
const
routeOptions
=
__uniRoutes
.
find
(
route
=>
route
.
path
===
pagePath
)
...
@@ -104,7 +108,8 @@ export function initLifecycle (Vue) {
...
@@ -104,7 +108,8 @@ export function initLifecycle (Vue) {
},
},
mounted
()
{
mounted
()
{
if
(
this
.
mpType
===
'
page
'
)
{
if
(
this
.
mpType
===
'
page
'
)
{
callPageHook
(
this
.
$scope
,
'
onReady
'
)
callPageHook
(
this
.
$scope
,
'
onReady
'
)
preloadSubPackages
(
this
.
$scope
.
route
)
}
}
}
}
})
})
...
...
src/platforms/mp-alipay/runtime/api/protocols.js
浏览文件 @
fa4a8028
...
@@ -3,7 +3,8 @@ import {
...
@@ -3,7 +3,8 @@ import {
}
from
'
uni-shared
'
}
from
'
uni-shared
'
// 不支持的 API 列表
// 不支持的 API 列表
const
todos
=
[
const
todos
=
[
'
preloadPage
'
'
preloadPage
'
,
'
loadSubPackage
'
// 'getRecorderManager',
// 'getRecorderManager',
// 'getBackgroundAudioManager',
// 'getBackgroundAudioManager',
// 'createInnerAudioContext',
// 'createInnerAudioContext',
...
...
src/platforms/mp-baidu/runtime/api/protocols.js
浏览文件 @
fa4a8028
import
previewImage
from
'
../../../mp-weixin/helpers/normalize-preview-image
'
import
previewImage
from
'
../../../mp-weixin/helpers/normalize-preview-image
'
// 不支持的 API 列表
// 不支持的 API 列表
const
todos
=
[
const
todos
=
[
'
preloadPage
'
'
preloadPage
'
// 'hideKeyboard',
// 'hideKeyboard',
// 'onGyroscopeChange',
// 'onGyroscopeChange',
...
@@ -31,7 +31,7 @@ const todos = [
...
@@ -31,7 +31,7 @@ const todos = [
// 'stopBeaconDiscovery',
// 'stopBeaconDiscovery',
// 'hideShareMenu',
// 'hideShareMenu',
// 'onWindowResize',
// 'onWindowResize',
// 'offWindowResize',
// 'offWindowResize',
// 'vibrate'
// 'vibrate'
]
]
...
@@ -117,4 +117,4 @@ export {
...
@@ -117,4 +117,4 @@ export {
protocols
,
protocols
,
todos
,
todos
,
canIUses
canIUses
}
}
src/platforms/mp-qq/runtime/api/protocols.js
浏览文件 @
fa4a8028
...
@@ -3,7 +3,8 @@ export const protocols = {
...
@@ -3,7 +3,8 @@ export const protocols = {
previewImage
previewImage
}
}
export
const
todos
=
[
export
const
todos
=
[
'
preloadPage
'
'
preloadPage
'
,
'
loadSubPackage
'
// 'startBeaconDiscovery',
// 'startBeaconDiscovery',
// 'stopBeaconDiscovery',
// 'stopBeaconDiscovery',
// 'getBeacons',
// 'getBeacons',
...
...
src/platforms/mp-toutiao/runtime/api/protocols.js
浏览文件 @
fa4a8028
...
@@ -2,7 +2,8 @@ import previewImage from '../../../mp-weixin/helpers/normalize-preview-image'
...
@@ -2,7 +2,8 @@ import previewImage from '../../../mp-weixin/helpers/normalize-preview-image'
// 不支持的 API 列表
// 不支持的 API 列表
const
todos
=
[
const
todos
=
[
'
preloadPage
'
'
preloadPage
'
,
'
loadSubPackage
'
// 'createCameraContext',
// 'createCameraContext',
// 'createLivePlayerContext',
// 'createLivePlayerContext',
// 'getSavedFileInfo',
// 'getSavedFileInfo',
...
...
src/platforms/mp-weixin/runtime/api/protocols.js
浏览文件 @
fa4a8028
...
@@ -22,6 +22,7 @@ export const protocols = {
...
@@ -22,6 +22,7 @@ export const protocols = {
}
}
export
const
todos
=
[
export
const
todos
=
[
'
vibrate
'
,
'
vibrate
'
,
'
preloadPage
'
'
preloadPage
'
,
'
loadSubPackage
'
]
]
export
const
canIUses
=
[]
export
const
canIUses
=
[]
src/platforms/quickapp-webview/runtime/api/protocols.js
浏览文件 @
fa4a8028
...
@@ -3,5 +3,8 @@ import previewImage from '../../../mp-weixin/helpers/normalize-preview-image'
...
@@ -3,5 +3,8 @@ import previewImage from '../../../mp-weixin/helpers/normalize-preview-image'
export
const
protocols
=
{
export
const
protocols
=
{
previewImage
previewImage
}
}
export
const
todos
=
[]
export
const
todos
=
[
export
const
canIUses
=
[]
'
preloadPage
'
,
'
loadSubPackage
'
]
export
const
canIUses
=
[]
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录