fix: 展示工作空间真实请求错误
This commit is contained in:
1 parent
aeb7eb7322
commit
4987689cb0
1 file changed
+13
-3
@@ -58,7 +58,11 @@ export function WorkspacePage() {
|
|||||||
});
|
});
|
||||||
if (query.isLoading) return <Card loading />;
|
if (query.isLoading) return <Card loading />;
|
||||||
if (query.isError || !query.data) {
|
if (query.isError || !query.data) {
|
||||||
const expired = query.error instanceof ApiClientError && query.error.status === 401;
|
const errorStatus =
|
||||||
|
query.error instanceof ApiClientError
|
||||||
|
? query.error.status
|
||||||
|
: (query.error as { status?: number } | null)?.status;
|
||||||
|
const expired = errorStatus === 401;
|
||||||
return (
|
return (
|
||||||
<Card
|
<Card
|
||||||
title={expired ? "登录状态已失效" : "工作空间加载失败"}
|
title={expired ? "登录状态已失效" : "工作空间加载失败"}
|
||||||
@@ -70,10 +74,16 @@ export function WorkspacePage() {
|
|||||||
>
|
>
|
||||||
重新登录
|
重新登录
|
||||||
</Button>
|
</Button>
|
||||||
) : undefined
|
) : (
|
||||||
|
<Button onClick={() => void query.refetch()}>重新请求</Button>
|
||||||
|
)
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
{expired ? "请重新登录后再访问工作空间。" : "请检查 API 服务后刷新重试。"}
|
{expired
|
||||||
|
? "请重新登录后再访问工作空间。"
|
||||||
|
: query.error instanceof Error
|
||||||
|
? query.error.message
|
||||||
|
: "请检查 API 服务后刷新重试。"}
|
||||||
</Card>
|
</Card>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user