merge(HEL-192): 集成问天解势修复到 .11 正式线(含 HEL-183 顶栏修复)
This commit is contained in:
@@ -1363,7 +1363,8 @@ async function interpretHeaven(mode) {
|
||||
} catch (error) {
|
||||
stopHeavenReadingAnimation();
|
||||
state.heavenReadingLoading = false;
|
||||
state.heavenReadingError = error.message || "问天解读失败";
|
||||
const detail = error?.payload?.message || error?.payload?.error || error.message;
|
||||
state.heavenReadingError = detail || "问天解读失败";
|
||||
renderHeavenReadingDialog();
|
||||
showHeavenNotice(state.heavenReadingError);
|
||||
showToast(state.heavenReadingError);
|
||||
|
||||
+19
-2
@@ -46,12 +46,29 @@
|
||||
}
|
||||
}
|
||||
|
||||
function readableRequestError(error) {
|
||||
const message = String(error?.message || "");
|
||||
if (
|
||||
error instanceof TypeError
|
||||
|| /failed to fetch|networkerror|load failed|network request failed/i.test(message)
|
||||
) {
|
||||
return "网络请求失败,服务暂时不可用,请稍后重试。";
|
||||
}
|
||||
return message || "请求失败";
|
||||
}
|
||||
|
||||
async function request(url, method = "GET", body = null, options = {}) {
|
||||
const response = await fetch(url, requestOptions(method, body, options.signal));
|
||||
let response;
|
||||
try {
|
||||
response = await fetch(url, requestOptions(method, body, options.signal));
|
||||
} catch (error) {
|
||||
throw new ApiError(readableRequestError(error), 0, null);
|
||||
}
|
||||
const payload = await parseJson(response);
|
||||
handleUnauthorized(response, url);
|
||||
if (!response.ok || payload.error) {
|
||||
throw new ApiError(payload.error || "请求失败", response.status, payload);
|
||||
const message = payload.message || payload.error || "请求失败";
|
||||
throw new ApiError(message, response.status, payload);
|
||||
}
|
||||
return payload;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user