Skip to content

Commit d50cc1d

Browse files
committed
更新[BoxJs]: 可以修改已保存的会话
1 parent 6ddde93 commit d50cc1d

2 files changed

Lines changed: 64 additions & 4 deletions

File tree

‎box/release/box.release.json‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
11
{
22
"releases": [
3+
{
4+
"version": "0.4.0",
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+
},
316
{
417
"version": "0.3.10",
518
"tags": ["beta"],

‎chavy.box.js‎

Lines changed: 51 additions & 4 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.3.10'
4+
$.version = '0.4.0'
55
$.versionType = 'beta'
66
$.KEY_sessions = 'chavy_boxjs_sessions'
77
$.KEY_versions = 'chavy_boxjs_versions'
@@ -408,7 +408,7 @@ async function handleApi() {
408408
$.msg($.name, $.subt, $.desc.join('\n'))
409409
}
410410
// 保存至指定会话
411-
if (data.cmd === 'saveSessionTo') {
411+
else if (data.cmd === 'saveSessionTo') {
412412
const { fromapp, toSession } = data.val
413413
const sessions = getSessions()
414414
const session = sessions.find((s) => s.id === toSession.id)
@@ -419,6 +419,20 @@ async function handleApi() {
419419
$.desc.push(`会话名称: ${session.name}`, `应用名称: ${session.appName}`, `会话编号: ${session.id}`, `应用编号: ${session.appId}`, `数据: ${JSON.stringify(session)}`)
420420
$.msg($.name, $.subt, $.desc.join('\n'))
421421
}
422+
// 修改指定会话
423+
else if (data.cmd === 'onModSession') {
424+
const sessiondat = data.val
425+
const sessions = getSessions()
426+
const session = sessions.find((s) => s.id === sessiondat.id)
427+
$.log(JSON.stringify(session))
428+
session.name = sessiondat.name
429+
session.datas = sessiondat.datas
430+
const savesuc = $.setdata(JSON.stringify(sessions), $.KEY_sessions)
431+
$.subt = `保存会话: ${savesuc ? '成功' : '失败'} (${session.appName})`
432+
$.desc = []
433+
$.desc.push(`会话名称: ${session.name}`, `应用名称: ${session.appName}`, `会话编号: ${session.id}`, `应用编号: ${session.appId}`, `数据: ${JSON.stringify(session)}`)
434+
$.msg($.name, $.subt, $.desc.join('\n'))
435+
}
422436
// 保存当前会话
423437
else if (data.cmd === 'saveCurAppSession') {
424438
const app = data.val
@@ -909,7 +923,7 @@ function printHtml(data, curapp = null, curview = 'app') {
909923
<v-divider></v-divider>
910924
<v-card-actions>
911925
<v-spacer></v-spacer>
912-
<v-menu bottom left v-if="ui.curappSessions.length > 0">
926+
<v-menu bottom left v-if="ui.curappSessions && ui.curappSessions.length > 0">
913927
<template v-slot:activator="{ on }">
914928
<v-btn v-on="on" small text color="success">保存至</v-btn>
915929
</template>
@@ -925,6 +939,17 @@ function printHtml(data, curapp = null, curview = 'app') {
925939
<v-card class="ml-10 mt-4" v-for="(session, sessionIdx) in ui.curappSessions" :key="session.id">
926940
<v-subheader>
927941
#{{ sessionIdx + 1 }} {{ session.name }}
942+
<v-spacer></v-spacer>
943+
<v-menu bottom left>
944+
<template v-slot:activator="{ on }">
945+
<v-btn icon v-on="on"><v-icon>mdi-dots-vertical</v-icon></v-btn>
946+
</template>
947+
<v-list dense>
948+
<v-list-item @click="ui.modSessionDialog.show = true, ui.modSessionDialog.session = JSON.parse(JSON.stringify(session))">
949+
<v-list-item-title>修改会话</v-list-item-title>
950+
</v-list-item>
951+
</v-list>
952+
</v-menu>
928953
</v-subheader>
929954
<v-list-item two-line dense v-for="(data, dataIdx) in session.datas" :key="dataIdx">
930955
<v-list-item-content>
@@ -964,6 +989,24 @@ function printHtml(data, curapp = null, curview = 'app') {
964989
</v-card-actions>
965990
</v-card>
966991
</v-dialog>
992+
<v-dialog v-model="ui.modSessionDialog.show">
993+
<v-card v-if="ui.modSessionDialog.session">
994+
<v-card-title>
995+
修改会话
996+
</v-card-title>
997+
<v-divider></v-divider>
998+
<v-card-text>
999+
<v-text-field class="mt-4" v-model="ui.modSessionDialog.session.name" label="会话名称"></v-text-field>
1000+
<v-text-field v-for="(data, dataIdx) in ui.modSessionDialog.session.datas" :key="dataIdx" v-model="data.val" :label="data.key"></v-text-field>
1001+
</v-card-text>
1002+
<v-divider></v-divider>
1003+
<v-card-actions>
1004+
<v-spacer></v-spacer>
1005+
<v-btn text small color="grey darken-1" text @click="ui.modSessionDialog.show = false, ui.modSessionDialog.session = null">取消</v-btn>
1006+
<v-btn text small color="success darken-1" text @click="onModSession">保存</v-btn>
1007+
</v-card-actions>
1008+
</v-card>
1009+
</v-dialog>
9671010
</v-container>
9681011
<v-container fluid v-if="ui.curview === 'sub'">
9691012
<v-card class="mx-auto" v-if="appsubs.length > 0">
@@ -1303,6 +1346,7 @@ function printHtml(data, curapp = null, curview = 'app') {
13031346
overlay: { show: false },
13041347
autocomplete: { curapp: null },
13051348
refreshtip: { show: false },
1349+
modSessionDialog: { show: false, session: null },
13061350
editProfileDialog: { show: false, bak: '' },
13071351
impGlobalBakDialog: { show: false, bak: '' },
13081352
reloadConfirmDialog: { show: false, sec: 0, title: '操作成功', message: '是否马上刷新页面?' },
@@ -1452,7 +1496,6 @@ function printHtml(data, curapp = null, curview = 'app') {
14521496
methods: {
14531497
moment(date) {
14541498
return timeago.format(date, 'zh_CN');
1455-
// return moment(date).format('YYYY-MM-DD HH:mm:ss')
14561499
},
14571500
appfilter(item, queryText, itemText) {
14581501
return item.id.includes(queryText) || item.name.includes(queryText)
@@ -1518,6 +1561,10 @@ function printHtml(data, curapp = null, curview = 'app') {
15181561
axios.post('/api', JSON.stringify({ cmd: 'saveSessionTo', val }))
15191562
this.onReload()
15201563
},
1564+
onModSession () {
1565+
axios.post('/api', JSON.stringify({ cmd: 'onModSession', val: this.ui.modSessionDialog.session }))
1566+
this.onReload()
1567+
},
15211568
onSaveSession() {
15221569
const session = {
15231570
id: uuidv4(),

0 commit comments

Comments
 (0)