代码结构优化
This commit is contained in:
@@ -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 (
|
||||
<Card title={<Breadcrumb pageName="文章管理" />} 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'>
|
||||
<Table
|
||||
rowKey="id"
|
||||
dataSource={articleList}
|
||||
columns={columns as any}
|
||||
loading={loading}
|
||||
scroll={{ x: 'max-content' }}
|
||||
pagination={{
|
||||
position: ['bottomCenter'],
|
||||
pageSize: 8
|
||||
}}
|
||||
/>
|
||||
</Card>
|
||||
<>
|
||||
<Card title={<Breadcrumb pageName="文章管理" />} className={titleSty}></Card>
|
||||
|
||||
<Card className={`${titleSty} mt-4`}>
|
||||
<Table
|
||||
rowKey="id"
|
||||
dataSource={articleList}
|
||||
columns={columns as any}
|
||||
loading={loading}
|
||||
scroll={{ x: 'max-content' }}
|
||||
pagination={{
|
||||
position: ['bottomCenter'],
|
||||
pageSize: 8
|
||||
}}
|
||||
/>
|
||||
</Card>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
@@ -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 (
|
||||
<Card title={<Breadcrumb pageName="分类管理" />} 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'>
|
||||
<Card title={<Breadcrumb pageName="分类管理" />} className={titleSty}>
|
||||
<div className='mt-2 mb-4 text-center'>
|
||||
<Button type="primary" onClick={() => setModel(true)}>新增一级分类</Button>
|
||||
</div>
|
||||
|
||||
@@ -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 (
|
||||
<Card title={<Breadcrumb pageName="评论管理" />} 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'>
|
||||
<Card title={<Breadcrumb pageName="评论管理" />} className={titleSty}>
|
||||
<Tabs activeKey={info.tab} onChange={handleTabChange}>
|
||||
<TabPane tab="评论列表" key="list">
|
||||
{info.loading ? <Spin /> : <List data={info} getCommentList={getCommentList} />}
|
||||
|
||||
@@ -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 (
|
||||
<>
|
||||
<Card title={<Breadcrumb pageName="创作" />} 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'>
|
||||
<Card title={<Breadcrumb pageName="创作" />} className={titleSty}>
|
||||
<div className='fixed bottom-10 right-[5%] w-22 z-10'>
|
||||
<Button type="primary" className='w-full' onClick={() => setPublishOpen(true)} >
|
||||
<BiSave className='text-base' /> 保存</Button>
|
||||
|
||||
@@ -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: '服务器异常',
|
||||
|
||||
Reference in New Issue
Block a user