fix: 无法修改网络配置表单值

This commit is contained in:
Caulic committed 2025-01-22 01:16:35 +08:00
1 parent 899dbdc37e
commit 02329b6c4c
6 files changed
+73 -71

No files matched your search

@@ -2,25 +2,25 @@
<div>
<t-form labelAlign="left">
<t-form-item label="启用">
<t-switch v-model="config.enable" />
<t-switch v-model="props.config.data.enable" />
</t-form-item>
<t-form-item label="URL">
<t-input v-model="config.url" />
<t-input v-model="props.config.data.url" />
</t-form-item>
<t-form-item label="消息格式">
<t-select v-model="config.messagePostFormat" :options="messageFormatOptions" />
<t-select v-model="props.config.data.messagePostFormat" :options="messageFormatOptions" />
</t-form-item>
<t-form-item label="报告自身消息">
<t-switch v-model="config.reportSelfMessage" />
<t-switch v-model="props.config.data.reportSelfMessage" />
</t-form-item>
<t-form-item label="Token">
<t-input v-model="config.token" />
<t-input v-model="props.config.data.token" />
</t-form-item>
<t-form-item label="调试模式">
<t-switch v-model="config.debug" />
<t-switch v-model="props.config.data.debug" />
</t-form-item>
<t-form-item label="心跳间隔">
<t-input v-model.number="config.heartInterval" type="number" />
<t-input v-model.number="props.config.data.heartInterval" type="number" />
</t-form-item>
</t-form>
</div>
@@ -39,14 +39,14 @@ const defaultConfig: WebsocketClientConfig = {
reconnectInterval: 5000,
token: '',
debug: false,
heartInterval: 30000
heartInterval: 30000,
};
const props = defineProps<{
config: WebsocketClientConfig;
config: { data: WebsocketClientConfig };
}>();
const config = ref(Object.assign({}, defaultConfig, props.config));
props.config.data = { ...defaultConfig, ...props.config.data };
const messageFormatOptions = ref([
{ label: 'Array', value: 'array' },
@@ -54,13 +54,13 @@ const messageFormatOptions = ref([
]);
watch(
() => config.value.messagePostFormat,
() => props.config.data.messagePostFormat,
(newValue) => {
if (newValue !== 'array' && newValue !== 'string') {
config.value.messagePostFormat = 'array';
props.config.data.messagePostFormat = 'array';
}
}
);
</script>
<style scoped></style>
<style scoped></style>