Skip to content

Commit 1b0dbaa

Browse files
committed
feat: 增加恢复 Online 状态后重置数据方法
1 parent b6971fd commit 1b0dbaa

File tree

1 file changed

+9
-5
lines changed
  • src/BootstrapBlazor/wwwroot/modules

1 file changed

+9
-5
lines changed

src/BootstrapBlazor/wwwroot/modules/net.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,20 @@ export function init(id, options) {
1111
});
1212
}
1313

14+
const resetState = () => {
15+
const { downlink, effectiveType, rtt } = navigator.connection;
16+
invoke.invokeMethodAsync(onNetworkStateChangedCallback, {
17+
downlink, networkType: effectiveType, rTT: rtt
18+
});
19+
}
20+
1421
const onlineStateChanged = () => {
1522
if (Array.isArray(indicators)) {
1623
indicators.forEach(indicator => {
1724
const el = document.getElementById(indicator);
1825
if (el) {
1926
el.classList.remove('offline');
27+
resetState();
2028
}
2129
});
2230
}
@@ -40,11 +48,7 @@ export function init(id, options) {
4048
onlineStateChanged,
4149
offlineStateChanged
4250
});
43-
44-
const { downlink, effectiveType, rtt } = navigator.connection;
45-
invoke.invokeMethodAsync(onNetworkStateChangedCallback, {
46-
downlink, networkType: effectiveType, rTT: rtt
47-
});
51+
resetState();
4852
}
4953

5054
export async function dispose(id) {

0 commit comments

Comments
 (0)