修改全局变量

This commit is contained in:
fofolee 2022-04-03 20:48:48 +08:00
parent 0fc83c31de
commit ec82130469
7 changed files with 50 additions and 31 deletions

View File

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

View File

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

View File

@ -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",

View File

@ -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,

View File

@ -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);
}
},
//

View File

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