Skip to content

Commit cfcd8c4

Browse files
committed
更新[BoxJs]: 新增自动主题, 修复版本更新不提示问题
1 parent 1c7cd13 commit cfcd8c4

2 files changed

Lines changed: 61 additions & 19 deletions

File tree

‎box/release/box.release.json‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,22 @@
11
{
22
"releases": [
3+
{
4+
"version": "0.4.21",
5+
"tags": ["beta"],
6+
"author": "@chavyleung",
7+
"icon": "https://avatars3.githubusercontent.com/u/29748519",
8+
"repo": "https://github.com/chavyleung",
9+
"notes": [
10+
{
11+
"name": "新增",
12+
"descs": ["颜色主题可跟随系统 (明亮主题下强制使用彩色图标)"]
13+
},
14+
{
15+
"name": "修复",
16+
"descs": ["有新版本但没有提示问题"]
17+
}
18+
]
19+
},
320
{
421
"version": "0.4.20",
522
"tags": ["beta"],

‎chavy.box.js‎

Lines changed: 44 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const $ = new Env('BoxJs')
22
$.domain = '8.8.8.8'
33

4-
$.version = '0.4.20'
4+
$.version = '0.4.21'
55
$.versionType = 'beta'
66
$.KEY_sessions = 'chavy_boxjs_sessions'
77
$.KEY_versions = 'chavy_boxjs_versions'
@@ -718,13 +718,13 @@ function printHtml(data, curapp = null, curview = 'app') {
718718
<template v-slot:activator="{ on }">
719719
<v-btn icon v-on="on">
720720
<v-avatar size="26">
721-
<img :src="box.syscfgs.envs.find(e=>e.id===box.syscfgs.env).icons[box.usercfgs.isTransparentIcons ? 0 : 1]" alt="box.syscfgs.env" />
721+
<img :src="box.syscfgs.envs.find(e=>e.id===box.syscfgs.env).icons[iconIdx]" alt="box.syscfgs.env" />
722722
</v-avatar>
723723
</v-btn>
724724
</template>
725725
<v-list dense>
726726
<v-list-item v-for="(env, envIdx) in box.syscfgs.envs" :key="env.id" @click="box.syscfgs.env=env.id">
727-
<v-list-item-avatar size="24"><v-img :src="env.icons[box.usercfgs.isTransparentIcons ? 0 : 1]"></v-img></v-list-item-avatar>
727+
<v-list-item-avatar size="24"><v-img :src="env.icons[iconIdx]"></v-img></v-list-item-avatar>
728728
<v-list-item-title>{{ env.id }}</v-list-item-title>
729729
</v-list-item>
730730
</v-list>
@@ -734,8 +734,8 @@ function printHtml(data, curapp = null, curview = 'app') {
734734
<template v-slot:item="{ item }">
735735
<v-list-item @click="goAppSessionView(item)">
736736
<v-list-item-avatar>
737-
<img v-if="item.icons" :src="item.icons[box.usercfgs.isTransparentIcons ? 0 : 1]">
738-
<img v-else :src="ui.icons[box.usercfgs.isTransparentIcons ? 0 : 1]">
737+
<img v-if="item.icons" :src="item.icons[iconIdx]">
738+
<img v-else :src="ui.icons[iconIdx]">
739739
</v-list-item-avatar>
740740
<v-list-item-content>
741741
<v-list-item-title>{{ item.name }} ({{ item.id }})</v-list-item-title>
@@ -763,7 +763,7 @@ function printHtml(data, curapp = null, curview = 'app') {
763763
<template v-slot:activator>
764764
<v-btn fab>
765765
<v-avatar size="56">
766-
<img :src="box.syscfgs.boxjs.icons[box.usercfgs.isTransparentIcons ? 0 : 1]" :alt="box.syscfgs.boxjs.repo" />
766+
<img :src="box.syscfgs.boxjs.icons[iconIdx]" :alt="box.syscfgs.boxjs.repo" />
767767
</v-avatar>
768768
</v-btn>
769769
</template>
@@ -820,12 +820,17 @@ function printHtml(data, curapp = null, curview = 'app') {
820820
</v-list-item>
821821
<v-list-item>
822822
<v-list-item-content>
823-
<v-switch label="明亮主题" v-model="box.usercfgs.isLight"></v-switch>
823+
<v-select
824+
hide-details
825+
v-model="box.usercfgs.theme"
826+
:items="[{text: '跟随系统', value: 'auto'}, {text: '暗黑', value: 'dark'}, {text: '明亮', value: 'light'}]"
827+
label="颜色主题"
828+
>
824829
</v-list-item-content>
825830
</v-list-item>
826831
<v-list-item>
827832
<v-list-item-content>
828-
<v-switch label="透明图标" v-model="box.usercfgs.isTransparentIcons" @change="onUserCfgsChange"></v-switch>
833+
<v-switch label="透明图标" v-model="box.usercfgs.isTransparentIcons" @change="onUserCfgsChange" :disabled="!darkMode"></v-switch>
829834
</v-list-item-content>
830835
<v-list-item-action @click="onLink(box.syscfgs.orz3.repo)">
831836
<v-btn fab small text>
@@ -839,7 +844,7 @@ function printHtml(data, curapp = null, curview = 'app') {
839844
</v-list-item-content>
840845
<v-list-item-action @click="onLink(box.syscfgs.boxjs.repo)">
841846
<v-btn fab small text>
842-
<v-avatar size="32"><img :src="box.syscfgs.boxjs.icons[box.usercfgs.isTransparentIcons ? 0 : 1]" :alt="box.syscfgs.boxjs.repo" /></v-avatar>
847+
<v-avatar size="32"><img :src="box.syscfgs.boxjs.icons[iconIdx]" :alt="box.syscfgs.boxjs.repo" /></v-avatar>
843848
</v-btn>
844849
</v-list-item-action>
845850
</v-list-item>
@@ -1367,13 +1372,13 @@ function printHtml(data, curapp = null, curview = 'app') {
13671372
<template v-slot:activator="{ on }">
13681373
<v-btn icon v-on="on">
13691374
<v-avatar size="26">
1370-
<img :src="box.syscfgs.envs.find(e=>e.id===box.syscfgs.env).icons[box.usercfgs.isTransparentIcons ? 0 : 1]" alt="box.syscfgs.env" />
1375+
<img :src="box.syscfgs.envs.find(e=>e.id===box.syscfgs.env).icons[iconIdx]" alt="box.syscfgs.env" />
13711376
</v-avatar>
13721377
</v-btn>
13731378
</template>
13741379
<v-list dense>
13751380
<v-list-item v-for="(env, envIdx) in box.syscfgs.envs" :key="env.id" @click="box.syscfgs.env=env.id">
1376-
<v-list-item-avatar size="24"><v-img :src="env.icons[box.usercfgs.isTransparentIcons ? 0 : 1]"></v-img></v-list-item-avatar>
1381+
<v-list-item-avatar size="24"><v-img :src="env.icons[iconIdx]"></v-img></v-list-item-avatar>
13771382
<v-list-item-title>{{ env.id }}</v-list-item-title>
13781383
</v-list-item>
13791384
</v-list>
@@ -1481,6 +1486,29 @@ function printHtml(data, curapp = null, curview = 'app') {
14811486
}
14821487
},
14831488
computed: {
1489+
darkMode: function() {
1490+
const isSysDark = window.matchMedia('(prefers-color-scheme: dark)').matches
1491+
let isDark = !this.box.usercfgs.isLight
1492+
if (this.box.usercfgs.theme === 'auto') {
1493+
isDark = isSysDark ? true : false
1494+
} else if (this.box.usercfgs.theme === 'dark') {
1495+
isDark = true
1496+
} else if (this.box.usercfgs.theme === 'light') {
1497+
isDark = false
1498+
}
1499+
return isDark
1500+
},
1501+
iconIdx: function() {
1502+
let idx = 1
1503+
if (this.box.usercfgs.theme === 'auto') {
1504+
if (this.darkMode === true) {
1505+
idx = this.box.usercfgs.isTransparentIcons ? 0 : 1
1506+
}
1507+
} else if (this.box.usercfgs.theme === 'dark') {
1508+
idx = this.box.usercfgs.isTransparentIcons ? 0 : 1
1509+
}
1510+
return idx
1511+
},
14841512
apps: function () {
14851513
const apps = []
14861514
apps.push(...this.box.sysapps)
@@ -1624,9 +1652,9 @@ function printHtml(data, curapp = null, curview = 'app') {
16241652
this.onUserCfgsChange()
16251653
}
16261654
},
1627-
'box.usercfgs.isLight': {
1655+
'box.usercfgs.theme': {
16281656
handler(newval, oldval) {
1629-
this.$vuetify.theme.dark = !this.box.usercfgs.isLight
1657+
this.$vuetify.theme.dark = this.darkMode
16301658
this.onUserCfgsChange()
16311659
}
16321660
}
@@ -1640,7 +1668,7 @@ function printHtml(data, curapp = null, curview = 'app') {
16401668
},
16411669
appicon(app) {
16421670
const deficons = ['https://raw.githubusercontent.com/Orz-3/mini/master/appstore.png', 'https://raw.githubusercontent.com/Orz-3/task/master/appstore.png']
1643-
const iconIdx = this.box.usercfgs.isTransparentIcons ? 0 : 1
1671+
const iconIdx = this.iconIdx
16441672
if (app.icons && Array.isArray(app.icons)) {
16451673
return app.icons[iconIdx] || deficons[iconIdx]
16461674
} else {
@@ -1886,24 +1914,21 @@ function printHtml(data, curapp = null, curview = 'app') {
18861914
var _v1 = v1.split('.'),
18871915
_v2 = v2.split('.'),
18881916
_r = _v1[0] - _v2[0]
1889-
return _r == 0 && v1 != v2 ? compareVersion(_v1.splice(1).join('.'), _v2.splice(1).join('.')) : _r
1917+
return _r == 0 && v1 != v2 ? this.compareVersion(_v1.splice(1).join('.'), _v2.splice(1).join('.')) : _r
18901918
},
18911919
onGoToRepo(url) {
18921920
window.open(url)
18931921
}
18941922
},
18951923
mounted: function () {
1896-
this.$vuetify.theme.dark = !this.box.usercfgs.isLight
1924+
this.$vuetify.theme.dark = this.darkMode
18971925
if (this.ui.curapp) {
18981926
this.goAppSessionView(this.ui.curapp)
18991927
}
19001928
setTimeout(() => {
19011929
this.ui.navi.show = true
1902-
}, 500)
1903-
setTimeout(() => {
19041930
this.ui.box.show = true
19051931
}, 500)
1906-
19071932
const curver = this.box.syscfgs.version
19081933
const vers = this.box.versions
19091934
if (this.ui.curview === 'sub') {

0 commit comments

Comments
 (0)