Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
我本凡人 一念云泥
uni-app
提交
be9dfe80
uni-app
项目概览
我本凡人 一念云泥
/
uni-app
与 Fork 源项目一致
Fork自
DCloud / uni-app
通知
4
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
be9dfe80
编写于
12月 24, 2019
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(v3): condition
上级
5aa2189e
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
147 addition
and
96 deletion
+147
-96
packages/uni-app-plus/dist/index.v3.js
packages/uni-app-plus/dist/index.v3.js
+17
-12
packages/webpack-uni-pages-loader/lib/platforms/app-plus/index.js
.../webpack-uni-pages-loader/lib/platforms/app-plus/index.js
+11
-58
packages/webpack-uni-pages-loader/lib/platforms/app-plus/index.v3.js
...bpack-uni-pages-loader/lib/platforms/app-plus/index.v3.js
+85
-0
packages/webpack-uni-pages-loader/lib/platforms/mp.js
packages/webpack-uni-pages-loader/lib/platforms/mp.js
+17
-14
src/platforms/app-plus/service/api/route/navigate-back.js
src/platforms/app-plus/service/api/route/navigate-back.js
+12
-6
src/platforms/app-plus/service/api/route/re-launch.js
src/platforms/app-plus/service/api/route/re-launch.js
+4
-5
src/platforms/app-plus/service/framework/webview/parser/webview-style-parser.js
.../service/framework/webview/parser/webview-style-parser.js
+1
-1
未找到文件。
packages/uni-app-plus/dist/index.v3.js
浏览文件 @
be9dfe80
...
...
@@ -7111,8 +7111,8 @@ var serviceContext = (function () {
if
(
!
currentPage
.
__uniapp_webview
)
{
return
backPage
(
webview
)
}
backWebview
(
webview
,
()
=>
{
backPage
(
webview
);
backWebview
(
webview
,
()
=>
{
backPage
(
webview
);
});
}
...
...
@@ -7138,10 +7138,16 @@ var serviceContext = (function () {
uni
.
hideToast
();
// 后退时,关闭 toast,loading
currentPage
.
$page
.
meta
.
isQuit
?
quit
()
:
back
(
delta
,
animationType
,
animationDuration
);
// 当前页面是 condition 进入
if
(
currentPage
.
$page
.
id
===
1
&&
__uniConfig
.
realEntryPagePath
)
{
uni
.
reLaunch
({
url
:
'
/
'
+
__uniConfig
.
realEntryPagePath
});
}
else
{
currentPage
.
$page
.
meta
.
isQuit
?
quit
()
:
back
(
delta
,
animationType
,
animationDuration
);
}
return
{
errMsg
:
'
navigateBack:ok
'
}
...
...
@@ -7319,7 +7325,7 @@ var serviceContext = (function () {
const
titleNView
=
parseTitleNView
(
routeOptions
);
if
(
titleNView
)
{
if
(
id
===
1
&&
__uniConfig
.
realEntryPagePath
===
path
)
{
if
(
id
===
1
&&
__uniConfig
.
realEntryPagePath
)
{
titleNView
.
autoBackButton
=
true
;
}
webviewStyle
.
titleNView
=
titleNView
;
...
...
@@ -7995,17 +8001,16 @@ var serviceContext = (function () {
'
none
'
,
0
,
()
=>
{
pages
.
forEach
(
page
=>
{
page
.
$remove
();
page
.
$getAppWebview
().
close
(
'
none
'
);
});
invoke$1
(
callbackId
,
{
errMsg
:
'
reLaunch:ok
'
});
}
);
pages
.
forEach
(
page
=>
{
page
.
$remove
();
page
.
$getAppWebview
().
close
(
'
none
'
);
});
setStatusBarStyle
();
}
...
...
packages/webpack-uni-pages-loader/lib/platforms/app-plus/index.js
浏览文件 @
be9dfe80
...
...
@@ -4,27 +4,19 @@ const path = require('path')
const
merge
=
require
(
'
merge
'
)
const
{
parsePages
,
normalizePath
,
getFlexDirection
}
=
require
(
'
@dcloudio/uni-cli-shared
'
)
const
{
addPageUsingComponents
}
=
require
(
'
@dcloudio/uni-cli-shared/lib/pages
'
)
const
{
parseStyle
}
=
require
(
'
../../util
'
)
const
definePages
=
require
(
'
./define-pages
'
)
const
appConfigService
=
require
(
'
./app-config-service
'
)
const
wxPageOrientationMapping
=
{
auto
:
[
'
portrait-primary
'
,
'
portrait-secondary
'
,
'
landscape-primary
'
,
'
landscape-secondary
'
],
portrait
:
[
'
portrait-primary
'
,
'
portrait-secondary
'
],
landscape
:
[
'
landscape-primary
'
,
'
landscape-secondary
'
]
}
const
wxPageOrientationMapping
=
{
auto
:
[
'
portrait-primary
'
,
'
portrait-secondary
'
,
'
landscape-primary
'
,
'
landscape-secondary
'
],
portrait
:
[
'
portrait-primary
'
,
'
portrait-secondary
'
],
landscape
:
[
'
landscape-primary
'
,
'
landscape-secondary
'
]
}
function
parseConfig
(
appJson
)
{
return
{
...
...
@@ -137,7 +129,7 @@ module.exports = function (pagesJson, userManifestJson) {
if
(
manifestJson
.
plus
.
screenOrientation
)
{
// app平台优先使用 manifest 配置
manifestJson
.
screenOrientation
=
manifestJson
.
plus
.
screenOrientation
delete
manifestJson
.
plus
.
screenOrientation
}
else
if
(
appJson
.
window
&&
appJson
.
window
.
pageOrientation
)
{
// 兼容微信小程序
}
else
if
(
appJson
.
window
&&
appJson
.
window
.
pageOrientation
)
{
// 兼容微信小程序
const
pageOrientationValue
=
wxPageOrientationMapping
[
appJson
.
window
.
pageOrientation
]
if
(
pageOrientationValue
)
{
manifestJson
.
screenOrientation
=
pageOrientationValue
...
...
@@ -484,51 +476,12 @@ module.exports = function (pagesJson, userManifestJson) {
return
[
manifest
,
parseConfig
(
appJson
)]
}
if
(
process
.
env
.
UNI_USING_V3
)
{
// v3
appJson
.
entryPagePath
=
appJson
.
pages
[
0
]
// timeout
normalizeNetworkTimeout
(
appJson
)
appJson
.
page
=
Object
.
create
(
null
)
const
addPage
=
function
(
pagePath
,
windowOptions
,
nvue
)
{
// 缓存页面级usingComponents
addPageUsingComponents
(
pagePath
,
windowOptions
.
usingComponents
)
delete
windowOptions
.
usingComponents
appJson
.
page
[
pagePath
]
=
{
window
:
windowOptions
,
nvue
}
}
parsePages
(
pagesJson
,
function
(
page
)
{
addPage
(
page
.
path
,
parseStyle
(
page
.
style
),
!!
page
.
nvue
)
},
function
(
root
,
page
)
{
addPage
(
normalizePath
(
path
.
join
(
root
,
page
.
path
)),
parseStyle
(
page
.
style
,
root
),
!!
page
.
nvue
)
if
(
process
.
env
.
UNI_USING_V3
)
{
return
require
(
'
./index.v3
'
)(
appJson
,
manifestJson
,
{
manifest
,
pagesJson
,
normalizeNetworkTimeout
})
// nvue 权限
manifestJson
.
permissions
.
UniNView
=
{
'
description
'
:
'
UniNView原生渲染
'
}
// TODO 需要考虑 condition
manifestJson
.
plus
.
launchwebview
.
id
=
'
1
'
// 首页 id 固定 为 1
// 删除首页 style 中的 uni-app 配置(不注入 app-view.js)
delete
manifestJson
.
plus
.
launchwebview
[
'
uni-app
'
]
if
(
appJson
.
page
[
appJson
.
entryPagePath
].
nvue
)
{
// 首页是 nvue
manifestJson
.
launch_path
=
''
// 首页地址为空
manifestJson
.
plus
.
launchwebview
.
uniNView
=
{
path
:
appJson
.
entryPagePath
}
if
(
manifestJson
.
plus
.
tabBar
)
{
manifestJson
.
plus
.
tabBar
.
child
=
[
'
lauchwebview
'
]
}
}
else
{
manifestJson
.
plus
.
launch_path
=
'
__uniappview.html
'
// 首页地址固定
}
manifest
.
name
=
'
manifest.json
'
manifest
.
content
=
JSON
.
stringify
(
manifest
.
content
)
delete
appJson
.
nvue
return
[
manifest
,
definePages
(
appJson
),
appConfigService
(
appJson
)]
}
return
[
app
,
manifest
]
}
packages/webpack-uni-pages-loader/lib/platforms/app-plus/index.v3.js
0 → 100644
浏览文件 @
be9dfe80
const
path
=
require
(
'
path
'
)
const
{
normalizePath
}
=
require
(
'
@dcloudio/uni-cli-shared
'
)
const
{
parsePages
,
addPageUsingComponents
}
=
require
(
'
@dcloudio/uni-cli-shared/lib/pages
'
)
const
{
parseStyle
}
=
require
(
'
../../util
'
)
const
definePages
=
require
(
'
./define-pages
'
)
const
appConfigService
=
require
(
'
./app-config-service
'
)
function
parseEntryPagePath
(
appJson
,
manifestJson
)
{
const
argsJsonStr
=
manifestJson
.
plus
.
arguments
if
(
argsJsonStr
)
{
try
{
const
args
=
JSON
.
parse
(
argsJsonStr
)
const
pathName
=
args
.
path
||
args
.
pathName
if
(
pathName
&&
pathName
!==
appJson
.
pages
[
0
])
{
appJson
.
entryPagePath
=
pathName
appJson
.
realEntryPagePath
=
appJson
.
pages
[
0
]
}
}
catch
(
e
)
{}
}
if
(
!
appJson
.
entryPagePath
)
{
appJson
.
entryPagePath
=
appJson
.
pages
[
0
]
}
}
module
.
exports
=
function
(
appJson
,
manifestJson
,
{
pagesJson
,
manifest
,
normalizeNetworkTimeout
})
{
parseEntryPagePath
(
appJson
,
manifestJson
)
// timeout
normalizeNetworkTimeout
(
appJson
)
appJson
.
page
=
Object
.
create
(
null
)
const
addPage
=
function
(
pagePath
,
windowOptions
,
nvue
)
{
// 缓存页面级usingComponents
addPageUsingComponents
(
pagePath
,
windowOptions
.
usingComponents
)
delete
windowOptions
.
usingComponents
appJson
.
page
[
pagePath
]
=
{
window
:
windowOptions
,
nvue
}
}
parsePages
(
pagesJson
,
function
(
page
)
{
addPage
(
page
.
path
,
parseStyle
(
page
.
style
),
!!
page
.
nvue
)
},
function
(
root
,
page
)
{
addPage
(
normalizePath
(
path
.
join
(
root
,
page
.
path
)),
parseStyle
(
page
.
style
,
root
),
!!
page
.
nvue
)
})
// nvue 权限
manifestJson
.
permissions
.
UniNView
=
{
'
description
'
:
'
UniNView原生渲染
'
}
// TODO 需要考虑 condition
manifestJson
.
plus
.
launchwebview
.
id
=
'
1
'
// 首页 id 固定 为 1
// 删除首页 style 中的 uni-app 配置(不注入 app-view.js)
delete
manifestJson
.
plus
.
launchwebview
[
'
uni-app
'
]
if
(
appJson
.
page
[
appJson
.
entryPagePath
].
nvue
)
{
// 首页是 nvue
manifestJson
.
launch_path
=
''
// 首页地址为空
manifestJson
.
plus
.
launchwebview
.
uniNView
=
{
path
:
appJson
.
entryPagePath
}
if
(
manifestJson
.
plus
.
tabBar
)
{
manifestJson
.
plus
.
tabBar
.
child
=
[
'
lauchwebview
'
]
}
}
else
{
manifestJson
.
plus
.
launch_path
=
'
__uniappview.html
'
// 首页地址固定
}
manifest
.
name
=
'
manifest.json
'
manifest
.
content
=
JSON
.
stringify
(
manifest
.
content
)
delete
appJson
.
nvue
return
[
manifest
,
definePages
(
appJson
),
appConfigService
(
appJson
)]
}
packages/webpack-uni-pages-loader/lib/platforms/mp.js
浏览文件 @
be9dfe80
...
...
@@ -67,22 +67,21 @@ const manifestJson2AppJson = {
'
debug
'
:
defaultCopy
}
const
pagesJson2ProjectJson
=
{
'
condition
'
:
function
(
name
,
value
,
json
)
{
if
(
process
.
env
.
NODE_ENV
===
'
development
'
)
{
// 仅开发期间 condition 生效
// 启动Condition
const
condition
=
getCondition
(
value
)
if
(
condition
)
{
if
(
!
json
.
condition
)
{
json
.
condition
=
{}
}
process
.
UNI_CONDITION
=
condition
// app-plus编译时,需要获取该参数
json
.
condition
.
miniprogram
=
condition
function
parseCondition
(
projectJson
,
pagesJson
)
{
if
(
process
.
env
.
NODE_ENV
===
'
development
'
)
{
// 仅开发期间 condition 生效
// 启动Condition
const
condition
=
getCondition
(
pagesJson
)
if
(
condition
)
{
if
(
!
projectJson
.
condition
)
{
projectJson
.
condition
=
{}
}
projectJson
.
condition
.
miniprogram
=
condition
}
}
}
const
pagesJson2ProjectJson
=
{}
const
manifestJson2ProjectJson
=
{
'
name
'
:
function
(
name
,
value
,
json
)
{
...
...
@@ -119,7 +118,8 @@ function copyToJson (json, fromJson, options) {
})
}
function
getCondition
(
condition
)
{
function
getCondition
(
pagesJson
)
{
const
condition
=
pagesJson
.
condition
const
launchPagePath
=
process
.
env
.
UNI_CLI_LAUNCH_PAGE_PATH
||
''
const
launchPageQuery
=
process
.
env
.
UNI_CLI_LAUNCH_PAGE_QUERY
||
''
...
...
@@ -158,10 +158,11 @@ function getCondition (condition) {
}
}
if
(
launchPagePath
)
{
return
{
pagesJson
.
condition
=
{
'
current
'
:
0
,
'
list
'
:
[
launchPageOptions
]
}
return
pagesJson
.
condition
}
return
false
}
...
...
@@ -248,7 +249,9 @@ module.exports = function (pagesJson, manifestJson, project = {}) {
content
:
require
(
projectPath
)
}
}
}
else
{
}
else
{
parseCondition
(
project
,
pagesJson
)
copyToJson
(
project
,
pagesJson
,
pagesJson2ProjectJson
)
copyToJson
(
project
,
manifestJson
,
manifestJson2ProjectJson
)
...
...
src/platforms/app-plus/service/api/route/navigate-back.js
浏览文件 @
be9dfe80
...
...
@@ -73,8 +73,8 @@ function back (delta, animationType, animationDuration) {
if
(
!
currentPage
.
__uniapp_webview
)
{
return
backPage
(
webview
)
}
backWebview
(
webview
,
()
=>
{
backPage
(
webview
)
backWebview
(
webview
,
()
=>
{
backPage
(
webview
)
})
}
...
...
@@ -100,10 +100,16 @@ export function navigateBack ({
uni
.
hideToast
()
// 后退时,关闭 toast,loading
currentPage
.
$page
.
meta
.
isQuit
?
quit
()
:
back
(
delta
,
animationType
,
animationDuration
)
// 当前页面是 condition 进入
if
(
currentPage
.
$page
.
id
===
1
&&
__uniConfig
.
realEntryPagePath
)
{
uni
.
reLaunch
({
url
:
'
/
'
+
__uniConfig
.
realEntryPagePath
})
}
else
{
currentPage
.
$page
.
meta
.
isQuit
?
quit
()
:
back
(
delta
,
animationType
,
animationDuration
)
}
return
{
errMsg
:
'
navigateBack:ok
'
}
...
...
src/platforms/app-plus/service/api/route/re-launch.js
浏览文件 @
be9dfe80
...
...
@@ -42,17 +42,16 @@ function _reLaunch ({
'
none
'
,
0
,
()
=>
{
pages
.
forEach
(
page
=>
{
page
.
$remove
()
page
.
$getAppWebview
().
close
(
'
none
'
)
})
invoke
(
callbackId
,
{
errMsg
:
'
reLaunch:ok
'
})
}
)
pages
.
forEach
(
page
=>
{
page
.
$remove
()
page
.
$getAppWebview
().
close
(
'
none
'
)
})
setStatusBarStyle
()
}
...
...
src/platforms/app-plus/service/framework/webview/parser/webview-style-parser.js
浏览文件 @
be9dfe80
...
...
@@ -44,7 +44,7 @@ export function parseWebviewStyle (id, path, routeOptions = {}) {
const
titleNView
=
parseTitleNView
(
routeOptions
)
if
(
titleNView
)
{
if
(
id
===
1
&&
__uniConfig
.
realEntryPagePath
===
path
)
{
if
(
id
===
1
&&
__uniConfig
.
realEntryPagePath
)
{
titleNView
.
autoBackButton
=
true
}
webviewStyle
.
titleNView
=
titleNView
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录