重构数据同步功能,新增客户端模式

This commit is contained in:
lyswhut
2023-02-28 18:01:56 +08:00
parent b42092884e
commit 3b70acc3ca
43 changed files with 2232 additions and 1249 deletions
+53 -16
View File
@@ -32,25 +32,62 @@ export default () => {
immediate: true,
})
watch(() => appSetting['sync.mode'], (mode) => {
sync.mode = mode
})
watch(() => appSetting['sync.enable'], enable => {
void sendSyncAction({
action: 'enable',
data: {
enable,
port: appSetting['sync.port'],
},
})
switch (appSetting['sync.mode']) {
case 'server':
if (appSetting['sync.server.port']) {
void sendSyncAction({
action: 'enable_server',
data: {
enable: appSetting['sync.enable'],
port: appSetting['sync.server.port'],
},
})
}
break
case 'client':
if (appSetting['sync.client.host']) {
void sendSyncAction({
action: 'enable_client',
data: {
enable: appSetting['sync.enable'],
host: appSetting['sync.client.host'],
},
})
}
break
default:
break
}
sync.enable = enable
})
watch(() => appSetting['sync.port'], port => {
void sendSyncAction({
action: 'enable',
data: {
enable: appSetting['sync.enable'],
port: appSetting['sync.port'],
},
})
sync.port = port
watch(() => appSetting['sync.server.port'], port => {
if (appSetting['sync.mode'] == 'server') {
void sendSyncAction({
action: 'enable_server',
data: {
enable: appSetting['sync.enable'],
port: appSetting['sync.server.port'],
},
})
}
sync.server.port = port
})
watch(() => appSetting['sync.client.host'], host => {
if (appSetting['sync.mode'] == 'client') {
void sendSyncAction({
action: 'enable_client',
data: {
enable: appSetting['sync.enable'],
host: appSetting['sync.client.host'],
},
})
}
sync.client.host = host
})
watch(() => appSetting['network.proxy.enable'], enable => {