mirror of
https://github.com/fofolee/uTools-quickcommand.git
synced 2025-08-08 13:29:32 +08:00
修改全局变量
This commit is contained in:
parent
0fc83c31de
commit
ec82130469
@ -26,8 +26,7 @@ module.exports = configure(function (ctx) {
|
|||||||
// --> 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
|
||||||
|
@ -12,10 +12,10 @@ export default defineComponent({
|
|||||||
},
|
},
|
||||||
computed: {},
|
computed: {},
|
||||||
created: function () {
|
created: function () {
|
||||||
this.pluginEnterEvent();
|
this.init();
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
pluginEnterEvent() {
|
init() {
|
||||||
// 版本检测
|
// 版本检测
|
||||||
const requiredVersion = "2.6.1";
|
const requiredVersion = "2.6.1";
|
||||||
let version = utools.getAppVersion();
|
let version = utools.getAppVersion();
|
||||||
|
10
src/boot/global.js
Normal file
10
src/boot/global.js
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
import { boot } from 'quasar/wrappers'
|
||||||
|
import UTOOLS from "../js/utools.js";
|
||||||
|
import programmings from '../js/programs.js';
|
||||||
|
|
||||||
|
// "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
|
||||||
|
})
|
@ -175,13 +175,11 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import allProgrammings from "../js/programs.js";
|
|
||||||
import UTOOLS from "../js/utools.js";
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
allProgrammings: allProgrammings,
|
allProgrammings: this.$programmings,
|
||||||
isCommandActivated: this.activated,
|
isCommandActivated: this.activated,
|
||||||
maxCmdStingLen: 8,
|
maxCmdStingLen: 8,
|
||||||
cmdBadgeSheet: {
|
cmdBadgeSheet: {
|
||||||
@ -266,8 +264,8 @@ export default {
|
|||||||
type: "disable",
|
type: "disable",
|
||||||
data: this.commandInfo.features.code,
|
data: this.commandInfo.features.code,
|
||||||
};
|
};
|
||||||
if (!UTOOLS.whole.removeFeature(this.commandInfo.features.code)) {
|
if (!this.$utools.whole.removeFeature(this.commandInfo.features.code)) {
|
||||||
UTOOLS.whole.setFeature(
|
this.$utools.whole.setFeature(
|
||||||
JSON.parse(JSON.stringify(this.commandInfo.features))
|
JSON.parse(JSON.stringify(this.commandInfo.features))
|
||||||
);
|
);
|
||||||
event.type = "enable";
|
event.type = "enable";
|
||||||
@ -280,8 +278,8 @@ export default {
|
|||||||
if (!x) return;
|
if (!x) return;
|
||||||
let code = this.commandInfo.features.code;
|
let code = this.commandInfo.features.code;
|
||||||
utools.copyText(JSON.stringify(this.commandInfo, null, 4));
|
utools.copyText(JSON.stringify(this.commandInfo, null, 4));
|
||||||
UTOOLS.delDB(UTOOLS.DBPRE.QC + code);
|
this.$utools.delDB(this.$utools.DBPRE.QC + code);
|
||||||
UTOOLS.whole.removeFeature(code);
|
this.$utools.whole.removeFeature(code);
|
||||||
this.isCommandAlive = false;
|
this.isCommandAlive = false;
|
||||||
this.$emit("commandChanged", {
|
this.$emit("commandChanged", {
|
||||||
type: "remove",
|
type: "remove",
|
||||||
|
@ -129,15 +129,13 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import allProgrammings from "../js/programs.js";
|
|
||||||
import MonocaEditor from "components/MonocaEditor";
|
import MonocaEditor from "components/MonocaEditor";
|
||||||
import UTOOLS from "../js/utools.js";
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: { MonocaEditor },
|
components: { MonocaEditor },
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
options: Object.keys(allProgrammings),
|
options: Object.keys(this.$programmings),
|
||||||
program: "quickcommand",
|
program: "quickcommand",
|
||||||
customOptions: { bin: "", argv: "", ext: "" },
|
customOptions: { bin: "", argv: "", ext: "" },
|
||||||
scptarg: "",
|
scptarg: "",
|
||||||
@ -165,7 +163,7 @@ export default {
|
|||||||
// 读取历史记录
|
// 读取历史记录
|
||||||
loadOrSaveHistory() {
|
loadOrSaveHistory() {
|
||||||
// 读取
|
// 读取
|
||||||
var history = UTOOLS.getDB(UTOOLS.DBPRE.CFG + "codeHistory");
|
var history = this.$utools.getDB(this.$utools.DBPRE.CFG + "codeHistory");
|
||||||
if (history.program) {
|
if (history.program) {
|
||||||
this.$refs.editor.setEditorValue(history.cmd);
|
this.$refs.editor.setEditorValue(history.cmd);
|
||||||
this.program = history.program;
|
this.program = history.program;
|
||||||
@ -184,7 +182,7 @@ export default {
|
|||||||
customOptions: JSON.parse(JSON.stringify(this.customOptions)),
|
customOptions: JSON.parse(JSON.stringify(this.customOptions)),
|
||||||
};
|
};
|
||||||
// 保存
|
// 保存
|
||||||
UTOOLS.putDB(saveData, UTOOLS.DBPRE.CFG + "codeHistory");
|
this.$utools.putDB(saveData, this.$utools.DBPRE.CFG + "codeHistory");
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
// 绑定快捷键
|
// 绑定快捷键
|
||||||
@ -197,7 +195,7 @@ export default {
|
|||||||
},
|
},
|
||||||
// 匹配编程语言
|
// 匹配编程语言
|
||||||
matchLanguage() {
|
matchLanguage() {
|
||||||
let language = Object.values(allProgrammings).filter(
|
let language = Object.values(this.$programmings).filter(
|
||||||
(program) => program.ext === this.customOptions.ext
|
(program) => program.ext === this.customOptions.ext
|
||||||
);
|
);
|
||||||
if (language.length) {
|
if (language.length) {
|
||||||
@ -206,7 +204,7 @@ export default {
|
|||||||
},
|
},
|
||||||
// 设置编程语言
|
// 设置编程语言
|
||||||
setLanguage(language) {
|
setLanguage(language) {
|
||||||
let highlight = allProgrammings[language].highlight;
|
let highlight = this.$programmings[language].highlight;
|
||||||
this.$refs.editor.setEditorLanguage(highlight ? highlight : language);
|
this.$refs.editor.setEditorLanguage(highlight ? highlight : language);
|
||||||
},
|
},
|
||||||
// 打开文档
|
// 打开文档
|
||||||
@ -255,7 +253,7 @@ export default {
|
|||||||
this.showRunResult(stdout, raw, true);
|
this.showRunResult(stdout, raw, true);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
let option = allProgrammings[this.program];
|
let option = this.$programmings[this.program];
|
||||||
if (this.program === "custom")
|
if (this.program === "custom")
|
||||||
option = {
|
option = {
|
||||||
bin: this.customOptions.bin,
|
bin: this.customOptions.bin,
|
||||||
|
@ -276,7 +276,6 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import UTOOLS from "../js/utools.js";
|
|
||||||
import quickcommandParser from "../js/quickcommandParser.js";
|
import quickcommandParser from "../js/quickcommandParser.js";
|
||||||
import CommandCard from "components/CommandCard";
|
import CommandCard from "components/CommandCard";
|
||||||
|
|
||||||
@ -365,7 +364,18 @@ export default {
|
|||||||
this.activatedQuickPanels = activatedFeatures.quickpanels;
|
this.activatedQuickPanels = activatedFeatures.quickpanels;
|
||||||
// 所有的快捷命令
|
// 所有的快捷命令
|
||||||
this.allQuickCommands = this.getAllQuickCommands();
|
this.allQuickCommands = this.getAllQuickCommands();
|
||||||
|
let userPreferences = this.$utools.getDB(
|
||||||
|
this.$utools.DBPRE.CFG + "preferences"
|
||||||
|
);
|
||||||
|
this.commandCardStyle = userPreferences.commandCardStyle || "normal";
|
||||||
console.log("ConfigurationPage", this);
|
console.log("ConfigurationPage", this);
|
||||||
|
utools.onPluginOut(() => {
|
||||||
|
userPreferences.commandCardStyle = this.commandCardStyle;
|
||||||
|
this.$utools.putDB(
|
||||||
|
userPreferences,
|
||||||
|
this.$utools.DBPRE.CFG + "preferences"
|
||||||
|
);
|
||||||
|
});
|
||||||
},
|
},
|
||||||
// 获取所有已启用的命令的 features 以及面板名称
|
// 获取所有已启用的命令的 features 以及面板名称
|
||||||
getActivatedFeatures() {
|
getActivatedFeatures() {
|
||||||
@ -385,9 +395,9 @@ export default {
|
|||||||
// 获取所有的快捷命令(导出的格式)
|
// 获取所有的快捷命令(导出的格式)
|
||||||
getAllQuickCommands() {
|
getAllQuickCommands() {
|
||||||
let allQcs = {};
|
let allQcs = {};
|
||||||
UTOOLS.getDocs(UTOOLS.DBPRE.QC).forEach(
|
this.$utools
|
||||||
(x) => (allQcs[x.data.features.code] = x.data)
|
.getDocs(this.$utools.DBPRE.QC)
|
||||||
);
|
.forEach((x) => (allQcs[x.data.features.code] = x.data));
|
||||||
return allQcs;
|
return allQcs;
|
||||||
},
|
},
|
||||||
// 监听命令变更时间
|
// 监听命令变更时间
|
||||||
@ -450,15 +460,18 @@ export default {
|
|||||||
};
|
};
|
||||||
// 单个命令导入
|
// 单个命令导入
|
||||||
if (dataToPushed.single) {
|
if (dataToPushed.single) {
|
||||||
UTOOLS.putDB(
|
this.$utools.putDB(
|
||||||
dataToPushed.qc,
|
dataToPushed.qc,
|
||||||
UTOOLS.DBPRE.QC + dataToPushed.qc.features.code
|
this.$utools.DBPRE.QC + dataToPushed.qc.features.code
|
||||||
);
|
);
|
||||||
this.allQuickCommands[dataToPushed.qc.features.code] = dataToPushed.qc;
|
this.allQuickCommands[dataToPushed.qc.features.code] = dataToPushed.qc;
|
||||||
// 多个命令导入
|
// 多个命令导入
|
||||||
} else {
|
} else {
|
||||||
for (var code of Object.keys(dataToPushed.qc)) {
|
for (var code of Object.keys(dataToPushed.qc)) {
|
||||||
UTOOLS.putDB(dataToPushed.qc[code], UTOOLS.DBPRE.QC + code);
|
this.$utools.putDB(
|
||||||
|
dataToPushed.qc[code],
|
||||||
|
this.$utools.DBPRE.QC + code
|
||||||
|
);
|
||||||
}
|
}
|
||||||
Object.assign(this.allQuickCommands, dataToPushed.qc);
|
Object.assign(this.allQuickCommands, dataToPushed.qc);
|
||||||
}
|
}
|
||||||
@ -512,9 +525,10 @@ export default {
|
|||||||
if (!isConfirmed)
|
if (!isConfirmed)
|
||||||
return quickcommand.showMessageBox("取消操作", "info");
|
return quickcommand.showMessageBox("取消操作", "info");
|
||||||
this.exportAllCommands(false);
|
this.exportAllCommands(false);
|
||||||
UTOOLS.getDocs(UTOOLS.DBPRE.QC)
|
this.$utools
|
||||||
|
.getDocs(this.$utools.DBPRE.QC)
|
||||||
.map((x) => x._id)
|
.map((x) => x._id)
|
||||||
.forEach((y) => UTOOLS.delDB(y));
|
.forEach((y) => this.$utools.delDB(y));
|
||||||
this.importDefaultCommands();
|
this.importDefaultCommands();
|
||||||
this.clearAllFeatures();
|
this.clearAllFeatures();
|
||||||
Object.keys(this.allQuickCommands).forEach((featureCode) => {
|
Object.keys(this.allQuickCommands).forEach((featureCode) => {
|
||||||
@ -529,7 +543,7 @@ export default {
|
|||||||
// 删除所有 features
|
// 删除所有 features
|
||||||
clearAllFeatures() {
|
clearAllFeatures() {
|
||||||
for (var feature of utools.getFeatures()) {
|
for (var feature of utools.getFeatures()) {
|
||||||
UTOOLS.whole.removeFeature(feature.code);
|
this.$utools.whole.removeFeature(feature.code);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// 导入默认命令
|
// 导入默认命令
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
import { route } from 'quasar/wrappers'
|
import { route } from 'quasar/wrappers'
|
||||||
import { createRouter, createMemoryHistory, createWebHistory, createWebHashHistory } from 'vue-router'
|
import { createRouter, createMemoryHistory, createWebHistory, createWebHashHistory } from 'vue-router'
|
||||||
import routes from './routes'
|
import routes from './routes'
|
||||||
import quickcommand from '../js/quickcommand'
|
import quickcommandUI from '../js/quickcommand'
|
||||||
|
|
||||||
window.quickcommand = quickcommand
|
Object.assign(window.quickcommand, quickcommandUI)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If not building with SSR mode, you can
|
* If not building with SSR mode, you can
|
||||||
|
Loading…
x
Reference in New Issue
Block a user