添加声音设置选项,修复RPC超时不抛出异常的BUG

This commit is contained in:
fangxiang 2021-12-22 10:22:31 +08:00
parent 810f213bc2
commit 54742f2d8d
5 changed files with 205 additions and 150 deletions

View File

@ -52,7 +52,7 @@ export default class ClientConnection {
password?: string | null password?: string | null
) { ) {
this.reconnectTo(url, user_name, password); this.reconnectTo(url, user_name, password);
setTimeout(() => { setInterval(() => {
this.checkRpcTimeout(); this.checkRpcTimeout();
}, 1000); }, 1000);
} }
@ -102,6 +102,8 @@ export default class ClientConnection {
const current_datetime = new Date().getTime(); const current_datetime = new Date().getTime();
this.rpc_map.forEach((v, k, m) => { this.rpc_map.forEach((v, k, m) => {
if (current_datetime - v.send_timestamp > v.timeout_timestamp) { 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( public async setSystemNetwork(
request: Protocol.SetSystemNetworkRequestEntity request: Protocol.SetSystemNetworkRequestEntity
) { ) {
try { return await this.doRpc<Protocol.SetSystemNetworkResponseEntity>(request);
return await this.doRpc<Protocol.SetSystemNetworkResponseEntity>(request);
} catch (e) {
console.error(e);
}
} }
public async setSystemGraphics( public async setSystemGraphics(
request: Protocol.SetSystemGraphicsRequestEntity request: Protocol.SetSystemGraphicsRequestEntity
) { ) {
try { return await this.doRpc<Protocol.SetSystemGraphicsResponseEntity>(request);
return await this.doRpc<Protocol.SetSystemGraphicsResponseEntity>(
request
);
} catch (e) {
console.error(e);
}
} }
public async setSystemOther(request: Protocol.SetSystemOtherRequestEntity) { public async setSystemOther(request: Protocol.SetSystemOtherRequestEntity) {
try { return await this.doRpc<Protocol.SetSystemOtherResponseEntity>(request);
return await this.doRpc<Protocol.SetSystemOtherResponseEntity>(request);
} catch (e) {
console.error(e);
}
} }
public async getSupportResolutions() { public async getSupportResolutions() {
try { try {

View File

@ -293,110 +293,161 @@
<q-tab-panel name="other" class="_panel"> <q-tab-panel name="other" class="_panel">
<q-card class="fit"> <q-card class="fit">
<q-card-section> <q-scroll-area style="height: 55vh">
<q-form ref="other_form" @submit="applyOther"> <q-card-section>
<q-list> <q-form ref="other_form" @submit="applyOther">
<q-item> <q-list>
<q-item-section avatar class="width_5_3">{{ <q-item>
$t("use ntp") + ":" <q-item-section avatar class="width_5_3">{{
}}</q-item-section> $t("output audio card") + ":"
<q-item-section> }}</q-item-section>
<q-select <q-item-section>
v-model="use_ntp" <q-select
:loading="loading" v-model="output_audio_card"
:disable="loading" :loading="loading"
:options="[$t('enable'), $t('disable')]" :disable="loading"
/> :options="output_audio_card_options"
</q-item-section> emit-value
</q-item> map-options
<q-item v-if="use_ntp == $t('enable')"> />
<q-item-section avatar class="width_5_3">{{ </q-item-section>
$t("ntp server") + ":" </q-item>
}}</q-item-section> <q-item>
<q-item-section> <q-item-section avatar class="width_5_3">{{
<q-input $t("muted") + ":"
v-model="ntp_server" }}</q-item-section>
:loading="loading" <q-item-section>
:disable="loading" <q-select
:rules="[ v-model="system_muted"
(val) => :loading="loading"
(val && val.length > 0) || :disable="loading"
$t('Please type something'), :options="[$t('on'), $t('off')]"
]" />
lazy-rules </q-item-section>
/> </q-item>
</q-item-section> <q-item v-if="system_muted == $t('off')">
</q-item> <q-item-section avatar class="width_5_3">{{
<q-item v-if="use_ntp == $t('enable')"> $t("volume") + ":"
<q-item-section avatar class="width_5_3">{{ }}</q-item-section>
$t("ntp sync delay(S)") + ":" <q-item-section>
}}</q-item-section> <q-input
<q-item-section> v-model="system_volume"
<q-input :loading="loading"
v-model="ntp_sync_delay" :disable="loading"
:loading="loading" type="number"
:disable="loading" :rules="[
type="number" (val) =>
:rules="[ (val != null &&
(val) => val != undefined &&
(val != null && val.toString().length > 0) ||
val != undefined && $t('Please type something'),
val.toString().length > 0) || ]"
$t('Please type something'), lazy-rules
]" />
lazy-rules </q-item-section>
/> </q-item>
</q-item-section> <q-item>
</q-item> <q-item-section avatar class="width_5_3">{{
<q-item v-if="use_ntp == $t('disable')"> $t("use ntp") + ":"
<q-item-section avatar class="width_5_3">{{ }}</q-item-section>
$t("current datetime") + ":" <q-item-section>
}}</q-item-section> <q-select
<q-item-section> v-model="use_ntp"
<q-input :loading="loading"
v-model="current_date" :disable="loading"
:loading="loading" :options="[$t('enable'), $t('disable')]"
:disable="loading" />
type="date" </q-item-section>
:rules="[ </q-item>
(val) => <q-item v-if="use_ntp == $t('enable')">
(val && val.length > 0) || <q-item-section avatar class="width_5_3">{{
$t('Please type something'), $t("ntp server") + ":"
]" }}</q-item-section>
lazy-rules <q-item-section>
/> <q-input
</q-item-section> v-model="ntp_server"
<q-item-section> :loading="loading"
<q-input :disable="loading"
v-model="current_time" :rules="[
:loading="loading" (val) =>
:disable="loading" (val && val.length > 0) ||
type="time" $t('Please type something'),
:rules="[ ]"
(val) => lazy-rules
(val && val.length > 0) || />
$t('Please type something'), </q-item-section>
]" </q-item>
lazy-rules <q-item v-if="use_ntp == $t('enable')">
/> <q-item-section avatar class="width_5_3">{{
</q-item-section> $t("ntp sync delay(S)") + ":"
</q-item> }}</q-item-section>
<q-item> <q-item-section>
<q-item-section avatar class="width_5_3">{{ <q-input
$t("time zone") + ":" v-model="ntp_sync_delay"
}}</q-item-section> :loading="loading"
<q-item-section> :disable="loading"
<q-select type="number"
v-model="time_zone" :rules="[
:loading="loading" (val) =>
:disable="loading" (val != null &&
:options="time_zone_options" val != undefined &&
/> val.toString().length > 0) ||
</q-item-section> $t('Please type something'),
</q-item> ]"
</q-list> lazy-rules
</q-form> />
</q-card-section> </q-item-section>
</q-item>
<q-item v-if="use_ntp == $t('disable')">
<q-item-section avatar class="width_5_3">{{
$t("current datetime") + ":"
}}</q-item-section>
<q-item-section>
<q-input
v-model="current_date"
:loading="loading"
:disable="loading"
type="date"
:rules="[
(val) =>
(val && val.length > 0) ||
$t('Please type something'),
]"
lazy-rules
/>
</q-item-section>
<q-item-section>
<q-input
v-model="current_time"
:loading="loading"
:disable="loading"
type="time"
:rules="[
(val) =>
(val && val.length > 0) ||
$t('Please type something'),
]"
lazy-rules
/>
</q-item-section>
</q-item>
<q-item>
<q-item-section avatar class="width_5_3">{{
$t("time zone") + ":"
}}</q-item-section>
<q-item-section>
<q-select
v-model="time_zone"
:loading="loading"
:disable="loading"
:options="time_zone_options"
/>
</q-item-section>
</q-item>
</q-list>
</q-form>
</q-card-section>
</q-scroll-area>
</q-card> </q-card>
</q-tab-panel> </q-tab-panel>
@ -734,6 +785,13 @@ export default defineComponent({
let output_board_resolution = ref(""); let output_board_resolution = ref("");
let output_board_resolution_options = ref(["1", "2", "3"]); 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 use_ntp = ref($t.t("enable"));
let ntp_server = ref(""); let ntp_server = ref("");
let ntp_sync_delay = ref(180); let ntp_sync_delay = ref(180);
@ -836,6 +894,14 @@ export default defineComponent({
const refresh_other = () => { const refresh_other = () => {
const config = GlobalData.getInstance()?.applicationConfig; const config = GlobalData.getInstance()?.applicationConfig;
if (config) { 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 = use_ntp.value =
config.use_ntp != "0" ? $t.t("enable") : $t.t("disable"); config.use_ntp != "0" ? $t.t("enable") : $t.t("disable");
ntp_server.value = config.ntp_server; ntp_server.value = config.ntp_server;
@ -881,6 +947,7 @@ export default defineComponent({
}; };
const applyNetwork = async () => { const applyNetwork = async () => {
loading.value = true;
const request = new Protocol.SetSystemNetworkRequestEntity(); const request = new Protocol.SetSystemNetworkRequestEntity();
request.auto_ip = auto_ip.value == $t.t("enable"); request.auto_ip = auto_ip.value == $t.t("enable");
request.ip_address = ip_address.value; request.ip_address = ip_address.value;
@ -918,10 +985,12 @@ export default defineComponent({
(success ? $t.t("success") : $t.t("fail")) + (success ? $t.t("success") : $t.t("fail")) +
"!", "!",
position: "top", position: "top",
timeout: 1000, timeout: 2500,
}); });
loading.value = false;
}; };
const applyGraphics = async () => { const applyGraphics = async () => {
loading.value = true;
const request = new Protocol.SetSystemGraphicsRequestEntity(); const request = new Protocol.SetSystemGraphicsRequestEntity();
request.brightness = brightness.value; request.brightness = brightness.value;
request.contrast = contrast.value; request.contrast = contrast.value;
@ -945,7 +1014,7 @@ export default defineComponent({
(success ? $t.t("success") : $t.t("fail")) + (success ? $t.t("success") : $t.t("fail")) +
"!", "!",
position: "top", position: "top",
timeout: 1000, timeout: 2500,
}); });
if ( if (
old_resolution != device_resolution.value || old_resolution != device_resolution.value ||
@ -965,10 +1034,17 @@ export default defineComponent({
}); });
} catch {} } catch {}
} }
loading.value = false;
}; };
const applyOther = async () => { const applyOther = async () => {
loading.value = true;
const request = new Protocol.SetSystemOtherRequestEntity(); 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.use_ntp = use_ntp.value == $t.t("enable");
request.ntp_sync_delay = ntp_sync_delay.value; request.ntp_sync_delay = ntp_sync_delay.value;
request.ntp_server = ntp_server.value; request.ntp_server = ntp_server.value;
@ -996,11 +1072,13 @@ export default defineComponent({
(success ? $t.t("success") : $t.t("fail")) + (success ? $t.t("success") : $t.t("fail")) +
"!", "!",
position: "top", position: "top",
timeout: 1000, timeout: 2500,
}); });
loading.value = false;
}; };
const applyOutputBoard = async () => { const applyOutputBoard = async () => {
loading.value = true;
const request = new Protocol.SetOutputBoardSettingRequestEntity(); const request = new Protocol.SetOutputBoardSettingRequestEntity();
request.wall_col = output_board_wall_col.value; request.wall_col = output_board_wall_col.value;
request.wall_row = output_board_wall_row.value; request.wall_row = output_board_wall_row.value;
@ -1026,8 +1104,9 @@ export default defineComponent({
(success ? $t.t("success") : $t.t("fail")) + (success ? $t.t("success") : $t.t("fail")) +
"!", "!",
position: "top", position: "top",
timeout: 1000, timeout: 2500,
}); });
loading.value = false;
}; };
const apply = () => { const apply = () => {
@ -1047,30 +1126,6 @@ export default defineComponent({
break; 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 = () => { const restoreOutputBoard = () => {
GlobalData.getInstance().getCurrentClient()?.restoreOutputBoard(); GlobalData.getInstance().getCurrentClient()?.restoreOutputBoard();
}; };
@ -1093,6 +1148,10 @@ export default defineComponent({
device_resolution_options, device_resolution_options,
output_board_resolution, output_board_resolution,
output_board_resolution_options, output_board_resolution_options,
output_audio_card,
output_audio_card_options,
system_muted,
system_volume,
use_ntp, use_ntp,
ntp_server, ntp_server,
ntp_sync_delay, ntp_sync_delay,

View File

@ -22,4 +22,7 @@ export default class ApplicationConfigEntity {
graphics_contrast: number = 100; graphics_contrast: number = 100;
graphics_hue: number = 100; graphics_hue: number = 100;
device_rotate: number = 0; device_rotate: number = 0;
system_volume: number = 100;
system_muted: number = 0;
output_audio_card: string = "";
} }

View File

@ -1197,6 +1197,9 @@ export namespace Protocol {
} }
export class SetSystemOtherRequestEntity extends Protocol.PacketEntity { export class SetSystemOtherRequestEntity extends Protocol.PacketEntity {
system_muted: boolean = false;
system_volume: number = 100;
output_audio_card: string = "";
use_ntp: boolean = false; use_ntp: boolean = false;
ntp_server: string = "ntp.ntsc.ac.cn"; ntp_server: string = "ntp.ntsc.ac.cn";
ntp_sync_delay: number = 60; ntp_sync_delay: number = 60;

View File

@ -263,4 +263,6 @@ export default {
"set output board": "设置输出板", "set output board": "设置输出板",
"major graphics parameters have been changed and need to be restarted to take effect. Restart the system": "major graphics parameters have been changed and need to be restarted to take effect. Restart the system":
"重要图形参数已更改,需要重启后生效,是否重启", "重要图形参数已更改,需要重启后生效,是否重启",
"output audio card": "输出声卡",
muted: "静音",
}; };