fix: 明确后台工作空间登录失效提示
This commit is contained in:
1 parent
02966cf65c
commit
aeb7eb7322
1 file changed
+21
-1
@@ -1,6 +1,7 @@
|
||||
import { Button, Card, Form, Input, Modal, Select, Space, Table, Tag, message } from "antd";
|
||||
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
import { createApiClient } from "../../lib/api.js";
|
||||
import { ApiClientError } from "@personal-brand/api-client";
|
||||
import type { BrandFieldDefinition, BrandModule } from "@personal-brand/api-client";
|
||||
import { useState } from "react";
|
||||
|
||||
@@ -56,7 +57,26 @@ export function WorkspacePage() {
|
||||
},
|
||||
});
|
||||
if (query.isLoading) return <Card loading />;
|
||||
if (query.isError || !query.data) return <Card>工作空间加载失败,请刷新重试。</Card>;
|
||||
if (query.isError || !query.data) {
|
||||
const expired = query.error instanceof ApiClientError && query.error.status === 401;
|
||||
return (
|
||||
<Card
|
||||
title={expired ? "登录状态已失效" : "工作空间加载失败"}
|
||||
extra={
|
||||
expired ? (
|
||||
<Button
|
||||
type="primary"
|
||||
onClick={() => window.dispatchEvent(new Event("admin-auth-expired"))}
|
||||
>
|
||||
重新登录
|
||||
</Button>
|
||||
) : undefined
|
||||
}
|
||||
>
|
||||
{expired ? "请重新登录后再访问工作空间。" : "请检查 API 服务后刷新重试。"}
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
const { modules, fields, installations } = query.data;
|
||||
return (
|
||||
<Space direction="vertical" size="large" style={{ width: "100%" }}>
|
||||
|
||||
Reference in new issue
Block a user