Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
uni-app
提交
fb2e5277
U
uni-app
项目概览
DCloud
/
uni-app
3 个月 前同步成功
通知
725
Star
38705
Fork
3642
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
7
列表
看板
标记
里程碑
合并请求
1
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
7
Issue
7
列表
看板
标记
里程碑
合并请求
1
合并请求
1
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
fb2e5277
编写于
9月 23, 2020
作者:
Q
qiang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: App、H5 新增 rpx 计算相关配置
上级
211d4749
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
45 addition
and
29 deletion
+45
-29
packages/webpack-uni-pages-loader/lib/index-new.js
packages/webpack-uni-pages-loader/lib/index-new.js
+3
-3
packages/webpack-uni-pages-loader/lib/platforms/app-plus/define-pages.js
...k-uni-pages-loader/lib/platforms/app-plus/define-pages.js
+8
-3
packages/webpack-uni-pages-loader/lib/platforms/app-plus/index.js
.../webpack-uni-pages-loader/lib/platforms/app-plus/index.js
+14
-14
packages/webpack-uni-pages-loader/lib/platforms/app-plus/index.v3.js
...bpack-uni-pages-loader/lib/platforms/app-plus/index.v3.js
+8
-8
src/core/service/api/base/upx2px.js
src/core/service/api/base/upx2px.js
+12
-1
未找到文件。
packages/webpack-uni-pages-loader/lib/index-new.js
浏览文件 @
fb2e5277
...
...
@@ -17,7 +17,7 @@ const {
}
=
require
(
'
@dcloudio/uni-cli-shared/lib/cache
'
)
const
{
initTheme
,
initTheme
,
parseTheme
}
=
require
(
'
@dcloudio/uni-cli-shared/lib/theme
'
)
...
...
@@ -95,7 +95,7 @@ module.exports = function (content, map) {
})
}
const
jsonFiles
=
require
(
'
./platforms/
'
+
process
.
env
.
UNI_PLATFORM
)(
pagesJson
,
manifestJson
)
const
jsonFiles
=
require
(
'
./platforms/
'
+
process
.
env
.
UNI_PLATFORM
)(
pagesJson
,
manifestJson
,
isAppView
)
if
(
jsonFiles
&&
jsonFiles
.
length
)
{
if
(
process
.
env
.
UNI_USING_V3
)
{
...
...
@@ -144,4 +144,4 @@ module.exports = function (content, map) {
}
this
.
callback
(
null
,
''
,
map
)
}
}
packages/webpack-uni-pages-loader/lib/platforms/app-plus/define-pages.js
浏览文件 @
fb2e5277
...
...
@@ -7,10 +7,14 @@ function generatePageCode (pages, pageOptions) {
}).
join
(
'
\n
'
)
}
module
.
exports
=
function
definePages
(
appJson
)
{
function
generateUniConfig
(
appJson
,
isAppView
)
{
return
isAppView
?
`window.__uniConfig =
${
JSON
.
stringify
({
window
:
appJson
.
window
},
null
)}
;`
:
''
}
module
.
exports
=
function
definePages
(
appJson
,
isAppView
)
{
return
{
name
:
'
define-pages.js
'
,
content
:
`
content
:
`
if (typeof Promise !== 'undefined' && !Promise.prototype.finally) {
Promise.prototype.finally = function(callback) {
const promise = this.constructor
...
...
@@ -22,10 +26,11 @@ if (typeof Promise !== 'undefined' && !Promise.prototype.finally) {
)
}
}
${
generateUniConfig
(
appJson
,
isAppView
)}
if(uni.restoreGlobal){
uni.restoreGlobal(weex,plus,setTimeout,clearTimeout,setInterval,clearInterval)
}
${
generatePageCode
(
appJson
.
pages
,
appJson
.
page
)}
`
}
}
}
packages/webpack-uni-pages-loader/lib/platforms/app-plus/index.js
浏览文件 @
fb2e5277
...
...
@@ -91,7 +91,7 @@ function updateFileFlag (appJson) {
}
}
module
.
exports
=
function
(
pagesJson
,
userManifestJson
)
{
module
.
exports
=
function
(
pagesJson
,
userManifestJson
,
isAppView
)
{
const
{
app
}
=
require
(
'
../mp
'
)(
pagesJson
,
userManifestJson
)
...
...
@@ -179,7 +179,7 @@ module.exports = function (pagesJson, userManifestJson) {
if
(
!
manifestJson
.
permissions
)
{
manifestJson
.
permissions
=
{}
}
const
nvuePages
=
process
.
env
.
UNI_USING_V3_NATIVE
?
pagesJson
.
pages
:
(
pagesJson
.
nvue
&&
pagesJson
.
nvue
.
pages
)
if
(
nvuePages
&&
nvuePages
.
length
)
{
...
...
@@ -197,12 +197,12 @@ module.exports = function (pagesJson, userManifestJson) {
appJson
.
nvue
=
{
pages
}
if
(
process
.
env
.
UNI_USING_V3_NATIVE
)
{
appJson
.
nvue
.
entryPagePath
=
nvuePages
[
0
]
}
else
if
(
pagesJson
.
nvue
.
entryPagePath
)
{
appJson
.
nvue
.
entryPagePath
=
pagesJson
.
nvue
.
entryPagePath
}
if
(
process
.
env
.
UNI_USING_V3_NATIVE
)
{
appJson
.
nvue
.
entryPagePath
=
nvuePages
[
0
]
}
else
if
(
pagesJson
.
nvue
.
entryPagePath
)
{
appJson
.
nvue
.
entryPagePath
=
pagesJson
.
nvue
.
entryPagePath
}
// nvue 权限
manifestJson
.
permissions
.
UniNView
=
{
...
...
@@ -347,10 +347,10 @@ module.exports = function (pagesJson, userManifestJson) {
resources
[
key
.
replace
(
/
\.
nvue$/
,
'
.js
'
)]
=
confusion
.
resources
[
key
]
}
if
(
!
Object
.
keys
(
nvuePages
).
find
(
path
=>
{
const
subNVues
=
nvuePages
[
path
].
window
.
subNVues
||
[]
// TODO
return
(
path
.
replace
(
/
\.
html$/
,
'
.nvue
'
)
===
key
||
path
.
replace
(
/
\.
html$/
,
'
.nvue
'
)
+
'
.nvue
'
===
key
)
||
subNVues
.
find
(({
path
const
subNVues
=
nvuePages
[
path
].
window
.
subNVues
||
[]
// TODO
return
(
path
.
replace
(
/
\.
html$/
,
'
.nvue
'
)
===
key
||
path
.
replace
(
/
\.
html$/
,
'
.nvue
'
)
+
'
.nvue
'
===
key
)
||
subNVues
.
find
(({
path
})
=>
path
===
key
.
replace
(
/
\.
nvue$/
,
''
))
})
&&
!
pagesJson
.
pages
.
find
(({
style
=
{}
...
...
@@ -514,7 +514,7 @@ module.exports = function (pagesJson, userManifestJson) {
manifest
,
pagesJson
,
normalizeNetworkTimeout
})
}
,
isAppView
)
}
return
[
app
,
manifest
]
}
}
packages/webpack-uni-pages-loader/lib/platforms/app-plus/index.v3.js
浏览文件 @
fb2e5277
...
...
@@ -52,7 +52,7 @@ module.exports = function (appJson, manifestJson, {
pagesJson
,
manifest
,
normalizeNetworkTimeout
})
{
}
,
isAppView
)
{
parseEntryPagePath
(
appJson
,
manifestJson
)
// timeout
...
...
@@ -82,12 +82,12 @@ module.exports = function (appJson, manifestJson, {
// 删除首页 style 中的 uni-app 配置(不注入 app-view.js)
delete
manifestJson
.
plus
.
launchwebview
[
'
uni-app
'
]
const
entryPagePath
=
appJson
.
entryPagePath
if
(
!
appJson
.
page
[
entryPagePath
])
{
console
.
error
(
`pages.json condition['list'][current]['path']:
${
entryPagePath
}
需在 pages 数组中`
)
process
.
exit
(
0
)
const
entryPagePath
=
appJson
.
entryPagePath
if
(
!
appJson
.
page
[
entryPagePath
])
{
console
.
error
(
`pages.json condition['list'][current]['path']:
${
entryPagePath
}
需在 pages 数组中`
)
process
.
exit
(
0
)
}
if
(
appJson
.
page
[
entryPagePath
].
nvue
)
{
// 首页是 nvue
manifestJson
.
launch_path
=
''
// 首页地址为空
...
...
@@ -109,5 +109,5 @@ module.exports = function (appJson, manifestJson, {
manifest
.
name
=
'
manifest.json
'
manifest
.
content
=
JSON
.
stringify
(
manifest
.
content
)
delete
appJson
.
nvue
return
[
manifest
,
definePages
(
appJson
),
appConfigService
(
appJson
)]
return
[
manifest
,
definePages
(
appJson
,
isAppView
),
appConfigService
(
appJson
)]
}
src/core/service/api/base/upx2px.js
浏览文件 @
fb2e5277
...
...
@@ -16,6 +16,11 @@ function checkDeviceWidth () {
isIOS
=
platform
===
'
ios
'
}
function
checkValue
(
value
,
defaultValue
)
{
value
=
Number
(
value
)
return
isNaN
(
value
)
?
defaultValue
:
value
}
export
function
upx2px
(
number
,
newDeviceWidth
)
{
if
(
deviceWidth
===
0
)
{
checkDeviceWidth
()
...
...
@@ -25,7 +30,13 @@ export function upx2px (number, newDeviceWidth) {
if
(
number
===
0
)
{
return
0
}
let
result
=
(
number
/
BASE_DEVICE_WIDTH
)
*
(
newDeviceWidth
||
deviceWidth
)
const
config
=
__uniConfig
.
globalStyle
||
__uniConfig
.
window
||
{}
const
maxWidth
=
checkValue
(
config
.
rpxCalcMaxDeviceWidth
,
960
)
const
baseWidth
=
checkValue
(
config
.
rpxCalcBaseDeviceWidth
,
375
)
const
includeWidth
=
checkValue
(
config
.
rpxCalcIncludeWidth
,
750
)
let
width
=
newDeviceWidth
||
deviceWidth
width
=
number
===
includeWidth
||
width
<=
maxWidth
?
width
:
baseWidth
let
result
=
(
number
/
BASE_DEVICE_WIDTH
)
*
width
if
(
result
<
0
)
{
result
=
-
result
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录