mirror of
https://github.com/fofolee/uTools-quickcommand.git
synced 2025-06-10 23:54:57 +08:00
脚本运行后就自动保存,保存时不关闭界面
This commit is contained in:
parent
619ee689f5
commit
897d597885
@ -1,18 +1,27 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="absolute-full container" style="overflow: 'hidden'">
|
<div class="absolute-full container" style="overflow: 'hidden'">
|
||||||
<!-- 命令设置栏 -->
|
<!-- 命令设置栏 -->
|
||||||
<CommandSideBar ref="sidebar" :canCommandSave="canCommandSave" :quickcommandInfo="quickcommandInfo"
|
<CommandSideBar
|
||||||
class="absolute-left shadow-10" :style="{
|
ref="sidebar"
|
||||||
|
:canCommandSave="canCommandSave"
|
||||||
|
:quickcommandInfo="quickcommandInfo"
|
||||||
|
class="absolute-left shadow-10"
|
||||||
|
:style="{
|
||||||
width: sideBarWidth + 'px',
|
width: sideBarWidth + 'px',
|
||||||
zIndex: 1,
|
zIndex: 1,
|
||||||
// transition: '0.3s',
|
// transition: '0.3s',
|
||||||
}" v-if="showSidebar"></CommandSideBar>
|
}"
|
||||||
|
v-if="showSidebar"
|
||||||
|
></CommandSideBar>
|
||||||
<!-- 编程语言栏 -->
|
<!-- 编程语言栏 -->
|
||||||
<div class="absolute-top" :style="{
|
<div
|
||||||
|
class="absolute-top"
|
||||||
|
:style="{
|
||||||
left: showSidebar ? sideBarWidth + 'px' : 65,
|
left: showSidebar ? sideBarWidth + 'px' : 65,
|
||||||
zIndex: 1,
|
zIndex: 1,
|
||||||
// transition: '0.3s',
|
// transition: '0.3s',
|
||||||
}">
|
}"
|
||||||
|
>
|
||||||
<div class="row" v-show="!!languageBarHeight">
|
<div class="row" v-show="!!languageBarHeight">
|
||||||
<!-- 去掉收起侧栏功能,处理侧栏宽度变化时,Monaco调整大小导致ResizeObserver loop limit exceeded错误 -->
|
<!-- 去掉收起侧栏功能,处理侧栏宽度变化时,Monaco调整大小导致ResizeObserver loop limit exceeded错误 -->
|
||||||
<!-- <div class="col-auto flex">
|
<!-- <div class="col-auto flex">
|
||||||
@ -21,9 +30,19 @@
|
|||||||
</div> -->
|
</div> -->
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<div>
|
<div>
|
||||||
<q-select dense standout="bg-primary text-white" square hide-bottom-space color="primary"
|
<q-select
|
||||||
transition-show="jump-down" transition-hide="jump-up" @update:model-value="programChanged"
|
dense
|
||||||
v-model="quickcommandInfo.program" :options="programLanguages" label="环境">
|
standout="bg-primary text-white"
|
||||||
|
square
|
||||||
|
hide-bottom-space
|
||||||
|
color="primary"
|
||||||
|
transition-show="jump-down"
|
||||||
|
transition-hide="jump-up"
|
||||||
|
@update:model-value="programChanged"
|
||||||
|
v-model="quickcommandInfo.program"
|
||||||
|
:options="programLanguages"
|
||||||
|
label="环境"
|
||||||
|
>
|
||||||
<template v-slot:append>
|
<template v-slot:append>
|
||||||
<q-avatar size="lg" square>
|
<q-avatar size="lg" square>
|
||||||
<img :src="$root.programs[quickcommandInfo.program].icon" />
|
<img :src="$root.programs[quickcommandInfo.program].icon" />
|
||||||
@ -45,20 +64,34 @@
|
|||||||
<q-separator vertical />
|
<q-separator vertical />
|
||||||
<div class="col-auto justify-end flex">
|
<div class="col-auto justify-end flex">
|
||||||
<q-btn-group unelevated>
|
<q-btn-group unelevated>
|
||||||
<q-btn-dropdown v-show="quickcommandInfo.program !== 'html'" style="padding: 0 10px" dense flat ref="settings"
|
<q-btn-dropdown
|
||||||
color="primary" :icon="quickcommandInfo.program === 'quickcommand'
|
v-show="quickcommandInfo.program !== 'html'"
|
||||||
|
style="padding: 0 10px"
|
||||||
|
dense
|
||||||
|
flat
|
||||||
|
ref="settings"
|
||||||
|
color="primary"
|
||||||
|
:icon="
|
||||||
|
quickcommandInfo.program === 'quickcommand'
|
||||||
? 'insights'
|
? 'insights'
|
||||||
: 'settings'
|
: 'settings'
|
||||||
">
|
"
|
||||||
|
>
|
||||||
<q-list>
|
<q-list>
|
||||||
<!-- quickcommand系列按键 -->
|
<!-- quickcommand系列按键 -->
|
||||||
<q-item clickable v-for="(item, index) in ['keyboard', 'ads_click', 'help']" :key="index" @click="
|
<q-item
|
||||||
|
clickable
|
||||||
|
v-for="(item, index) in ['keyboard', 'ads_click', 'help']"
|
||||||
|
:key="index"
|
||||||
|
@click="
|
||||||
[
|
[
|
||||||
() => (showRecorder = true),
|
() => (showRecorder = true),
|
||||||
() => (showActions = true),
|
() => (showActions = true),
|
||||||
showHelp,
|
showHelp,
|
||||||
][index]
|
][index]
|
||||||
" v-show="quickcommandInfo.program === 'quickcommand'">
|
"
|
||||||
|
v-show="quickcommandInfo.program === 'quickcommand'"
|
||||||
|
>
|
||||||
<q-item-section avatar>
|
<q-item-section avatar>
|
||||||
<q-icon :name="item" />
|
<q-icon :name="item" />
|
||||||
</q-item-section>
|
</q-item-section>
|
||||||
@ -67,15 +100,29 @@
|
|||||||
}}</q-item-section>
|
}}</q-item-section>
|
||||||
</q-item>
|
</q-item>
|
||||||
<!-- 自定义解释器 -->
|
<!-- 自定义解释器 -->
|
||||||
<q-item v-for="(item, index) in Object.keys(
|
<q-item
|
||||||
|
v-for="(item, index) in Object.keys(
|
||||||
quickcommandInfo.customOptions
|
quickcommandInfo.customOptions
|
||||||
)" :key="index" v-show="quickcommandInfo.program === 'custom'">
|
)"
|
||||||
<q-input stack-label autofocus dense outlined class="full-width" @blur="matchLanguage" :label="[
|
:key="index"
|
||||||
|
v-show="quickcommandInfo.program === 'custom'"
|
||||||
|
>
|
||||||
|
<q-input
|
||||||
|
stack-label
|
||||||
|
autofocus
|
||||||
|
dense
|
||||||
|
outlined
|
||||||
|
class="full-width"
|
||||||
|
@blur="matchLanguage"
|
||||||
|
:label="
|
||||||
|
[
|
||||||
'解释器路径,如:/opt/python',
|
'解释器路径,如:/opt/python',
|
||||||
'运行参数,如:-u',
|
'运行参数,如:-u',
|
||||||
'脚本后缀,不含点,如:py',
|
'脚本后缀,不含点,如:py',
|
||||||
][index]
|
][index]
|
||||||
" v-model="quickcommandInfo.customOptions[item]">
|
"
|
||||||
|
v-model="quickcommandInfo.customOptions[item]"
|
||||||
|
>
|
||||||
<template v-slot:prepend>
|
<template v-slot:prepend>
|
||||||
<q-icon name="code" />
|
<q-icon name="code" />
|
||||||
</template>
|
</template>
|
||||||
@ -83,17 +130,36 @@
|
|||||||
</q-item>
|
</q-item>
|
||||||
<!-- 脚本参数 -->
|
<!-- 脚本参数 -->
|
||||||
<q-item v-show="quickcommandInfo.program !== 'quickcommand'">
|
<q-item v-show="quickcommandInfo.program !== 'quickcommand'">
|
||||||
<q-input dense stack-label outlined label="脚本参数" class="full-width" v-model="quickcommandInfo.scptarg">
|
<q-input
|
||||||
|
dense
|
||||||
|
stack-label
|
||||||
|
outlined
|
||||||
|
label="脚本参数"
|
||||||
|
class="full-width"
|
||||||
|
v-model="quickcommandInfo.scptarg"
|
||||||
|
>
|
||||||
<template v-slot:prepend>
|
<template v-slot:prepend>
|
||||||
<q-icon name="input" />
|
<q-icon name="input" />
|
||||||
</template>
|
</template>
|
||||||
</q-input>
|
</q-input>
|
||||||
</q-item>
|
</q-item>
|
||||||
<!-- 编码设置 -->
|
<!-- 编码设置 -->
|
||||||
<q-item v-for="(item, index) in Object.keys(quickcommandInfo.charset)" :key="index"
|
<q-item
|
||||||
v-show="quickcommandInfo.program !== 'quickcommand'">
|
v-for="(item, index) in Object.keys(quickcommandInfo.charset)"
|
||||||
<q-select dense outlined stack-label clearable class="full-width" :label="['脚本编码', '输出编码'][index]"
|
:key="index"
|
||||||
v-model="quickcommandInfo.charset[item]" :options="['GBK', 'utf8', 'Big5']" type="text">
|
v-show="quickcommandInfo.program !== 'quickcommand'"
|
||||||
|
>
|
||||||
|
<q-select
|
||||||
|
dense
|
||||||
|
outlined
|
||||||
|
stack-label
|
||||||
|
clearable
|
||||||
|
class="full-width"
|
||||||
|
:label="['脚本编码', '输出编码'][index]"
|
||||||
|
v-model="quickcommandInfo.charset[item]"
|
||||||
|
:options="['GBK', 'utf8', 'Big5']"
|
||||||
|
type="text"
|
||||||
|
>
|
||||||
<template v-slot:prepend>
|
<template v-slot:prepend>
|
||||||
<q-icon :name="['format_size', 'output'][index]" />
|
<q-icon :name="['format_size', 'output'][index]" />
|
||||||
</template>
|
</template>
|
||||||
@ -102,10 +168,26 @@
|
|||||||
</q-list>
|
</q-list>
|
||||||
</q-btn-dropdown>
|
</q-btn-dropdown>
|
||||||
<q-separator vertical inset />
|
<q-separator vertical inset />
|
||||||
<q-btn style="padding: 0 10px" dense flat color="primary" icon="play_arrow" label="运行"
|
<q-btn
|
||||||
@click="runCurrentCommand()"></q-btn>
|
style="padding: 0 10px"
|
||||||
<q-btn flat style="padding: 0 10px" dense v-if="!isRunCodePage" :disable="!canCommandSave"
|
dense
|
||||||
:color="canCommandSave ? 'primary' : 'grey'" icon="save" label="保存" @click="saveCurrentCommand()"></q-btn>
|
flat
|
||||||
|
color="primary"
|
||||||
|
icon="play_arrow"
|
||||||
|
label="运行"
|
||||||
|
@click="runCurrentCommand()"
|
||||||
|
></q-btn>
|
||||||
|
<q-btn
|
||||||
|
flat
|
||||||
|
style="padding: 0 10px"
|
||||||
|
dense
|
||||||
|
v-if="!isRunCodePage"
|
||||||
|
:disable="!canCommandSave"
|
||||||
|
:color="canCommandSave ? 'primary' : 'grey'"
|
||||||
|
icon="save"
|
||||||
|
label="保存"
|
||||||
|
@click="saveCurrentCommand()"
|
||||||
|
></q-btn>
|
||||||
</q-btn-group>
|
</q-btn-group>
|
||||||
</div>
|
</div>
|
||||||
<q-dialog v-model="showActions">
|
<q-dialog v-model="showActions">
|
||||||
@ -116,12 +198,19 @@
|
|||||||
</q-dialog>
|
</q-dialog>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<MonacoEditor class="absolute-bottom" :placeholder="true" ref="editor" @loaded="monacoInit"
|
<MonacoEditor
|
||||||
@typing="(val) => monacoTyping(val)" @keyStroke="monacoKeyStroke" :style="{
|
class="absolute-bottom"
|
||||||
|
:placeholder="true"
|
||||||
|
ref="editor"
|
||||||
|
@loaded="monacoInit"
|
||||||
|
@typing="(val) => monacoTyping(val)"
|
||||||
|
@keyStroke="monacoKeyStroke"
|
||||||
|
:style="{
|
||||||
top: languageBarHeight + 'px',
|
top: languageBarHeight + 'px',
|
||||||
left: action.type === 'run' ? 0 : sideBarWidth + 'px',
|
left: action.type === 'run' ? 0 : sideBarWidth + 'px',
|
||||||
// transition: '0.3s',
|
// transition: '0.3s',
|
||||||
}" />
|
}"
|
||||||
|
/>
|
||||||
<!-- 运行结果 -->
|
<!-- 运行结果 -->
|
||||||
<CommandRunResult :action="action" ref="result"></CommandRunResult>
|
<CommandRunResult :action="action" ref="result"></CommandRunResult>
|
||||||
</div>
|
</div>
|
||||||
@ -195,7 +284,7 @@ export default {
|
|||||||
this.configurationPage.allQuickCommandTags,
|
this.configurationPage.allQuickCommandTags,
|
||||||
"默认",
|
"默认",
|
||||||
"未分类",
|
"未分类",
|
||||||
"搜索结果",
|
"搜索结果"
|
||||||
// "来自分享"
|
// "来自分享"
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
@ -256,7 +345,7 @@ export default {
|
|||||||
this.sideBarWidth = !!this.sideBarWidth ? 0 : defaultSideBarWidth;
|
this.sideBarWidth = !!this.sideBarWidth ? 0 : defaultSideBarWidth;
|
||||||
},
|
},
|
||||||
// 保存
|
// 保存
|
||||||
saveCurrentCommand() {
|
saveCurrentCommand(config = { silent: false }) {
|
||||||
let updatedData = this.$refs.sidebar?.SaveMenuData();
|
let updatedData = this.$refs.sidebar?.SaveMenuData();
|
||||||
if (!updatedData) return;
|
if (!updatedData) return;
|
||||||
Object.assign(this.quickcommandInfo, _.cloneDeep(updatedData));
|
Object.assign(this.quickcommandInfo, _.cloneDeep(updatedData));
|
||||||
@ -269,9 +358,17 @@ export default {
|
|||||||
type: "save",
|
type: "save",
|
||||||
data: newQuickcommandInfo,
|
data: newQuickcommandInfo,
|
||||||
});
|
});
|
||||||
|
if (!config.silent)
|
||||||
|
quickcommand.showMessageBox(
|
||||||
|
"保存成功!",
|
||||||
|
"success",
|
||||||
|
1000,
|
||||||
|
"bottom-right"
|
||||||
|
);
|
||||||
},
|
},
|
||||||
// 运行
|
// 运行
|
||||||
runCurrentCommand(cmd) {
|
runCurrentCommand(cmd) {
|
||||||
|
this.saveCurrentCommand({ silent: true });
|
||||||
let command = _.cloneDeep(this.quickcommandInfo);
|
let command = _.cloneDeep(this.quickcommandInfo);
|
||||||
if (cmd) command.cmd = cmd;
|
if (cmd) command.cmd = cmd;
|
||||||
command.output =
|
command.output =
|
||||||
|
@ -89,7 +89,7 @@ export default {
|
|||||||
);
|
);
|
||||||
}),
|
}),
|
||||||
|
|
||||||
showMessageBox: (message, icon = "success", time) => {
|
showMessageBox: (message, icon = "success", time, position = "top") => {
|
||||||
message = _.truncate(message, { length: 1200 });
|
message = _.truncate(message, { length: 1200 });
|
||||||
if (icon === "success") icon = "positive";
|
if (icon === "success") icon = "positive";
|
||||||
if (icon === "error") icon = "negative";
|
if (icon === "error") icon = "negative";
|
||||||
@ -99,7 +99,7 @@ export default {
|
|||||||
type: icon,
|
type: icon,
|
||||||
message: message,
|
message: message,
|
||||||
timeout: time,
|
timeout: time,
|
||||||
position: "top",
|
position: position,
|
||||||
actions:
|
actions:
|
||||||
time === 0
|
time === 0
|
||||||
? [
|
? [
|
||||||
|
@ -619,7 +619,7 @@ export default {
|
|||||||
switch (event.type) {
|
switch (event.type) {
|
||||||
case "save":
|
case "save":
|
||||||
this.saveCommand(event.data);
|
this.saveCommand(event.data);
|
||||||
this.isCommandEditorShow = false;
|
// this.isCommandEditorShow = false;
|
||||||
default:
|
default:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user