Skip to content

Commit

Permalink
更新[BoxJs TF]: 新增可以设置多张壁纸
Browse files Browse the repository at this point in the history
  • Loading branch information
chavyleung committed Aug 15, 2020
1 parent 1b1c1fb commit 8e38fda
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 5 deletions.
32 changes: 31 additions & 1 deletion box/chavy.boxjs.html
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,20 @@
</v-select>
</v-list-item-content>
</v-list-item>
<v-list-item class="mt-4" v-show="box.usercfgs.bgimgs">
<v-list-item-content>
<v-select
hide-details
v-model="box.usercfgs.bgimg"
:items="bgimgs"
item-text="name"
item-value="url"
@change="saveUserCfgs"
label="背景图片"
>
</v-select>
</v-list-item-content>
</v-list-item>
<v-list-item class="mt-4">
<v-switch
dense
Expand Down Expand Up @@ -1183,6 +1197,22 @@ <h2 :class="version === ver.version ? 'primary--text' : undefined">v{{ver.versio
isWallpaper() {
return !!this.box.usercfgs.bgimg
},
// 是否存在多张壁纸
isMutiWallpaper() {
return this.bgimgs && this.bgimgs.length > 2
},
// 背景图片列表
bgimgs() {
const items = []
const bgimgs = this.box.usercfgs.bgimgs
if (bgimgs) {
bgimgs.split('\n').forEach((img) => {
const [name, url] = img.split(',')
items.push({ name, url })
})
}
return items
},
// 样式
appStyle() {
if (this.path !== '/') {
Expand Down Expand Up @@ -1598,7 +1628,7 @@ <h2 :class="version === ver.version ? 'primary--text' : undefined">v{{ver.versio
},
// 运行远程脚本
runScript(url, timeout) {
const opts = { url, timeout }
const opts = { url, timeout, isRemote: true }
axios.post('/api/runScript', opts)
},
// 运行文本脚本
Expand Down
10 changes: 6 additions & 4 deletions box/chavy.boxjs.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const $ = new Env('BoxJs')

$.version = '0.7.18'
$.version = '0.7.19'
$.versionType = 'beta'

/**
Expand Down Expand Up @@ -249,12 +249,14 @@ function getSystemApps() {
descs: ['可设置 http-api 地址 & 超时时间 (Surge TF)', '可设置明暗两种主题下的主色调'],
keys: [
'@chavy_boxjs_userCfgs.httpapi',
'@chavy_boxjs_userCfgs.bgimg',
'@chavy_boxjs_userCfgs.color_dark_primary',
'@chavy_boxjs_userCfgs.color_light_primary'
],
settings: [
{ id: '@chavy_boxjs_userCfgs.httpapis', name: 'HTTP-API (Surge TF)', val: '', type: 'textarea', placeholder: ',examplekey@127.0.0.1:6166', autoGrow: true, rows: 2, desc: '示例: ,examplekey@127.0.0.1:6166! 注意: 以逗号开头, 逗号分隔多个地址, 可加回车' },
{ id: '@chavy_boxjs_userCfgs.httpapis', name: 'HTTP-API (Surge TF)', val: '', type: 'textarea', placeholder: ',examplekey@127.0.0.1:6166', autoGrow: true, rows: 2, persistentHint:true, desc: '示例: ,examplekey@127.0.0.1:6166! 注意: 以逗号开头, 逗号分隔多个地址, 可加回车' },
{ id: '@chavy_boxjs_userCfgs.httpapi_timeout', name: 'HTTP-API Timeout (Surge TF)', val: 20, type: 'number', persistentHint:true, desc: '如果脚本作者指定了超时时间, 会优先使用脚本指定的超时时间.' },
{ id: '@chavy_boxjs_userCfgs.bgimgs', name: '背景图片清单', val: '无背景,\n妹子,http://api.btstu.cn/sjbz/zsy.php', type: 'textarea', placeholder: '无, {回车} 妹子,图片地址', persistentHint:true, autoGrow: true, rows: 2, desc: '逗号分隔名字和链接, 回车分隔多个地址' },
{ id: '@chavy_boxjs_userCfgs.bgimg', name: '背景图片', val: '', type: 'text', placeholder: 'http://api.btstu.cn/sjbz/zsy.php', persistentHint:true, desc: '输入背景图标的在线链接' },
{ id: '@chavy_boxjs_userCfgs.color_light_primary', name: '明亮色调', canvas: true, val: '#F7BB0E', type: 'colorpicker', desc: '' },
{ id: '@chavy_boxjs_userCfgs.color_dark_primary', name: '暗黑色调', canvas: true, val: '#2196F3', type: 'colorpicker', desc: '' }
Expand Down Expand Up @@ -502,7 +504,7 @@ async function apiRunScript() {
}
} else {
// 对于手动执行的脚本, 把 $done 的时机交给脚本自主控制
$.isSkipDone = false
$.isSkipDone = true
$request = undefined
eval(opts.script)
}
Expand Down Expand Up @@ -570,7 +572,7 @@ function upgradeUserData() {
* ===================================
*/
function doneBox() {
if ($.isSkipDone) {
if ($.isSkipDone === true) {
return
}
// 记录当前使用哪个域名访问
Expand Down
17 changes: 17 additions & 0 deletions box/release/box.release.tf.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
{
"releases": [
{
"version": "0.7.19",
"tags": ["beta"],
"author": "@chavyleung",
"icon": "https://avatars3.githubusercontent.com/u/29748519",
"repo": "https://github.com/chavyleung",
"notes": [
{
"name": "新增",
"descs": ["可以设置多张壁纸 (偏好设置)"]
},
{
"name": "注意",
"descs": ["设置多张壁纸后,在侧栏切换"]
}
]
},
{
"version": "0.7.18",
"tags": ["beta"],
Expand Down

0 comments on commit 8e38fda

Please sign in to comment.