feat: 保存数据

This commit is contained in:
手瓜一十雪 2024-11-15 20:00:49 +08:00
parent cc93ed3567
commit 2d5b4bc90a

View File

@ -10,7 +10,7 @@
</template> </template>
<script setup> <script setup>
import { ref, shallowRef, onMounted } from 'vue'; import { ref, shallowRef, onMounted, watch } from 'vue';
import { defaultOnebotConfig, mergeOnebotConfigs } from '../../../src/onebot/config/config'; import { defaultOnebotConfig, mergeOnebotConfigs } from '../../../src/onebot/config/config';
import { QQLoginManager } from '../backend/shell'; import { QQLoginManager } from '../backend/shell';
import HttpServerComponent from './network/HttpServerComponent.vue'; import HttpServerComponent from './network/HttpServerComponent.vue';
@ -114,6 +114,23 @@ const removeTab = ({ value: val, index }) => {
} }
}; };
const syncConfig = async () => {
const networkConfig = {};
panelData.value.forEach(panel => {
const key = panel.value.split('-')[0];
if (!networkConfig[key]) {
networkConfig[key] = [];
}
networkConfig[key].push(panel.config);
});
const userConfig = await getOB11Config();
const mergedConfig = mergeOnebotConfigs(defaultOnebotConfig, userConfig);
mergedConfig.network = networkConfig;
await setOB11Config(mergedConfig);
};
watch(panelData, syncConfig, { deep: true });
onMounted(() => { onMounted(() => {
loadConfig(); loadConfig();
}); });