mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-19 08:00:13 +01:00
🎨 Use Endpoint for network connectivity checks when syncing with third-party cloud providers https://github.com/siyuan-note/siyuan/issues/7805
This commit is contained in:
parent
05daece0d1
commit
c09c2a048f
1 changed files with 3 additions and 16 deletions
|
|
@ -945,23 +945,10 @@ powerMonitor.on("suspend", () => {
|
||||||
powerMonitor.on("resume", async () => {
|
powerMonitor.on("resume", async () => {
|
||||||
// 桌面端系统休眠唤醒后判断网络连通性后再执行数据同步 https://github.com/siyuan-note/siyuan/issues/6687
|
// 桌面端系统休眠唤醒后判断网络连通性后再执行数据同步 https://github.com/siyuan-note/siyuan/issues/6687
|
||||||
writeLog("system resume");
|
writeLog("system resume");
|
||||||
|
|
||||||
|
const eNet = require("electron").net
|
||||||
const isOnline = async () => {
|
const isOnline = async () => {
|
||||||
try {
|
return eNet.isOnline()
|
||||||
const result = await fetch("https://www.baidu.com", {timeout: 1000});
|
|
||||||
return 200 === result.status;
|
|
||||||
} catch (e) {
|
|
||||||
try {
|
|
||||||
const result = await fetch("https://icanhazip.com", {timeout: 1000});
|
|
||||||
return 200 === result.status;
|
|
||||||
} catch (e) {
|
|
||||||
try {
|
|
||||||
const result = await fetch("https://api.ipify.org", {timeout: 1000});
|
|
||||||
return 200 === result.status;
|
|
||||||
} catch (e) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
let online = false;
|
let online = false;
|
||||||
for (let i = 0; i < 7; i++) {
|
for (let i = 0; i < 7; i++) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue