fix: 仪表盘的『插件配置』中不显示 JSON 编辑窗

该提交与 #1919 关联。

精准定位错误 @Pine-Ln,Fix from Gemini 2.5 Pro.

这个问题是由两个错误叠加造成的:

1. **组件崩溃**:`AstrBotConfig.vue` 混用了 Vue 3 的 `<script setup>` 和旧式 `<script>` 写法,导致作用域冲突,模板无法访问国际化函数 `t`,引发 `ReferenceError: t is not defined`。

2. **设置项不显示**:原代码根据用户已保存的设置数据来渲染字段,导致新增的设置项(如 `editor_mode`)因为用户配置中没有初始值而不显示。

1. **统一 API 写法**:将整个组件重构为纯 `<script setup>` 写法,解决作用域冲突。

2. **修正渲染逻辑**:将 `v-for` 循环改为遍历设置蓝图 (metadata) 而不是用户数据,确保所有定义的设置项都能显示。
This commit is contained in:
Magstic
2025-06-25 17:55:20 +08:00
committed by Soulter
parent d2dd07bad7
commit 80d2ad40bc
@@ -1,6 +1,25 @@
<script setup>
import { VueMonacoEditor } from '@guolao/vue-monaco-editor'
import { ref } from 'vue'
import ListConfigItem from './ListConfigItem.vue'
import { useI18n } from '@/i18n/composables'
defineProps({
metadata: {
type: Object,
required: true
},
iterable: {
type: Object,
required: true
},
metadataKey: {
type: String,
required: true
}
})
const { t } = useI18n()
const dialog = ref(false)
const currentEditingKey = ref('')
@@ -307,35 +326,7 @@ function saveEditedContent() {
</v-dialog>
</template>
<script>
import ListConfigItem from './ListConfigItem.vue';
import { useI18n } from '@/i18n/composables';
export default {
name: 'AstrBotConfig',
components: {
ListConfigItem
},
setup() {
const { t } = useI18n();
return { t };
},
props: {
metadata: {
type: Object,
required: true
},
iterable: {
type: Object,
required: true
},
metadataKey: {
type: String,
required: true
}
}
}
</script>
<style scoped>
.config-section {
@@ -464,4 +455,4 @@ export default {
padding: 4px;
}
}
</style>
</style>