Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
20岁爱吃必胜客
uni-app
提交
a8ffe9de
U
uni-app
项目概览
20岁爱吃必胜客
/
uni-app
与 Fork 源项目一致
Fork自
DCloud / uni-app
通知
1
Star
0
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,发现更多精彩内容 >>
提交
a8ffe9de
编写于
3月 20, 2020
作者:
Q
qiang
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'dev' of github.com:dcloudio/uni-app into dev
上级
e3ab46d0
084509ad
变更
18
隐藏空白更改
内联
并排
Showing
18 changed file
with
199 addition
and
153 deletion
+199
-153
packages/uni-app-plus/dist/index.v3.js
packages/uni-app-plus/dist/index.v3.js
+45
-22
packages/uni-cli-shared/lib/pages.js
packages/uni-cli-shared/lib/pages.js
+2
-2
packages/uni-cli-shared/lib/platform.js
packages/uni-cli-shared/lib/platform.js
+5
-4
packages/uni-cli-shared/template/common/__uniappsuccess.png
packages/uni-cli-shared/template/common/__uniappsuccess.png
+0
-0
packages/vue-cli-plugin-hbuilderx/build/webpack.nvue.conf.js
packages/vue-cli-plugin-hbuilderx/build/webpack.nvue.conf.js
+7
-18
packages/vue-cli-plugin-hbuilderx/packages/webpack-app-plus-nvue-plugin/index.js
...-hbuilderx/packages/webpack-app-plus-nvue-plugin/index.js
+1
-1
packages/vue-cli-plugin-hbuilderx/packages/webpack-app-plus-plugin/index.js
...lugin-hbuilderx/packages/webpack-app-plus-plugin/index.js
+1
-1
packages/vue-cli-plugin-uni/commands/build.js
packages/vue-cli-plugin-uni/commands/build.js
+6
-2
packages/vue-cli-plugin-uni/lib/env.js
packages/vue-cli-plugin-uni/lib/env.js
+14
-12
packages/webpack-uni-mp-loader/lib/plugin/index-new.js
packages/webpack-uni-mp-loader/lib/plugin/index-new.js
+1
-1
packages/webpack-uni-pages-loader/lib/index-new.js
packages/webpack-uni-pages-loader/lib/index-new.js
+2
-2
packages/webpack-uni-pages-loader/lib/platforms/app-plus/app-config-service.js
...pages-loader/lib/platforms/app-plus/app-config-service.js
+5
-4
packages/webpack-uni-pages-loader/lib/platforms/app-plus/index.js
.../webpack-uni-pages-loader/lib/platforms/app-plus/index.js
+42
-28
src/core/service/plugins/index.js
src/core/service/plugins/index.js
+11
-1
src/platforms/app-plus/service/api/device/bluetooth.js
src/platforms/app-plus/service/api/device/bluetooth.js
+5
-26
src/platforms/app-plus/service/framework/navigator.js
src/platforms/app-plus/service/framework/navigator.js
+31
-11
src/platforms/app-plus/service/framework/page.js
src/platforms/app-plus/service/framework/page.js
+1
-1
src/platforms/app-plus/service/framework/subscribe-handlers/index.js
...ms/app-plus/service/framework/subscribe-handlers/index.js
+20
-17
未找到文件。
packages/uni-app-plus/dist/index.v3.js
浏览文件 @
a8ffe9de
...
...
@@ -8058,28 +8058,39 @@ var serviceContext = (function () {
let
todoNavigator
=
false
;
function
setTodoNavigator
(
path
,
callback
,
msg
)
{
todoNavigator
=
{
path
:
path
,
nvue
:
__uniRoutes
.
find
(
route
=>
route
.
path
===
path
).
meta
.
isNVue
,
navigate
:
callback
};
if
(
process
.
env
.
NODE_ENV
!==
'
production
'
)
{
console
.
log
(
`todoNavigator:
${
todoNavigator
.
path
}
${
msg
}
`
);
}
}
function
navigate
(
path
,
callback
,
isAppLaunch
)
{
{
if
(
isAppLaunch
&&
__uniConfig
.
splashscreen
&&
__uniConfig
.
splashscreen
.
autoclose
&&
(
!
__uniConfig
.
splashscreen
.
alwaysShowBeforeRender
))
{
plus
.
navigator
.
closeSplashscreen
();
{
if
(
isAppLaunch
&&
__uniConfig
.
splashscreen
&&
__uniConfig
.
splashscreen
.
autoclose
&&
(
!
__uniConfig
.
splashscreen
.
alwaysShowBeforeRender
))
{
plus
.
navigator
.
closeSplashscreen
();
}
if
(
!
isAppLaunch
&&
todoNavigator
)
{
return
console
.
error
(
`已存在待跳转页面
${
todoNavigator
.
path
}
,请不要连续多次跳转页面
${
path
}
`
)
}
if
(
__uniConfig
.
renderer
===
'
native
'
)
{
// 纯原生无需wait逻辑
// 如果是首页还未初始化,需要等一等,其他无需等待
if
(
getCurrentPages
().
length
===
0
)
{
return
setTodoNavigator
(
path
,
callback
,
'
waitForReady
'
)
}
return
callback
()
}
// 未创建 preloadWebview 或 preloadWebview 已被使用
const
waitPreloadWebview
=
!
preloadWebview
||
(
preloadWebview
&&
preloadWebview
.
__uniapp_route
);
// 已创建未 loaded
const
waitPreloadWebviewReady
=
preloadWebview
&&
!
preloadWebview
.
loaded
;
if
(
waitPreloadWebview
||
waitPreloadWebviewReady
)
{
todoNavigator
=
{
path
:
path
,
nvue
:
__uniRoutes
.
find
(
route
=>
route
.
path
===
path
).
meta
.
isNVue
,
navigate
:
callback
};
if
(
process
.
env
.
NODE_ENV
!==
'
production
'
)
{
console
.
log
(
`todoNavigator:
${
todoNavigator
.
path
}
${
waitPreloadWebview
?
'
waitForCreate
'
:
'
waitForReady
'
}
`
);
}
setTodoNavigator
(
path
,
callback
,
waitPreloadWebview
?
'
waitForCreate
'
:
'
waitForReady
'
);
}
else
{
callback
();
}
...
...
@@ -8105,6 +8116,15 @@ var serviceContext = (function () {
function
navigateFinish
()
{
{
if
(
__uniConfig
.
renderer
===
'
native
'
)
{
if
(
!
todoNavigator
)
{
return
}
if
(
todoNavigator
.
nvue
)
{
return
todoNavigate
()
}
return
}
// 创建预加载
const
preloadWebview
=
createPreloadWebview
();
if
(
process
.
env
.
NODE_ENV
!==
'
production
'
)
{
...
...
@@ -8227,7 +8247,7 @@ var serviceContext = (function () {
}
if
(
process
.
env
.
NODE_ENV
!==
'
production
'
)
{
console
.
log
(
`[uni-app] registerPage
`
,
path
,
webview
.
id
);
console
.
log
(
`[uni-app] registerPage
(
${
path
}
,
${
webview
.
id
}
)`
);
}
initWebview
(
webview
,
routeOptions
,
path
,
query
);
...
...
@@ -12467,14 +12487,20 @@ var serviceContext = (function () {
subscribeHandler
(
data
.
type
,
data
.
data
,
data
.
pageId
);
});
subscribe
(
WEBVIEW_READY
,
onWebviewReady
);
if
(
__uniConfig
.
renderer
!==
'
native
'
)
{
subscribe
(
WEBVIEW_READY
,
onWebviewReady
);
subscribe
(
VD_SYNC
,
onVdSync
);
subscribe
(
VD_SYNC_CALLBACK
,
onVdSyncCallback
);
const
entryPagePath
=
'
/
'
+
__uniConfig
.
entryPagePath
;
const
routeOptions
=
__uniRoutes
.
find
(
route
=>
route
.
path
===
entryPagePath
);
if
(
!
routeOptions
.
meta
.
isNVue
)
{
// 首页是 vue
// 防止首页 webview 初始化过早, service 还未开始监听
publishHandler
(
WEBVIEW_READY
,
Object
.
create
(
null
),
[
1
]);
const
entryPagePath
=
'
/
'
+
__uniConfig
.
entryPagePath
;
const
routeOptions
=
__uniRoutes
.
find
(
route
=>
route
.
path
===
entryPagePath
);
if
(
!
routeOptions
.
meta
.
isNVue
)
{
// 首页是 vue
// 防止首页 webview 初始化过早, service 还未开始监听
publishHandler
(
WEBVIEW_READY
,
Object
.
create
(
null
),
[
1
]);
}
}
// 应该使用subscribe,兼容老版本先用 on api 吧
on
(
'
api.
'
+
WEB_INVOKE_APPSERVICE$1
,
function
(
data
,
webviewIds
)
{
emit
(
'
onWebInvokeAppService
'
,
data
,
webviewIds
);
...
...
@@ -12482,10 +12508,7 @@ var serviceContext = (function () {
subscribe
(
'
onWxsInvokeCallMethod
'
,
onWxsInvokeCallMethod
);
subscribe
(
VD_SYNC
,
onVdSync
);
subscribe
(
VD_SYNC_CALLBACK
,
onVdSyncCallback
);
subscribe
(
INVOKE_API
,
onInvokeApi
);
subscribe
(
INVOKE_API
,
onInvokeApi
);
subscribe
(
WEBVIEW_INSERTED
,
onWebviewInserted
);
subscribe
(
WEBVIEW_REMOVED
,
onWebviewRemoved
);
...
...
packages/uni-cli-shared/lib/pages.js
浏览文件 @
a8ffe9de
...
...
@@ -150,7 +150,7 @@ function isValidPage (page, root = '') {
process
.
UNI_NVUE_ENTRY
[
pagePath
]
=
getNVueMainJsPath
(
pagePath
)
if
(
process
.
env
.
UNI_USING_V3
)
{
// 不移除
if
(
process
.
env
.
UNI_USING_V3
||
process
.
env
.
UNI_USING_V3_NATIVE
)
{
// 不移除
page
.
nvue
=
true
return
true
}
else
{
...
...
@@ -214,7 +214,7 @@ function parseEntry (pagesJson) {
process
.
UNI_NVUE_ENTRY
=
{}
if
(
process
.
env
.
UNI_USING_NATIVE
)
{
if
(
process
.
env
.
UNI_USING_NATIVE
||
process
.
env
.
UNI_USING_V3_NATIVE
)
{
process
.
UNI_NVUE_ENTRY
[
'
app-config
'
]
=
path
.
resolve
(
process
.
env
.
UNI_INPUT_DIR
,
'
pages.json
'
)
process
.
UNI_NVUE_ENTRY
[
'
app-service
'
]
=
path
.
resolve
(
process
.
env
.
UNI_INPUT_DIR
,
getMainEntry
())
}
...
...
packages/uni-cli-shared/lib/platform.js
浏览文件 @
a8ffe9de
...
...
@@ -160,7 +160,11 @@ const PLATFORMS = {
const
files
=
[
'
hybrid/html
'
]
let
wxcomponents
=
[]
if
(
!
process
.
env
.
UNI_USING_NATIVE
&&
!
process
.
env
.
UNI_USING_V3
)
{
if
(
!
process
.
env
.
UNI_USING_NATIVE
&&
!
process
.
env
.
UNI_USING_V3
&&
!
process
.
env
.
UNI_USING_V3_NATIVE
)
{
wxcomponents
=
getCopyOptions
([
'
wxcomponents
'
],
{
to
:
path
.
resolve
(
process
.
env
.
UNI_OUTPUT_TMP_DIR
,
'
wxcomponents
'
)
})
...
...
@@ -535,9 +539,6 @@ module.exports = {
if
(
process
.
env
.
UNI_PLATFORM
===
'
h5
'
&&
vueOptions
&&
vueOptions
.
runtimeCompiler
)
{
return
'
@dcloudio/vue-cli-plugin-uni/packages/h5-vue/dist/vue.esm.js
'
}
if
(
process
.
env
.
UNI_PLATFORM
===
'
app-plus
'
&&
process
.
env
.
UNI_USING_V3
)
{
return
'
@dcloudio/uni-app-plus/dist/service.runtime.esm.js
'
}
if
(
process
.
env
.
UNI_USING_COMPONENTS
)
{
return
uniRuntime
}
...
...
packages/uni-cli-shared/template/common/__uniappsuccess.png
0 → 100644
浏览文件 @
a8ffe9de
2.0 KB
packages/vue-cli-plugin-hbuilderx/build/webpack.nvue.conf.js
浏览文件 @
a8ffe9de
...
...
@@ -45,14 +45,18 @@ const provide = {
'
uniCloud
'
:
[
uniCloudPath
,
'
default
'
]
}
if
(
process
.
env
.
UNI_USING_V3
||
process
.
env
.
UNI_USING_NATIVE
)
{
if
(
process
.
env
.
UNI_USING_V3
||
process
.
env
.
UNI_USING_NATIVE
||
process
.
env
.
UNI_USING_V3_NATIVE
)
{
provide
[
'
uni.getCurrentSubNVue
'
]
=
[
path
.
resolve
(
__dirname
,
'
../packages/uni-app-plus-nvue/dist/get-current-sub-nvue.js
'
),
'
default
'
]
provide
[
'
uni.requireNativePlugin
'
]
=
[
path
.
resolve
(
__dirname
,
'
../packages/uni-app-plus-nvue/dist/require-native-plugin.js
'
),
'
default
'
]
}
if
(
!
process
.
env
.
UNI_USING_V3
)
{
if
(
!
process
.
env
.
UNI_USING_V3
&&
!
process
.
env
.
UNI_USING_V3_NATIVE
)
{
if
(
!
process
.
env
.
UNI_USING_NATIVE
)
{
provide
[
'
uni
'
]
=
[
path
.
resolve
(
__dirname
,
uniPath
),
'
default
'
]
}
...
...
@@ -171,7 +175,7 @@ rules.unshift({
}]
})
if
(
process
.
env
.
UNI_USING_NATIVE
)
{
if
(
process
.
env
.
UNI_USING_NATIVE
||
process
.
env
.
UNI_USING_V3_NATIVE
)
{
plugins
.
push
(
new
WebpackUniMPPlugin
())
const
array
=
[{
from
:
path
.
resolve
(
process
.
env
.
UNI_INPUT_DIR
,
'
static
'
),
...
...
@@ -181,21 +185,6 @@ if (process.env.UNI_USING_NATIVE) {
array
.
push
({
from
:
path
.
resolve
(
getTemplatePath
(),
'
common
'
),
to
:
process
.
env
.
UNI_OUTPUT_DIR
},
{
from
:
path
.
resolve
(
process
.
env
.
UNI_HBUILDERX_PLUGINS
,
'
weapp-tools/template/common
'
),
to
:
process
.
env
.
UNI_OUTPUT_DIR
,
ignore
:
[
'
*.js
'
,
'
*.json
'
,
'
__uniapppicker.html
'
,
'
__uniappview.html
'
,
'
__uniappmarker@3x.png
'
,
'
__uniappopenlocation.html
'
,
'
__uniapppicker.html
'
]
})
}
else
{
let
nativeTemplatePath
=
path
.
resolve
(
process
.
env
.
UNI_HBUILDERX_PLUGINS
,
'
weapp-tools/template/v8-native
'
)
...
...
packages/vue-cli-plugin-hbuilderx/packages/webpack-app-plus-nvue-plugin/index.js
浏览文件 @
a8ffe9de
...
...
@@ -5,7 +5,7 @@ const {
class
WebpackAppPlusNVuePlugin
{
apply
(
compiler
)
{
let
isFirst
=
!
process
.
env
.
UNI_USING_NATIVE
let
isFirst
=
!
process
.
env
.
UNI_USING_NATIVE
&&
!
process
.
env
.
UNI_USING_V3_NATIVE
const
chunkVersions
=
{}
const
changedFiles
=
[]
...
...
packages/vue-cli-plugin-hbuilderx/packages/webpack-app-plus-plugin/index.js
浏览文件 @
a8ffe9de
...
...
@@ -105,7 +105,7 @@ class WebpackAppPlusPlugin {
compiler
.
hooks
.
done
.
tapPromise
(
'
WebpackAppPlusPlugin
'
,
compilation
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
if
(
process
.
env
.
UNI_USING_NATIVE
)
{
if
(
process
.
env
.
UNI_USING_NATIVE
||
process
.
env
.
UNI_USING_V3_NATIVE
)
{
return
resolve
()
}
...
...
packages/vue-cli-plugin-uni/commands/build.js
浏览文件 @
a8ffe9de
...
...
@@ -124,11 +124,15 @@ async function build (args, api, options) {
await
fs
.
emptyDir
(
targetDir
)
}
if
(
process
.
env
.
UNI_USING_NATIVE
)
{
if
(
process
.
env
.
UNI_USING_NATIVE
||
process
.
env
.
UNI_USING_V3_NATIVE
)
{
webpackConfigs
.
length
=
0
}
if
(
process
.
env
.
UNI_USING_NATIVE
||
(
process
.
UNI_NVUE_ENTRY
&&
Object
.
keys
(
process
.
UNI_NVUE_ENTRY
).
length
))
{
if
(
process
.
env
.
UNI_USING_NATIVE
||
process
.
env
.
UNI_USING_V3_NATIVE
||
(
process
.
UNI_NVUE_ENTRY
&&
Object
.
keys
(
process
.
UNI_NVUE_ENTRY
).
length
)
)
{
webpackConfigs
.
push
(
require
(
'
@dcloudio/vue-cli-plugin-hbuilderx/build/webpack.nvue.conf.js
'
)(
process
.
UNI_NVUE_ENTRY
))
}
...
...
packages/vue-cli-plugin-uni/lib/env.js
浏览文件 @
a8ffe9de
...
...
@@ -172,19 +172,20 @@ if (process.env.UNI_PLATFORM === 'app-plus') {
if
(
platformOptions
.
nvueCompiler
===
'
weex
'
)
{
isNVueCompiler
=
false
}
if
(
platformOptions
.
renderer
!==
'
native
'
&&
// 非 native
(
platformOptions
.
compilerVersion
===
'
3
'
||
platformOptions
.
compilerVersion
===
3
)
if
(
platformOptions
.
compilerVersion
===
'
3
'
||
platformOptions
.
compilerVersion
===
3
)
{
delete
process
.
env
.
UNI_USING_CACHE
process
.
env
.
UNI_USING_V3
=
true
platformOptions
.
usingComponents
=
true
if
(
platformOptions
.
renderer
===
'
native
'
)
{
process
.
env
.
UNI_USING_V3_NATIVE
=
true
}
else
{
process
.
env
.
UNI_USING_V3
=
true
platformOptions
.
usingComponents
=
true
}
process
.
env
.
UNI_OUTPUT_TMP_DIR
=
''
isNVueCompiler
=
true
// v3 目前仅支持 uni-app 模式
}
if
(
platformOptions
.
renderer
===
'
native
'
)
{
}
else
if
(
platformOptions
.
renderer
===
'
native
'
)
{
// 纯原生目前不提供 cache
delete
process
.
env
.
UNI_USING_CACHE
process
.
env
.
UNI_USING_NATIVE
=
true
...
...
@@ -267,8 +268,8 @@ const warningMsg =
const
needWarning
=
!
platformOptions
.
usingComponents
||
usingComponentsAbsent
let
hasNVue
=
false
// 输出编译器版本等信息
if
(
process
.
env
.
UNI_USING_NATIVE
)
{
console
.
log
(
'
当前nvue编译模式:
'
+
(
isNVueCompiler
?
'
uni-app
'
:
'
weex
'
)
+
if
(
process
.
env
.
UNI_USING_NATIVE
||
process
.
env
.
UNI_USING_V3_NATIVE
)
{
console
.
log
(
'
当前nvue编译模式
'
+
(
process
.
env
.
UNI_USING_V3_NATIVE
?
'
(v3)
'
:
''
)
+
'
:
'
+
(
isNVueCompiler
?
'
uni-app
'
:
'
weex
'
)
+
'
。编译模式差异见:https://ask.dcloud.net.cn/article/36074
'
)
}
else
if
(
process
.
env
.
UNI_PLATFORM
!==
'
h5
'
&&
process
.
env
.
UNI_PLATFORM
!==
'
quickapp
'
)
{
try
{
...
...
@@ -362,7 +363,8 @@ if (
process
.
env
.
UNI_USING_CACHE
&&
process
.
env
.
UNI_PLATFORM
!==
'
h5
'
&&
!
process
.
env
.
UNI_USING_V3
&&
!
process
.
env
.
UNI_USING_NATIVE
!
process
.
env
.
UNI_USING_NATIVE
&&
!
process
.
env
.
UNI_USING_V3_NATIVE
)
{
// 使用 cache, 拷贝 cache 的 json
const
cacheJsonDir
=
path
.
resolve
(
process
.
env
.
UNI_CLI_CONTEXT
,
...
...
packages/webpack-uni-mp-loader/lib/plugin/index-new.js
浏览文件 @
a8ffe9de
...
...
@@ -67,7 +67,7 @@ function addSubPackagesRequire (compilation) {
class
WebpackUniMPPlugin
{
apply
(
compiler
)
{
if
(
!
process
.
env
.
UNI_USING_NATIVE
)
{
if
(
!
process
.
env
.
UNI_USING_NATIVE
&&
!
process
.
env
.
UNI_USING_V3_NATIVE
)
{
compiler
.
hooks
.
emit
.
tapPromise
(
'
webpack-uni-mp-emit
'
,
compilation
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
addSubPackagesRequire
(
compilation
)
...
...
packages/webpack-uni-pages-loader/lib/index-new.js
浏览文件 @
a8ffe9de
...
...
@@ -106,11 +106,11 @@ module.exports = function (content) {
})
return
appConfigContent
}
if
(
process
.
env
.
UNI_USING_NATIVE
)
{
if
(
process
.
env
.
UNI_USING_NATIVE
||
process
.
env
.
UNI_USING_V3_NATIVE
)
{
let
appConfigContent
=
''
jsonFiles
.
forEach
(
jsonFile
=>
{
if
(
jsonFile
)
{
if
(
jsonFile
.
name
===
'
app-config.js
'
)
{
if
(
jsonFile
.
name
===
'
app-config.js
'
||
jsonFile
.
name
===
'
define-pages.js
'
)
{
appConfigContent
=
jsonFile
.
content
}
else
{
this
.
emitFile
(
jsonFile
.
name
,
jsonFile
.
content
)
...
...
packages/webpack-uni-pages-loader/lib/platforms/app-plus/app-config-service.js
浏览文件 @
a8ffe9de
...
...
@@ -24,20 +24,21 @@ function parseRoutes (config) {
__uniRoutes
.
push
(
route
)
})
return
__uniRoutes
return
__uniRoutes
}
module
.
exports
=
function
definePages
(
appJson
)
{
module
.
exports
=
function
definePages
(
appJson
)
{
const
__uniRoutes
=
parseRoutes
(
appJson
)
delete
appJson
.
page
delete
appJson
.
usingComponents
delete
appJson
.
nvueCompiler
delete
appJson
.
renderer
// 保留renderer
// delete appJson.renderer
return
{
name
:
'
app-config-service.js
'
,
content
:
`
var isReady=false;var onReadyCallbacks=[];
var isReady=false;var onReadyCallbacks=[];
var __uniConfig =
${
JSON
.
stringify
(
appJson
,
null
)}
;
var __uniRoutes =
${
JSON
.
stringify
(
__uniRoutes
)}
;
__uniConfig.onReady=function(callback){if(__uniConfig.ready){callback()}else{onReadyCallbacks.push(callback)}};Object.defineProperty(__uniConfig,"ready",{get:function(){return isReady},set:function(val){isReady=val;if(!isReady){return}const callbacks=onReadyCallbacks.slice(0);onReadyCallbacks.length=0;callbacks.forEach(function(callback){callback()})}});
...
...
packages/webpack-uni-pages-loader/lib/platforms/app-plus/index.js
浏览文件 @
a8ffe9de
...
...
@@ -55,6 +55,41 @@ function normalizeNetworkTimeout (appJson) {
}
}
function
updateFileFlag
(
appJson
)
{
// 已经不再根据文件识别,理论可废弃此处的逻辑
if
(
process
.
env
.
UNI_USING_V3
||
process
.
env
.
UNI_USING_V3_NATIVE
)
{
return
}
const
nvueCompilerFilePath
=
path
.
resolve
(
process
.
env
.
UNI_OUTPUT_DIR
,
'
__uniappnvuecompiler.js
'
)
const
nvueCompilerExists
=
fs
.
existsSync
(
nvueCompilerFilePath
)
if
(
appJson
.
nvueCompiler
===
'
uni-app
'
)
{
if
(
!
nvueCompilerExists
)
{
fsExtra
.
outputFile
(
nvueCompilerFilePath
,
''
)
}
}
else
{
if
(
nvueCompilerExists
)
{
fs
.
unlinkSync
(
nvueCompilerFilePath
)
}
}
const
rendererFilePath
=
path
.
resolve
(
process
.
env
.
UNI_OUTPUT_DIR
,
'
__uniapprenderer.js
'
)
const
rendererExists
=
fs
.
existsSync
(
rendererFilePath
)
if
(
appJson
.
renderer
===
'
native
'
)
{
if
(
!
rendererExists
)
{
fsExtra
.
outputFile
(
rendererFilePath
,
''
)
}
}
else
{
if
(
rendererExists
)
{
fs
.
unlinkSync
(
rendererFilePath
)
}
}
}
module
.
exports
=
function
(
pagesJson
,
userManifestJson
)
{
const
{
app
...
...
@@ -239,31 +274,7 @@ module.exports = function (pagesJson, userManifestJson) {
appJson
.
renderer
=
'
auto
'
}
const
nvueCompilerFilePath
=
path
.
resolve
(
process
.
env
.
UNI_OUTPUT_DIR
,
'
__uniappnvuecompiler.js
'
)
const
nvueCompilerExists
=
fs
.
existsSync
(
nvueCompilerFilePath
)
if
(
appJson
.
nvueCompiler
===
'
uni-app
'
)
{
if
(
!
nvueCompilerExists
)
{
fsExtra
.
outputFile
(
nvueCompilerFilePath
,
''
)
}
}
else
{
if
(
nvueCompilerExists
)
{
fs
.
unlinkSync
(
nvueCompilerFilePath
)
}
}
const
rendererFilePath
=
path
.
resolve
(
process
.
env
.
UNI_OUTPUT_DIR
,
'
__uniapprenderer.js
'
)
const
rendererExists
=
fs
.
existsSync
(
rendererFilePath
)
if
(
appJson
.
renderer
===
'
native
'
)
{
if
(
!
rendererExists
)
{
fsExtra
.
outputFile
(
rendererFilePath
,
''
)
}
}
else
{
if
(
rendererExists
)
{
fs
.
unlinkSync
(
rendererFilePath
)
}
}
updateFileFlag
(
appJson
)
appJson
.
splashscreen
=
{
alwaysShowBeforeRender
:
false
,
// 是否启用白屏检测 关闭 splash
...
...
@@ -321,7 +332,7 @@ module.exports = function (pagesJson, userManifestJson) {
// 检查原生混淆选项
const
confusion
=
manifestJson
.
plus
.
confusion
if
(
confusion
&&
confusion
.
resources
)
{
const
resources
=
{}
const
resources
=
{}
const
nvuePages
=
(
appJson
.
nvue
&&
appJson
.
nvue
.
pages
)
||
{}
for
(
const
key
in
confusion
.
resources
)
{
if
(
path
.
extname
(
key
)
===
'
.js
'
)
{
// 支持 js 混淆,过滤掉
...
...
@@ -356,7 +367,10 @@ module.exports = function (pagesJson, userManifestJson) {
const
uniApp
=
require
(
'
../../../package.json
'
)[
'
uni-app
'
]
manifestJson
.
plus
[
'
uni-app
'
]
=
uniApp
// 控制页类型
const
control
=
process
.
env
.
UNI_USING_V3
?
'
uni-v3
'
:
(
process
.
env
.
UNI_USING_V8
?
'
v8
'
:
'
webview
'
)
const
control
=
(
process
.
env
.
UNI_USING_V3
||
process
.
env
.
UNI_USING_V3_NATIVE
)
?
'
uni-v3
'
:
(
process
.
env
.
UNI_USING_V8
?
'
v8
'
:
'
webview
'
)
manifestJson
.
plus
[
'
uni-app
'
].
control
=
control
manifestJson
.
plus
[
'
uni-app
'
].
nvueCompiler
=
appJson
.
nvueCompiler
manifestJson
.
plus
[
'
uni-app
'
].
renderer
=
appJson
.
renderer
...
...
@@ -480,7 +494,7 @@ module.exports = function (pagesJson, userManifestJson) {
return
[
manifest
,
parseConfig
(
appJson
)]
}
if
(
process
.
env
.
UNI_USING_V3
)
{
if
(
process
.
env
.
UNI_USING_V3
||
process
.
env
.
UNI_USING_V3_NATIVE
)
{
return
require
(
'
./index.v3
'
)(
appJson
,
manifestJson
,
{
manifest
,
pagesJson
,
...
...
src/core/service/plugins/index.js
浏览文件 @
a8ffe9de
...
...
@@ -59,7 +59,17 @@ function getLocation (base = '/') {
export
default
{
install
(
Vue
,
{
routes
}
=
{})
{
}
=
{})
{
if
(
__PLATFORM__
===
'
h5
'
&&
Vue
.
config
.
devtools
&&
typeof
window
!==
'
undefined
'
&&
window
.
navigator
.
userAgent
.
toLowerCase
().
indexOf
(
'
hbuilderx
'
)
!==
-
1
)
{
// HBuilderX 内置浏览器禁用 devtools 提示
Vue
.
config
.
devtools
=
false
}
initPolyfill
(
Vue
)
lifecycleMixin
(
Vue
)
...
...
src/platforms/app-plus/service/api/device/bluetooth.js
浏览文件 @
a8ffe9de
import
{
invoke
,
publish
,
arrayBufferToBase64
,
base64ToArrayBuffer
publish
}
from
'
../../bridge
'
/**
...
...
@@ -53,16 +51,6 @@ function bluetoothOn (method, beforeSuccess) {
return
true
}
function
checkDevices
(
data
)
{
data
.
devices
=
data
.
devices
.
map
(
device
=>
{
var
advertisData
=
device
.
advertisData
if
(
advertisData
&&
typeof
advertisData
!==
'
string
'
)
{
device
.
advertisData
=
arrayBufferToBase64
(
advertisData
)
}
return
device
})
}
var
onBluetoothAdapterStateChange
var
onBluetoothDeviceFound
var
onBLEConnectionStateChange
...
...
@@ -83,7 +71,7 @@ export function getBluetoothAdapterState (data, callbackId) {
}
export
function
startBluetoothDevicesDiscovery
(
data
,
callbackId
)
{
onBluetoothDeviceFound
=
onBluetoothDeviceFound
||
bluetoothOn
(
'
onBluetoothDeviceFound
'
,
checkDevices
)
onBluetoothDeviceFound
=
onBluetoothDeviceFound
||
bluetoothOn
(
'
onBluetoothDeviceFound
'
)
bluetoothExec
(
'
startBluetoothDevicesDiscovery
'
,
callbackId
,
data
)
}
...
...
@@ -92,7 +80,7 @@ export function stopBluetoothDevicesDiscovery (data, callbackId) {
}
export
function
getBluetoothDevices
(
data
,
callbackId
)
{
bluetoothExec
(
'
getBluetoothDevices
'
,
callbackId
,
{}
,
checkDevices
)
bluetoothExec
(
'
getBluetoothDevices
'
,
callbackId
,
{})
}
export
function
getConnectedBluetoothDevices
(
data
,
callbackId
)
{
...
...
@@ -118,18 +106,12 @@ export function getBLEDeviceCharacteristics (data, callbackId) {
}
export
function
notifyBLECharacteristicValueChange
(
data
,
callbackId
)
{
onBLECharacteristicValueChange
=
onBLECharacteristicValueChange
||
bluetoothOn
(
'
onBLECharacteristicValueChange
'
,
data
=>
{
data
.
value
=
arrayBufferToBase64
(
data
.
value
)
})
onBLECharacteristicValueChange
=
onBLECharacteristicValueChange
||
bluetoothOn
(
'
onBLECharacteristicValueChange
'
)
bluetoothExec
(
'
notifyBLECharacteristicValueChange
'
,
callbackId
,
data
)
}
export
function
notifyBLECharacteristicValueChanged
(
data
,
callbackId
)
{
onBLECharacteristicValueChange
=
onBLECharacteristicValueChange
||
bluetoothOn
(
'
onBLECharacteristicValueChange
'
,
data
=>
{
data
.
value
=
arrayBufferToBase64
(
data
.
value
)
})
onBLECharacteristicValueChange
=
onBLECharacteristicValueChange
||
bluetoothOn
(
'
onBLECharacteristicValueChange
'
)
bluetoothExec
(
'
notifyBLECharacteristicValueChanged
'
,
callbackId
,
data
)
}
...
...
@@ -139,8 +121,5 @@ export function readBLECharacteristicValue (data, callbackId) {
}
export
function
writeBLECharacteristicValue
(
data
,
callbackId
)
{
if
(
typeof
data
.
value
===
'
string
'
)
{
data
.
value
=
base64ToArrayBuffer
(
data
.
value
)
}
bluetoothExec
(
'
writeBLECharacteristicValue
'
,
callbackId
,
data
)
}
src/platforms/app-plus/service/framework/navigator.js
浏览文件 @
a8ffe9de
...
...
@@ -6,28 +6,39 @@ import {
let
todoNavigator
=
false
function
setTodoNavigator
(
path
,
callback
,
msg
)
{
todoNavigator
=
{
path
:
path
,
nvue
:
__uniRoutes
.
find
(
route
=>
route
.
path
===
path
).
meta
.
isNVue
,
navigate
:
callback
}
if
(
process
.
env
.
NODE_ENV
!==
'
production
'
)
{
console
.
log
(
`todoNavigator:
${
todoNavigator
.
path
}
${
msg
}
`
)
}
}
export
function
navigate
(
path
,
callback
,
isAppLaunch
)
{
if
(
__PLATFORM__
===
'
app-plus
'
)
{
if
(
isAppLaunch
&&
__uniConfig
.
splashscreen
&&
__uniConfig
.
splashscreen
.
autoclose
&&
(
!
__uniConfig
.
splashscreen
.
alwaysShowBeforeRender
))
{
plus
.
navigator
.
closeSplashscreen
()
if
(
__PLATFORM__
===
'
app-plus
'
)
{
if
(
isAppLaunch
&&
__uniConfig
.
splashscreen
&&
__uniConfig
.
splashscreen
.
autoclose
&&
(
!
__uniConfig
.
splashscreen
.
alwaysShowBeforeRender
))
{
plus
.
navigator
.
closeSplashscreen
()
}
if
(
!
isAppLaunch
&&
todoNavigator
)
{
return
console
.
error
(
`已存在待跳转页面
${
todoNavigator
.
path
}
,请不要连续多次跳转页面
${
path
}
`
)
}
if
(
__uniConfig
.
renderer
===
'
native
'
)
{
// 纯原生无需wait逻辑
// 如果是首页还未初始化,需要等一等,其他无需等待
if
(
getCurrentPages
().
length
===
0
)
{
return
setTodoNavigator
(
path
,
callback
,
'
waitForReady
'
)
}
return
callback
()
}
// 未创建 preloadWebview 或 preloadWebview 已被使用
const
waitPreloadWebview
=
!
preloadWebview
||
(
preloadWebview
&&
preloadWebview
.
__uniapp_route
)
// 已创建未 loaded
const
waitPreloadWebviewReady
=
preloadWebview
&&
!
preloadWebview
.
loaded
if
(
waitPreloadWebview
||
waitPreloadWebviewReady
)
{
todoNavigator
=
{
path
:
path
,
nvue
:
__uniRoutes
.
find
(
route
=>
route
.
path
===
path
).
meta
.
isNVue
,
navigate
:
callback
}
if
(
process
.
env
.
NODE_ENV
!==
'
production
'
)
{
console
.
log
(
`todoNavigator:
${
todoNavigator
.
path
}
${
waitPreloadWebview
?
'
waitForCreate
'
:
'
waitForReady
'
}
`
)
}
setTodoNavigator
(
path
,
callback
,
waitPreloadWebview
?
'
waitForCreate
'
:
'
waitForReady
'
)
}
else
{
callback
()
}
...
...
@@ -53,6 +64,15 @@ function todoNavigate () {
export
function
navigateFinish
()
{
if
(
__PLATFORM__
===
'
app-plus
'
)
{
if
(
__uniConfig
.
renderer
===
'
native
'
)
{
if
(
!
todoNavigator
)
{
return
}
if
(
todoNavigator
.
nvue
)
{
return
todoNavigate
()
}
return
}
// 创建预加载
const
preloadWebview
=
createPreloadWebview
()
if
(
process
.
env
.
NODE_ENV
!==
'
production
'
)
{
...
...
src/platforms/app-plus/service/framework/page.js
浏览文件 @
a8ffe9de
...
...
@@ -61,7 +61,7 @@ export function registerPage ({
}
if
(
process
.
env
.
NODE_ENV
!==
'
production
'
)
{
console
.
log
(
`[uni-app] registerPage
`
,
path
,
webview
.
id
)
console
.
log
(
`[uni-app] registerPage
(
${
path
}
,
${
webview
.
id
}
)`
)
}
initWebview
(
webview
,
routeOptions
,
path
,
query
)
...
...
src/platforms/app-plus/service/framework/subscribe-handlers/index.js
浏览文件 @
a8ffe9de
...
...
@@ -5,8 +5,8 @@ import {
VD_SYNC_CALLBACK
,
INVOKE_API
,
WEBVIEW_READY
,
WEB_INVOKE_APPSERVICE
,
WEBVIEW_INSERTED
,
WEB_INVOKE_APPSERVICE
,
WEBVIEW_INSERTED
,
WEBVIEW_REMOVED
}
from
'
../../../constants
'
...
...
@@ -21,11 +21,11 @@ import onVdSyncCallback from './on-vd-sync-callback'
import
onInvokeApi
from
'
./on-invoke-api
'
import
onWxsInvokeCallMethod
from
'
./on-wxs-invoke-call-method
'
import
{
onWebviewInserted
,
onWebviewRemoved
}
from
'
./on-webview-lifecycle
'
import
{
onWebviewInserted
,
onWebviewRemoved
}
from
'
./on-webview-lifecycle
'
export
function
initSubscribeHandlers
()
{
const
{
...
...
@@ -45,14 +45,20 @@ export function initSubscribeHandlers () {
subscribeHandler
(
data
.
type
,
data
.
data
,
data
.
pageId
)
})
subscribe
(
WEBVIEW_READY
,
onWebviewReady
)
if
(
__uniConfig
.
renderer
!==
'
native
'
)
{
subscribe
(
WEBVIEW_READY
,
onWebviewReady
)
subscribe
(
VD_SYNC
,
onVdSync
)
subscribe
(
VD_SYNC_CALLBACK
,
onVdSyncCallback
)
const
entryPagePath
=
'
/
'
+
__uniConfig
.
entryPagePath
const
routeOptions
=
__uniRoutes
.
find
(
route
=>
route
.
path
===
entryPagePath
)
if
(
!
routeOptions
.
meta
.
isNVue
)
{
// 首页是 vue
// 防止首页 webview 初始化过早, service 还未开始监听
publishHandler
(
WEBVIEW_READY
,
Object
.
create
(
null
),
[
1
])
const
entryPagePath
=
'
/
'
+
__uniConfig
.
entryPagePath
const
routeOptions
=
__uniRoutes
.
find
(
route
=>
route
.
path
===
entryPagePath
)
if
(
!
routeOptions
.
meta
.
isNVue
)
{
// 首页是 vue
// 防止首页 webview 初始化过早, service 还未开始监听
publishHandler
(
WEBVIEW_READY
,
Object
.
create
(
null
),
[
1
])
}
}
// 应该使用subscribe,兼容老版本先用 on api 吧
on
(
'
api.
'
+
WEB_INVOKE_APPSERVICE
,
function
(
data
,
webviewIds
)
{
emit
(
'
onWebInvokeAppService
'
,
data
,
webviewIds
)
...
...
@@ -60,10 +66,7 @@ export function initSubscribeHandlers () {
subscribe
(
'
onWxsInvokeCallMethod
'
,
onWxsInvokeCallMethod
)
subscribe
(
VD_SYNC
,
onVdSync
)
subscribe
(
VD_SYNC_CALLBACK
,
onVdSyncCallback
)
subscribe
(
INVOKE_API
,
onInvokeApi
)
subscribe
(
INVOKE_API
,
onInvokeApi
)
subscribe
(
WEBVIEW_INSERTED
,
onWebviewInserted
)
subscribe
(
WEBVIEW_REMOVED
,
onWebviewRemoved
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录