更新 @kevisual/api 版本至 0.0.25,优化路由初始化失败时的错误处理逻辑

This commit is contained in:
2026-01-21 23:09:31 +08:00
parent aa2bf17791
commit a1460a97b4
2 changed files with 9 additions and 3 deletions

View File

@@ -18,8 +18,10 @@ export const initApi = async (opts: {
const query = item?.api?.query || new Query({ url: item?.api?.url || '/api/router' })
const res = await query.post<{ list: RouterItem[] }>({ path: "router", key: 'list', token: token });
if (res.code !== 200) {
console.error('初始化路由失败:', query.url, res.message);
return
return {
code: res.code,
message: `初始化路由失败: ${res.message}, url: ${query.url}`
}
}
let _list = res.data?.list || []
if (opts?.exclude) {
@@ -52,4 +54,8 @@ export const initApi = async (opts: {
}).addTo(router);
}
}
return {
code: 200,
message: '初始化路由成功'
}
}