导出功能调整

This commit is contained in:
fofolee 2022-04-03 22:15:09 +08:00
parent fcc83a0955
commit 8ae8f52212
2 changed files with 38 additions and 4 deletions

View File

@ -30,7 +30,7 @@
运行 运行
</q-tooltip></q-btn </q-tooltip></q-btn
> >
<q-btn flat round color="primary" icon="share"> <q-btn v-if="canCommandEdit" flat round color="primary" icon="share">
<q-tooltip anchor="top middle" self="center middle"> <q-tooltip anchor="top middle" self="center middle">
导出 导出
</q-tooltip> </q-tooltip>
@ -51,7 +51,13 @@
</q-list> </q-list>
</q-menu> </q-menu>
</q-btn> </q-btn>
<q-btn flat round color="red" icon="close" @click="removeCommand" <q-btn
v-if="canCommandEdit"
flat
round
color="red"
icon="close"
@click="removeCommand"
><q-tooltip anchor="top middle" self="center middle"> ><q-tooltip anchor="top middle" self="center middle">
删除 删除
</q-tooltip></q-btn </q-tooltip></q-btn
@ -59,7 +65,11 @@
</div> </div>
</div> </div>
<!-- 未启用的命令文字为灰色 --> <!-- 未启用的命令文字为灰色 -->
<q-card v-ripple :style="isCommandActivated ? '' : 'color:grey'"> <q-card
@click="handleCardClick"
v-ripple
:style="isCommandActivated ? '' : 'color:grey'"
>
<q-card-section> <q-card-section>
<!-- logo --> <!-- logo -->
<div class="row" :class="cardStyleVars.logoPosition"> <div class="row" :class="cardStyleVars.logoPosition">
@ -222,6 +232,12 @@ export default {
if (cmd.type && cmd.type === "window") return false; if (cmd.type && cmd.type === "window") return false;
return true; return true;
}, },
//
canCommandEdit() {
if (utools.isDev()) return true;
let tags = this.commandInfo.tags;
return tags && tags.includes("默认") ? false : true;
},
// //
cmdBadgeColor() { cmdBadgeColor() {
return (cmdType = "keyword") => { return (cmdType = "keyword") => {
@ -251,6 +267,18 @@ export default {
} }
return shortStr === str ? shortStr : shortStr + "..."; return shortStr === str ? shortStr : shortStr + "...";
}, },
//
handleCardClick() {
//
if (this.cardStyle.code === 1) return this.runCommand();
if (!this.canCommandEdit)
return quickcommand.showMessageBox("默认命令不可编辑", "warning");
this.editCommand();
},
//
editCommand() {
console.log(this.commandInfo);
},
// //
runCommand() { runCommand() {
utools.redirect( utools.redirect(

View File

@ -508,7 +508,13 @@ export default {
}, },
], ],
}; };
let stringifyCommands = JSON.stringify(this.allQuickCommands); let commandsToExport = JSON.parse(JSON.stringify(this.allQuickCommands));
//
if (!utools.isDev())
Object.keys(commandsToExport).forEach((code) => {
if (code.includes("default_")) delete commandsToExport[code];
});
let stringifyCommands = JSON.stringify(commandsToExport);
if (saveAsFile) { if (saveAsFile) {
window.saveFile(stringifyCommands, options); window.saveFile(stringifyCommands, options);
quickcommand.showMessageBox("导出成功!"); quickcommand.showMessageBox("导出成功!");