更改全局变量存储方式

This commit is contained in:
fofolee 2022-04-19 00:06:22 +08:00
parent a27fe4c338
commit ca01808c93
19 changed files with 209 additions and 180 deletions

View File

@ -214,22 +214,22 @@ if (process.platform !== 'linux') quickcommand.runInTerminal = function(cmdline,
}
let getCommandToLaunchTerminal = (cmdline, dir) => {
let cd = ''
if (utools.isWindows()) {
let appPath = path.join(utools.getPath('home'), '/AppData/Local/Microsoft/WindowsApps/')
// 直接 existsSync wt.exe 无效
if (fs.existsSync(appPath) && fs.readdirSync(appPath).includes('wt.exe')) {
cmdline = cmdline.replace(/"/g, `\\"`)
if (dir) cd = `-d "${dir.replace(/\\/g, '/')}"`
command = `${appPath}wt.exe ${cd} cmd /k "${cmdline}"`
let cd = ''
if (utools.isWindows()) {
let appPath = path.join(utools.getPath('home'), '/AppData/Local/Microsoft/WindowsApps/')
// 直接 existsSync wt.exe 无效
if (fs.existsSync(appPath) && fs.readdirSync(appPath).includes('wt.exe')) {
cmdline = cmdline.replace(/"/g, `\\"`)
if (dir) cd = `-d "${dir.replace(/\\/g, '/')}"`
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 {
cmdline = cmdline.replace(/"/g, `^"`)
if (dir) cd = `cd /d "${dir.replace(/\\/g, '/')}" &&`
command = `${cd} start "" cmd /k "${cmdline}"`
}
} else {
cmdline = cmdline.replace(/"/g, `\\"`)
if (dir) cd = `cd ${dir.replace(/ /g, `\\\\ `)} &&`
cmdline = cmdline.replace(/"/g, `\\"`)
if (dir) cd = `cd ${dir.replace(/ /g, `\\\\ `)} &&`
if (fs.existsSync('/Applications/iTerm.app')) {
command = `osascript -e 'tell application "iTerm"
create window with default profile
@ -453,7 +453,7 @@ let parseStdout = stdout => stdout.map(x => parseItem(x)).join("\n")
// 屏蔽危险函数
window.getuToolsLite = () => {
var utoolsLite = Object.assign({}, utools)
if (utools.isDev()) return utoolsLite
// if (utools.isDev()) return utoolsLite
// 数据库相关接口
delete utoolsLite.db
delete utoolsLite.dbStorage

View File

@ -28,9 +28,7 @@ module.exports = configure(function(ctx) {
// app boot file (/src/boot)
// --> boot files are part of "main.js"
// https://v2.quasar.dev/quasar-cli-webpack/boot-files
boot: [
'global.js'
],
boot: [],
// https://v2.quasar.dev/quasar-cli-webpack/quasar-config-js#Property%3A-css
css: [

View File

@ -7,12 +7,20 @@
<script>
import { defineComponent } from "vue";
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({
name: "App",
data() {
return {
setCssVar: setCssVar,
programs: programmings,
profile: defaultProfile,
utools: UTOOLS,
cronJobs: {},
};
},
computed: {},
@ -23,7 +31,16 @@ export default defineComponent({
init() {
window.root = this;
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";
let version = utools.getAppVersion();
if (version < requiredVersion) {
@ -31,67 +48,93 @@ export default defineComponent({
name: "needupdate",
params: { version: version, requiredVersion: requiredVersion },
});
return;
return false;
}
this.startUp();
//
utools.onPluginEnter((enter) => {
//
this.$q.dark.set(utools.isDarkColors());
//
quickcommand.enterData = enter;
quickcommand.payload = enter.payload;
this.$router.push(enter.code);
});
// 退
utools.onPluginOut(() => {
//
this.saveProfile();
//
this.$router.push("/");
//
window.temporaryStoreSoldOut();
return true;
},
startUp() {
//
let userProfile = this.utools.getDB(
this.utools.DBPRE.CFG + "preferences"
);
_.merge(defaultProfile, _.cloneDeep(userProfile));
//
_.forIn(this.profile.crontabs, (cronExp, featureCode) => {
this.runCronTask(featureCode, cronExp);
});
//
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() {
let commandEditor = this.$refs.view.$refs.commandEditor;
if (commandEditor && commandEditor.action.type !== "edit") {
let command = _.cloneDeep(commandEditor.quickcommandInfo);
command.cursorPosition = commandEditor.$refs.editor.getCursorPosition();
this.$profile.codeHistory[commandEditor.action.type] = command;
this.profile.codeHistory[commandEditor.action.type] = command;
}
this.$utools.putDB(
_.cloneDeep(this.$profile),
this.$utools.DBPRE.CFG + "preferences"
this.utools.putDB(
_.cloneDeep(this.profile),
this.utools.DBPRE.CFG + "preferences"
);
},
//
startUp() {
//
if (this.$profile.quickFeatures.apiServer.serverStatus) {
window
.quickcommandHttpServer()
.run(
this.$profile.quickFeatures.apiServer.cmd,
this.$profile.quickFeatures.apiServer.port
);
console.log("Server Start...");
runCronTask(featureCode, cronExp) {
this.cronJobs[featureCode] = Cron(cronExp, () => {
this.runCommandSilently(featureCode);
});
},
runCommandSilently(featureCode) {
let command = this.utools.getDB(this.utools.DBPRE.QC + featureCode);
if (command.program === "quickcommand") {
window.runCodeInSandbox(command.cmd, () => {});
} else {
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>
<style>
.q-tooltip {
font-size: 11px;
}
:root {
--q-dark: #464646;
--q-dark-page: #303133;
}
.q-tooltip {
font-size: 11px;
}
.q-chip {
background: #e3e3e39a;
}
.q-chip--dark {
background: #676666;
}
.commandLogo {
cursor: pointer;
transition: 0.2s;

View File

@ -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
})

View File

@ -36,8 +36,8 @@
dense
flat
round
color="blue-9"
icon="insights"
:color="!!cronExp ? 'amber' : 'blue-9'"
:icon="!!cronExp ? 'timer' : 'insights'"
>
<q-tooltip anchor="top middle" self="center middle">
设置
@ -79,9 +79,9 @@
<q-item-section side>
<q-icon name="timer" />
</q-item-section>
<q-item-section>添加定时任务</q-item-section>
<q-item-section>定时任务</q-item-section>
<q-tooltip
>定时执行当前命令仅匹配类型为关键字时可用</q-tooltip
>在后台定时执行当前命令仅匹配类型为关键字时可用且一律忽略输出</q-tooltip
>
</q-item>
</q-list>
@ -231,8 +231,7 @@
</div>
<q-dialog v-model="showCrontab">
<CrontabSetting
:cronStatus="$profile.crontabs[featureCode]?.status"
:cronExp="$profile.crontabs[featureCode]?.cronExp"
:cronExp="cronExp"
@addCrontab="addCrontab"
@delCrontab="delCrontab"
/>
@ -249,7 +248,7 @@ export default {
components: { CrontabSetting },
data() {
return {
allProgrammings: this.$programmings,
allProgrammings: this.$root.programs,
maxCmdStingLen: 8,
commandTypes: commandTypes,
platformTypes: platformTypes,
@ -314,6 +313,9 @@ export default {
featureCode() {
return this.commandInfo.features.code;
},
cronExp() {
return this.$root.profile.crontabs[this.featureCode];
},
},
props: {
commandInfo: Object,
@ -358,19 +360,12 @@ export default {
this.$emit("commandChanged", event);
},
addCrontab(cronExp) {
this.$profile.crontabs[this.featureCode] = {
cronStatus: true,
cronExp: cronExp,
};
this.cronJob = this.$Cron(cronExp, () => {
this.runCommand();
});
this.$root.profile.crontabs[this.featureCode] = cronExp;
this.$root.runCronTask(this.featureCode, cronExp);
},
delCrontab() {
this.$profile.crontabs[this.featureCode] = {
cronStatus: false,
};
this.cronJob.stop();
delete this.$root.profile.crontabs[this.featureCode];
this.$root.cronJobs[this.featureCode].stop();
},
// /
toggleCommandActivated() {

View File

@ -61,13 +61,13 @@
>
<template v-slot:append>
<q-avatar size="lg" square>
<img :src="$programmings[quickcommandInfo.program].icon" />
<img :src="$root.programs[quickcommandInfo.program].icon" />
</q-avatar>
</template>
<template v-slot:option="scope">
<q-item v-bind="scope.itemProps">
<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-label v-html="scope.opt" />
@ -166,7 +166,7 @@ export default {
components: { MonacoEditor, CommandSideBar, CommandRunResult },
data() {
return {
programLanguages: Object.keys(this.$programmings),
programLanguages: Object.keys(this.$root.programs),
sideBarWidth: 250,
languageBarHeight: 40,
canCommandSave: this.action.type === "code" ? false : true,
@ -214,7 +214,7 @@ export default {
init() {
let quickCommandInfo =
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]
: this.action.data;
quickCommandInfo?.program &&
@ -234,7 +234,7 @@ export default {
},
//
matchLanguage() {
let language = Object.values(this.$programmings).filter(
let language = Object.values(this.$root.programs).filter(
(program) => program.ext === this.quickcommandInfo.customOptions.ext
);
if (language.length) {
@ -243,7 +243,7 @@ export default {
},
//
setLanguage(language) {
let highlight = this.$programmings[language].highlight;
let highlight = this.$root.programs[language].highlight;
this.$refs.editor.setEditorLanguage(highlight ? highlight : language);
},
//
@ -330,9 +330,9 @@ export default {
if (!updatedData) return;
Object.assign(this.quickcommandInfo, _.cloneDeep(updatedData));
let newQuickcommandInfo = _.cloneDeep(this.quickcommandInfo);
this.$utools.putDB(
this.$root.utools.putDB(
newQuickcommandInfo,
this.$utools.DBPRE.QC + this.quickcommandInfo.features.code
this.$root.utools.DBPRE.QC + this.quickcommandInfo.features.code
);
this.$emit("editorEvent", {
type: "save",

View File

@ -106,9 +106,10 @@ export default {
!outPlugin && this.showRunResult(stdout, true, action);
});
} else {
let option = this.$programmings[currentCommand.program];
if (currentCommand.program === "custom")
option = currentCommand.customOptions;
let option =
currentCommand.program === "custom"
? currentCommand.customOptions
: this.$root.programs[currentCommand.program];
option.scptarg = currentCommand.scptarg;
option.charset = currentCommand.charset;
window.runCodeFile(

View File

@ -331,7 +331,8 @@ export default {
},
setIcon(language) {
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() {
let data = { type: "key", match: [] };

View File

@ -32,20 +32,20 @@
input-class="text-center"
style="width: 280px"
autofocus
v-model="quickFeatures.favFile.tag"
v-model="$root.profile.quickFeatures.favFile.tag"
type="text"
>
<template v-slot:append>
<q-toggle
@click="toggleFeature('favFile')"
v-model="quickFeatures.favFile.enable"
v-model="$root.profile.quickFeatures.favFile.enable"
checked-icon="check"
color="primary"
/>
</template>
<q-tooltip
>启用后选中文件可以通过超级面板快速将文件收藏到{{
quickFeatures.favFile.tag
$root.profile.quickFeatures.favFile.tag
}}标签
</q-tooltip>
</q-input>
@ -61,20 +61,20 @@
outlined
input-class="text-center"
style="width: 280px"
v-model="quickFeatures.favUrl.tag"
v-model="$root.profile.quickFeatures.favUrl.tag"
type="text"
>
<template v-slot:append>
<q-toggle
@click="toggleFeature('favUrl')"
v-model="quickFeatures.favUrl.enable"
v-model="$root.profile.quickFeatures.favUrl.enable"
checked-icon="check"
color="primary"
/>
</template>
<q-tooltip
>启用后在浏览器界面可以通过超级面板快速将网址收藏到{{
quickFeatures.favUrl.tag
$root.profile.quickFeatures.favUrl.tag
}}标签
</q-tooltip>
</q-input>
@ -91,13 +91,13 @@
input-class="text-center"
style="width: 280px"
autofocus
v-model="quickFeatures.pluNickName.tag"
v-model="$root.profile.quickFeatures.pluNickName.tag"
type="text"
>
<template v-slot:append>
<q-toggle
@click="toggleFeature('pluNickName')"
v-model="quickFeatures.pluNickName.enable"
v-model="$root.profile.quickFeatures.pluNickName.enable"
checked-icon="check"
color="primary"
/>
@ -105,7 +105,7 @@
<q-tooltip
>启用后在主输入框输入插件别名可以快速设置插件别名<br />
并将所有设置的别名保存至{{
quickFeatures.pluNickName.tag
$root.profile.quickFeatures.pluNickName.tag
}}标签
</q-tooltip>
</q-input>
@ -119,7 +119,7 @@
prefix="开启快捷命令服务"
suffix="端口"
outlined
v-model="quickFeatures.apiServer.port"
v-model="$root.profile.quickFeatures.apiServer.port"
input-class="text-center"
style="width: 280px"
type="text"
@ -127,7 +127,7 @@
<template v-slot:append>
<q-toggle
@click="toggleFeature('apiServer')"
v-model="quickFeatures.apiServer.enable"
v-model="$root.profile.quickFeatures.apiServer.enable"
checked-icon="check"
color="primary"
/>
@ -135,7 +135,7 @@
<q-tooltip
>启用后在主输入框输入快捷命令服务可以进入配置一个后台服务<br />
通过本地监听{{
quickFeatures.apiServer.port
$root.profile.quickFeatures.apiServer.port
}}端口的形式接收用户传送过来的参数然后根据参数执行不同的操作
<br />
本功能的意义在于 utools
@ -233,7 +233,7 @@
no-header
no-footer
@change="setPrimaryColor"
v-model="primaryColor"
v-model="$root.profile.primaryColor"
/>
<q-btn
color="primary"
@ -343,7 +343,6 @@ export default {
selectFile: ref(null),
showAbout: false,
showPanelConf: false,
quickFeatures: this.$profile.quickFeatures,
features: features,
};
},
@ -391,21 +390,21 @@ export default {
},
//
setPrimaryColor() {
this.setCssVar("primary", this.$profile.primaryColor);
this.setCssVar("primary", this.$root.profile.primaryColor);
},
//
resetPrimary() {
this.$profile.primaryColor = this.$profile.defaultPrimaryColor;
this.$root.profile.primaryColor = this.$root.profile.defaultPrimaryColor;
this.setPrimaryColor();
},
//
changeBackground(reset = false) {
this.$profile.backgroundImg = reset ? null : this.selectFile.path;
this.$root.profile.backgroundImg = reset ? null : this.selectFile.path;
this.configurationPage.$forceUpdate();
},
//
unMarkTag() {
this.$utools.whole.removeFeature(
this.$root.utools.whole.removeFeature(
`panel_${window.hexEncode(this.currentTag)}`
);
_.pull(this.$root.$refs.view.activatedQuickPanels, this.currentTag);
@ -413,8 +412,8 @@ export default {
},
//
toggleFeature(type) {
this.$utools.whole.removeFeature(this.features[type].code) ||
this.$utools.whole.setFeature(_.cloneDeep(this.features[type]));
this.$root.utools.whole.removeFeature(this.features[type].code) ||
this.$root.utools.whole.setFeature(_.cloneDeep(this.features[type]));
},
},
};

View File

@ -54,7 +54,7 @@
flat
color="negative"
icon="alarm_off"
v-if="cronStatus"
v-if="!!cronExp"
@click="delCrontab"
label="禁用"
/>
@ -71,22 +71,24 @@
</template>
<script>
import Cron from "croner";
export default {
data() {
return {
cronDetail: {
default: {
min: { label: "分钟", value: "" },
hour: { label: "小时", value: "" },
day: { label: "天", value: "*" },
month: { label: "月", value: "*" },
week: { label: "星期", value: "*" },
},
cronDetail: {},
intervalId: null,
nextLeftTime: null,
};
},
props: {
cronStatus: Boolean,
cronExp: String,
},
computed: {
@ -97,7 +99,7 @@ export default {
},
cronJob() {
try {
return this.$Cron(this.cronConverted);
return Cron(this.cronConverted);
} catch (error) {
return null;
}
@ -127,6 +129,7 @@ export default {
window.showHelpPage("#Q0e7s");
},
initValue() {
this.cronDetail = _.cloneDeep(this.default);
if (!this.cronExp) return;
let splited = this.cronExp.split(" ");
Object.keys(this.cronDetail).forEach((key, index) => {
@ -146,6 +149,7 @@ export default {
},
delCrontab() {
this.$emit("delCrontab");
this.cronDetail = _.cloneDeep(this.default);
quickcommand.showMessageBox("禁用成功");
},
},

View File

@ -71,7 +71,7 @@ export default {
},
methods: {
markTag() {
this.$utools.whole.setFeature(_.cloneDeep(this.features));
this.$root.utools.whole.setFeature(_.cloneDeep(this.features));
this.$root.$refs.view.activatedQuickPanels.push(this.currentTag);
quickcommand.showMessageBox(
`主输入框输入『${this.features.cmds.join("、")}』即可直接进入『${

View File

@ -6,8 +6,8 @@
ref="editor"
@typing="
(val) => {
if ($profile.quickFeatures.apiServer.cmd !== val) {
$profile.quickFeatures.apiServer.cmd = val;
if ($root.profile.quickFeatures.apiServer.cmd !== val) {
$root.profile.quickFeatures.apiServer.cmd = val;
}
restartServer();
}
@ -33,7 +33,7 @@
<q-badge color="primary" dense square>POST</q-badge
><q-badge color="primary" dense square>GET</q-badge>
<span>
http://127.0.0.1:{{ $profile.quickFeatures.apiServer.port }}
http://127.0.0.1:{{ $root.profile.quickFeatures.apiServer.port }}
</span>
<span>的参数均会作为本脚本里的变量 </span>
</div>
@ -44,7 +44,9 @@
flat
color="negative"
icon="stop"
v-if="serverStatus && !restartTimer"
v-if="
$root.profile.quickFeatures.apiServer.serverStatus && !restartTimer
"
@click="stopServer"
label="停止服务"
/>
@ -52,7 +54,9 @@
flat
color="warning"
icon="restart_alt"
v-else-if="serverStatus && !!restartTimer"
v-else-if="
$root.profile.quickFeatures.apiServer.serverStatus && !!restartTimer
"
@click="restartServer"
label="正在重载"
/>
@ -78,12 +82,13 @@ export default {
data() {
return {
bottomHeight: 40,
serverStatus: this.$profile.quickFeatures.apiServer.serverStatus,
restartTimer: null,
};
},
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.restartTimer = null;
},
@ -96,33 +101,31 @@ export default {
)
.then((ok) => {
if (!ok) return;
this.$profile.quickFeatures.apiServer.serverStatus =
this.serverStatus = true;
this.$root.profile.quickFeatures.apiServer.serverStatus = true;
window
.quickcommandHttpServer()
.run(
this.$profile.quickFeatures.apiServer.cmd,
this.$profile.quickFeatures.apiServer.port
this.$root.profile.quickFeatures.apiServer.cmd,
this.$root.profile.quickFeatures.apiServer.port
);
quickcommand.showMessageBox("启动服务成功!");
});
},
stopServer() {
window.quickcommandHttpServer().stop();
this.$profile.quickFeatures.apiServer.serverStatus =
this.serverStatus = false;
this.$root.profile.quickFeatures.apiServer.serverStatus = false;
quickcommand.showMessageBox("关闭服务成功!");
},
restartServer() {
if (!this.serverStatus) return;
if (!this.$root.profile.quickFeatures.apiServer.serverStatus) return;
clearTimeout(this.restartTimer);
this.restartTimer = setTimeout(() => {
window.quickcommandHttpServer().stop();
window
.quickcommandHttpServer()
.run(
this.$profile.quickFeatures.apiServer.cmd,
this.$profile.quickFeatures.apiServer.port
this.$root.profile.quickFeatures.apiServer.cmd,
this.$root.profile.quickFeatures.apiServer.port
);
this.restartTimer = null;
}, 1000);

View File

@ -21,7 +21,7 @@ export default {
program: "quickcommand",
cmd: `open(\"${file.path.replace(/\\/g, "\\\\")}\")`,
output: "ignore",
tags: [this.$profile.quickFeatures.favFile.tag],
tags: [this.$root.profile.quickFeatures.favFile.tag],
};
this.importCommand(command);
});

View File

@ -47,7 +47,7 @@ export default {
program: "quickcommand",
cmd: `visit(\"${url}\")\n`,
output: "ignore",
tags: [this.$profile.quickFeatures.favUrl.tag],
tags: [this.$root.profile.quickFeatures.favUrl.tag],
};
try {
let res = await quickcommand.downloadFile(iconUrl, iconPath);

View File

@ -127,7 +127,7 @@ export default {
program: "quickcommand",
cmd: `utools.redirect("${this.feature.cmd}");utools.showMainWindow()`,
output: "ignore",
tags: [this.$profile.quickFeatures.pluNickName.tag],
tags: [this.$root.profile.quickFeatures.pluNickName.tag],
};
this.importCommand(command);
this.nickName = [];

View File

@ -23,7 +23,7 @@ export default {
},
computed: {
currentCommand() {
return this.$utools.whole.db.get("qc_" + this.featureCode).data;
return this.$root.utools.whole.db.get("qc_" + this.featureCode).data;
},
},
methods: {

View File

@ -40,8 +40,8 @@
bottom: footerBarHeight,
left: tabBarWidth,
background:
commandCardStyle === 'mini' && $profile.backgroundImg
? 'url(file:///' + $profile.backgroundImg + ')'
commandCardStyle === 'mini' && $root.profile.backgroundImg
? 'url(file:///' + $root.profile.backgroundImg + ')'
: 'none',
backgroundSize: 'cover',
}"
@ -118,7 +118,7 @@
<!-- 切换视图 -->
<q-btn-toggle
v-model="commandCardStyle"
@click="$profile.commandCardStyle = commandCardStyle"
@click="$root.profile.commandCardStyle = commandCardStyle"
toggle-color="primary"
flat
:options="[
@ -227,7 +227,7 @@ export default {
isCommandEditorShow: false,
commandEditorAction: {},
footerBarHeight: "40px",
commandCardStyle: this.$profile.commandCardStyle,
commandCardStyle: this.$root.profile.commandCardStyle,
commandCardStyleSheet: {
mini: {
width: "20%",
@ -334,7 +334,10 @@ export default {
},
importDefaultCommands() {
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);
},
@ -356,8 +359,8 @@ export default {
//
getAllQuickCommands() {
let allQcs = {};
this.$utools
.getDocs(this.$utools.DBPRE.QC)
this.$root.utools
.getDocs(this.$root.utools.DBPRE.QC)
.forEach((x) => (allQcs[x.data.features.code] = x.data));
return allQcs;
},
@ -390,14 +393,14 @@ export default {
},
//
enableCommand(code) {
this.$utools.whole.setFeature(
this.$root.utools.whole.setFeature(
_.cloneDeep(this.allQuickCommands[code].features)
);
this.activatedQuickCommandFeatureCodes.push(code);
},
//
disableCommand(code) {
this.$utools.whole.removeFeature(code);
this.$root.utools.whole.removeFeature(code);
this.activatedQuickCommandFeatureCodes =
this.activatedQuickCommandFeatureCodes.filter((x) => x !== code);
},
@ -405,7 +408,7 @@ export default {
removeCommand(code) {
utools.copyText(JSON.stringify(this.allQuickCommands[code], null, 4));
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);
if (!this.allQuickCommandTags.includes(this.currentTag))
this.currentTag = "默认";
@ -455,7 +458,10 @@ export default {
dataToPushed = parsedData.qc;
}
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);
quickcommand.showMessageBox("导入成功!");
@ -512,10 +518,10 @@ export default {
if (!isConfirmed)
return quickcommand.showMessageBox("取消操作", "info");
this.exportAllCommands(false);
this.$utools
.getDocs(this.$utools.DBPRE.QC)
this.$root.utools
.getDocs(this.$root.utools.DBPRE.QC)
.map((x) => x._id)
.forEach((y) => this.$utools.delDB(y));
.forEach((y) => this.$root.utools.delDB(y));
this.importDefaultCommands();
this.clearAllFeatures();
Object.keys(this.allQuickCommands).forEach((featureCode) => {
@ -531,7 +537,7 @@ export default {
// features
clearAllFeatures() {
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))
this.activatedQuickCommandFeatureCodes.push(code);
//
this.$utools.whole.removeFeature(code);
this.$utools.whole.setFeature(command.features);
this.$root.utools.whole.removeFeature(code);
this.$root.utools.whole.setFeature(command.features);
this.locateToCommand(command.tags, code);
},
editorEvent(event) {

View File

@ -186,7 +186,10 @@ export default {
return quickcommand.showMessageBox("该命令格式有误!", "error");
let pushData = _.cloneDeep(command);
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("导入成功!可到「来自分享」标签查看");
},
updateSearch() {

View File

@ -24,11 +24,11 @@ export default {
methods: {
importCommand(command) {
command = _.cloneDeep(command);
this.$utools.putDB(
this.$root.utools.putDB(
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() {
return Number(