window.ConfigEditor = { setup() { const { ref, onMounted } = Vue; const api = useApi(); const configData = ref({}); const configLabels = ref({}); const loaded = ref(false); const saving = ref(false); async function load() { const json = await api.getConfig(); if (json) { configData.value = json.data; configLabels.value = json.labels || {}; loaded.value = true; } } async function save() { saving.value = true; const json = await api.saveConfig(configData.value); if (json) ElementPlus.ElMessage.success('配置已保存'); saving.value = false; } onMounted(load); return { configData, configLabels, loaded, saving, save }; }, template: `
加载中...
` };