fix(wifi) wifi info never update
This commit is contained in:
parent
aaea2c50a7
commit
94d8061436
|
@ -80,7 +80,6 @@
|
||||||
|
|
||||||
|
|
||||||
<el-descriptions
|
<el-descriptions
|
||||||
:title="'Wi-Fi ' + translate('wifi.stationInfo')"
|
|
||||||
:column="1"
|
:column="1"
|
||||||
border
|
border
|
||||||
class="description-style"
|
class="description-style"
|
||||||
|
@ -90,7 +89,7 @@
|
||||||
<el-tag v-if="!isConnected" type="danger">{{ translate('wifi.disconnected') }}</el-tag>
|
<el-tag v-if="!isConnected" type="danger">{{ translate('wifi.disconnected') }}</el-tag>
|
||||||
</template>
|
</template>
|
||||||
<template #extra>
|
<template #extra>
|
||||||
<el-switch v-model="wifiSta_On" :disabled="wsStore.state != ControlEvent.CONNECTED || !wifiAp_On"
|
<el-switch v-model="wifiSta_On" :disabled="!isConnected || !wifiAp_On"
|
||||||
:active-text="translate('wifi.enabled')" :inactive-text="translate('wifi.disabled')" :loading="wifiMode_loading"
|
:active-text="translate('wifi.enabled')" :inactive-text="translate('wifi.disabled')" :loading="wifiMode_loading"
|
||||||
:before-change="()=>beforeWifiModeChange('STA')"
|
:before-change="()=>beforeWifiModeChange('STA')"
|
||||||
/>
|
/>
|
||||||
|
@ -102,7 +101,7 @@
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<template #default>
|
<template #default>
|
||||||
<p>{{ wifiStaApInfo.rssi }}</p>
|
<p> {{ wifi_rssi_to_percent(wifiStaApInfo.rssi) }} % ({{ wifiStaApInfo.rssi }} dBm)</p>
|
||||||
</template>
|
</template>
|
||||||
</el-descriptions-item>
|
</el-descriptions-item>
|
||||||
<el-descriptions-item span="4">
|
<el-descriptions-item span="4">
|
||||||
|
@ -174,7 +173,7 @@
|
||||||
{{ translate('wifi.IPmode') }}
|
{{ translate('wifi.IPmode') }}
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<el-select v-model="wifiStaticInfo.static_ip_en" :disabled="wsStore.state != ControlEvent.CONNECTED">
|
<el-select v-model="wifiStaticInfo.static_ip_en" :disabled="!isConnected">
|
||||||
<el-option
|
<el-option
|
||||||
v-for="item in staIPModeOptions"
|
v-for="item in staIPModeOptions"
|
||||||
:key="item.key"
|
:key="item.key"
|
||||||
|
@ -212,7 +211,7 @@
|
||||||
{{ translate('wifi.DNSmode') }}
|
{{ translate('wifi.DNSmode') }}
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<el-select v-model="wifiStaticInfo.static_dns_en" :disabled="wsStore.state != ControlEvent.CONNECTED">
|
<el-select v-model="wifiStaticInfo.static_dns_en" :disabled="!isConnected">
|
||||||
<el-option
|
<el-option
|
||||||
v-for="item in staDNSModeOptions"
|
v-for="item in staDNSModeOptions"
|
||||||
:key="item.key"
|
:key="item.key"
|
||||||
|
@ -245,7 +244,6 @@
|
||||||
<el-divider></el-divider>
|
<el-divider></el-divider>
|
||||||
|
|
||||||
<el-descriptions
|
<el-descriptions
|
||||||
:title="'Wi-Fi ' + translate('wifi.hotspotInfo')"
|
|
||||||
:column="1"
|
:column="1"
|
||||||
border
|
border
|
||||||
class="description-style"
|
class="description-style"
|
||||||
|
@ -255,7 +253,7 @@
|
||||||
<el-tag v-if="!isConnected" type="danger">{{ translate('wifi.disconnected') }}</el-tag>
|
<el-tag v-if="!isConnected" type="danger">{{ translate('wifi.disconnected') }}</el-tag>
|
||||||
</template>
|
</template>
|
||||||
<template #extra>
|
<template #extra>
|
||||||
<el-switch v-model="wifiAp_On" :disabled="wsStore.state != ControlEvent.CONNECTED || !wifiSta_On"
|
<el-switch v-model="wifiAp_On" :disabled="!isConnected || !wifiSta_On"
|
||||||
:loading="wifiMode_loading" :active-text="translate('wifi.enabled')" :inactive-text="translate('wifi.disabled')"
|
:loading="wifiMode_loading" :active-text="translate('wifi.enabled')" :inactive-text="translate('wifi.disabled')"
|
||||||
:before-change="()=>beforeWifiModeChange('AP')"
|
:before-change="()=>beforeWifiModeChange('AP')"
|
||||||
/>
|
/>
|
||||||
|
@ -386,21 +384,19 @@ let wifiModeOptions = computed( () => [
|
||||||
|
|
||||||
let wsStore = useWsStore();
|
let wsStore = useWsStore();
|
||||||
|
|
||||||
const defWifiInfo: ComputedRef<WifiInfo> = computed(() => {
|
const defWifiInfo: WifiInfo = {
|
||||||
return {
|
|
||||||
cmd: 1,
|
cmd: 1,
|
||||||
module: 1,
|
module: 1,
|
||||||
gateway: translate('wifi.disconnected'),
|
gateway: "-",
|
||||||
ip: translate('wifi.disconnected'),
|
ip: "-",
|
||||||
mac: translate('wifi.disconnected'),
|
mac: "-",
|
||||||
dns_main: translate('wifi.disconnected'),
|
dns_main: "-",
|
||||||
dns_backup: translate('wifi.disconnected'),
|
dns_backup: "-",
|
||||||
rssi: 0,
|
rssi: 0,
|
||||||
netmask: translate('wifi.disconnected'),
|
netmask: "-",
|
||||||
ssid: translate('wifi.disconnected'),
|
ssid: "-",
|
||||||
password: ""
|
password: "",
|
||||||
};
|
}
|
||||||
});
|
|
||||||
|
|
||||||
const staIPModeOptions = [
|
const staIPModeOptions = [
|
||||||
{
|
{
|
||||||
|
@ -422,8 +418,9 @@ const staDNSModeOptions = [
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
let wifiStaApInfo: ComputedRef<WifiInfo> = computed(() => defWifiInfo.value);
|
const isConnected = computed(() => wsStore.state === ControlEvent.CONNECTED)
|
||||||
let wifiApInfo: ComputedRef<WifiInfo> = computed(() => defWifiInfo.value);
|
let wifiStaApInfo = reactive<WifiInfo>({...defWifiInfo});
|
||||||
|
let wifiApInfo = reactive<WifiInfo>({...defWifiInfo});
|
||||||
let wifiStaticInfo = reactive<IWifiStaStaticInfo>({
|
let wifiStaticInfo = reactive<IWifiStaStaticInfo>({
|
||||||
dns_backup: "0.0.0.0",
|
dns_backup: "0.0.0.0",
|
||||||
dns_main: "0.0.0.0",
|
dns_main: "0.0.0.0",
|
||||||
|
@ -463,7 +460,7 @@ const onClientMsg = (msg: ApiJsonMsg) => {
|
||||||
}
|
}
|
||||||
if (connectBtnClicked) {
|
if (connectBtnClicked) {
|
||||||
connectBtnClicked = 0;
|
connectBtnClicked = 0;
|
||||||
globalNotifyRightSide(wifiStaApInfo.value.ssid + " " + translate('wifi.connectionSuccess'), "success");
|
globalNotifyRightSide(wifiStaApInfo.ssid + " " + translate('wifi.connectionSuccess'), "success");
|
||||||
wifi_sta_get_static_info();
|
wifi_sta_get_static_info();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -573,7 +570,7 @@ const onClientCtrl = (msg: ControlMsg) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
function onScanClick() {
|
function onScanClick() {
|
||||||
if (wsStore.state !== ControlEvent.CONNECTED) {
|
if (!isConnected.value) {
|
||||||
globalNotify(translate('wifi.debuggerNotConnected'), 'error');
|
globalNotify(translate('wifi.debuggerNotConnected'), 'error');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -582,7 +579,7 @@ function onScanClick() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function onConnectClick() {
|
function onConnectClick() {
|
||||||
if (wsStore.state !== ControlEvent.CONNECTED) {
|
if (!isConnected.value) {
|
||||||
globalNotify(translate('wifi.debuggerNotConnected'), 'error');
|
globalNotify(translate('wifi.debuggerNotConnected'), 'error');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -609,13 +606,24 @@ function wifiChangeMode() {
|
||||||
wifi_set_mode(wifiMode.value);
|
wifi_set_mode(wifiMode.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function wifi_rssi_to_percent(rssi: number)
|
||||||
|
{
|
||||||
|
if (rssi <= -100) {
|
||||||
|
return 0;
|
||||||
|
} else if (rssi >= -50) {
|
||||||
|
return 100;
|
||||||
|
} else {
|
||||||
|
return 2 * (rssi + 100);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function wifiApChangeCredential() {
|
function wifiApChangeCredential() {
|
||||||
if (wifiApInfo.value.ssid === "") {
|
if (wifiApInfo.ssid === "") {
|
||||||
globalNotifyRightSide(translate('wifi.enterAPName'), "error");
|
globalNotifyRightSide(translate('wifi.enterAPName'), "error");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
wifiMode_loading.value = true;
|
wifiMode_loading.value = true;
|
||||||
wifi_ap_set_credential(wifiApInfo.value.ssid, wifiApInfo.value.password);
|
wifi_ap_set_credential(wifiApInfo.ssid, wifiApInfo.password);
|
||||||
}
|
}
|
||||||
|
|
||||||
function wifiStaSetStaticInfo() {
|
function wifiStaSetStaticInfo() {
|
||||||
|
|
Loading…
Reference in New Issue