Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2ca8d40

Browse files
committed
更新[BoxJs TF]: 顶栏和底栏可以设置跟随滚动
1 parent d6b64a6 commit 2ca8d40

File tree

3 files changed

+92
-18
lines changed

3 files changed

+92
-18
lines changed

box/chavy.boxjs.html

Lines changed: 78 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,13 @@
9393
<div id="BG"></div>
9494
<div id="app" v-cloak>
9595
<v-app v-if="box" :style="appViewStyle">
96-
<v-app-bar app v-bind="appBarBind" :class="appBarClass" :value="!isHidedSearchBar" v-touch="{ up: () => isHidedSearchBar = true }">
96+
<v-app-bar
97+
ref="appBar"
98+
v-bind="appBarBind"
99+
:class="!$refs.appBar || $refs.appBar.isActive ? 'safe' : undefined"
100+
:value="!isHidedSearchBar"
101+
v-touch="{ up: () => isHidedSearchBar = true }"
102+
>
97103
<!-- 搜索条 -->
98104
<v-autocomplete v-bind="ui.searchBar" :label="title" @click="ui.searchDialog.show = true" hide-no-data hide-details solo>
99105
<template #prepend-inner>
@@ -296,6 +302,22 @@
296302
<v-avatar size="32"><v-icon>mdi-dock-top</v-icon></v-avatar>
297303
</v-btn>
298304
</v-list-item>
305+
<v-list-item class="mt-4">
306+
<v-switch
307+
dense
308+
class="mt-0"
309+
label="自动顶栏"
310+
v-model="isAutoSearchBar"
311+
@change="saveUserCfgs"
312+
:persistent-hint="true"
313+
hint="顶栏跟随主屏滚动"
314+
>
315+
</v-switch>
316+
<v-spacer></v-spacer>
317+
<v-btn fab small text>
318+
<v-avatar size="32"><v-icon>mdi-format-align-top</v-icon></v-avatar>
319+
</v-btn>
320+
</v-list-item>
299321
<v-list-item class="mt-4">
300322
<v-switch
301323
dense
@@ -312,6 +334,22 @@
312334
<v-avatar size="32"><v-icon>mdi-dock-bottom</v-icon></v-avatar>
313335
</v-btn>
314336
</v-list-item>
337+
<v-list-item class="mt-4">
338+
<v-switch
339+
dense
340+
class="mt-0"
341+
label="自动底栏"
342+
v-model="isAutoNaviBottom"
343+
@change="saveUserCfgs"
344+
:persistent-hint="true"
345+
hint="底栏跟随主屏滚动"
346+
>
347+
</v-switch>
348+
<v-spacer></v-spacer>
349+
<v-btn fab small text>
350+
<v-avatar size="32"><v-icon>mdi-format-align-bottom</v-icon></v-avatar>
351+
</v-btn>
352+
</v-list-item>
315353
<!-- <v-list-item class="mt-4">
316354
<v-switch
317355
dense
@@ -456,7 +494,7 @@
456494
</v-list>
457495
</v-navigation-drawer>
458496
<!-- 主页 -->
459-
<v-main v-scroll="onScroll">
497+
<v-main class="appBarBind.app ? 'safe' : ''" v-scroll="onScroll">
460498
<v-snackbar top app v-model="ui.snackbar.show" v-bind="ui.snackbar">{{ui.snackbar.msg}}</v-snackbar>
461499
<!-- 主页 -->
462500
<v-container
@@ -1098,14 +1136,7 @@ <h2 :style="appTitleStyle">{{curbak.name}}</h2>
10981136
</v-container>
10991137
</v-main>
11001138
<!-- 底部 -->
1101-
<v-bottom-navigation
1102-
app
1103-
grow
1104-
color="primary"
1105-
:value="view"
1106-
:input-value="!isHidedNaviBottom"
1107-
v-touch="{ down: () => isHidedNaviBottom = true }"
1108-
>
1139+
<v-bottom-navigation ref="naviBar" v-bind="naviBarBind" v-touch="{ down: () => isHidedNaviBottom = true }">
11091140
<v-progress-linear :active="isLoading" height="2" absolute top indeterminate></v-progress-linear>
11101141
<v-btn @click="switchView('')" value="">首页<v-icon>mdi-home</v-icon></v-btn>
11111142
<v-btn @click="switchView('app')" value="app">应用<v-icon>mdi-application</v-icon></v-btn>
@@ -1411,6 +1442,17 @@ <h2 :class="version === ver.version ? 'primary--text' : undefined">v{{ver.versio
14111442
this.box.usercfgs.isHidedSearchBar = val === true
14121443
}
14131444
},
1445+
isAutoSearchBar: {
1446+
get() {
1447+
return this.box.usercfgs.isAutoSearchBar
1448+
},
1449+
set(val) {
1450+
this.box.usercfgs.isAutoSearchBar = val === true
1451+
if (val === false && !this.isHidedSearchBar) {
1452+
this.$refs.appBar.isActive = true
1453+
}
1454+
}
1455+
},
14141456
isHidedAppIcons: {
14151457
get() {
14161458
return this.box.usercfgs.isHidedAppIcons || this.isWallpaperMode
@@ -1427,6 +1469,17 @@ <h2 :class="version === ver.version ? 'primary--text' : undefined">v{{ver.versio
14271469
this.box.usercfgs.isHidedNaviBottom = val === true
14281470
}
14291471
},
1472+
isAutoNaviBottom: {
1473+
get() {
1474+
return this.box.usercfgs.isAutoNaviBottom
1475+
},
1476+
set(val) {
1477+
this.box.usercfgs.isAutoNaviBottom = val === true
1478+
if (val === false && !this.isHidedNaviBottom) {
1479+
this.$refs.naviBar.isActive = true
1480+
}
1481+
}
1482+
},
14301483
// 判断是否有壁纸
14311484
isWallpaper() {
14321485
return !!this.box.usercfgs.bgimg
@@ -1478,20 +1531,29 @@ <h2 :class="version === ver.version ? 'primary--text' : undefined">v{{ver.versio
14781531
return style
14791532
},
14801533
appBarBind() {
1534+
const app = true
14811535
const isEmptyLight = this.isWebApp && !this.isDarkMode && !this.isWallpaper
14821536
const color = isEmptyLight ? 'primary' : 'transparent'
14831537
const flat = color === 'transparent'
1484-
const hideOnScroll = false
1538+
const hideOnScroll = !this.isHidedSearchBar && this.isAutoSearchBar
14851539
const collapseOnScroll = false
1486-
return { color, flat, hideOnScroll, collapseOnScroll }
1487-
},
1488-
appBarClass() {
1489-
return !this.isHidedSearchBar ? 'safe' : ''
1540+
const scrollThreshold = 20
1541+
return { app, color, flat, hideOnScroll, collapseOnScroll, scrollThreshold }
14901542
},
14911543
searchBarBind() {
14921544
const color = this.isDarkMode ? null : 'primary'
14931545
return { color }
14941546
},
1547+
naviBarBind() {
1548+
const app = true
1549+
const grow = true
1550+
const color = 'primary'
1551+
const value = this.view
1552+
const inputValue = !this.isHidedNaviBottom
1553+
const hideOnScroll = !this.isHidedNaviBottom && this.isAutoNaviBottom
1554+
const scrollThreshold = 160
1555+
return { app, grow, color, value, inputValue, hideOnScroll, scrollThreshold }
1556+
},
14951557
appIconFontStyle() {
14961558
const style = {
14971559
'font-size': '10px',
@@ -2070,7 +2132,7 @@ <h2 :class="version === ver.version ? 'primary--text' : undefined">v{{ver.versio
20702132
// 修改应用会话
20712133
updateAppSession(session) {
20722134
session.datas.forEach((dat) => {
2073-
// 如果属性值是 undefinded 或 null, 则修改为 ``, 否则转为字符串
2135+
// 如果属性值是 undefined 或 null, 则修改为 ``, 否则转为字符串
20742136
dat.val = !_.isNil(dat.val) ? _.toString(dat.val) : ''
20752137
})
20762138
const key = 'chavy_boxjs_sessions'

box/chavy.boxjs.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ const $ = new Env('BoxJs')
33
// 为 eval 准备的上下文环境
44
const $eval_env = {}
55

6-
$.version = '0.7.54'
6+
$.version = '0.7.55'
77
$.versionType = 'beta'
88

99
/**

box/release/box.release.tf.json

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,21 @@
11
{
22
"releases": [
3+
{
4+
"version": "0.7.55",
5+
"tags": ["beta"],
6+
"author": "@chavyleung",
7+
"msg": "更新[BoxJs TF]: 顶栏和底栏可以设置跟随滚动",
8+
"notes": [
9+
{
10+
"name": "新增",
11+
"descs": ["顶栏和底栏可以设置跟随滚动"]
12+
}
13+
]
14+
},
315
{
416
"version": "0.7.54",
517
"tags": ["beta"],
6-
"author": "@GideonSenku",
18+
"author": "@id77",
719
"icon": "https://avatars3.githubusercontent.com/u/29748519",
820
"repo": "https://github.com/chavyleung",
921
"msg": "更新[BoxJs TF]: 侧栏增加新的贡献者 @id77",

0 commit comments

Comments
 (0)