mirror of
https://github.com/fofolee/uTools-quickcommand.git
synced 2025-06-07 13:34:08 +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"
|
||||
// https://v2.quasar.dev/quasar-cli-webpack/boot-files
|
||||
boot: [
|
||||
|
||||
|
||||
'global.js'
|
||||
],
|
||||
|
||||
// https://v2.quasar.dev/quasar-cli-webpack/quasar-config-js#Property%3A-css
|
||||
|
@ -12,10 +12,10 @@ export default defineComponent({
|
||||
},
|
||||
computed: {},
|
||||
created: function () {
|
||||
this.pluginEnterEvent();
|
||||
this.init();
|
||||
},
|
||||
methods: {
|
||||
pluginEnterEvent() {
|
||||
init() {
|
||||
// 版本检测
|
||||
const requiredVersion = "2.6.1";
|
||||
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>
|
||||
|
||||
<script>
|
||||
import allProgrammings from "../js/programs.js";
|
||||
import UTOOLS from "../js/utools.js";
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
allProgrammings: allProgrammings,
|
||||
allProgrammings: this.$programmings,
|
||||
isCommandActivated: this.activated,
|
||||
maxCmdStingLen: 8,
|
||||
cmdBadgeSheet: {
|
||||
@ -266,8 +264,8 @@ export default {
|
||||
type: "disable",
|
||||
data: this.commandInfo.features.code,
|
||||
};
|
||||
if (!UTOOLS.whole.removeFeature(this.commandInfo.features.code)) {
|
||||
UTOOLS.whole.setFeature(
|
||||
if (!this.$utools.whole.removeFeature(this.commandInfo.features.code)) {
|
||||
this.$utools.whole.setFeature(
|
||||
JSON.parse(JSON.stringify(this.commandInfo.features))
|
||||
);
|
||||
event.type = "enable";
|
||||
@ -280,8 +278,8 @@ export default {
|
||||
if (!x) return;
|
||||
let code = this.commandInfo.features.code;
|
||||
utools.copyText(JSON.stringify(this.commandInfo, null, 4));
|
||||
UTOOLS.delDB(UTOOLS.DBPRE.QC + code);
|
||||
UTOOLS.whole.removeFeature(code);
|
||||
this.$utools.delDB(this.$utools.DBPRE.QC + code);
|
||||
this.$utools.whole.removeFeature(code);
|
||||
this.isCommandAlive = false;
|
||||
this.$emit("commandChanged", {
|
||||
type: "remove",
|
||||
|
@ -129,15 +129,13 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import allProgrammings from "../js/programs.js";
|
||||
import MonocaEditor from "components/MonocaEditor";
|
||||
import UTOOLS from "../js/utools.js";
|
||||
|
||||
export default {
|
||||
components: { MonocaEditor },
|
||||
data() {
|
||||
return {
|
||||
options: Object.keys(allProgrammings),
|
||||
options: Object.keys(this.$programmings),
|
||||
program: "quickcommand",
|
||||
customOptions: { bin: "", argv: "", ext: "" },
|
||||
scptarg: "",
|
||||
@ -165,7 +163,7 @@ export default {
|
||||
// 读取历史记录
|
||||
loadOrSaveHistory() {
|
||||
// 读取
|
||||
var history = UTOOLS.getDB(UTOOLS.DBPRE.CFG + "codeHistory");
|
||||
var history = this.$utools.getDB(this.$utools.DBPRE.CFG + "codeHistory");
|
||||
if (history.program) {
|
||||
this.$refs.editor.setEditorValue(history.cmd);
|
||||
this.program = history.program;
|
||||
@ -184,7 +182,7 @@ export default {
|
||||
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() {
|
||||
let language = Object.values(allProgrammings).filter(
|
||||
let language = Object.values(this.$programmings).filter(
|
||||
(program) => program.ext === this.customOptions.ext
|
||||
);
|
||||
if (language.length) {
|
||||
@ -206,7 +204,7 @@ export default {
|
||||
},
|
||||
// 设置编程语言
|
||||
setLanguage(language) {
|
||||
let highlight = allProgrammings[language].highlight;
|
||||
let highlight = this.$programmings[language].highlight;
|
||||
this.$refs.editor.setEditorLanguage(highlight ? highlight : language);
|
||||
},
|
||||
// 打开文档
|
||||
@ -255,7 +253,7 @@ export default {
|
||||
this.showRunResult(stdout, raw, true);
|
||||
});
|
||||
} else {
|
||||
let option = allProgrammings[this.program];
|
||||
let option = this.$programmings[this.program];
|
||||
if (this.program === "custom")
|
||||
option = {
|
||||
bin: this.customOptions.bin,
|
||||
|
@ -276,7 +276,6 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import UTOOLS from "../js/utools.js";
|
||||
import quickcommandParser from "../js/quickcommandParser.js";
|
||||
import CommandCard from "components/CommandCard";
|
||||
|
||||
@ -365,7 +364,18 @@ export default {
|
||||
this.activatedQuickPanels = activatedFeatures.quickpanels;
|
||||
// 所有的快捷命令
|
||||
this.allQuickCommands = this.getAllQuickCommands();
|
||||
let userPreferences = this.$utools.getDB(
|
||||
this.$utools.DBPRE.CFG + "preferences"
|
||||
);
|
||||
this.commandCardStyle = userPreferences.commandCardStyle || "normal";
|
||||
console.log("ConfigurationPage", this);
|
||||
utools.onPluginOut(() => {
|
||||
userPreferences.commandCardStyle = this.commandCardStyle;
|
||||
this.$utools.putDB(
|
||||
userPreferences,
|
||||
this.$utools.DBPRE.CFG + "preferences"
|
||||
);
|
||||
});
|
||||
},
|
||||
// 获取所有已启用的命令的 features 以及面板名称
|
||||
getActivatedFeatures() {
|
||||
@ -385,9 +395,9 @@ export default {
|
||||
// 获取所有的快捷命令(导出的格式)
|
||||
getAllQuickCommands() {
|
||||
let allQcs = {};
|
||||
UTOOLS.getDocs(UTOOLS.DBPRE.QC).forEach(
|
||||
(x) => (allQcs[x.data.features.code] = x.data)
|
||||
);
|
||||
this.$utools
|
||||
.getDocs(this.$utools.DBPRE.QC)
|
||||
.forEach((x) => (allQcs[x.data.features.code] = x.data));
|
||||
return allQcs;
|
||||
},
|
||||
// 监听命令变更时间
|
||||
@ -450,15 +460,18 @@ export default {
|
||||
};
|
||||
// 单个命令导入
|
||||
if (dataToPushed.single) {
|
||||
UTOOLS.putDB(
|
||||
this.$utools.putDB(
|
||||
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;
|
||||
// 多个命令导入
|
||||
} else {
|
||||
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);
|
||||
}
|
||||
@ -512,9 +525,10 @@ export default {
|
||||
if (!isConfirmed)
|
||||
return quickcommand.showMessageBox("取消操作", "info");
|
||||
this.exportAllCommands(false);
|
||||
UTOOLS.getDocs(UTOOLS.DBPRE.QC)
|
||||
this.$utools
|
||||
.getDocs(this.$utools.DBPRE.QC)
|
||||
.map((x) => x._id)
|
||||
.forEach((y) => UTOOLS.delDB(y));
|
||||
.forEach((y) => this.$utools.delDB(y));
|
||||
this.importDefaultCommands();
|
||||
this.clearAllFeatures();
|
||||
Object.keys(this.allQuickCommands).forEach((featureCode) => {
|
||||
@ -529,7 +543,7 @@ export default {
|
||||
// 删除所有 features
|
||||
clearAllFeatures() {
|
||||
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 { createRouter, createMemoryHistory, createWebHistory, createWebHashHistory } from 'vue-router'
|
||||
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
|
||||
|
Loading…
x
Reference in New Issue
Block a user