@leeguoo/pwtk-network-debugger 1.2.21 → 1.2.23
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/dist/index.cjs.js +3 -3
- package/dist/index.esm.js +30 -12
- package/dist/index.js +3 -3
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -7976,19 +7976,32 @@ async function createShareLink(requestData) {
|
|
|
7976
7976
|
decryptedResponse: requestData.decryptedResponse,
|
|
7977
7977
|
error: requestData.error,
|
|
7978
7978
|
creator: "PWTK Network Debugger by Leo (@leeguoo)",
|
|
7979
|
-
version: "1.2.
|
|
7979
|
+
version: "1.2.23"
|
|
7980
7980
|
}
|
|
7981
7981
|
};
|
|
7982
7982
|
const originalFetch = window.__originalFetch || window.fetch;
|
|
7983
|
-
const
|
|
7984
|
-
|
|
7985
|
-
|
|
7986
|
-
|
|
7987
|
-
|
|
7988
|
-
|
|
7989
|
-
|
|
7990
|
-
|
|
7991
|
-
|
|
7983
|
+
const apiUrl = "https://curl.bwg.leeguoo.com/api/share";
|
|
7984
|
+
logger.debug("使用分享API:", apiUrl);
|
|
7985
|
+
let response;
|
|
7986
|
+
try {
|
|
7987
|
+
response = await originalFetch(apiUrl, {
|
|
7988
|
+
method: "POST",
|
|
7989
|
+
headers: {
|
|
7990
|
+
"Content-Type": "application/json"
|
|
7991
|
+
},
|
|
7992
|
+
body: JSON.stringify({
|
|
7993
|
+
data: shareData
|
|
7994
|
+
})
|
|
7995
|
+
});
|
|
7996
|
+
} catch (fetchError) {
|
|
7997
|
+
if (fetchError.name === "TypeError" && fetchError.message.includes("fetch")) {
|
|
7998
|
+
throw new Error(`网络连接失败: 无法连接到分享服务器 (${apiUrl}). 可能原因: CORS策略限制或网络问题`);
|
|
7999
|
+
}
|
|
8000
|
+
throw fetchError;
|
|
8001
|
+
}
|
|
8002
|
+
if (!response.ok) {
|
|
8003
|
+
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
|
|
8004
|
+
}
|
|
7992
8005
|
const result = await response.json();
|
|
7993
8006
|
if (result.shareId) {
|
|
7994
8007
|
const shareUrl = `https://curl.bwg.leeguoo.com/share/${result.shareId}`;
|
|
@@ -7998,8 +8011,13 @@ async function createShareLink(requestData) {
|
|
|
7998
8011
|
throw new Error(result.error || "创建分享失败");
|
|
7999
8012
|
}
|
|
8000
8013
|
} catch (error) {
|
|
8001
|
-
|
|
8002
|
-
|
|
8014
|
+
const errorMessage = error.message || error.toString() || "未知错误";
|
|
8015
|
+
logger.error("NetworkDebugger: 创建分享链接失败:", {
|
|
8016
|
+
message: errorMessage,
|
|
8017
|
+
name: error.name,
|
|
8018
|
+
stack: error.stack?.split("\n")[0]
|
|
8019
|
+
});
|
|
8020
|
+
throw new Error(errorMessage);
|
|
8003
8021
|
}
|
|
8004
8022
|
}
|
|
8005
8023
|
async function copyToClipboard(text) {
|