Skip to content

Commit

Permalink
更新[BoxJs]: 新增 desc、descs、desc_html、descs_html 属性
Browse files Browse the repository at this point in the history
  • Loading branch information
chavyleung committed Jul 30, 2020
1 parent 77c669c commit 9cd62cc
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 10 deletions.
21 changes: 21 additions & 0 deletions box/release/box.release.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,26 @@
{
"releases": [
{
"version": "0.6.16",
"tags": ["beta"],
"author": "@chavyleung",
"icon": "https://avatars3.githubusercontent.com/u/29748519",
"repo": "https://github.com/chavyleung",
"notes": [
{
"name": "订阅配置",
"descs": ["新增: desc、descs、desc_html、descs_html 属性", "与 id、name 同级"]
},
{
"name": "示例",
"descs": ["https://gist.githubusercontent.com/chavyleung/9d53fc4809eb41dca5f5923790ec5554/raw/09742d3473420d8e0bd7b02a910849f65af879fa/chavy.app.sub.simple.json"]
},
{
"name": "注意",
"descs": ["本次更新主要面向开发者"]
}
]
},
{
"version": "0.6.15",
"tags": ["beta"],
Expand Down
36 changes: 26 additions & 10 deletions chavy.box.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const $ = new Env('BoxJs')

$.version = '0.6.15'
$.version = '0.6.16'
$.versionType = 'beta'
$.KEY_sessions = 'chavy_boxjs_sessions'
$.KEY_versions = 'chavy_boxjs_versions'
Expand Down Expand Up @@ -95,6 +95,7 @@ function getSystemApps() {
{
id: 'BoxSetting',
name: '偏好设置',
descs: ['可设置 http-api 地址 & 超时时间 (Surge TF)', '可设置明暗两种主题下的主色调'],
keys: ['@chavy_boxjs_userCfgs.httpapi', '@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: ',[email protected]:6166', autoGrow: true, rows: 2, desc: '示例: ,[email protected]:6166! 注意: 以逗号开头, 逗号分隔多个地址, 可加回车' },
Expand All @@ -109,6 +110,7 @@ function getSystemApps() {
{
id: 'BoxSwitcher',
name: '会话切换',
desc: '打开静默运行后, 切换会话将不再发出系统通知 \n注: 不影响日志记录',
keys: [],
settings: [{ id: 'CFG_BoxSwitcher_isSilent', name: '静默运行', val: false, type: 'boolean', desc: '切换会话时不发出系统通知!' }],
author: '@chavyleung',
Expand Down Expand Up @@ -510,7 +512,7 @@ async function handleHome() {
const box = await getBoxData()
$.html = printHtml(JSON.stringify(box))
if (box.usercfgs.isDebugFormat) {
console.log(printHtml(`'\${data}'`, `'\${curapp}'`, `\${curview}`))
console.log(printHtml(`'\${data}'`, `'\${appId}'`, `\${curview}`))
} else if (box.usercfgs.isDebugData) {
console.log($.html)
}
Expand All @@ -528,9 +530,9 @@ async function handleApp(appId) {
if (curapp.script && $.isSurge()) {
await $.getScript(curapp.script).then((script) => (curapp.script_text = script))
}
$.html = printHtml(JSON.stringify(box), JSON.stringify(curapp), 'appsession')
$.html = printHtml(JSON.stringify(box), appId)
if (box.usercfgs.isDebugFormat) {
console.log(printHtml(`'\${data}'`, `'\${curapp}'`, `\${curview}`))
console.log(printHtml(`'\${data}'`, `'\${appId}'`, `\${curview}`))
} else if (box.usercfgs.isDebugData) {
console.log($.html)
}
Expand All @@ -540,7 +542,7 @@ async function handleSub() {
const box = await getBoxData()
$.html = printHtml(JSON.stringify(box), null, 'sub')
if (box.usercfgs.isDebugFormat) {
console.log(printHtml(`'\${data}'`, `'\${curapp}'`, `\${curview}`))
console.log(printHtml(`'\${data}'`, `'\${appId}'`, `\${curview}`))
} else if (box.usercfgs.isDebugData) {
console.log($.html)
}
Expand All @@ -550,7 +552,7 @@ async function handleMy() {
const box = await getBoxData()
$.html = printHtml(JSON.stringify(box), null, 'my')
if (box.usercfgs.isDebugFormat) {
console.log(printHtml(`'\${data}'`, `'\${curapp}'`, `\${curview}`))
console.log(printHtml(`'\${data}'`, `'\${appId}'`, `\${curview}`))
} else if (box.usercfgs.isDebugData) {
console.log($.html)
}
Expand Down Expand Up @@ -711,7 +713,7 @@ function printRevertHtml() {
`
}

function printHtml(data, curapp = null, curview = 'app') {
function printHtml(data, appId = '', curview = 'app') {
return `
<!DOCTYPE html>
<html lang="zh-CN">
Expand All @@ -735,6 +737,9 @@ function printHtml(data, curapp = null, curview = 'app') {
padding-top: constant(safe-area-inset-top) !important;
padding-top: env(safe-area-inset-top);
}
.text-pre-wrap {
white-space: pre-wrap !important;
}
.v-app-bar,
.v-navigation-drawer__content {
box-sizing: content-box;
Expand Down Expand Up @@ -1044,6 +1049,14 @@ function printHtml(data, curapp = null, curview = 'app') {
<v-spacer></v-spacer>
<v-btn v-if="ui.curapp.script" icon @click="onRunScript(ui.curapp.script, ui.curapp.script_timeout)"><v-icon color="primary">mdi-play-circle</v-icon></v-btn>
</v-subheader>
<v-card flat class="mx-auto mb-4" color="transparent" v-if="ui.curapp.desc || ui.curapp.descs || ui.curapp.desc_html || ui.curapp.descs_html">
<v-card-text class="py-2">
<p v-if="ui.curapp.desc" v-text="ui.curapp.desc" class="body-2 text-pre-wrap"></p>
<p v-for="(desc, descIdx) in ui.curapp.descs" v-text="desc" :class="ui.curapp.descs.length === descIdx + 1 ? 'body-2 text-pre-wrap' : 'mb-0 body-2 text-pre-wrap'"></p>
<p v-if="ui.curapp.desc_html" v-html="ui.curapp.desc_html"></p>
<div v-for="(desc_html, desc_htmlIdx) in ui.curapp.descs_html" v-html="desc_html"></div>
</v-card-text>
</v-card>
<v-card class="mx-auto mb-4">
<template v-if="Array.isArray(ui.curapp.scripts)">
<v-subheader>
Expand Down Expand Up @@ -1554,6 +1567,7 @@ function printHtml(data, curapp = null, curview = 'app') {
<script src="https://cdn.jsdelivr.net/npm/uuid@latest/dist/umd/uuidv4.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/vue-clipboard.min.js"></script>
<script>
const boxdat = ${data}
new Vue({
el: '#app',
vuetify: new Vuetify({ theme: { dark: true } }),
Expand All @@ -1563,7 +1577,8 @@ function printHtml(data, curapp = null, curview = 'app') {
scrollY: 0,
bfview: 'app',
curview: '${curview}',
curapp: ${curapp},
appId: '${appId}',
curapp: null,
curappTabs: { curtab: 'sessions' },
curappSessions: null,
overlay: { show: false, val: 60 },
Expand All @@ -1589,7 +1604,7 @@ function printHtml(data, curapp = null, curview = 'app') {
drawer: { show: false },
icons: ['https://raw.githubusercontent.com/Orz-3/mini/master/appstore.png', 'https://raw.githubusercontent.com/Orz-3/task/master/appstore.png']
},
box: ${data}
box: boxdat
}
},
computed: {
Expand Down Expand Up @@ -2144,7 +2159,8 @@ function printHtml(data, curapp = null, curview = 'app') {
this.getContributors()
this.ui.navi.show = true
this.ui.box.show = true
if (this.ui.curapp) {
if (this.ui.appId) {
this.ui.curapp = this.apps.find(app => app.id === this.ui.appId)
this.goAppSessionView(this.ui.curapp)
}
if (this.ui.curview === 'sub') {
Expand Down

0 comments on commit 9cd62cc

Please sign in to comment.