diff --git a/src/pages/Article/index.tsx b/src/pages/Article/index.tsx index d461d14..63caff5 100644 --- a/src/pages/Article/index.tsx +++ b/src/pages/Article/index.tsx @@ -122,20 +122,26 @@ const Article: React.FC = () => { }, ]; + const titleSty = "border-stroke dark:border-strokedark [&>.ant-card-head]:border-stroke [&>.ant-card-head]:dark:border-strokedark dark:bg-boxdark [&>.ant-card-body]:!p-0" + return ( - } className='border-stroke dark:border-strokedark [&>.ant-card-head]:border-stroke [&>.ant-card-head]:dark:border-strokedark dark:bg-boxdark [&>.ant-card-body]:!p-0'> - - + <> + } className={titleSty}> + + +
+ + ); }; diff --git a/src/pages/Cate/index.tsx b/src/pages/Cate/index.tsx index f5f4239..e368367 100644 --- a/src/pages/Cate/index.tsx +++ b/src/pages/Cate/index.tsx @@ -123,8 +123,10 @@ const CateManager: React.FC = () => { } }, [cate, model]); + const titleSty = "border-stroke dark:border-strokedark [&>.ant-card-head]:border-stroke [&>.ant-card-head]:dark:border-strokedark dark:bg-boxdark [&>.ant-card-body]:pt-2" + return ( - } className='border-stroke dark:border-strokedark [&>.ant-card-head]:border-stroke [&>.ant-card-head]:dark:border-strokedark dark:bg-boxdark [&>.ant-card-body]:pt-2'> + } className={titleSty}>
diff --git a/src/pages/Comment/index.tsx b/src/pages/Comment/index.tsx index 7ec0485..af55300 100644 --- a/src/pages/Comment/index.tsx +++ b/src/pages/Comment/index.tsx @@ -35,8 +35,10 @@ const CommentManager: React.FC = () => { getCommentList(); }; + const titleSty = "border-stroke dark:border-strokedark [&>.ant-card-head]:border-stroke [&>.ant-card-head]:dark:border-strokedark dark:bg-boxdark [&>.ant-card-body]:pt-2" + return ( - } className='border-stroke dark:border-strokedark [&>.ant-card-head]:border-stroke [&>.ant-card-head]:dark:border-strokedark dark:bg-boxdark [&>.ant-card-body]:pt-2'> + } className={titleSty}> {info.loading ? : } diff --git a/src/pages/Create/index.tsx b/src/pages/Create/index.tsx index 4094d37..86120f3 100644 --- a/src/pages/Create/index.tsx +++ b/src/pages/Create/index.tsx @@ -24,9 +24,11 @@ const Create = () => { }) }, [content]) + const titleSty = "border-stroke dark:border-strokedark [&>.ant-card-head]:border-stroke [&>.ant-card-head]:dark:border-strokedark dark:bg-boxdark [&>.ant-card-body]:pt-2" + return ( <> - } className='border-stroke dark:border-strokedark [&>.ant-card-head]:border-stroke [&>.ant-card-head]:dark:border-strokedark dark:bg-boxdark [&>.ant-card-body]:pt-2'> + } className={titleSty}>
diff --git a/src/utils/request.ts b/src/utils/request.ts index e21dbe4..473b152 100644 --- a/src/utils/request.ts +++ b/src/utils/request.ts @@ -21,8 +21,6 @@ instance.interceptors.request.use( (config: InternalAxiosRequestConfig) => { const token = store.token - // if(config.method === "get") return config - // 如果有token就把赋值给请求头 if (token) config.headers["Authorization"] = `Bearer ${token}`; @@ -41,18 +39,6 @@ instance.interceptors.request.use( // 响应拦截 instance.interceptors.response.use( (res: AxiosResponse) => { - // 如果code为401就证明认证失败 - if (res.data.code === 401) { - return Modal.error({ - title: '暂无权限', - content: '🔒️ 登录已过期,是否重新登录?', - okText: "去登录", - onOk: () => { - store.quitLogin() - } - }); - } - // 只要code不等于200, 就相当于响应失败 if (res.data?.code !== 200) { notification.error({ @@ -66,6 +52,20 @@ instance.interceptors.response.use( return res.data; }, (err: AxiosError) => { + // 如果code为401就证明认证失败 + if (err.response?.status === 401) { + Modal.error({ + title: '暂无权限', + content: '🔒️ 登录已过期,是否重新登录?', + okText: "去登录", + onOk: () => { + store.quitLogin() + } + }); + + return Promise.reject(err.response?.data); + } + // 服务器异常:网络错误、请求超时、状态码不在200-299之间等等 notification.error({ message: '服务器异常',