修改programs引用方式

This commit is contained in:
fofolee 2025-02-12 15:14:55 +08:00
parent 6e8a0c79e3
commit b4a14e2a9e
4 changed files with 18 additions and 8 deletions

View File

@ -171,7 +171,7 @@ export default {
let option = let option =
command.program === "custom" command.program === "custom"
? command.customOptions ? command.customOptions
: this.$root.programs[command.program]; : programs[command.program];
option.scptarg = command.scptarg || ""; option.scptarg = command.scptarg || "";
option.charset = command.charset || {}; option.charset = command.charset || {};
option.envPath = this.$root.nativeProfile.envPath.trim() || ""; option.envPath = this.$root.nativeProfile.envPath.trim() || "";

View File

@ -46,7 +46,7 @@
width="16px" width="16px"
/> />
<div>|</div> <div>|</div>
<q-img :src="$root.programs[commandInfo.program].icon" width="16px" /> <q-img :src="programs[commandInfo.program].icon" width="16px" />
<div class="text-subtitle2">{{ programName }}</div> <div class="text-subtitle2">{{ programName }}</div>
</div> </div>
</q-card-section> </q-card-section>
@ -55,6 +55,7 @@
<script> <script>
import CommandTypeTag from "../CommandTypeTag.vue"; import CommandTypeTag from "../CommandTypeTag.vue";
import platformTypes from "js/options/platformTypes.js"; import platformTypes from "js/options/platformTypes.js";
import programs from "js/options/programs.js";
export default { export default {
name: "DenseLayout", name: "DenseLayout",
@ -69,11 +70,12 @@ export default {
data() { data() {
return { return {
platformTypes, platformTypes,
programs,
}; };
}, },
computed: { computed: {
program() { program() {
return this.$root.programs[this.commandInfo.program]; return this.programs[this.commandInfo.program];
}, },
programName() { programName() {
return this.program.shortName ?? this.program.name; return this.program.shortName ?? this.program.name;

View File

@ -50,6 +50,7 @@
<script> <script>
import CommandTypeTag from "../CommandTypeTag.vue"; import CommandTypeTag from "../CommandTypeTag.vue";
import platformTypes from "js/options/platformTypes.js"; import platformTypes from "js/options/platformTypes.js";
import programs from "js/options/programs.js";
export default { export default {
name: "ListLayout", name: "ListLayout",
@ -64,11 +65,12 @@ export default {
data() { data() {
return { return {
platformTypes, platformTypes,
programs,
}; };
}, },
computed: { computed: {
program() { program() {
return this.$root.programs[this.commandInfo.program]; return this.programs[this.commandInfo.program];
}, },
}, },
}; };

View File

@ -17,13 +17,13 @@
> >
<template v-slot:append> <template v-slot:append>
<q-avatar size="lg" square> <q-avatar size="lg" square>
<img :src="$root.programs[modelValue.program].icon" /> <img :src="programs[modelValue.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="$root.programs[scope.opt].icon" /> <img width="32" :src="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" />
@ -162,6 +162,7 @@
</template> </template>
<script> <script>
import programs from "js/options/programs.js";
export default { export default {
name: "CommandLanguageBar", name: "CommandLanguageBar",
@ -190,9 +191,14 @@ export default {
"save", "save",
"show-composer", "show-composer",
], ],
data() {
return {
programs,
};
},
computed: { computed: {
programLanguages() { programLanguages() {
return Object.keys(this.$root.programs); return Object.keys(this.programs);
}, },
}, },
methods: { methods: {
@ -235,7 +241,7 @@ export default {
}, },
matchLanguage() { matchLanguage() {
if (!this.modelValue.customOptions.ext) return; if (!this.modelValue.customOptions.ext) return;
let language = Object.values(this.$root.programs).filter( let language = Object.values(this.programs).filter(
(program) => program.ext === this.modelValue.customOptions.ext (program) => program.ext === this.modelValue.customOptions.ext
); );
if (language.length) { if (language.length) {