debug: 排课 clazz API 失败时输出 [ClazzApi]/[ClazzQuery] 到 vConsole
Made-with: Cursor
This commit is contained in:
+32
-6
@@ -74,7 +74,7 @@ export default function useClazz() {
|
||||
async function query(start_from: string, end_by: string) {
|
||||
let {currentRole, current:{hty_id}} = usingUser.store;
|
||||
load_start()
|
||||
const {r, d, e} = await request({
|
||||
const {r, d, e, statusCode} = await request({
|
||||
url: "/api/v1/clazz/find_all_non_repeatable_within_date_range_by_hty_id",
|
||||
method: "GET", data: {start_from, end_by, hty_id}
|
||||
})
|
||||
@@ -91,6 +91,13 @@ export default function useClazz() {
|
||||
return false;
|
||||
});
|
||||
} else {
|
||||
console.warn("[ClazzQuery] non_repeatable failed", {
|
||||
e,
|
||||
statusCode,
|
||||
start_from,
|
||||
end_by,
|
||||
hty_id,
|
||||
});
|
||||
showFailToast(e);
|
||||
}
|
||||
return Promise.resolve(r);
|
||||
@@ -100,7 +107,7 @@ export default function useClazz() {
|
||||
load_start()
|
||||
|
||||
await Promise.all(hty_ids.map(async hty_id => {
|
||||
const {r, d, e} = await request({
|
||||
const {r, d, e, statusCode} = await request({
|
||||
url: "/api/v1/clazz/find_all_non_repeatable_within_date_range_by_hty_id",
|
||||
method: "GET", data: {start_from, end_by, hty_id}
|
||||
})
|
||||
@@ -111,7 +118,13 @@ export default function useClazz() {
|
||||
repeatList: []
|
||||
}
|
||||
} else {
|
||||
console.error("query failed...", e)
|
||||
console.warn("[ClazzQuery] subsidiary non_repeatable failed", {
|
||||
e,
|
||||
statusCode,
|
||||
hty_id,
|
||||
start_from,
|
||||
end_by,
|
||||
});
|
||||
}
|
||||
}));
|
||||
load_done()
|
||||
@@ -160,7 +173,7 @@ export default function useClazz() {
|
||||
async function query_repeats(start_from: string, end_by: string) {
|
||||
let {current:{hty_id}} = usingUser.store;
|
||||
load_start()
|
||||
const {r, d, e} = await request({
|
||||
const {r, d, e, statusCode} = await request({
|
||||
url: "/api/v1/clazz/find_all_repeatable_within_date_range_by_hty_id",
|
||||
method: "GET", data: {start_from, end_by, hty_id}
|
||||
})
|
||||
@@ -169,6 +182,13 @@ export default function useClazz() {
|
||||
const repeatList = normalizeClazzListPayload(d, "query_repeatable");
|
||||
store.repeatList = repeat_prepare(start_from, end_by, repeatList, store.list);
|
||||
} else {
|
||||
console.warn("[ClazzQuery] repeatable failed", {
|
||||
e,
|
||||
statusCode,
|
||||
start_from,
|
||||
end_by,
|
||||
hty_id,
|
||||
});
|
||||
showFailToast(e);
|
||||
}
|
||||
return Promise.resolve(r);
|
||||
@@ -178,7 +198,7 @@ export default function useClazz() {
|
||||
async function query_repeats_for_subsidiaries(start_from: string, end_by: string, hty_ids: string[]) {
|
||||
load_start()
|
||||
await Promise.all(hty_ids.map(async hty_id => {
|
||||
const {r, d, e} = await request({
|
||||
const {r, d, e, statusCode} = await request({
|
||||
url: "/api/v1/clazz/find_all_repeatable_within_date_range_by_hty_id",
|
||||
method: "GET", data: {start_from, end_by, hty_id}
|
||||
})
|
||||
@@ -187,7 +207,13 @@ export default function useClazz() {
|
||||
store.subsidiaryClazzByHtyId[hty_id] = store.subsidiaryClazzByHtyId[hty_id] || {list: [], repeatList: []}
|
||||
store.subsidiaryClazzByHtyId[hty_id].repeatList = repeat_prepare(start_from, end_by, repeatList, store.subsidiaryClazzByHtyId[hty_id].list);
|
||||
} else {
|
||||
console.error("query failed...", e)
|
||||
console.warn("[ClazzQuery] subsidiary repeatable failed", {
|
||||
e,
|
||||
statusCode,
|
||||
hty_id,
|
||||
start_from,
|
||||
end_by,
|
||||
});
|
||||
}
|
||||
}))
|
||||
load_done()
|
||||
|
||||
+28
-1
@@ -100,7 +100,7 @@ export default function request({url = '', method = 'get', data, params, ...rest
|
||||
}
|
||||
|
||||
return axiosInstance.request({url, method, data, params, ...rest}).then(response => {
|
||||
let {statusText, status, data: res, headers} = response;
|
||||
let {statusText, status, data: res, headers, config} = response;
|
||||
if (status === 401) {
|
||||
const isCozeRequest = url?.startsWith('/coze');
|
||||
const rawErr = (res && typeof res === 'object' && (res.e || (res.error && res.error.message))) || 'Login failed';
|
||||
@@ -161,6 +161,33 @@ export default function request({url = '', method = 'get', data, params, ...rest
|
||||
'接口返回了页面而非 JSON(请确认 Nginx 已将 /api/v1/clazz/ 反代到 htykc)';
|
||||
}
|
||||
|
||||
const finalUrl = (config && typeof config.url === 'string' ? config.url : '') || url || '';
|
||||
const isClazzApi =
|
||||
finalUrl.includes('/api/v1/clazz') ||
|
||||
(typeof url === 'string' && url.includes('/api/v1/clazz'));
|
||||
if (isClazzApi && (!resolved.r || status >= 400)) {
|
||||
let bodySnippet = '';
|
||||
if (typeof res === 'string') {
|
||||
bodySnippet = res.slice(0, 240);
|
||||
} else if (res && typeof res === 'object') {
|
||||
try {
|
||||
bodySnippet = JSON.stringify(res).slice(0, 500);
|
||||
} catch {
|
||||
bodySnippet = '[object]';
|
||||
}
|
||||
}
|
||||
console.warn('[ClazzApi]', {
|
||||
method: (config?.method || method || 'get').toUpperCase(),
|
||||
url: finalUrl,
|
||||
httpStatus: status,
|
||||
statusText,
|
||||
businessOk: resolved.r,
|
||||
toastOrErr: resolved.e,
|
||||
hty_err: resolved.hty_err,
|
||||
bodySnippet,
|
||||
});
|
||||
}
|
||||
|
||||
return Promise.resolve(resolved);
|
||||
})
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user