添加开发API允许局域网访问选项(#1828)

This commit is contained in:
lyswhut
2024-04-01 22:44:34 +08:00
parent 703327ed41
commit cd7d5ed665
10 changed files with 31 additions and 11 deletions
+11 -4
View File
@@ -5,12 +5,13 @@ import { openAPI } from '@renderer/store'
import { setAutoPause } from '@renderer/core/lyric'
export default () => {
const handleEnable = async(enable: boolean, port: string) => {
const handleEnable = async(enable: boolean, port: string, bindLan: boolean) => {
await sendOpenAPIAction({
action: 'enable',
data: {
enable,
port,
bindLan,
},
}).then((status) => {
openAPI.address = status.address
@@ -27,16 +28,22 @@ export default () => {
})
}
watch(() => appSetting['openAPI.enable'], enable => {
void handleEnable(enable, appSetting['openAPI.port'])
void handleEnable(enable, appSetting['openAPI.port'], appSetting['openAPI.bindLan'])
})
watch(() => appSetting['openAPI.port'], port => {
void handleEnable(appSetting['openAPI.enable'], port)
if (!appSetting['openAPI.enable']) return
void handleEnable(appSetting['openAPI.enable'], port, appSetting['openAPI.bindLan'])
})
watch(() => appSetting['openAPI.bindLan'], bindLan => {
if (!appSetting['openAPI.enable']) return
void handleEnable(appSetting['openAPI.enable'], appSetting['openAPI.port'], bindLan)
})
return async() => {
if (appSetting['openAPI.enable']) {
void handleEnable(true, appSetting['openAPI.port'])
void handleEnable(true, appSetting['openAPI.port'], appSetting['openAPI.bindLan'])
}
}
}