Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
genary
uni-app
提交
fb2e5277
U
uni-app
项目概览
genary
/
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,发现更多精彩内容 >>
提交
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 {
...
@@ -17,7 +17,7 @@ const {
}
=
require
(
'
@dcloudio/uni-cli-shared/lib/cache
'
)
}
=
require
(
'
@dcloudio/uni-cli-shared/lib/cache
'
)
const
{
const
{
initTheme
,
initTheme
,
parseTheme
parseTheme
}
=
require
(
'
@dcloudio/uni-cli-shared/lib/theme
'
)
}
=
require
(
'
@dcloudio/uni-cli-shared/lib/theme
'
)
...
@@ -95,7 +95,7 @@ module.exports = function (content, map) {
...
@@ -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
(
jsonFiles
&&
jsonFiles
.
length
)
{
if
(
process
.
env
.
UNI_USING_V3
)
{
if
(
process
.
env
.
UNI_USING_V3
)
{
...
@@ -144,4 +144,4 @@ module.exports = function (content, map) {
...
@@ -144,4 +144,4 @@ module.exports = function (content, map) {
}
}
this
.
callback
(
null
,
''
,
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) {
...
@@ -7,10 +7,14 @@ function generatePageCode (pages, pageOptions) {
}).
join
(
'
\n
'
)
}).
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
{
return
{
name
:
'
define-pages.js
'
,
name
:
'
define-pages.js
'
,
content
:
`
content
:
`
if (typeof Promise !== 'undefined' && !Promise.prototype.finally) {
if (typeof Promise !== 'undefined' && !Promise.prototype.finally) {
Promise.prototype.finally = function(callback) {
Promise.prototype.finally = function(callback) {
const promise = this.constructor
const promise = this.constructor
...
@@ -22,10 +26,11 @@ if (typeof Promise !== 'undefined' && !Promise.prototype.finally) {
...
@@ -22,10 +26,11 @@ if (typeof Promise !== 'undefined' && !Promise.prototype.finally) {
)
)
}
}
}
}
${
generateUniConfig
(
appJson
,
isAppView
)}
if(uni.restoreGlobal){
if(uni.restoreGlobal){
uni.restoreGlobal(weex,plus,setTimeout,clearTimeout,setInterval,clearInterval)
uni.restoreGlobal(weex,plus,setTimeout,clearTimeout,setInterval,clearInterval)
}
}
${
generatePageCode
(
appJson
.
pages
,
appJson
.
page
)}
${
generatePageCode
(
appJson
.
pages
,
appJson
.
page
)}
`
`
}
}
}
}
packages/webpack-uni-pages-loader/lib/platforms/app-plus/index.js
浏览文件 @
fb2e5277
...
@@ -91,7 +91,7 @@ function updateFileFlag (appJson) {
...
@@ -91,7 +91,7 @@ function updateFileFlag (appJson) {
}
}
}
}
module
.
exports
=
function
(
pagesJson
,
userManifestJson
)
{
module
.
exports
=
function
(
pagesJson
,
userManifestJson
,
isAppView
)
{
const
{
const
{
app
app
}
=
require
(
'
../mp
'
)(
pagesJson
,
userManifestJson
)
}
=
require
(
'
../mp
'
)(
pagesJson
,
userManifestJson
)
...
@@ -179,7 +179,7 @@ module.exports = function (pagesJson, userManifestJson) {
...
@@ -179,7 +179,7 @@ module.exports = function (pagesJson, userManifestJson) {
if
(
!
manifestJson
.
permissions
)
{
if
(
!
manifestJson
.
permissions
)
{
manifestJson
.
permissions
=
{}
manifestJson
.
permissions
=
{}
}
}
const
nvuePages
=
process
.
env
.
UNI_USING_V3_NATIVE
?
pagesJson
.
pages
:
(
pagesJson
.
nvue
&&
pagesJson
.
nvue
.
pages
)
const
nvuePages
=
process
.
env
.
UNI_USING_V3_NATIVE
?
pagesJson
.
pages
:
(
pagesJson
.
nvue
&&
pagesJson
.
nvue
.
pages
)
if
(
nvuePages
&&
nvuePages
.
length
)
{
if
(
nvuePages
&&
nvuePages
.
length
)
{
...
@@ -197,12 +197,12 @@ module.exports = function (pagesJson, userManifestJson) {
...
@@ -197,12 +197,12 @@ module.exports = function (pagesJson, userManifestJson) {
appJson
.
nvue
=
{
appJson
.
nvue
=
{
pages
pages
}
}
if
(
process
.
env
.
UNI_USING_V3_NATIVE
)
{
if
(
process
.
env
.
UNI_USING_V3_NATIVE
)
{
appJson
.
nvue
.
entryPagePath
=
nvuePages
[
0
]
appJson
.
nvue
.
entryPagePath
=
nvuePages
[
0
]
}
else
if
(
pagesJson
.
nvue
.
entryPagePath
)
{
}
else
if
(
pagesJson
.
nvue
.
entryPagePath
)
{
appJson
.
nvue
.
entryPagePath
=
pagesJson
.
nvue
.
entryPagePath
appJson
.
nvue
.
entryPagePath
=
pagesJson
.
nvue
.
entryPagePath
}
}
// nvue 权限
// nvue 权限
manifestJson
.
permissions
.
UniNView
=
{
manifestJson
.
permissions
.
UniNView
=
{
...
@@ -347,10 +347,10 @@ module.exports = function (pagesJson, userManifestJson) {
...
@@ -347,10 +347,10 @@ module.exports = function (pagesJson, userManifestJson) {
resources
[
key
.
replace
(
/
\.
nvue$/
,
'
.js
'
)]
=
confusion
.
resources
[
key
]
resources
[
key
.
replace
(
/
\.
nvue$/
,
'
.js
'
)]
=
confusion
.
resources
[
key
]
}
}
if
(
!
Object
.
keys
(
nvuePages
).
find
(
path
=>
{
if
(
!
Object
.
keys
(
nvuePages
).
find
(
path
=>
{
const
subNVues
=
nvuePages
[
path
].
window
.
subNVues
||
[]
const
subNVues
=
nvuePages
[
path
].
window
.
subNVues
||
[]
// TODO
// TODO
return
(
path
.
replace
(
/
\.
html$/
,
'
.nvue
'
)
===
key
||
path
.
replace
(
/
\.
html$/
,
'
.nvue
'
)
+
'
.nvue
'
===
key
)
||
subNVues
.
find
(({
return
(
path
.
replace
(
/
\.
html$/
,
'
.nvue
'
)
===
key
||
path
.
replace
(
/
\.
html$/
,
'
.nvue
'
)
+
'
.nvue
'
===
key
)
||
subNVues
.
find
(({
path
path
})
=>
path
===
key
.
replace
(
/
\.
nvue$/
,
''
))
})
=>
path
===
key
.
replace
(
/
\.
nvue$/
,
''
))
})
&&
!
pagesJson
.
pages
.
find
(({
})
&&
!
pagesJson
.
pages
.
find
(({
style
=
{}
style
=
{}
...
@@ -514,7 +514,7 @@ module.exports = function (pagesJson, userManifestJson) {
...
@@ -514,7 +514,7 @@ module.exports = function (pagesJson, userManifestJson) {
manifest
,
manifest
,
pagesJson
,
pagesJson
,
normalizeNetworkTimeout
normalizeNetworkTimeout
})
}
,
isAppView
)
}
}
return
[
app
,
manifest
]
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, {
...
@@ -52,7 +52,7 @@ module.exports = function (appJson, manifestJson, {
pagesJson
,
pagesJson
,
manifest
,
manifest
,
normalizeNetworkTimeout
normalizeNetworkTimeout
})
{
}
,
isAppView
)
{
parseEntryPagePath
(
appJson
,
manifestJson
)
parseEntryPagePath
(
appJson
,
manifestJson
)
// timeout
// timeout
...
@@ -82,12 +82,12 @@ module.exports = function (appJson, manifestJson, {
...
@@ -82,12 +82,12 @@ module.exports = function (appJson, manifestJson, {
// 删除首页 style 中的 uni-app 配置(不注入 app-view.js)
// 删除首页 style 中的 uni-app 配置(不注入 app-view.js)
delete
manifestJson
.
plus
.
launchwebview
[
'
uni-app
'
]
delete
manifestJson
.
plus
.
launchwebview
[
'
uni-app
'
]
const
entryPagePath
=
appJson
.
entryPagePath
const
entryPagePath
=
appJson
.
entryPagePath
if
(
!
appJson
.
page
[
entryPagePath
])
{
if
(
!
appJson
.
page
[
entryPagePath
])
{
console
.
error
(
console
.
error
(
`pages.json condition['list'][current]['path']:
${
entryPagePath
}
需在 pages 数组中`
`pages.json condition['list'][current]['path']:
${
entryPagePath
}
需在 pages 数组中`
)
)
process
.
exit
(
0
)
process
.
exit
(
0
)
}
}
if
(
appJson
.
page
[
entryPagePath
].
nvue
)
{
// 首页是 nvue
if
(
appJson
.
page
[
entryPagePath
].
nvue
)
{
// 首页是 nvue
manifestJson
.
launch_path
=
''
// 首页地址为空
manifestJson
.
launch_path
=
''
// 首页地址为空
...
@@ -109,5 +109,5 @@ module.exports = function (appJson, manifestJson, {
...
@@ -109,5 +109,5 @@ module.exports = function (appJson, manifestJson, {
manifest
.
name
=
'
manifest.json
'
manifest
.
name
=
'
manifest.json
'
manifest
.
content
=
JSON
.
stringify
(
manifest
.
content
)
manifest
.
content
=
JSON
.
stringify
(
manifest
.
content
)
delete
appJson
.
nvue
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 () {
...
@@ -16,6 +16,11 @@ function checkDeviceWidth () {
isIOS
=
platform
===
'
ios
'
isIOS
=
platform
===
'
ios
'
}
}
function
checkValue
(
value
,
defaultValue
)
{
value
=
Number
(
value
)
return
isNaN
(
value
)
?
defaultValue
:
value
}
export
function
upx2px
(
number
,
newDeviceWidth
)
{
export
function
upx2px
(
number
,
newDeviceWidth
)
{
if
(
deviceWidth
===
0
)
{
if
(
deviceWidth
===
0
)
{
checkDeviceWidth
()
checkDeviceWidth
()
...
@@ -25,7 +30,13 @@ export function upx2px (number, newDeviceWidth) {
...
@@ -25,7 +30,13 @@ export function upx2px (number, newDeviceWidth) {
if
(
number
===
0
)
{
if
(
number
===
0
)
{
return
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
)
{
if
(
result
<
0
)
{
result
=
-
result
result
=
-
result
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录