Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
uni-app
提交
34ab6a53
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,发现更多精彩内容 >>
提交
34ab6a53
编写于
10月 30, 2020
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(h5): add maxWidth
上级
3384b90e
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
77 addition
and
22 deletion
+77
-22
packages/vue-cli-plugin-uni/lib/split-chunks.js
packages/vue-cli-plugin-uni/lib/split-chunks.js
+2
-3
packages/webpack-uni-pages-loader/lib/platforms/h5.js
packages/webpack-uni-pages-loader/lib/platforms/h5.js
+12
-10
src/platforms/h5/components/app/index.vue
src/platforms/h5/components/app/index.vue
+9
-2
src/platforms/h5/components/app/layout.vue
src/platforms/h5/components/app/layout.vue
+52
-5
src/platforms/h5/components/app/tabBar.vue
src/platforms/h5/components/app/tabBar.vue
+2
-2
未找到文件。
packages/vue-cli-plugin-uni/lib/split-chunks.js
浏览文件 @
34ab6a53
...
...
@@ -166,7 +166,7 @@ module.exports = function getSplitChunks () {
if
(
module
.
resource
&&
module
.
reasons
)
{
for
(
let
index
=
0
;
index
<
module
.
reasons
.
length
;
index
++
)
{
const
m
=
module
.
reasons
[
index
]
if
(
m
.
module
&&
m
.
module
.
resource
)
{
const
resource
=
normalizePath
(
m
.
module
.
resource
)
if
(
...
...
@@ -202,8 +202,7 @@ module.exports = function getSplitChunks () {
matchSubPackages
.
has
(
root
+
'
/
'
)
&&
!
hasMainPackage
(
chunks
)
&&
!
hasMainPackageComponent
(
module
,
matchSubPackages
.
values
().
next
().
value
)
)
{
)
{
if
(
process
.
env
.
UNI_OPT_TRACE
)
{
console
.
log
(
root
,
module
.
resource
,
chunks
.
map
(
chunk
=>
chunk
.
name
))
}
...
...
packages/webpack-uni-pages-loader/lib/platforms/h5.js
浏览文件 @
34ab6a53
...
...
@@ -154,10 +154,11 @@ const getPageComponents = function (inputDir, pagesJson) {
isTabBar
,
tabBarIndex
,
isQuit
:
isEntry
||
isTabBar
,
windowTop
,
topWindow
:
pageStyle
.
topWindow
,
leftWindow
:
pageStyle
.
leftWindow
,
rightWindow
:
pageStyle
.
rightWindow
windowTop
,
topWindow
:
pageStyle
.
topWindow
,
leftWindow
:
pageStyle
.
leftWindow
,
rightWindow
:
pageStyle
.
rightWindow
,
maxWidth
:
pageStyle
.
maxWidth
}
}).
filter
(
pageComponents
=>
!!
pageComponents
)
}
...
...
@@ -214,10 +215,11 @@ const genPageRoutes = function (pageComponents) {
isEntry
,
isTabBar
,
windowTop
,
tabBarIndex
,
topWindow
,
leftWindow
,
rightWindow
tabBarIndex
,
topWindow
,
leftWindow
,
rightWindow
,
maxWidth
})
=>
{
return
`
{
...
...
@@ -228,7 +230,7 @@ component: {
'Page',
{
props: Object.assign({
${
isQuit
?
'
isQuit:true,
\n
'
:
''
}${
isEntry
?
'
isEntry:true,
\n
'
:
''
}${
isTabBar
?
'
isTabBar:true,
\n
'
:
''
}
${
isQuit
?
'
isQuit:true,
\n
'
:
''
}${
isEntry
?
'
isEntry:true,
\n
'
:
''
}${
isTabBar
?
'
isTabBar:true,
\n
'
:
''
}
${
topWindow
===
false
?
'
topWindow:false,
\n
'
:
''
}${
leftWindow
===
false
?
'
leftWindow:false,
\n
'
:
''
}${
rightWindow
===
false
?
'
rightWindow:false,
\n
'
:
''
}
${
isTabBar
?
(
'
tabBarIndex:
'
+
tabBarIndex
)
:
''
}
},__uniConfig.globalStyle,
${
JSON
.
stringify
(
props
)}
)
...
...
@@ -243,7 +245,7 @@ component: {
},
meta:{
${
isQuit
?
'
\n
id:
'
+
(
id
++
)
+
'
,
'
:
''
}
name:'
${
name
}
',
isNVue:
${
isNVue
}
,
${
topWindow
===
false
?
'
topWindow:false,
\n
'
:
''
}${
leftWindow
===
false
?
'
leftWindow:false,
\n
'
:
''
}${
rightWindow
===
false
?
'
rightWindow:false,
\n
'
:
''
}
isNVue:
${
isNVue
}
,
maxWidth:
${
maxWidth
||
0
}
,
${
topWindow
===
false
?
'
topWindow:false,
\n
'
:
''
}${
leftWindow
===
false
?
'
leftWindow:false,
\n
'
:
''
}${
rightWindow
===
false
?
'
rightWindow:false,
\n
'
:
''
}
pagePath:'
${
route
}
'
${
isQuit
?
'
,
\n
isQuit:true
'
:
''
}${
isEntry
?
'
,
\n
isEntry:true
'
:
''
}${
isTabBar
?
'
,
\n
isTabBar:true
'
:
''
}${
tabBarIndex
!==
-
1
?
(
'
,
\n
tabBarIndex:
'
+
tabBarIndex
)
:
''
}
,
windowTop:
${
windowTop
}
}
...
...
src/platforms/h5/components/app/index.vue
浏览文件 @
34ab6a53
<
template
>
<uni-app
:class=
"
{'uni-app--showtabbar':showTabBar}">
<uni-app
:class=
"
{'uni-app--showtabbar':showTabBar
,'uni-app--maxwidth':showMaxWidth
}">
<layout
ref=
"layout"
:router-key=
"key"
:keep-alive-include=
"keepAliveInclude"
@
maxWidth=
"onMaxWidth"
/>
<tab-bar
v-if=
"hasTabBar"
...
...
@@ -63,7 +64,8 @@ export default {
transitionName
:
'
fade
'
,
hideTabBar
:
false
,
tabBar
:
__uniConfig
.
tabBar
||
{},
sysComponents
:
this
.
$sysComponents
sysComponents
:
this
.
$sysComponents
,
showMaxWidth
:
false
}
},
computed
:
{
...
...
@@ -113,6 +115,11 @@ export default {
UniServiceJSBridge
.
emit
(
'
onAppEnterBackground
'
)
}
})
},
methods
:
{
onMaxWidth
(
showMaxWidth
)
{
this
.
showMaxWidth
=
showMaxWidth
}
}
}
</
script
>
...
...
src/platforms/h5/components/app/layout.vue
浏览文件 @
34ab6a53
...
...
@@ -134,6 +134,7 @@ export default {
},
data
()
{
return
{
marginWidth
:
0
,
leftWindowStyle
:
''
,
rightWindowStyle
:
''
,
topWindowStyle
:
''
,
...
...
@@ -144,7 +145,8 @@ export default {
apiShowTopWindow
:
false
,
apiShowLeftWindow
:
false
,
apiShowRightWindow
:
false
,
navigationBarTitleText
:
''
navigationBarTitleText
:
''
,
maxWidthMeidaQuery
:
false
}
},
computed
:
{
...
...
@@ -175,6 +177,9 @@ export default {
}
},
watch
:
{
$route
()
{
this
.
checkMaxWidth
()
},
showTopWindow
(
newVal
,
val
)
{
if
(
newVal
)
{
this
.
$nextTick
(
this
.
onTopWindowInit
)
...
...
@@ -230,6 +235,10 @@ export default {
})
}
}
this
.
initMaxWidth
()
},
mounted
()
{
this
.
checkMaxWidth
()
},
methods
:
{
resetApiShowWindow
()
{
...
...
@@ -257,6 +266,42 @@ export default {
}
}
},
initMaxWidth
()
{
window
.
addEventListener
(
'
resize
'
,
()
=>
{
this
.
checkMaxWidth
()
})
},
checkMaxWidth
()
{
const
maxWidth
=
parseInt
(
this
.
$route
.
meta
.
maxWidth
)
let
showMaxWidth
=
false
if
(
window
.
innerWidth
>
maxWidth
)
{
showMaxWidth
=
true
}
else
{
showMaxWidth
=
false
}
this
.
$emit
(
'
maxWidth
'
,
showMaxWidth
)
if
(
!
this
.
$containerElem
)
{
this
.
$containerElem
=
document
.
querySelector
(
'
uni-content,uni-app
'
)
}
if
(
!
this
.
$containerElem
)
{
return
}
if
(
showMaxWidth
&&
maxWidth
)
{
this
.
marginWidth
=
(
window
.
innerWidth
-
maxWidth
)
/
2
this
.
$nextTick
(()
=>
{
this
.
onLeftWindowInit
()
this
.
onRightWindowInit
()
this
.
$containerElem
.
setAttribute
(
'
style
'
,
'
max-width:
'
+
maxWidth
+
'
px;margin:0 auto
'
)
})
}
else
{
this
.
marginWidth
=
0
this
.
$nextTick
(()
=>
{
this
.
onLeftWindowInit
()
this
.
onRightWindowInit
()
this
.
$containerElem
.
removeAttribute
(
'
style
'
)
})
}
},
initWindowMinWidth
(
type
)
{
const
name
=
type
+
'
Window
'
if
(
this
[
name
])
{
...
...
@@ -300,22 +345,24 @@ export default {
},
onLeftWindowInit
()
{
if
(
!
(
this
.
responsive
&&
this
.
leftWindow
))
{
updateCssVar
(
'
--window-left
'
,
this
.
marginWidth
+
'
px
'
)
return
}
if
(
this
.
leftWindowStyle
&&
this
.
leftWindowStyle
.
width
)
{
updateCssVar
(
'
--window-left
'
,
this
.
$refs
.
leftWindow
.
offsetWidth
+
'
px
'
)
updateCssVar
(
'
--window-left
'
,
this
.
$refs
.
leftWindow
.
offsetWidth
+
this
.
marginWidth
+
'
px
'
)
}
else
{
updateCssVar
(
'
--window-left
'
,
this
.
$refs
.
left
.
$el
.
offsetWidth
+
'
px
'
)
updateCssVar
(
'
--window-left
'
,
this
.
$refs
.
left
.
$el
.
offsetWidth
+
this
.
marginWidth
+
'
px
'
)
}
},
onRightWindowInit
()
{
if
(
!
(
this
.
responsive
&&
this
.
rightWindow
))
{
updateCssVar
(
'
--window-right
'
,
this
.
marginWidth
+
'
px
'
)
return
}
if
(
this
.
rightWindowStyle
&&
this
.
rightWindowStyle
.
width
)
{
updateCssVar
(
'
--window-right
'
,
this
.
$refs
.
rightWindow
.
offsetWidth
+
'
px
'
)
updateCssVar
(
'
--window-right
'
,
this
.
$refs
.
rightWindow
.
offsetWidth
+
this
.
marginWidth
+
'
px
'
)
}
else
{
updateCssVar
(
'
--window-right
'
,
this
.
$refs
.
right
.
$el
.
offsetWidth
+
'
px
'
)
updateCssVar
(
'
--window-right
'
,
this
.
$refs
.
right
.
$el
.
offsetWidth
+
this
.
marginWidth
+
'
px
'
)
}
}
}
...
...
src/platforms/h5/components/app/tabBar.vue
浏览文件 @
34ab6a53
...
...
@@ -66,9 +66,9 @@ uni-tabbar {
uni-tabbar
.uni-tabbar
{
display
:
flex
;
position
:
fixed
;
left
:
0
;
left
:
var
(
--window-left
);
right
:
var
(
--window-right
);
bottom
:
0
;
width
:
100%
;
z-index
:
998
;
box-sizing
:
border-box
;
padding-bottom
:
0
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录