mirror of
https://github.com/fofolee/uTools-quickcommand.git
synced 2025-06-30 21:13:02 +08:00
更改全局变量存储方式
This commit is contained in:
parent
a27fe4c338
commit
ca01808c93
@ -214,22 +214,22 @@ if (process.platform !== 'linux') quickcommand.runInTerminal = function(cmdline,
|
|||||||
}
|
}
|
||||||
|
|
||||||
let getCommandToLaunchTerminal = (cmdline, dir) => {
|
let getCommandToLaunchTerminal = (cmdline, dir) => {
|
||||||
let cd = ''
|
let cd = ''
|
||||||
if (utools.isWindows()) {
|
if (utools.isWindows()) {
|
||||||
let appPath = path.join(utools.getPath('home'), '/AppData/Local/Microsoft/WindowsApps/')
|
let appPath = path.join(utools.getPath('home'), '/AppData/Local/Microsoft/WindowsApps/')
|
||||||
// 直接 existsSync wt.exe 无效
|
// 直接 existsSync wt.exe 无效
|
||||||
if (fs.existsSync(appPath) && fs.readdirSync(appPath).includes('wt.exe')) {
|
if (fs.existsSync(appPath) && fs.readdirSync(appPath).includes('wt.exe')) {
|
||||||
cmdline = cmdline.replace(/"/g, `\\"`)
|
cmdline = cmdline.replace(/"/g, `\\"`)
|
||||||
if (dir) cd = `-d "${dir.replace(/\\/g, '/')}"`
|
if (dir) cd = `-d "${dir.replace(/\\/g, '/')}"`
|
||||||
command = `${appPath}wt.exe ${cd} cmd /k "${cmdline}"`
|
command = `${appPath}wt.exe ${cd} cmd /k "${cmdline}"`
|
||||||
|
} else {
|
||||||
|
cmdline = cmdline.replace(/"/g, `^"`)
|
||||||
|
if (dir) cd = `cd /d "${dir.replace(/\\/g, '/')}" &&`
|
||||||
|
command = `${cd} start "" cmd /k "${cmdline}"`
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
cmdline = cmdline.replace(/"/g, `^"`)
|
cmdline = cmdline.replace(/"/g, `\\"`)
|
||||||
if (dir) cd = `cd /d "${dir.replace(/\\/g, '/')}" &&`
|
if (dir) cd = `cd ${dir.replace(/ /g, `\\\\ `)} &&`
|
||||||
command = `${cd} start "" cmd /k "${cmdline}"`
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
cmdline = cmdline.replace(/"/g, `\\"`)
|
|
||||||
if (dir) cd = `cd ${dir.replace(/ /g, `\\\\ `)} &&`
|
|
||||||
if (fs.existsSync('/Applications/iTerm.app')) {
|
if (fs.existsSync('/Applications/iTerm.app')) {
|
||||||
command = `osascript -e 'tell application "iTerm"
|
command = `osascript -e 'tell application "iTerm"
|
||||||
create window with default profile
|
create window with default profile
|
||||||
@ -453,7 +453,7 @@ let parseStdout = stdout => stdout.map(x => parseItem(x)).join("\n")
|
|||||||
// 屏蔽危险函数
|
// 屏蔽危险函数
|
||||||
window.getuToolsLite = () => {
|
window.getuToolsLite = () => {
|
||||||
var utoolsLite = Object.assign({}, utools)
|
var utoolsLite = Object.assign({}, utools)
|
||||||
if (utools.isDev()) return utoolsLite
|
// if (utools.isDev()) return utoolsLite
|
||||||
// 数据库相关接口
|
// 数据库相关接口
|
||||||
delete utoolsLite.db
|
delete utoolsLite.db
|
||||||
delete utoolsLite.dbStorage
|
delete utoolsLite.dbStorage
|
||||||
@ -668,4 +668,4 @@ window.quickcommandHttpServer = () => {
|
|||||||
run,
|
run,
|
||||||
stop
|
stop
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -28,9 +28,7 @@ module.exports = configure(function(ctx) {
|
|||||||
// app boot file (/src/boot)
|
// app boot file (/src/boot)
|
||||||
// --> boot files are part of "main.js"
|
// --> boot files are part of "main.js"
|
||||||
// https://v2.quasar.dev/quasar-cli-webpack/boot-files
|
// https://v2.quasar.dev/quasar-cli-webpack/boot-files
|
||||||
boot: [
|
boot: [],
|
||||||
'global.js'
|
|
||||||
],
|
|
||||||
|
|
||||||
// https://v2.quasar.dev/quasar-cli-webpack/quasar-config-js#Property%3A-css
|
// https://v2.quasar.dev/quasar-cli-webpack/quasar-config-js#Property%3A-css
|
||||||
css: [
|
css: [
|
||||||
|
123
src/App.vue
123
src/App.vue
@ -7,12 +7,20 @@
|
|||||||
<script>
|
<script>
|
||||||
import { defineComponent } from "vue";
|
import { defineComponent } from "vue";
|
||||||
import { setCssVar } from "quasar";
|
import { setCssVar } from "quasar";
|
||||||
|
import UTOOLS from "./js/utools.js";
|
||||||
|
import programmings from "./js/options/programs.js";
|
||||||
|
import defaultProfile from "./js/options/defaultProfile.js";
|
||||||
|
import Cron from "croner";
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: "App",
|
name: "App",
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
setCssVar: setCssVar,
|
setCssVar: setCssVar,
|
||||||
|
programs: programmings,
|
||||||
|
profile: defaultProfile,
|
||||||
|
utools: UTOOLS,
|
||||||
|
cronJobs: {},
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {},
|
computed: {},
|
||||||
@ -23,7 +31,16 @@ export default defineComponent({
|
|||||||
init() {
|
init() {
|
||||||
window.root = this;
|
window.root = this;
|
||||||
window.utools = window.getuToolsLite();
|
window.utools = window.getuToolsLite();
|
||||||
// 版本检测
|
if (!this.checkVer()) return;
|
||||||
|
this.startUp();
|
||||||
|
utools.onPluginEnter((enter) => {
|
||||||
|
this.enterPlugin(enter);
|
||||||
|
});
|
||||||
|
utools.onPluginOut(() => {
|
||||||
|
this.outPlugin();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
checkVer() {
|
||||||
const requiredVersion = "2.6.1";
|
const requiredVersion = "2.6.1";
|
||||||
let version = utools.getAppVersion();
|
let version = utools.getAppVersion();
|
||||||
if (version < requiredVersion) {
|
if (version < requiredVersion) {
|
||||||
@ -31,67 +48,93 @@ export default defineComponent({
|
|||||||
name: "needupdate",
|
name: "needupdate",
|
||||||
params: { version: version, requiredVersion: requiredVersion },
|
params: { version: version, requiredVersion: requiredVersion },
|
||||||
});
|
});
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
this.startUp();
|
return true;
|
||||||
// 进入插件
|
},
|
||||||
utools.onPluginEnter((enter) => {
|
startUp() {
|
||||||
// 暗黑模式
|
// 读取用户配置
|
||||||
this.$q.dark.set(utools.isDarkColors());
|
let userProfile = this.utools.getDB(
|
||||||
// 路由跳转
|
this.utools.DBPRE.CFG + "preferences"
|
||||||
quickcommand.enterData = enter;
|
);
|
||||||
quickcommand.payload = enter.payload;
|
_.merge(defaultProfile, _.cloneDeep(userProfile));
|
||||||
this.$router.push(enter.code);
|
// 计划任务
|
||||||
});
|
_.forIn(this.profile.crontabs, (cronExp, featureCode) => {
|
||||||
// 退出插件
|
this.runCronTask(featureCode, cronExp);
|
||||||
utools.onPluginOut(() => {
|
|
||||||
// 保存偏好
|
|
||||||
this.saveProfile();
|
|
||||||
// 切到空路由
|
|
||||||
this.$router.push("/");
|
|
||||||
// 清空临时数据
|
|
||||||
window.temporaryStoreSoldOut();
|
|
||||||
});
|
});
|
||||||
|
// 快捷命令服务
|
||||||
|
if (this.profile.quickFeatures.apiServer.serverStatus) {
|
||||||
|
window
|
||||||
|
.quickcommandHttpServer()
|
||||||
|
.run(
|
||||||
|
this.profile.quickFeatures.apiServer.cmd,
|
||||||
|
this.profile.quickFeatures.apiServer.port
|
||||||
|
);
|
||||||
|
console.log("Server Start...");
|
||||||
|
}
|
||||||
|
// 默认主题色
|
||||||
|
this.setCssVar("primary", this.profile.primaryColor);
|
||||||
|
},
|
||||||
|
enterPlugin(enter) {
|
||||||
|
this.$q.dark.set(utools.isDarkColors());
|
||||||
|
quickcommand.enterData = enter;
|
||||||
|
quickcommand.payload = enter.payload;
|
||||||
|
this.$router.push(enter.code);
|
||||||
|
},
|
||||||
|
outPlugin() {
|
||||||
|
this.saveProfile();
|
||||||
|
this.$router.push("/");
|
||||||
|
window.temporaryStoreSoldOut();
|
||||||
},
|
},
|
||||||
saveProfile() {
|
saveProfile() {
|
||||||
let commandEditor = this.$refs.view.$refs.commandEditor;
|
let commandEditor = this.$refs.view.$refs.commandEditor;
|
||||||
if (commandEditor && commandEditor.action.type !== "edit") {
|
if (commandEditor && commandEditor.action.type !== "edit") {
|
||||||
let command = _.cloneDeep(commandEditor.quickcommandInfo);
|
let command = _.cloneDeep(commandEditor.quickcommandInfo);
|
||||||
command.cursorPosition = commandEditor.$refs.editor.getCursorPosition();
|
command.cursorPosition = commandEditor.$refs.editor.getCursorPosition();
|
||||||
this.$profile.codeHistory[commandEditor.action.type] = command;
|
this.profile.codeHistory[commandEditor.action.type] = command;
|
||||||
}
|
}
|
||||||
this.$utools.putDB(
|
this.utools.putDB(
|
||||||
_.cloneDeep(this.$profile),
|
_.cloneDeep(this.profile),
|
||||||
this.$utools.DBPRE.CFG + "preferences"
|
this.utools.DBPRE.CFG + "preferences"
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
// 随插件启动执行
|
runCronTask(featureCode, cronExp) {
|
||||||
startUp() {
|
this.cronJobs[featureCode] = Cron(cronExp, () => {
|
||||||
// 如果配置了后台服务则开启监听
|
this.runCommandSilently(featureCode);
|
||||||
if (this.$profile.quickFeatures.apiServer.serverStatus) {
|
});
|
||||||
window
|
},
|
||||||
.quickcommandHttpServer()
|
runCommandSilently(featureCode) {
|
||||||
.run(
|
let command = this.utools.getDB(this.utools.DBPRE.QC + featureCode);
|
||||||
this.$profile.quickFeatures.apiServer.cmd,
|
if (command.program === "quickcommand") {
|
||||||
this.$profile.quickFeatures.apiServer.port
|
window.runCodeInSandbox(command.cmd, () => {});
|
||||||
);
|
} else {
|
||||||
console.log("Server Start...");
|
let option =
|
||||||
|
command.program === "custom"
|
||||||
|
? command.customOptions
|
||||||
|
: this.programs[command.program];
|
||||||
|
option.scptarg = command.scptarg;
|
||||||
|
option.charset = command.charset;
|
||||||
|
window.runCodeFile(command.cmd, option, false, () => {});
|
||||||
}
|
}
|
||||||
// 默认主题色
|
|
||||||
this.setCssVar("primary", this.$profile.primaryColor);
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
.q-tooltip {
|
|
||||||
font-size: 11px;
|
|
||||||
}
|
|
||||||
:root {
|
:root {
|
||||||
--q-dark: #464646;
|
--q-dark: #464646;
|
||||||
--q-dark-page: #303133;
|
--q-dark-page: #303133;
|
||||||
}
|
}
|
||||||
|
.q-tooltip {
|
||||||
|
font-size: 11px;
|
||||||
|
}
|
||||||
|
.q-chip {
|
||||||
|
background: #e3e3e39a;
|
||||||
|
}
|
||||||
|
.q-chip--dark {
|
||||||
|
background: #676666;
|
||||||
|
}
|
||||||
.commandLogo {
|
.commandLogo {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
transition: 0.2s;
|
transition: 0.2s;
|
||||||
|
@ -1,24 +0,0 @@
|
|||||||
import {
|
|
||||||
boot
|
|
||||||
} from 'quasar/wrappers'
|
|
||||||
import UTOOLS from "../js/utools.js";
|
|
||||||
import programmings from '../js/options/programs.js';
|
|
||||||
import defaultProfile from "../js/options/defaultProfile.js"
|
|
||||||
import Cron from "croner"
|
|
||||||
|
|
||||||
// 配置数据存取
|
|
||||||
let userProfile = UTOOLS.getDB(
|
|
||||||
UTOOLS.DBPRE.CFG + "preferences"
|
|
||||||
);
|
|
||||||
_.merge(defaultProfile, _.cloneDeep(userProfile))
|
|
||||||
|
|
||||||
// "async" is optional;
|
|
||||||
// more info on params: https://v2.quasar.dev/quasar-cli/boot-files
|
|
||||||
export default boot(async({
|
|
||||||
app
|
|
||||||
}) => {
|
|
||||||
app.config.globalProperties.$utools = UTOOLS
|
|
||||||
app.config.globalProperties.$programmings = programmings
|
|
||||||
app.config.globalProperties.$profile = defaultProfile
|
|
||||||
app.config.globalProperties.$Cron = Cron
|
|
||||||
})
|
|
@ -36,8 +36,8 @@
|
|||||||
dense
|
dense
|
||||||
flat
|
flat
|
||||||
round
|
round
|
||||||
color="blue-9"
|
:color="!!cronExp ? 'amber' : 'blue-9'"
|
||||||
icon="insights"
|
:icon="!!cronExp ? 'timer' : 'insights'"
|
||||||
>
|
>
|
||||||
<q-tooltip anchor="top middle" self="center middle">
|
<q-tooltip anchor="top middle" self="center middle">
|
||||||
设置
|
设置
|
||||||
@ -79,9 +79,9 @@
|
|||||||
<q-item-section side>
|
<q-item-section side>
|
||||||
<q-icon name="timer" />
|
<q-icon name="timer" />
|
||||||
</q-item-section>
|
</q-item-section>
|
||||||
<q-item-section>添加定时任务</q-item-section>
|
<q-item-section>定时任务</q-item-section>
|
||||||
<q-tooltip
|
<q-tooltip
|
||||||
>定时执行当前命令,仅匹配类型为关键字时可用</q-tooltip
|
>在后台定时执行当前命令,仅匹配类型为关键字时可用,且一律忽略输出</q-tooltip
|
||||||
>
|
>
|
||||||
</q-item>
|
</q-item>
|
||||||
</q-list>
|
</q-list>
|
||||||
@ -231,8 +231,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<q-dialog v-model="showCrontab">
|
<q-dialog v-model="showCrontab">
|
||||||
<CrontabSetting
|
<CrontabSetting
|
||||||
:cronStatus="$profile.crontabs[featureCode]?.status"
|
:cronExp="cronExp"
|
||||||
:cronExp="$profile.crontabs[featureCode]?.cronExp"
|
|
||||||
@addCrontab="addCrontab"
|
@addCrontab="addCrontab"
|
||||||
@delCrontab="delCrontab"
|
@delCrontab="delCrontab"
|
||||||
/>
|
/>
|
||||||
@ -249,7 +248,7 @@ export default {
|
|||||||
components: { CrontabSetting },
|
components: { CrontabSetting },
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
allProgrammings: this.$programmings,
|
allProgrammings: this.$root.programs,
|
||||||
maxCmdStingLen: 8,
|
maxCmdStingLen: 8,
|
||||||
commandTypes: commandTypes,
|
commandTypes: commandTypes,
|
||||||
platformTypes: platformTypes,
|
platformTypes: platformTypes,
|
||||||
@ -314,6 +313,9 @@ export default {
|
|||||||
featureCode() {
|
featureCode() {
|
||||||
return this.commandInfo.features.code;
|
return this.commandInfo.features.code;
|
||||||
},
|
},
|
||||||
|
cronExp() {
|
||||||
|
return this.$root.profile.crontabs[this.featureCode];
|
||||||
|
},
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
commandInfo: Object,
|
commandInfo: Object,
|
||||||
@ -358,19 +360,12 @@ export default {
|
|||||||
this.$emit("commandChanged", event);
|
this.$emit("commandChanged", event);
|
||||||
},
|
},
|
||||||
addCrontab(cronExp) {
|
addCrontab(cronExp) {
|
||||||
this.$profile.crontabs[this.featureCode] = {
|
this.$root.profile.crontabs[this.featureCode] = cronExp;
|
||||||
cronStatus: true,
|
this.$root.runCronTask(this.featureCode, cronExp);
|
||||||
cronExp: cronExp,
|
|
||||||
};
|
|
||||||
this.cronJob = this.$Cron(cronExp, () => {
|
|
||||||
this.runCommand();
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
delCrontab() {
|
delCrontab() {
|
||||||
this.$profile.crontabs[this.featureCode] = {
|
delete this.$root.profile.crontabs[this.featureCode];
|
||||||
cronStatus: false,
|
this.$root.cronJobs[this.featureCode].stop();
|
||||||
};
|
|
||||||
this.cronJob.stop();
|
|
||||||
},
|
},
|
||||||
// 启用/禁用命令
|
// 启用/禁用命令
|
||||||
toggleCommandActivated() {
|
toggleCommandActivated() {
|
||||||
|
@ -61,13 +61,13 @@
|
|||||||
>
|
>
|
||||||
<template v-slot:append>
|
<template v-slot:append>
|
||||||
<q-avatar size="lg" square>
|
<q-avatar size="lg" square>
|
||||||
<img :src="$programmings[quickcommandInfo.program].icon" />
|
<img :src="$root.programs[quickcommandInfo.program].icon" />
|
||||||
</q-avatar>
|
</q-avatar>
|
||||||
</template>
|
</template>
|
||||||
<template v-slot:option="scope">
|
<template v-slot:option="scope">
|
||||||
<q-item v-bind="scope.itemProps">
|
<q-item v-bind="scope.itemProps">
|
||||||
<q-item-section avatar>
|
<q-item-section avatar>
|
||||||
<img width="32" :src="$programmings[scope.opt].icon" />
|
<img width="32" :src="$root.programs[scope.opt].icon" />
|
||||||
</q-item-section>
|
</q-item-section>
|
||||||
<q-item-section>
|
<q-item-section>
|
||||||
<q-item-label v-html="scope.opt" />
|
<q-item-label v-html="scope.opt" />
|
||||||
@ -166,7 +166,7 @@ export default {
|
|||||||
components: { MonacoEditor, CommandSideBar, CommandRunResult },
|
components: { MonacoEditor, CommandSideBar, CommandRunResult },
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
programLanguages: Object.keys(this.$programmings),
|
programLanguages: Object.keys(this.$root.programs),
|
||||||
sideBarWidth: 250,
|
sideBarWidth: 250,
|
||||||
languageBarHeight: 40,
|
languageBarHeight: 40,
|
||||||
canCommandSave: this.action.type === "code" ? false : true,
|
canCommandSave: this.action.type === "code" ? false : true,
|
||||||
@ -214,7 +214,7 @@ export default {
|
|||||||
init() {
|
init() {
|
||||||
let quickCommandInfo =
|
let quickCommandInfo =
|
||||||
this.action.type !== "edit"
|
this.action.type !== "edit"
|
||||||
? this.$utools.getDB(this.$utools.DBPRE.CFG + "preferences")
|
? this.$root.utools.getDB(this.$root.utools.DBPRE.CFG + "preferences")
|
||||||
?.codeHistory[this.action.type]
|
?.codeHistory[this.action.type]
|
||||||
: this.action.data;
|
: this.action.data;
|
||||||
quickCommandInfo?.program &&
|
quickCommandInfo?.program &&
|
||||||
@ -234,7 +234,7 @@ export default {
|
|||||||
},
|
},
|
||||||
// 匹配编程语言
|
// 匹配编程语言
|
||||||
matchLanguage() {
|
matchLanguage() {
|
||||||
let language = Object.values(this.$programmings).filter(
|
let language = Object.values(this.$root.programs).filter(
|
||||||
(program) => program.ext === this.quickcommandInfo.customOptions.ext
|
(program) => program.ext === this.quickcommandInfo.customOptions.ext
|
||||||
);
|
);
|
||||||
if (language.length) {
|
if (language.length) {
|
||||||
@ -243,7 +243,7 @@ export default {
|
|||||||
},
|
},
|
||||||
// 设置编程语言
|
// 设置编程语言
|
||||||
setLanguage(language) {
|
setLanguage(language) {
|
||||||
let highlight = this.$programmings[language].highlight;
|
let highlight = this.$root.programs[language].highlight;
|
||||||
this.$refs.editor.setEditorLanguage(highlight ? highlight : language);
|
this.$refs.editor.setEditorLanguage(highlight ? highlight : language);
|
||||||
},
|
},
|
||||||
// 打开文档
|
// 打开文档
|
||||||
@ -330,9 +330,9 @@ export default {
|
|||||||
if (!updatedData) return;
|
if (!updatedData) return;
|
||||||
Object.assign(this.quickcommandInfo, _.cloneDeep(updatedData));
|
Object.assign(this.quickcommandInfo, _.cloneDeep(updatedData));
|
||||||
let newQuickcommandInfo = _.cloneDeep(this.quickcommandInfo);
|
let newQuickcommandInfo = _.cloneDeep(this.quickcommandInfo);
|
||||||
this.$utools.putDB(
|
this.$root.utools.putDB(
|
||||||
newQuickcommandInfo,
|
newQuickcommandInfo,
|
||||||
this.$utools.DBPRE.QC + this.quickcommandInfo.features.code
|
this.$root.utools.DBPRE.QC + this.quickcommandInfo.features.code
|
||||||
);
|
);
|
||||||
this.$emit("editorEvent", {
|
this.$emit("editorEvent", {
|
||||||
type: "save",
|
type: "save",
|
||||||
|
@ -106,9 +106,10 @@ export default {
|
|||||||
!outPlugin && this.showRunResult(stdout, true, action);
|
!outPlugin && this.showRunResult(stdout, true, action);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
let option = this.$programmings[currentCommand.program];
|
let option =
|
||||||
if (currentCommand.program === "custom")
|
currentCommand.program === "custom"
|
||||||
option = currentCommand.customOptions;
|
? currentCommand.customOptions
|
||||||
|
: this.$root.programs[currentCommand.program];
|
||||||
option.scptarg = currentCommand.scptarg;
|
option.scptarg = currentCommand.scptarg;
|
||||||
option.charset = currentCommand.charset;
|
option.charset = currentCommand.charset;
|
||||||
window.runCodeFile(
|
window.runCodeFile(
|
||||||
|
@ -331,7 +331,8 @@ export default {
|
|||||||
},
|
},
|
||||||
setIcon(language) {
|
setIcon(language) {
|
||||||
this.currentCommand.features.icon?.slice(0, 10) === "data:image" ||
|
this.currentCommand.features.icon?.slice(0, 10) === "data:image" ||
|
||||||
(this.currentCommand.features.icon = this.$programmings[language].icon);
|
(this.currentCommand.features.icon =
|
||||||
|
this.$root.programs[language].icon);
|
||||||
},
|
},
|
||||||
getCommandType() {
|
getCommandType() {
|
||||||
let data = { type: "key", match: [] };
|
let data = { type: "key", match: [] };
|
||||||
|
@ -32,20 +32,20 @@
|
|||||||
input-class="text-center"
|
input-class="text-center"
|
||||||
style="width: 280px"
|
style="width: 280px"
|
||||||
autofocus
|
autofocus
|
||||||
v-model="quickFeatures.favFile.tag"
|
v-model="$root.profile.quickFeatures.favFile.tag"
|
||||||
type="text"
|
type="text"
|
||||||
>
|
>
|
||||||
<template v-slot:append>
|
<template v-slot:append>
|
||||||
<q-toggle
|
<q-toggle
|
||||||
@click="toggleFeature('favFile')"
|
@click="toggleFeature('favFile')"
|
||||||
v-model="quickFeatures.favFile.enable"
|
v-model="$root.profile.quickFeatures.favFile.enable"
|
||||||
checked-icon="check"
|
checked-icon="check"
|
||||||
color="primary"
|
color="primary"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
<q-tooltip
|
<q-tooltip
|
||||||
>启用后,选中文件可以通过超级面板快速将文件收藏到「{{
|
>启用后,选中文件可以通过超级面板快速将文件收藏到「{{
|
||||||
quickFeatures.favFile.tag
|
$root.profile.quickFeatures.favFile.tag
|
||||||
}}」标签
|
}}」标签
|
||||||
</q-tooltip>
|
</q-tooltip>
|
||||||
</q-input>
|
</q-input>
|
||||||
@ -61,20 +61,20 @@
|
|||||||
outlined
|
outlined
|
||||||
input-class="text-center"
|
input-class="text-center"
|
||||||
style="width: 280px"
|
style="width: 280px"
|
||||||
v-model="quickFeatures.favUrl.tag"
|
v-model="$root.profile.quickFeatures.favUrl.tag"
|
||||||
type="text"
|
type="text"
|
||||||
>
|
>
|
||||||
<template v-slot:append>
|
<template v-slot:append>
|
||||||
<q-toggle
|
<q-toggle
|
||||||
@click="toggleFeature('favUrl')"
|
@click="toggleFeature('favUrl')"
|
||||||
v-model="quickFeatures.favUrl.enable"
|
v-model="$root.profile.quickFeatures.favUrl.enable"
|
||||||
checked-icon="check"
|
checked-icon="check"
|
||||||
color="primary"
|
color="primary"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
<q-tooltip
|
<q-tooltip
|
||||||
>启用后,在浏览器界面可以通过超级面板快速将网址收藏到「{{
|
>启用后,在浏览器界面可以通过超级面板快速将网址收藏到「{{
|
||||||
quickFeatures.favUrl.tag
|
$root.profile.quickFeatures.favUrl.tag
|
||||||
}}」标签
|
}}」标签
|
||||||
</q-tooltip>
|
</q-tooltip>
|
||||||
</q-input>
|
</q-input>
|
||||||
@ -91,13 +91,13 @@
|
|||||||
input-class="text-center"
|
input-class="text-center"
|
||||||
style="width: 280px"
|
style="width: 280px"
|
||||||
autofocus
|
autofocus
|
||||||
v-model="quickFeatures.pluNickName.tag"
|
v-model="$root.profile.quickFeatures.pluNickName.tag"
|
||||||
type="text"
|
type="text"
|
||||||
>
|
>
|
||||||
<template v-slot:append>
|
<template v-slot:append>
|
||||||
<q-toggle
|
<q-toggle
|
||||||
@click="toggleFeature('pluNickName')"
|
@click="toggleFeature('pluNickName')"
|
||||||
v-model="quickFeatures.pluNickName.enable"
|
v-model="$root.profile.quickFeatures.pluNickName.enable"
|
||||||
checked-icon="check"
|
checked-icon="check"
|
||||||
color="primary"
|
color="primary"
|
||||||
/>
|
/>
|
||||||
@ -105,7 +105,7 @@
|
|||||||
<q-tooltip
|
<q-tooltip
|
||||||
>启用后,在主输入框输入「插件别名」可以快速设置插件别名<br />
|
>启用后,在主输入框输入「插件别名」可以快速设置插件别名<br />
|
||||||
并将所有设置的别名保存至「{{
|
并将所有设置的别名保存至「{{
|
||||||
quickFeatures.pluNickName.tag
|
$root.profile.quickFeatures.pluNickName.tag
|
||||||
}}」标签
|
}}」标签
|
||||||
</q-tooltip>
|
</q-tooltip>
|
||||||
</q-input>
|
</q-input>
|
||||||
@ -119,7 +119,7 @@
|
|||||||
prefix="开启快捷命令服务"
|
prefix="开启快捷命令服务"
|
||||||
suffix="端口"
|
suffix="端口"
|
||||||
outlined
|
outlined
|
||||||
v-model="quickFeatures.apiServer.port"
|
v-model="$root.profile.quickFeatures.apiServer.port"
|
||||||
input-class="text-center"
|
input-class="text-center"
|
||||||
style="width: 280px"
|
style="width: 280px"
|
||||||
type="text"
|
type="text"
|
||||||
@ -127,7 +127,7 @@
|
|||||||
<template v-slot:append>
|
<template v-slot:append>
|
||||||
<q-toggle
|
<q-toggle
|
||||||
@click="toggleFeature('apiServer')"
|
@click="toggleFeature('apiServer')"
|
||||||
v-model="quickFeatures.apiServer.enable"
|
v-model="$root.profile.quickFeatures.apiServer.enable"
|
||||||
checked-icon="check"
|
checked-icon="check"
|
||||||
color="primary"
|
color="primary"
|
||||||
/>
|
/>
|
||||||
@ -135,7 +135,7 @@
|
|||||||
<q-tooltip
|
<q-tooltip
|
||||||
>启用后,在主输入框输入「快捷命令服务」可以进入配置一个后台服务<br />
|
>启用后,在主输入框输入「快捷命令服务」可以进入配置一个后台服务<br />
|
||||||
通过本地监听{{
|
通过本地监听{{
|
||||||
quickFeatures.apiServer.port
|
$root.profile.quickFeatures.apiServer.port
|
||||||
}}端口的形式,接收用户传送过来的参数,然后根据参数执行不同的操作
|
}}端口的形式,接收用户传送过来的参数,然后根据参数执行不同的操作
|
||||||
<br />
|
<br />
|
||||||
本功能的意义在于,将 utools
|
本功能的意义在于,将 utools
|
||||||
@ -233,7 +233,7 @@
|
|||||||
no-header
|
no-header
|
||||||
no-footer
|
no-footer
|
||||||
@change="setPrimaryColor"
|
@change="setPrimaryColor"
|
||||||
v-model="primaryColor"
|
v-model="$root.profile.primaryColor"
|
||||||
/>
|
/>
|
||||||
<q-btn
|
<q-btn
|
||||||
color="primary"
|
color="primary"
|
||||||
@ -343,7 +343,6 @@ export default {
|
|||||||
selectFile: ref(null),
|
selectFile: ref(null),
|
||||||
showAbout: false,
|
showAbout: false,
|
||||||
showPanelConf: false,
|
showPanelConf: false,
|
||||||
quickFeatures: this.$profile.quickFeatures,
|
|
||||||
features: features,
|
features: features,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
@ -391,21 +390,21 @@ export default {
|
|||||||
},
|
},
|
||||||
// 设置主题色
|
// 设置主题色
|
||||||
setPrimaryColor() {
|
setPrimaryColor() {
|
||||||
this.setCssVar("primary", this.$profile.primaryColor);
|
this.setCssVar("primary", this.$root.profile.primaryColor);
|
||||||
},
|
},
|
||||||
// 重置主题色
|
// 重置主题色
|
||||||
resetPrimary() {
|
resetPrimary() {
|
||||||
this.$profile.primaryColor = this.$profile.defaultPrimaryColor;
|
this.$root.profile.primaryColor = this.$root.profile.defaultPrimaryColor;
|
||||||
this.setPrimaryColor();
|
this.setPrimaryColor();
|
||||||
},
|
},
|
||||||
// 修改面板视图背景
|
// 修改面板视图背景
|
||||||
changeBackground(reset = false) {
|
changeBackground(reset = false) {
|
||||||
this.$profile.backgroundImg = reset ? null : this.selectFile.path;
|
this.$root.profile.backgroundImg = reset ? null : this.selectFile.path;
|
||||||
this.configurationPage.$forceUpdate();
|
this.configurationPage.$forceUpdate();
|
||||||
},
|
},
|
||||||
// 取消收藏
|
// 取消收藏
|
||||||
unMarkTag() {
|
unMarkTag() {
|
||||||
this.$utools.whole.removeFeature(
|
this.$root.utools.whole.removeFeature(
|
||||||
`panel_${window.hexEncode(this.currentTag)}`
|
`panel_${window.hexEncode(this.currentTag)}`
|
||||||
);
|
);
|
||||||
_.pull(this.$root.$refs.view.activatedQuickPanels, this.currentTag);
|
_.pull(this.$root.$refs.view.activatedQuickPanels, this.currentTag);
|
||||||
@ -413,8 +412,8 @@ export default {
|
|||||||
},
|
},
|
||||||
// 实用功能
|
// 实用功能
|
||||||
toggleFeature(type) {
|
toggleFeature(type) {
|
||||||
this.$utools.whole.removeFeature(this.features[type].code) ||
|
this.$root.utools.whole.removeFeature(this.features[type].code) ||
|
||||||
this.$utools.whole.setFeature(_.cloneDeep(this.features[type]));
|
this.$root.utools.whole.setFeature(_.cloneDeep(this.features[type]));
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -54,7 +54,7 @@
|
|||||||
flat
|
flat
|
||||||
color="negative"
|
color="negative"
|
||||||
icon="alarm_off"
|
icon="alarm_off"
|
||||||
v-if="cronStatus"
|
v-if="!!cronExp"
|
||||||
@click="delCrontab"
|
@click="delCrontab"
|
||||||
label="禁用"
|
label="禁用"
|
||||||
/>
|
/>
|
||||||
@ -71,22 +71,24 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import Cron from "croner";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
cronDetail: {
|
default: {
|
||||||
min: { label: "分钟", value: "" },
|
min: { label: "分钟", value: "" },
|
||||||
hour: { label: "小时", value: "" },
|
hour: { label: "小时", value: "" },
|
||||||
day: { label: "天", value: "*" },
|
day: { label: "天", value: "*" },
|
||||||
month: { label: "月", value: "*" },
|
month: { label: "月", value: "*" },
|
||||||
week: { label: "星期", value: "*" },
|
week: { label: "星期", value: "*" },
|
||||||
},
|
},
|
||||||
|
cronDetail: {},
|
||||||
intervalId: null,
|
intervalId: null,
|
||||||
nextLeftTime: null,
|
nextLeftTime: null,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
cronStatus: Boolean,
|
|
||||||
cronExp: String,
|
cronExp: String,
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@ -97,7 +99,7 @@ export default {
|
|||||||
},
|
},
|
||||||
cronJob() {
|
cronJob() {
|
||||||
try {
|
try {
|
||||||
return this.$Cron(this.cronConverted);
|
return Cron(this.cronConverted);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -127,6 +129,7 @@ export default {
|
|||||||
window.showHelpPage("#Q0e7s");
|
window.showHelpPage("#Q0e7s");
|
||||||
},
|
},
|
||||||
initValue() {
|
initValue() {
|
||||||
|
this.cronDetail = _.cloneDeep(this.default);
|
||||||
if (!this.cronExp) return;
|
if (!this.cronExp) return;
|
||||||
let splited = this.cronExp.split(" ");
|
let splited = this.cronExp.split(" ");
|
||||||
Object.keys(this.cronDetail).forEach((key, index) => {
|
Object.keys(this.cronDetail).forEach((key, index) => {
|
||||||
@ -146,6 +149,7 @@ export default {
|
|||||||
},
|
},
|
||||||
delCrontab() {
|
delCrontab() {
|
||||||
this.$emit("delCrontab");
|
this.$emit("delCrontab");
|
||||||
|
this.cronDetail = _.cloneDeep(this.default);
|
||||||
quickcommand.showMessageBox("禁用成功");
|
quickcommand.showMessageBox("禁用成功");
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -71,7 +71,7 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
markTag() {
|
markTag() {
|
||||||
this.$utools.whole.setFeature(_.cloneDeep(this.features));
|
this.$root.utools.whole.setFeature(_.cloneDeep(this.features));
|
||||||
this.$root.$refs.view.activatedQuickPanels.push(this.currentTag);
|
this.$root.$refs.view.activatedQuickPanels.push(this.currentTag);
|
||||||
quickcommand.showMessageBox(
|
quickcommand.showMessageBox(
|
||||||
`主输入框输入『${this.features.cmds.join("、")}』即可直接进入『${
|
`主输入框输入『${this.features.cmds.join("、")}』即可直接进入『${
|
||||||
|
@ -6,8 +6,8 @@
|
|||||||
ref="editor"
|
ref="editor"
|
||||||
@typing="
|
@typing="
|
||||||
(val) => {
|
(val) => {
|
||||||
if ($profile.quickFeatures.apiServer.cmd !== val) {
|
if ($root.profile.quickFeatures.apiServer.cmd !== val) {
|
||||||
$profile.quickFeatures.apiServer.cmd = val;
|
$root.profile.quickFeatures.apiServer.cmd = val;
|
||||||
}
|
}
|
||||||
restartServer();
|
restartServer();
|
||||||
}
|
}
|
||||||
@ -33,7 +33,7 @@
|
|||||||
<q-badge color="primary" dense square>POST</q-badge
|
<q-badge color="primary" dense square>POST</q-badge
|
||||||
><q-badge color="primary" dense square>GET</q-badge>
|
><q-badge color="primary" dense square>GET</q-badge>
|
||||||
<span>
|
<span>
|
||||||
http://127.0.0.1:{{ $profile.quickFeatures.apiServer.port }}
|
http://127.0.0.1:{{ $root.profile.quickFeatures.apiServer.port }}
|
||||||
</span>
|
</span>
|
||||||
<span>的参数,均会作为本脚本里的变量 </span>
|
<span>的参数,均会作为本脚本里的变量 </span>
|
||||||
</div>
|
</div>
|
||||||
@ -44,7 +44,9 @@
|
|||||||
flat
|
flat
|
||||||
color="negative"
|
color="negative"
|
||||||
icon="stop"
|
icon="stop"
|
||||||
v-if="serverStatus && !restartTimer"
|
v-if="
|
||||||
|
$root.profile.quickFeatures.apiServer.serverStatus && !restartTimer
|
||||||
|
"
|
||||||
@click="stopServer"
|
@click="stopServer"
|
||||||
label="停止服务"
|
label="停止服务"
|
||||||
/>
|
/>
|
||||||
@ -52,7 +54,9 @@
|
|||||||
flat
|
flat
|
||||||
color="warning"
|
color="warning"
|
||||||
icon="restart_alt"
|
icon="restart_alt"
|
||||||
v-else-if="serverStatus && !!restartTimer"
|
v-else-if="
|
||||||
|
$root.profile.quickFeatures.apiServer.serverStatus && !!restartTimer
|
||||||
|
"
|
||||||
@click="restartServer"
|
@click="restartServer"
|
||||||
label="正在重载"
|
label="正在重载"
|
||||||
/>
|
/>
|
||||||
@ -78,12 +82,13 @@ export default {
|
|||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
bottomHeight: 40,
|
bottomHeight: 40,
|
||||||
serverStatus: this.$profile.quickFeatures.apiServer.serverStatus,
|
|
||||||
restartTimer: null,
|
restartTimer: null,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.$refs.editor.setEditorValue(this.$profile.quickFeatures.apiServer.cmd);
|
this.$refs.editor.setEditorValue(
|
||||||
|
this.$root.profile.quickFeatures.apiServer.cmd
|
||||||
|
);
|
||||||
this.$refs.editor.setEditorLanguage("javascript");
|
this.$refs.editor.setEditorLanguage("javascript");
|
||||||
this.restartTimer = null;
|
this.restartTimer = null;
|
||||||
},
|
},
|
||||||
@ -96,33 +101,31 @@ export default {
|
|||||||
)
|
)
|
||||||
.then((ok) => {
|
.then((ok) => {
|
||||||
if (!ok) return;
|
if (!ok) return;
|
||||||
this.$profile.quickFeatures.apiServer.serverStatus =
|
this.$root.profile.quickFeatures.apiServer.serverStatus = true;
|
||||||
this.serverStatus = true;
|
|
||||||
window
|
window
|
||||||
.quickcommandHttpServer()
|
.quickcommandHttpServer()
|
||||||
.run(
|
.run(
|
||||||
this.$profile.quickFeatures.apiServer.cmd,
|
this.$root.profile.quickFeatures.apiServer.cmd,
|
||||||
this.$profile.quickFeatures.apiServer.port
|
this.$root.profile.quickFeatures.apiServer.port
|
||||||
);
|
);
|
||||||
quickcommand.showMessageBox("启动服务成功!");
|
quickcommand.showMessageBox("启动服务成功!");
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
stopServer() {
|
stopServer() {
|
||||||
window.quickcommandHttpServer().stop();
|
window.quickcommandHttpServer().stop();
|
||||||
this.$profile.quickFeatures.apiServer.serverStatus =
|
this.$root.profile.quickFeatures.apiServer.serverStatus = false;
|
||||||
this.serverStatus = false;
|
|
||||||
quickcommand.showMessageBox("关闭服务成功!");
|
quickcommand.showMessageBox("关闭服务成功!");
|
||||||
},
|
},
|
||||||
restartServer() {
|
restartServer() {
|
||||||
if (!this.serverStatus) return;
|
if (!this.$root.profile.quickFeatures.apiServer.serverStatus) return;
|
||||||
clearTimeout(this.restartTimer);
|
clearTimeout(this.restartTimer);
|
||||||
this.restartTimer = setTimeout(() => {
|
this.restartTimer = setTimeout(() => {
|
||||||
window.quickcommandHttpServer().stop();
|
window.quickcommandHttpServer().stop();
|
||||||
window
|
window
|
||||||
.quickcommandHttpServer()
|
.quickcommandHttpServer()
|
||||||
.run(
|
.run(
|
||||||
this.$profile.quickFeatures.apiServer.cmd,
|
this.$root.profile.quickFeatures.apiServer.cmd,
|
||||||
this.$profile.quickFeatures.apiServer.port
|
this.$root.profile.quickFeatures.apiServer.port
|
||||||
);
|
);
|
||||||
this.restartTimer = null;
|
this.restartTimer = null;
|
||||||
}, 1000);
|
}, 1000);
|
||||||
|
@ -21,7 +21,7 @@ export default {
|
|||||||
program: "quickcommand",
|
program: "quickcommand",
|
||||||
cmd: `open(\"${file.path.replace(/\\/g, "\\\\")}\")`,
|
cmd: `open(\"${file.path.replace(/\\/g, "\\\\")}\")`,
|
||||||
output: "ignore",
|
output: "ignore",
|
||||||
tags: [this.$profile.quickFeatures.favFile.tag],
|
tags: [this.$root.profile.quickFeatures.favFile.tag],
|
||||||
};
|
};
|
||||||
this.importCommand(command);
|
this.importCommand(command);
|
||||||
});
|
});
|
||||||
|
@ -47,7 +47,7 @@ export default {
|
|||||||
program: "quickcommand",
|
program: "quickcommand",
|
||||||
cmd: `visit(\"${url}\")\n`,
|
cmd: `visit(\"${url}\")\n`,
|
||||||
output: "ignore",
|
output: "ignore",
|
||||||
tags: [this.$profile.quickFeatures.favUrl.tag],
|
tags: [this.$root.profile.quickFeatures.favUrl.tag],
|
||||||
};
|
};
|
||||||
try {
|
try {
|
||||||
let res = await quickcommand.downloadFile(iconUrl, iconPath);
|
let res = await quickcommand.downloadFile(iconUrl, iconPath);
|
||||||
|
@ -127,7 +127,7 @@ export default {
|
|||||||
program: "quickcommand",
|
program: "quickcommand",
|
||||||
cmd: `utools.redirect("${this.feature.cmd}");utools.showMainWindow()`,
|
cmd: `utools.redirect("${this.feature.cmd}");utools.showMainWindow()`,
|
||||||
output: "ignore",
|
output: "ignore",
|
||||||
tags: [this.$profile.quickFeatures.pluNickName.tag],
|
tags: [this.$root.profile.quickFeatures.pluNickName.tag],
|
||||||
};
|
};
|
||||||
this.importCommand(command);
|
this.importCommand(command);
|
||||||
this.nickName = [];
|
this.nickName = [];
|
||||||
|
@ -23,7 +23,7 @@ export default {
|
|||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
currentCommand() {
|
currentCommand() {
|
||||||
return this.$utools.whole.db.get("qc_" + this.featureCode).data;
|
return this.$root.utools.whole.db.get("qc_" + this.featureCode).data;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
@ -40,8 +40,8 @@
|
|||||||
bottom: footerBarHeight,
|
bottom: footerBarHeight,
|
||||||
left: tabBarWidth,
|
left: tabBarWidth,
|
||||||
background:
|
background:
|
||||||
commandCardStyle === 'mini' && $profile.backgroundImg
|
commandCardStyle === 'mini' && $root.profile.backgroundImg
|
||||||
? 'url(file:///' + $profile.backgroundImg + ')'
|
? 'url(file:///' + $root.profile.backgroundImg + ')'
|
||||||
: 'none',
|
: 'none',
|
||||||
backgroundSize: 'cover',
|
backgroundSize: 'cover',
|
||||||
}"
|
}"
|
||||||
@ -118,7 +118,7 @@
|
|||||||
<!-- 切换视图 -->
|
<!-- 切换视图 -->
|
||||||
<q-btn-toggle
|
<q-btn-toggle
|
||||||
v-model="commandCardStyle"
|
v-model="commandCardStyle"
|
||||||
@click="$profile.commandCardStyle = commandCardStyle"
|
@click="$root.profile.commandCardStyle = commandCardStyle"
|
||||||
toggle-color="primary"
|
toggle-color="primary"
|
||||||
flat
|
flat
|
||||||
:options="[
|
:options="[
|
||||||
@ -227,7 +227,7 @@ export default {
|
|||||||
isCommandEditorShow: false,
|
isCommandEditorShow: false,
|
||||||
commandEditorAction: {},
|
commandEditorAction: {},
|
||||||
footerBarHeight: "40px",
|
footerBarHeight: "40px",
|
||||||
commandCardStyle: this.$profile.commandCardStyle,
|
commandCardStyle: this.$root.profile.commandCardStyle,
|
||||||
commandCardStyleSheet: {
|
commandCardStyleSheet: {
|
||||||
mini: {
|
mini: {
|
||||||
width: "20%",
|
width: "20%",
|
||||||
@ -334,7 +334,10 @@ export default {
|
|||||||
},
|
},
|
||||||
importDefaultCommands() {
|
importDefaultCommands() {
|
||||||
for (var code of Object.keys(defaultCommands)) {
|
for (var code of Object.keys(defaultCommands)) {
|
||||||
this.$utools.putDB(defaultCommands[code], this.$utools.DBPRE.QC + code);
|
this.$root.utools.putDB(
|
||||||
|
defaultCommands[code],
|
||||||
|
this.$root.utools.DBPRE.QC + code
|
||||||
|
);
|
||||||
}
|
}
|
||||||
Object.assign(this.allQuickCommands, defaultCommands);
|
Object.assign(this.allQuickCommands, defaultCommands);
|
||||||
},
|
},
|
||||||
@ -356,8 +359,8 @@ export default {
|
|||||||
// 获取所有的快捷命令(导出的格式)
|
// 获取所有的快捷命令(导出的格式)
|
||||||
getAllQuickCommands() {
|
getAllQuickCommands() {
|
||||||
let allQcs = {};
|
let allQcs = {};
|
||||||
this.$utools
|
this.$root.utools
|
||||||
.getDocs(this.$utools.DBPRE.QC)
|
.getDocs(this.$root.utools.DBPRE.QC)
|
||||||
.forEach((x) => (allQcs[x.data.features.code] = x.data));
|
.forEach((x) => (allQcs[x.data.features.code] = x.data));
|
||||||
return allQcs;
|
return allQcs;
|
||||||
},
|
},
|
||||||
@ -390,14 +393,14 @@ export default {
|
|||||||
},
|
},
|
||||||
// 启用命令
|
// 启用命令
|
||||||
enableCommand(code) {
|
enableCommand(code) {
|
||||||
this.$utools.whole.setFeature(
|
this.$root.utools.whole.setFeature(
|
||||||
_.cloneDeep(this.allQuickCommands[code].features)
|
_.cloneDeep(this.allQuickCommands[code].features)
|
||||||
);
|
);
|
||||||
this.activatedQuickCommandFeatureCodes.push(code);
|
this.activatedQuickCommandFeatureCodes.push(code);
|
||||||
},
|
},
|
||||||
// 禁用命令
|
// 禁用命令
|
||||||
disableCommand(code) {
|
disableCommand(code) {
|
||||||
this.$utools.whole.removeFeature(code);
|
this.$root.utools.whole.removeFeature(code);
|
||||||
this.activatedQuickCommandFeatureCodes =
|
this.activatedQuickCommandFeatureCodes =
|
||||||
this.activatedQuickCommandFeatureCodes.filter((x) => x !== code);
|
this.activatedQuickCommandFeatureCodes.filter((x) => x !== code);
|
||||||
},
|
},
|
||||||
@ -405,7 +408,7 @@ export default {
|
|||||||
removeCommand(code) {
|
removeCommand(code) {
|
||||||
utools.copyText(JSON.stringify(this.allQuickCommands[code], null, 4));
|
utools.copyText(JSON.stringify(this.allQuickCommands[code], null, 4));
|
||||||
delete this.allQuickCommands[code];
|
delete this.allQuickCommands[code];
|
||||||
this.$utools.delDB(this.$utools.DBPRE.QC + code);
|
this.$root.utools.delDB(this.$root.utools.DBPRE.QC + code);
|
||||||
this.disableCommand(code);
|
this.disableCommand(code);
|
||||||
if (!this.allQuickCommandTags.includes(this.currentTag))
|
if (!this.allQuickCommandTags.includes(this.currentTag))
|
||||||
this.currentTag = "默认";
|
this.currentTag = "默认";
|
||||||
@ -455,7 +458,10 @@ export default {
|
|||||||
dataToPushed = parsedData.qc;
|
dataToPushed = parsedData.qc;
|
||||||
}
|
}
|
||||||
for (var code of Object.keys(dataToPushed)) {
|
for (var code of Object.keys(dataToPushed)) {
|
||||||
this.$utools.putDB(dataToPushed[code], this.$utools.DBPRE.QC + code);
|
this.$root.utools.putDB(
|
||||||
|
dataToPushed[code],
|
||||||
|
this.$root.utools.DBPRE.QC + code
|
||||||
|
);
|
||||||
}
|
}
|
||||||
Object.assign(this.allQuickCommands, dataToPushed);
|
Object.assign(this.allQuickCommands, dataToPushed);
|
||||||
quickcommand.showMessageBox("导入成功!");
|
quickcommand.showMessageBox("导入成功!");
|
||||||
@ -512,10 +518,10 @@ export default {
|
|||||||
if (!isConfirmed)
|
if (!isConfirmed)
|
||||||
return quickcommand.showMessageBox("取消操作", "info");
|
return quickcommand.showMessageBox("取消操作", "info");
|
||||||
this.exportAllCommands(false);
|
this.exportAllCommands(false);
|
||||||
this.$utools
|
this.$root.utools
|
||||||
.getDocs(this.$utools.DBPRE.QC)
|
.getDocs(this.$root.utools.DBPRE.QC)
|
||||||
.map((x) => x._id)
|
.map((x) => x._id)
|
||||||
.forEach((y) => this.$utools.delDB(y));
|
.forEach((y) => this.$root.utools.delDB(y));
|
||||||
this.importDefaultCommands();
|
this.importDefaultCommands();
|
||||||
this.clearAllFeatures();
|
this.clearAllFeatures();
|
||||||
Object.keys(this.allQuickCommands).forEach((featureCode) => {
|
Object.keys(this.allQuickCommands).forEach((featureCode) => {
|
||||||
@ -531,7 +537,7 @@ export default {
|
|||||||
// 删除所有 features
|
// 删除所有 features
|
||||||
clearAllFeatures() {
|
clearAllFeatures() {
|
||||||
for (var feature of utools.getFeatures()) {
|
for (var feature of utools.getFeatures()) {
|
||||||
this.$utools.whole.removeFeature(feature.code);
|
this.$root.utools.whole.removeFeature(feature.code);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// 搜索
|
// 搜索
|
||||||
@ -563,8 +569,8 @@ export default {
|
|||||||
if (!this.activatedQuickCommandFeatureCodes.includes(code))
|
if (!this.activatedQuickCommandFeatureCodes.includes(code))
|
||||||
this.activatedQuickCommandFeatureCodes.push(code);
|
this.activatedQuickCommandFeatureCodes.push(code);
|
||||||
// 先删除再添加,强制刷新
|
// 先删除再添加,强制刷新
|
||||||
this.$utools.whole.removeFeature(code);
|
this.$root.utools.whole.removeFeature(code);
|
||||||
this.$utools.whole.setFeature(command.features);
|
this.$root.utools.whole.setFeature(command.features);
|
||||||
this.locateToCommand(command.tags, code);
|
this.locateToCommand(command.tags, code);
|
||||||
},
|
},
|
||||||
editorEvent(event) {
|
editorEvent(event) {
|
||||||
|
@ -186,7 +186,10 @@ export default {
|
|||||||
return quickcommand.showMessageBox("该命令格式有误!", "error");
|
return quickcommand.showMessageBox("该命令格式有误!", "error");
|
||||||
let pushData = _.cloneDeep(command);
|
let pushData = _.cloneDeep(command);
|
||||||
if (!pushData?.tags.includes("来自分享")) pushData.tags.push("来自分享");
|
if (!pushData?.tags.includes("来自分享")) pushData.tags.push("来自分享");
|
||||||
this.$utools.putDB(_.cloneDeep(pushData), this.$utools.DBPRE.QC + code);
|
this.$root.utools.putDB(
|
||||||
|
_.cloneDeep(pushData),
|
||||||
|
this.$root.utools.DBPRE.QC + code
|
||||||
|
);
|
||||||
quickcommand.showMessageBox("导入成功!可到「来自分享」标签查看");
|
quickcommand.showMessageBox("导入成功!可到「来自分享」标签查看");
|
||||||
},
|
},
|
||||||
updateSearch() {
|
updateSearch() {
|
||||||
|
@ -24,11 +24,11 @@ export default {
|
|||||||
methods: {
|
methods: {
|
||||||
importCommand(command) {
|
importCommand(command) {
|
||||||
command = _.cloneDeep(command);
|
command = _.cloneDeep(command);
|
||||||
this.$utools.putDB(
|
this.$root.utools.putDB(
|
||||||
command,
|
command,
|
||||||
this.$utools.DBPRE.QC + command.features.code
|
this.$root.utools.DBPRE.QC + command.features.code
|
||||||
);
|
);
|
||||||
this.$utools.whole.setFeature(command.features);
|
this.$root.utools.whole.setFeature(command.features);
|
||||||
},
|
},
|
||||||
getUid() {
|
getUid() {
|
||||||
return Number(
|
return Number(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user