From 54742f2d8d0b54296b62186776b72e6ea1c71398 Mon Sep 17 00:00:00 2001 From: fangxiang Date: Wed, 22 Dec 2021 10:22:31 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=A3=B0=E9=9F=B3=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE=E9=80=89=E9=A1=B9=EF=BC=8C=E4=BF=AE=E5=A4=8DRPC?= =?UTF-8?q?=E8=B6=85=E6=97=B6=E4=B8=8D=E6=8A=9B=E5=87=BA=E5=BC=82=E5=B8=B8?= =?UTF-8?q?=E7=9A=84BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/common/ClientConnection.ts | 24 +- src/components/SystemSettingDialog.vue | 323 ++++++++++++++---------- src/entities/ApplicationConfigEntity.ts | 3 + src/entities/WSProtocol.ts | 3 + src/i18n/zh-CN/index.ts | 2 + 5 files changed, 205 insertions(+), 150 deletions(-) diff --git a/src/common/ClientConnection.ts b/src/common/ClientConnection.ts index 0374058..c954573 100644 --- a/src/common/ClientConnection.ts +++ b/src/common/ClientConnection.ts @@ -52,7 +52,7 @@ export default class ClientConnection { password?: string | null ) { this.reconnectTo(url, user_name, password); - setTimeout(() => { + setInterval(() => { this.checkRpcTimeout(); }, 1000); } @@ -102,6 +102,8 @@ export default class ClientConnection { const current_datetime = new Date().getTime(); this.rpc_map.forEach((v, k, m) => { if (current_datetime - v.send_timestamp > v.timeout_timestamp) { + v.reject(); + m.delete(k); } }); } @@ -635,29 +637,15 @@ export default class ClientConnection { public async setSystemNetwork( request: Protocol.SetSystemNetworkRequestEntity ) { - try { - return await this.doRpc(request); - } catch (e) { - console.error(e); - } + return await this.doRpc(request); } public async setSystemGraphics( request: Protocol.SetSystemGraphicsRequestEntity ) { - try { - return await this.doRpc( - request - ); - } catch (e) { - console.error(e); - } + return await this.doRpc(request); } public async setSystemOther(request: Protocol.SetSystemOtherRequestEntity) { - try { - return await this.doRpc(request); - } catch (e) { - console.error(e); - } + return await this.doRpc(request); } public async getSupportResolutions() { try { diff --git a/src/components/SystemSettingDialog.vue b/src/components/SystemSettingDialog.vue index 8196f20..656093d 100644 --- a/src/components/SystemSettingDialog.vue +++ b/src/components/SystemSettingDialog.vue @@ -293,110 +293,161 @@ - - - - - {{ - $t("use ntp") + ":" - }} - - - - - - {{ - $t("ntp server") + ":" - }} - - - - - - {{ - $t("ntp sync delay(S)") + ":" - }} - - - - - - {{ - $t("current datetime") + ":" - }} - - - - - - - - - {{ - $t("time zone") + ":" - }} - - - - - - - + + + + + + {{ + $t("output audio card") + ":" + }} + + + + + + {{ + $t("muted") + ":" + }} + + + + + + {{ + $t("volume") + ":" + }} + + + + + + {{ + $t("use ntp") + ":" + }} + + + + + + {{ + $t("ntp server") + ":" + }} + + + + + + {{ + $t("ntp sync delay(S)") + ":" + }} + + + + + + {{ + $t("current datetime") + ":" + }} + + + + + + + + + {{ + $t("time zone") + ":" + }} + + + + + + + + @@ -734,6 +785,13 @@ export default defineComponent({ let output_board_resolution = ref(""); let output_board_resolution_options = ref(["1", "2", "3"]); + let system_muted = ref($t.t("off")); + let system_volume = ref(100); + let output_audio_card_options = ref([ + { label: "3.5mm", value: "3.5mm" }, + { label: "HDMI1", value: "HDMI1" }, + ]); + let output_audio_card = ref(output_audio_card_options.value[0].value); let use_ntp = ref($t.t("enable")); let ntp_server = ref(""); let ntp_sync_delay = ref(180); @@ -836,6 +894,14 @@ export default defineComponent({ const refresh_other = () => { const config = GlobalData.getInstance()?.applicationConfig; if (config) { + output_audio_card.value = config.output_audio_card; + let muted = parseInt(config.system_muted.toString()); + if (isNaN(muted)) { + muted = 0; + } + system_muted.value = muted ? $t.t("on") : $t.t("off"); + system_volume.value = config.system_volume; + use_ntp.value = config.use_ntp != "0" ? $t.t("enable") : $t.t("disable"); ntp_server.value = config.ntp_server; @@ -881,6 +947,7 @@ export default defineComponent({ }; const applyNetwork = async () => { + loading.value = true; const request = new Protocol.SetSystemNetworkRequestEntity(); request.auto_ip = auto_ip.value == $t.t("enable"); request.ip_address = ip_address.value; @@ -918,10 +985,12 @@ export default defineComponent({ (success ? $t.t("success") : $t.t("fail")) + "!", position: "top", - timeout: 1000, + timeout: 2500, }); + loading.value = false; }; const applyGraphics = async () => { + loading.value = true; const request = new Protocol.SetSystemGraphicsRequestEntity(); request.brightness = brightness.value; request.contrast = contrast.value; @@ -945,7 +1014,7 @@ export default defineComponent({ (success ? $t.t("success") : $t.t("fail")) + "!", position: "top", - timeout: 1000, + timeout: 2500, }); if ( old_resolution != device_resolution.value || @@ -965,10 +1034,17 @@ export default defineComponent({ }); } catch {} } + loading.value = false; }; const applyOther = async () => { + loading.value = true; + const request = new Protocol.SetSystemOtherRequestEntity(); + + request.system_volume = parseInt(system_volume.value.toString()); + request.system_muted = system_muted.value == $t.t("on"); + request.output_audio_card = output_audio_card.value; request.use_ntp = use_ntp.value == $t.t("enable"); request.ntp_sync_delay = ntp_sync_delay.value; request.ntp_server = ntp_server.value; @@ -996,11 +1072,13 @@ export default defineComponent({ (success ? $t.t("success") : $t.t("fail")) + "!", position: "top", - timeout: 1000, + timeout: 2500, }); + loading.value = false; }; const applyOutputBoard = async () => { + loading.value = true; const request = new Protocol.SetOutputBoardSettingRequestEntity(); request.wall_col = output_board_wall_col.value; request.wall_row = output_board_wall_row.value; @@ -1026,8 +1104,9 @@ export default defineComponent({ (success ? $t.t("success") : $t.t("fail")) + "!", position: "top", - timeout: 1000, + timeout: 2500, }); + loading.value = false; }; const apply = () => { @@ -1047,30 +1126,6 @@ export default defineComponent({ break; } }; - - const apply1 = async () => { - loading.value = true; - try { - switch (tab.value) { - case "network": - await applyNetwork(); - break; - case "graphics": - await applyGraphics(); - break; - case "other": - await applyOther(); - break; - case "output_board": - await applyOutputBoard(); - break; - } - } catch (e) { - console.log(e); - } - loading.value = false; - }; - const restoreOutputBoard = () => { GlobalData.getInstance().getCurrentClient()?.restoreOutputBoard(); }; @@ -1093,6 +1148,10 @@ export default defineComponent({ device_resolution_options, output_board_resolution, output_board_resolution_options, + output_audio_card, + output_audio_card_options, + system_muted, + system_volume, use_ntp, ntp_server, ntp_sync_delay, diff --git a/src/entities/ApplicationConfigEntity.ts b/src/entities/ApplicationConfigEntity.ts index de8c99f..d8ed095 100644 --- a/src/entities/ApplicationConfigEntity.ts +++ b/src/entities/ApplicationConfigEntity.ts @@ -22,4 +22,7 @@ export default class ApplicationConfigEntity { graphics_contrast: number = 100; graphics_hue: number = 100; device_rotate: number = 0; + system_volume: number = 100; + system_muted: number = 0; + output_audio_card: string = ""; } diff --git a/src/entities/WSProtocol.ts b/src/entities/WSProtocol.ts index df75541..86d75c1 100644 --- a/src/entities/WSProtocol.ts +++ b/src/entities/WSProtocol.ts @@ -1197,6 +1197,9 @@ export namespace Protocol { } export class SetSystemOtherRequestEntity extends Protocol.PacketEntity { + system_muted: boolean = false; + system_volume: number = 100; + output_audio_card: string = ""; use_ntp: boolean = false; ntp_server: string = "ntp.ntsc.ac.cn"; ntp_sync_delay: number = 60; diff --git a/src/i18n/zh-CN/index.ts b/src/i18n/zh-CN/index.ts index 45aa520..f9bce8a 100644 --- a/src/i18n/zh-CN/index.ts +++ b/src/i18n/zh-CN/index.ts @@ -263,4 +263,6 @@ export default { "set output board": "设置输出板", "major graphics parameters have been changed and need to be restarted to take effect. Restart the system": "重要图形参数已更改,需要重启后生效,是否重启", + "output audio card": "输出声卡", + muted: "静音", };