desktop-pet-app 0.2.2 → 0.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/out/main/index.js +20 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -24,7 +24,7 @@ ELECTRON_MIRROR=https://npmmirror.com/mirrors/electron/ npm install --global ./d
|
|
|
24
24
|
desktop-pet
|
|
25
25
|
```
|
|
26
26
|
|
|
27
|
-
客户端默认连接 `
|
|
27
|
+
客户端默认连接 `https://deskpalai.com`,会自动推导 WebSocket、登录和更新接口。只有本地开发或私有部署时才需要设置 `DESKTOP_PET_HOST`。应用内更新仅接受 HTTPS 地址。
|
|
28
28
|
|
|
29
29
|
首次启动后,在宠物右键菜单中选择“登录账号”或“注册账号”。
|
|
30
30
|
|
package/out/main/index.js
CHANGED
|
@@ -1644,11 +1644,12 @@ async function fallbackChat(operationId) {
|
|
|
1644
1644
|
}
|
|
1645
1645
|
const REQUEST_TIMEOUT_MS = 6e3;
|
|
1646
1646
|
const DOWNLOAD_TIMEOUT_MS = 10 * 6e4;
|
|
1647
|
+
const LEGACY_OFFICIAL_HTTP_HOST = "47.94.20.104";
|
|
1647
1648
|
let status = { kind: "idle" };
|
|
1648
1649
|
function updateCheckURL() {
|
|
1649
1650
|
const override = process.env.DESKTOP_PET_UPDATE_API?.trim();
|
|
1650
1651
|
if (override) return validateUpdateAPIURL(override).toString();
|
|
1651
|
-
const relayURL =
|
|
1652
|
+
const relayURL = updateRelayURL();
|
|
1652
1653
|
const url = new URL(relayURL);
|
|
1653
1654
|
url.protocol = url.protocol === "wss:" ? "https:" : "http:";
|
|
1654
1655
|
url.pathname = "/api/updates/check";
|
|
@@ -1666,7 +1667,7 @@ async function checkForUpdates(currentVersion = electron.app.getVersion()) {
|
|
|
1666
1667
|
endpoint.searchParams.set("platform", process.platform);
|
|
1667
1668
|
endpoint.searchParams.set("arch", process.arch);
|
|
1668
1669
|
endpoint.searchParams.set("currentVersion", currentVersion);
|
|
1669
|
-
const response = await fetch(endpoint, {
|
|
1670
|
+
const response = await electron.net.fetch(endpoint.toString(), {
|
|
1670
1671
|
headers: updateCheckHeaders(endpoint),
|
|
1671
1672
|
signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS),
|
|
1672
1673
|
cache: "no-store"
|
|
@@ -1710,7 +1711,7 @@ async function downloadAvailableUpdate() {
|
|
|
1710
1711
|
const temporaryPath = `${artifactPath}.${node_crypto.randomUUID()}.download`;
|
|
1711
1712
|
try {
|
|
1712
1713
|
await promises.mkdir(updateDirectory, { recursive: true });
|
|
1713
|
-
const response = await fetch(available.releaseUrl, {
|
|
1714
|
+
const response = await electron.net.fetch(available.releaseUrl, {
|
|
1714
1715
|
headers: { accept: "application/octet-stream, application/wasm, */*" },
|
|
1715
1716
|
signal: AbortSignal.timeout(DOWNLOAD_TIMEOUT_MS),
|
|
1716
1717
|
cache: "no-store",
|
|
@@ -1854,6 +1855,19 @@ function storedRelayURL() {
|
|
|
1854
1855
|
return void 0;
|
|
1855
1856
|
}
|
|
1856
1857
|
}
|
|
1858
|
+
function updateRelayURL() {
|
|
1859
|
+
const stored = storedRelayURL();
|
|
1860
|
+
if (stored && !isLegacyOfficialHTTPURL(stored)) return stored;
|
|
1861
|
+
return configuredRelayURL();
|
|
1862
|
+
}
|
|
1863
|
+
function isLegacyOfficialHTTPURL(value) {
|
|
1864
|
+
try {
|
|
1865
|
+
const url = new URL(value);
|
|
1866
|
+
return url.protocol === "http:" && url.hostname === LEGACY_OFFICIAL_HTTP_HOST;
|
|
1867
|
+
} catch {
|
|
1868
|
+
return false;
|
|
1869
|
+
}
|
|
1870
|
+
}
|
|
1857
1871
|
function validateUpdateAPIURL(value) {
|
|
1858
1872
|
const url = new URL(value);
|
|
1859
1873
|
const local = url.hostname === "127.0.0.1" || url.hostname === "localhost" || url.hostname === "::1";
|
|
@@ -1912,6 +1926,9 @@ function compareVersions(a, b) {
|
|
|
1912
1926
|
}
|
|
1913
1927
|
function humanizeUpdateError(error) {
|
|
1914
1928
|
if (error instanceof DOMException && error.name === "TimeoutError") return "检查更新超时,请稍后重试";
|
|
1929
|
+
if (error instanceof TypeError && error.message === "fetch failed") {
|
|
1930
|
+
return "无法连接更新服务器,请检查网络或系统代理";
|
|
1931
|
+
}
|
|
1915
1932
|
if (error instanceof Error) return error.message;
|
|
1916
1933
|
return "暂时无法检查更新";
|
|
1917
1934
|
}
|