Skip to content

Commit 1c7cd13

Browse files
committed
更新[BoxJs]: 增加明暗主题切换, 优化页面渲染资源
1 parent b0b3e8f commit 1c7cd13

2 files changed

Lines changed: 54 additions & 22 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.20",
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.19",
522
"tags": ["beta"],

‎chavy.box.js‎

Lines changed: 37 additions & 22 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.19'
4+
$.version = '0.4.20'
55
$.versionType = 'beta'
66
$.KEY_sessions = 'chavy_boxjs_sessions'
77
$.KEY_versions = 'chavy_boxjs_versions'
@@ -42,9 +42,9 @@ $.html = $.name
4242
})
4343
.finally(() => {
4444
if ($.isapi) {
45-
$.done({ body: $.json })
45+
$done({ body: null })
4646
} else {
47-
$.done({ body: $.html })
47+
$.done({ status: 200, body: $.html })
4848
}
4949
})
5050

@@ -360,9 +360,6 @@ function wrapapps(apps) {
360360
} else {
361361
setting.val = val || setting.val
362362
}
363-
if (!Array.isArray(app.icons)) {
364-
app.icons = ['https://raw.githubusercontent.com/Orz-3/mini/master/appstore.png', 'https://raw.githubusercontent.com/Orz-3/task/master/appstore.png']
365-
}
366363
app.author = app.author ? app.author : '@anonymous'
367364
app.repo = app.repo ? app.repo : '作者很神秘, 没有留下任何线索!'
368365
})
@@ -765,25 +762,25 @@ function printHtml(data, curapp = null, curview = 'app') {
765762
<v-speed-dial v-show="ui.box.show && !box.usercfgs.isHideBoxIcon" fixed fab bottom direction="top" :left="ui.drawer.show || box.usercfgs.isLeftBoxIcon" :right="!box.usercfgs.isLeftBoxIcon === true" :class="box.usercfgs.isHideNavi ? '' : 'has-nav'">
766763
<template v-slot:activator>
767764
<v-btn fab>
768-
<v-avatar size="48">
765+
<v-avatar size="56">
769766
<img :src="box.syscfgs.boxjs.icons[box.usercfgs.isTransparentIcons ? 0 : 1]" :alt="box.syscfgs.boxjs.repo" />
770767
</v-avatar>
771768
</v-btn>
772769
</template>
773-
<v-btn v-if="!box.usercfgs.isHideHelp" fab small color="grey" @click="ui.versheet.show = true">
770+
<v-btn dark v-if="!box.usercfgs.isHideHelp" fab small color="grey" @click="ui.versheet.show = true">
774771
<v-icon>mdi-help</v-icon>
775772
</v-btn>
776-
<v-btn fab small color="pink" @click="box.usercfgs.isLeftBoxIcon = !box.usercfgs.isLeftBoxIcon, onUserCfgsChange()">
773+
<v-btn dark fab small color="pink" @click="box.usercfgs.isLeftBoxIcon = !box.usercfgs.isLeftBoxIcon, onUserCfgsChange()">
777774
<v-icon v-if="!box.usercfgs.isLeftBoxIcon">mdi-format-horizontal-align-left</v-icon>
778775
<v-icon v-else>mdi-format-horizontal-align-right</v-icon>
779776
</v-btn>
780-
<v-btn fab small color="indigo" @click="ui.impGlobalBakDialog.show = true">
777+
<v-btn dark fab small color="indigo" @click="ui.impGlobalBakDialog.show = true">
781778
<v-icon>mdi-database-import</v-icon>
782779
</v-btn>
783-
<v-btn fab small color="green" v-clipboard:copy="JSON.stringify(boxdat)" v-clipboard:success="onCopy">
780+
<v-btn dark fab small color="green" v-clipboard:copy="JSON.stringify(boxdat)" v-clipboard:success="onCopy">
784781
<v-icon>mdi-export-variant</v-icon>
785782
</v-btn>
786-
<v-btn fab small color="orange" @click="reload">
783+
<v-btn dark fab small color="orange" @click="reload">
787784
<v-icon>mdi-refresh</v-icon>
788785
</v-btn>
789786
</v-speed-dial>
@@ -807,7 +804,7 @@ function printHtml(data, curapp = null, curview = 'app') {
807804
<v-divider></v-divider>
808805
<v-list-item class="pt-1">
809806
<v-row align="center" justify="start" no-gutters>
810-
<v-col v-for="(c, cIdx) in box.syscfgs.contributors" cols="2">
807+
<v-col v-for="(c, cIdx) in box.syscfgs.contributors" cols="2" :key="c.id">
811808
<v-avatar class="ma-1" size="26" @click="onGoToRepo(c.repo)">
812809
<img :src="c.icon" />
813810
</v-avatar>
@@ -821,6 +818,11 @@ function printHtml(data, curapp = null, curview = 'app') {
821818
</v-list-item-content>
822819
<v-list-item-action>{{ box.usercfgs.refreshsecs }} 秒</v-list-item-action>
823820
</v-list-item>
821+
<v-list-item>
822+
<v-list-item-content>
823+
<v-switch label="明亮主题" v-model="box.usercfgs.isLight"></v-switch>
824+
</v-list-item-content>
825+
</v-list-item>
824826
<v-list-item>
825827
<v-list-item-content>
826828
<v-switch label="透明图标" v-model="box.usercfgs.isTransparentIcons" @change="onUserCfgsChange"></v-switch>
@@ -894,8 +896,7 @@ function printHtml(data, curapp = null, curview = 'app') {
894896
<v-expansion-panel-content>
895897
<v-list nav dense class="mx-n4">
896898
<v-list-item three-line dense v-for="(app, appIdx) in favapps" :key="app.id" @click="goAppSessionView(app)">
897-
<v-list-item-avatar v-if="app.icons"><v-img :src="app.icons[box.usercfgs.isTransparentIcons ? 0 : 1]"></v-img></v-list-item-avatar>
898-
<v-list-item-avatar v-else><v-img :src="ui.icons[box.usercfgs.isTransparentIcons ? 0 : 1]"></v-img></v-list-item-avatar>
899+
<v-list-item-avatar><v-img :src="appicon(app)"></v-img></v-list-item-avatar>
899900
<v-list-item-content>
900901
<v-list-item-title>{{ app.name }} ({{ app.id }})</v-list-item-title>
901902
<v-list-item-subtitle>{{ app.repo }}</v-list-item-subtitle>
@@ -933,8 +934,7 @@ function printHtml(data, curapp = null, curview = 'app') {
933934
<v-expansion-panel-content>
934935
<v-list nav dense class="mx-n4">
935936
<v-list-item three-line dense v-for="(app, appIdx) in sub.apps" :key="app.id" @click="goAppSessionView(app)">
936-
<v-list-item-avatar v-if="app.icons"><v-img :src="app.icons[box.usercfgs.isTransparentIcons ? 0 : 1]"></v-img></v-list-item-avatar>
937-
<v-list-item-avatar v-else><v-img :src="ui.icons[box.usercfgs.isTransparentIcons ? 0 : 1]"></v-img></v-list-item-avatar>
937+
<v-list-item-avatar><v-img :src="appicon(app)"></v-img></v-list-item-avatar>
938938
<v-list-item-content>
939939
<v-list-item-title>{{ app.name }} ({{ app.id }})</v-list-item-title>
940940
<v-list-item-subtitle>{{ app.repo }}</v-list-item-subtitle>
@@ -960,8 +960,7 @@ function printHtml(data, curapp = null, curview = 'app') {
960960
<v-expansion-panel-content>
961961
<v-list nav dense class="mx-n4">
962962
<v-list-item three-line dense v-for="(app, appIdx) in box.sysapps" :key="app.id" @click="goAppSessionView(app)">
963-
<v-list-item-avatar v-if="app.icons"><v-img :src="app.icons[box.usercfgs.isTransparentIcons ? 0 : 1]"></v-img></v-list-item-avatar>
964-
<v-list-item-avatar v-else="ui.icons"><v-img :src="app.icons[box.usercfgs.isTransparentIcons ? 0 : 1]"></v-img></v-list-item-avatar>
963+
<v-list-item-avatar><v-img :src="appicon(app)"></v-img></v-list-item-avatar>
965964
<v-list-item-content>
966965
<v-list-item-title>{{ app.name }} ({{ app.id }})</v-list-item-title>
967966
<v-list-item-subtitle>{{ app.repo }}</v-list-item-subtitle>
@@ -998,7 +997,7 @@ function printHtml(data, curapp = null, curview = 'app') {
998997
<v-checkbox class="mt-0" :hide-details="itemIdx + 1 !== setting.items.length" v-model="setting.val" :label="item.label" :value="item.key" v-for="(item, itemIdx) in setting.items" :key="item.key" multiple></v-checkbox>
999998
</template>
1000999
<v-text-field :label="setting.name" v-model="setting.val" :hint="setting.desc" :placeholder="setting.placeholder" type="number" v-else-if="setting.type === 'number'"></v-text-field>
1001-
<v-text-field :label="setting.name" v-model="setting.val" :hint="setting.desc" :placeholder="setting.placeholder" v-else="setting.type === 'text'"></v-text-field>
1000+
<v-text-field :label="setting.name" v-model="setting.val" :hint="setting.desc" :placeholder="setting.placeholder" v-else></v-text-field>
10021001
</template>
10031002
</v-form>
10041003
<v-divider></v-divider>
@@ -1440,8 +1439,8 @@ function printHtml(data, curapp = null, curview = 'app') {
14401439
</v-overlay>
14411440
</v-app>
14421441
</div>
1443-
<script src="https://cdn.jsdelivr.net/npm/vue@2.x/dist/vue.js"></script>
1444-
<script src="https://cdn.jsdelivr.net/npm/vuetify@2.x/dist/vuetify.js"></script>
1442+
<script src="https://cdn.jsdelivr.net/npm/vue@2.x/dist/vue.min.js"></script>
1443+
<script src="https://cdn.jsdelivr.net/npm/vuetify@2.x/dist/vuetify.min.js"></script>
14451444
<script src="https://cdn.jsdelivr.net/npm/axios@0.19.2/dist/axios.min.js"></script>
14461445
<script src="https://cdn.jsdelivr.net/npm/moment@2.26.0/moment.min.js"></script>
14471446
<script src="https://cdn.jsdelivr.net/npm/timeago.js@4.0.2/dist/timeago.full.min.js"></script>
@@ -1624,6 +1623,12 @@ function printHtml(data, curapp = null, curview = 'app') {
16241623
handler(newval, oldval) {
16251624
this.onUserCfgsChange()
16261625
}
1626+
},
1627+
'box.usercfgs.isLight': {
1628+
handler(newval, oldval) {
1629+
this.$vuetify.theme.dark = !this.box.usercfgs.isLight
1630+
this.onUserCfgsChange()
1631+
}
16271632
}
16281633
},
16291634
methods: {
@@ -1633,6 +1638,15 @@ function printHtml(data, curapp = null, curview = 'app') {
16331638
appfilter(item, queryText, itemText) {
16341639
return item.id.includes(queryText) || item.name.includes(queryText)
16351640
},
1641+
appicon(app) {
1642+
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
1644+
if (app.icons && Array.isArray(app.icons)) {
1645+
return app.icons[iconIdx] || deficons[iconIdx]
1646+
} else {
1647+
return deficons[iconIdx]
1648+
}
1649+
},
16361650
onLink(link) {
16371651
window.open(link)
16381652
},
@@ -1879,6 +1893,7 @@ function printHtml(data, curapp = null, curview = 'app') {
18791893
}
18801894
},
18811895
mounted: function () {
1896+
this.$vuetify.theme.dark = !this.box.usercfgs.isLight
18821897
if (this.ui.curapp) {
18831898
this.goAppSessionView(this.ui.curapp)
18841899
}

0 commit comments

Comments
 (0)