大改动
This commit is contained in:
@@ -23,28 +23,31 @@ export default () => {
|
|||||||
|
|
||||||
const getRecordList = async () => {
|
const getRecordList = async () => {
|
||||||
try {
|
try {
|
||||||
|
setLoading(true);
|
||||||
|
|
||||||
const { data } = await getRecordListAPI();
|
const { data } = await getRecordListAPI();
|
||||||
setRecordList(data as Record[]);
|
setRecordList(data as Record[]);
|
||||||
|
|
||||||
|
setLoading(false);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
setLoading(false);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setLoading(true);
|
|
||||||
getRecordList()
|
getRecordList()
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const delRecordData = async (id: number) => {
|
const delRecordData = async (id: number) => {
|
||||||
|
try {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
|
|
||||||
try {
|
|
||||||
await delRecordDataAPI(id);
|
await delRecordDataAPI(id);
|
||||||
await getRecordList();
|
await getRecordList();
|
||||||
form.resetFields()
|
form.resetFields()
|
||||||
notification.success({ message: '🎉 删除说说成功' })
|
notification.success({ message: '🎉 删除说说成功' })
|
||||||
|
|
||||||
|
setLoading(false);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}
|
}
|
||||||
@@ -116,9 +119,9 @@ export default () => {
|
|||||||
];
|
];
|
||||||
|
|
||||||
const onFilterSubmit = async (values: FilterForm) => {
|
const onFilterSubmit = async (values: FilterForm) => {
|
||||||
|
try {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
|
|
||||||
try {
|
|
||||||
const query = {
|
const query = {
|
||||||
key: values.content,
|
key: values.content,
|
||||||
startDate: values.createTime && values.createTime[0].valueOf() + '',
|
startDate: values.createTime && values.createTime[0].valueOf() + '',
|
||||||
@@ -126,12 +129,12 @@ export default () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const { data } = await getRecordListAPI({ query });
|
const { data } = await getRecordListAPI({ query });
|
||||||
setRecordList(data as Record[]);
|
setRecordList(data);
|
||||||
|
|
||||||
|
setLoading(false);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
setLoading(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -52,54 +52,56 @@ export default () => {
|
|||||||
// 获取角色列表
|
// 获取角色列表
|
||||||
const getRoleList = async () => {
|
const getRoleList = async () => {
|
||||||
try {
|
try {
|
||||||
|
setLoading(true);
|
||||||
|
|
||||||
const { data } = await getRoleListAPI();
|
const { data } = await getRoleListAPI();
|
||||||
setRoleList(data as Role[]);
|
setRoleList(data as Role[]);
|
||||||
|
|
||||||
|
setLoading(false);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
setLoading(false);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setLoading(true);
|
|
||||||
getRoleList()
|
getRoleList()
|
||||||
getRouteList()
|
getRouteList()
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
// 获取指定角色的路由列表
|
// 获取指定角色的路由列表
|
||||||
const bindingRoute = async (record: Role) => {
|
const bindingRoute = async (record: Role) => {
|
||||||
|
try {
|
||||||
setEditLoading(true)
|
setEditLoading(true)
|
||||||
|
|
||||||
try {
|
|
||||||
setIsModalOpen(true)
|
setIsModalOpen(true)
|
||||||
|
|
||||||
const { data } = await getRoleRouteListAPI(record.id);
|
const { data } = await getRoleRouteListAPI(record.id);
|
||||||
setTargetKeys(data.map(item => item.id) as number[])
|
setTargetKeys(data.map(item => item.id) as number[])
|
||||||
|
|
||||||
|
setEditLoading(false)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
setEditLoading(false)
|
setEditLoading(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
setEditLoading(false)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const editRoleData = async (record: Role) => {
|
const editRoleData = async (record: Role) => {
|
||||||
|
try {
|
||||||
setEditLoading(true);
|
setEditLoading(true);
|
||||||
|
|
||||||
try {
|
|
||||||
const { data } = await getRoleDataAPI(record.id);
|
const { data } = await getRoleDataAPI(record.id);
|
||||||
setRole(data);
|
setRole(data);
|
||||||
form.setFieldsValue(data);
|
form.setFieldsValue(data);
|
||||||
|
|
||||||
|
setEditLoading(false);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
setEditLoading(false);
|
setEditLoading(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
setEditLoading(false);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const delRoleData = async (id: number) => {
|
const delRoleData = async (id: number) => {
|
||||||
|
try {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
|
|
||||||
try {
|
|
||||||
await delRoleDataAPI(id);
|
await delRoleDataAPI(id);
|
||||||
await getRoleList();
|
await getRoleList();
|
||||||
message.success('🎉 删除角色成功');
|
message.success('🎉 删除角色成功');
|
||||||
@@ -109,9 +111,9 @@ export default () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const onSubmit = async () => {
|
const onSubmit = async () => {
|
||||||
|
try {
|
||||||
setBtnLoading(true)
|
setBtnLoading(true)
|
||||||
|
|
||||||
try {
|
|
||||||
form.validateFields().then(async (values: Role) => {
|
form.validateFields().then(async (values: Role) => {
|
||||||
if (role.id) {
|
if (role.id) {
|
||||||
await editRoleDataAPI({ ...role, ...values });
|
await editRoleDataAPI({ ...role, ...values });
|
||||||
@@ -126,11 +128,11 @@ export default () => {
|
|||||||
form.setFieldsValue({ name: '', description: '' })
|
form.setFieldsValue({ name: '', description: '' })
|
||||||
setRole({} as Role);
|
setRole({} as Role);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
setBtnLoading(false)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
setBtnLoading(false)
|
setBtnLoading(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
setBtnLoading(false)
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// 设置目标路由
|
// 设置目标路由
|
||||||
@@ -138,10 +140,11 @@ export default () => {
|
|||||||
|
|
||||||
// 绑定路由
|
// 绑定路由
|
||||||
const onBindingRouteSubmit = async () => {
|
const onBindingRouteSubmit = async () => {
|
||||||
|
try {
|
||||||
setBindingLoading(true);
|
setBindingLoading(true);
|
||||||
|
|
||||||
try {
|
|
||||||
await bindingRouteAPI(role.id, targetKeys)
|
await bindingRouteAPI(role.id, targetKeys)
|
||||||
|
setBindingLoading(false);
|
||||||
message.success('🎉 绑定成功');
|
message.success('🎉 绑定成功');
|
||||||
// 刷新页面
|
// 刷新页面
|
||||||
window.location.reload()
|
window.location.reload()
|
||||||
|
|||||||
@@ -33,51 +33,54 @@ export default () => {
|
|||||||
|
|
||||||
const getRouteList = async () => {
|
const getRouteList = async () => {
|
||||||
try {
|
try {
|
||||||
|
setLoading(true);
|
||||||
|
|
||||||
const { data } = await getRouteListAPI();
|
const { data } = await getRouteListAPI();
|
||||||
setList(data);
|
setList(data);
|
||||||
|
|
||||||
|
setLoading(false);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
setLoading(false);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setLoading(true);
|
|
||||||
getRouteList();
|
getRouteList();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const editRouteData = async (record: Route) => {
|
const editRouteData = async (record: Route) => {
|
||||||
|
try {
|
||||||
setLoading(true)
|
setLoading(true)
|
||||||
|
|
||||||
try {
|
|
||||||
const { data } = await getRouteDataAPI(record.id);
|
const { data } = await getRouteDataAPI(record.id);
|
||||||
setRoute(data);
|
setRoute(data);
|
||||||
form.setFieldsValue(data);
|
form.setFieldsValue(data);
|
||||||
|
|
||||||
|
setLoading(false)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
setLoading(false)
|
setLoading(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
setLoading(false)
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const delRouteData = async (id: number) => {
|
const delRouteData = async (id: number) => {
|
||||||
|
try {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
|
|
||||||
try {
|
|
||||||
await delRouteDataAPI(id);
|
await delRouteDataAPI(id);
|
||||||
await getRouteList();
|
await getRouteList();
|
||||||
message.success('🎉 删除路由成功');
|
message.success('🎉 删除路由成功');
|
||||||
|
|
||||||
|
setLoading(false)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
setLoading(false)
|
setLoading(false)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const onSubmit = async () => {
|
const onSubmit = async () => {
|
||||||
|
try {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
setBtnLoading(true)
|
setBtnLoading(true)
|
||||||
|
|
||||||
try {
|
|
||||||
form.validateFields().then(async (values: Route) => {
|
form.validateFields().then(async (values: Route) => {
|
||||||
if (route.id) {
|
if (route.id) {
|
||||||
await editRouteDataAPI({ ...route, ...values });
|
await editRouteDataAPI({ ...route, ...values });
|
||||||
@@ -92,13 +95,13 @@ export default () => {
|
|||||||
form.setFieldsValue({ path: '', description: '' })
|
form.setFieldsValue({ path: '', description: '' })
|
||||||
setRoute({} as Route);
|
setRoute({} as Route);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
setLoading(false)
|
||||||
|
setBtnLoading(true)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
setLoading(false)
|
setLoading(false)
|
||||||
setBtnLoading(true)
|
setBtnLoading(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
setLoading(false)
|
|
||||||
setBtnLoading(true)
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -20,17 +20,18 @@ export default () => {
|
|||||||
|
|
||||||
const getRssList = async () => {
|
const getRssList = async () => {
|
||||||
try {
|
try {
|
||||||
|
setLoading(true);
|
||||||
|
|
||||||
const { data } = await getRssListAPI();
|
const { data } = await getRssListAPI();
|
||||||
setList(data);
|
setList(data);
|
||||||
|
|
||||||
|
setLoading(false);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
setLoading(false);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setLoading(true);
|
|
||||||
getRssList();
|
getRssList();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
|||||||
@@ -19,25 +19,26 @@ export default () => {
|
|||||||
|
|
||||||
const getUserData = async () => {
|
const getUserData = async () => {
|
||||||
try {
|
try {
|
||||||
|
setLoading(true);
|
||||||
|
|
||||||
const { data } = await getUserDataAPI(store.user?.id);
|
const { data } = await getUserDataAPI(store.user?.id);
|
||||||
store.setUser(data);
|
store.setUser(data);
|
||||||
form.setFieldsValue(data);
|
form.setFieldsValue(data);
|
||||||
|
|
||||||
|
setLoading(false);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
setLoading(false);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setLoading(true);
|
|
||||||
getUserData();
|
getUserData();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const onSubmit = async (values: UserForm) => {
|
const onSubmit = async (values: UserForm) => {
|
||||||
|
try {
|
||||||
setLoading(true)
|
setLoading(true)
|
||||||
|
|
||||||
try {
|
|
||||||
await editUserDataAPI({
|
await editUserDataAPI({
|
||||||
id: store.user.id, ...values,
|
id: store.user.id, ...values,
|
||||||
role: undefined
|
role: undefined
|
||||||
|
|||||||
@@ -35,9 +35,9 @@ export default () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleSubmit = async (values: EditUser) => {
|
const handleSubmit = async (values: EditUser) => {
|
||||||
|
try {
|
||||||
setLoading(true)
|
setLoading(true)
|
||||||
|
|
||||||
try {
|
|
||||||
await editAdminPassAPI(values);
|
await editAdminPassAPI(values);
|
||||||
|
|
||||||
confirm({
|
confirm({
|
||||||
@@ -47,11 +47,11 @@ export default () => {
|
|||||||
onOk: store.quitLogin,
|
onOk: store.quitLogin,
|
||||||
cancelButtonProps: { style: { display: 'none' } }
|
cancelButtonProps: { style: { display: 'none' } }
|
||||||
});
|
});
|
||||||
|
|
||||||
|
setLoading(false)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
setLoading(false)
|
setLoading(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
setLoading(false)
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -1,49 +1,48 @@
|
|||||||
import { useEffect, useState } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
import { Spin, Form, notification, Input, Button } from 'antd';
|
import { Form, notification, Input, Button } from 'antd';
|
||||||
import { LoadingOutlined } from '@ant-design/icons';
|
|
||||||
import { Theme } from '@/types/app/project';
|
import { Theme } from '@/types/app/project';
|
||||||
import { editConfigDataAPI, getConfigDataAPI } from '@/api/Project';
|
import { editConfigDataAPI, getConfigDataAPI } from '@/api/Project';
|
||||||
|
|
||||||
const RecordTheme = () => {
|
export default () => {
|
||||||
const [loading, setLoading] = useState<boolean>(false);
|
const [loading, setLoading] = useState<boolean>(false);
|
||||||
|
|
||||||
const [form] = Form.useForm();
|
const [form] = Form.useForm();
|
||||||
|
|
||||||
const getLayoutData = async () => {
|
const getLayoutData = async () => {
|
||||||
try {
|
try {
|
||||||
const { data } = await getConfigDataAPI<Theme>("layout");
|
setLoading(true);
|
||||||
|
|
||||||
|
const { data } = await getConfigDataAPI<Theme>("layout");
|
||||||
form.setFieldsValue({
|
form.setFieldsValue({
|
||||||
record_name: data.record_name,
|
record_name: data.record_name,
|
||||||
record_info: data.record_info
|
record_info: data.record_info
|
||||||
});
|
});
|
||||||
|
|
||||||
|
setLoading(false);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
setLoading(false);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setLoading(true);
|
|
||||||
getLayoutData();
|
getLayoutData();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const editThemeData = async (values: { record_name: string, record_info: string }) => {
|
const editThemeData = async (values: { record_name: string, record_info: string }) => {
|
||||||
|
try {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
|
|
||||||
try {
|
|
||||||
await editConfigDataAPI("layout", values);
|
await editConfigDataAPI("layout", values);
|
||||||
|
|
||||||
notification.success({
|
notification.success({
|
||||||
message: '成功',
|
message: '成功',
|
||||||
description: '🎉 修改主题成功',
|
description: '🎉 修改主题成功',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
setLoading(false);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
setLoading(false);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -70,5 +69,3 @@ const RecordTheme = () => {
|
|||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default RecordTheme;
|
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
import { useState, useEffect } from 'react';
|
import { useState, useEffect } from 'react';
|
||||||
import { notification, Divider, Input, Alert, Button, Spin, Form } from 'antd';
|
import { notification, Divider, Input, Alert, Button, Form } from 'antd';
|
||||||
import { PictureOutlined, LoadingOutlined, CloudUploadOutlined } from '@ant-design/icons';
|
import { PictureOutlined, CloudUploadOutlined } from '@ant-design/icons';
|
||||||
import { editConfigDataAPI, getConfigDataAPI } from '@/api/Project';
|
import { editConfigDataAPI, getConfigDataAPI } from '@/api/Project';
|
||||||
import { Theme } from '@/types/app/project';
|
import { Theme } from '@/types/app/project';
|
||||||
import FileUpload from '@/components/FileUpload';
|
import FileUpload from '@/components/FileUpload';
|
||||||
|
|
||||||
const SynthesisTheme = () => {
|
export default () => {
|
||||||
const [loading, setLoading] = useState<boolean>(false);
|
const [loading, setLoading] = useState<boolean>(false);
|
||||||
|
|
||||||
const [isModalOpen, setIsModalOpen] = useState<boolean>(false);
|
const [isModalOpen, setIsModalOpen] = useState<boolean>(false);
|
||||||
@@ -22,6 +22,8 @@ const SynthesisTheme = () => {
|
|||||||
|
|
||||||
const getLayoutData = async () => {
|
const getLayoutData = async () => {
|
||||||
try {
|
try {
|
||||||
|
setLoading(true);
|
||||||
|
|
||||||
const { data } = await getConfigDataAPI<Theme>("layout");
|
const { data } = await getConfigDataAPI<Theme>("layout");
|
||||||
setTheme(data);
|
setTheme(data);
|
||||||
|
|
||||||
@@ -34,22 +36,21 @@ const SynthesisTheme = () => {
|
|||||||
covers: data.covers ? JSON.parse(data.covers).join("\n") : '',
|
covers: data.covers ? JSON.parse(data.covers).join("\n") : '',
|
||||||
reco_article: data.reco_article ? JSON.parse(data.reco_article).join("\n") : '',
|
reco_article: data.reco_article ? JSON.parse(data.reco_article).join("\n") : '',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
setLoading(false);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
setLoading(false);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setLoading(true);
|
|
||||||
getLayoutData();
|
getLayoutData();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const editThemeData = async (values: any) => {
|
const editThemeData = async (values: any) => {
|
||||||
|
try {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
|
|
||||||
try {
|
|
||||||
const updatedLayout = {
|
const updatedLayout = {
|
||||||
...theme,
|
...theme,
|
||||||
...values,
|
...values,
|
||||||
@@ -64,11 +65,11 @@ const SynthesisTheme = () => {
|
|||||||
message: '成功',
|
message: '成功',
|
||||||
description: '🎉 修改主题成功',
|
description: '🎉 修改主题成功',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
setLoading(false);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
setLoading(false);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const getFile = (name: string) => {
|
const getFile = (name: string) => {
|
||||||
@@ -199,5 +200,3 @@ const SynthesisTheme = () => {
|
|||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default SynthesisTheme;
|
|
||||||
@@ -43,53 +43,54 @@ export default () => {
|
|||||||
|
|
||||||
const getSwiperList = async () => {
|
const getSwiperList = async () => {
|
||||||
try {
|
try {
|
||||||
|
setLoading(true);
|
||||||
|
|
||||||
const { data } = await getSwiperListAPI();
|
const { data } = await getSwiperListAPI();
|
||||||
setList(data as Swiper[]);
|
setList(data as Swiper[]);
|
||||||
|
|
||||||
|
setLoading(false);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
setLoading(false);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setLoading(true);
|
|
||||||
getSwiperList();
|
getSwiperList();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const editSwiperData = async (record: Swiper) => {
|
const editSwiperData = async (record: Swiper) => {
|
||||||
|
try {
|
||||||
setEditLoading(true);
|
setEditLoading(true);
|
||||||
setTab('operate');
|
setTab('operate');
|
||||||
|
|
||||||
try {
|
|
||||||
const { data } = await getSwiperDataAPI(record.id)
|
const { data } = await getSwiperDataAPI(record.id)
|
||||||
setSwiper(data);
|
setSwiper(data);
|
||||||
form.setFieldsValue(record);
|
form.setFieldsValue(record);
|
||||||
|
|
||||||
|
setEditLoading(false);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
setEditLoading(false);
|
setEditLoading(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
setEditLoading(false);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const delSwiperData = async (id: number) => {
|
const delSwiperData = async (id: number) => {
|
||||||
|
try {
|
||||||
setBtnLoading(true);
|
setBtnLoading(true);
|
||||||
|
|
||||||
try {
|
|
||||||
await delSwiperDataAPI(id);
|
await delSwiperDataAPI(id);
|
||||||
await getSwiperList();
|
await getSwiperList();
|
||||||
message.success('🎉 删除轮播图成功');
|
message.success('🎉 删除轮播图成功');
|
||||||
|
|
||||||
|
setBtnLoading(false);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
setBtnLoading(false);
|
setBtnLoading(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
setBtnLoading(false);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const onSubmit = async () => {
|
const onSubmit = async () => {
|
||||||
|
try {
|
||||||
setBtnLoading(true)
|
setBtnLoading(true)
|
||||||
|
|
||||||
try {
|
|
||||||
form.validateFields().then(async (values: Swiper) => {
|
form.validateFields().then(async (values: Swiper) => {
|
||||||
if (swiper.id) {
|
if (swiper.id) {
|
||||||
await editSwiperDataAPI({ ...swiper, ...values });
|
await editSwiperDataAPI({ ...swiper, ...values });
|
||||||
@@ -104,6 +105,8 @@ export default () => {
|
|||||||
form.resetFields();
|
form.resetFields();
|
||||||
setSwiper({} as Swiper);
|
setSwiper({} as Swiper);
|
||||||
})
|
})
|
||||||
|
|
||||||
|
setBtnLoading(false)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
setBtnLoading(false)
|
setBtnLoading(false)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { useState, useEffect } from 'react';
|
import { useState, useEffect } from 'react';
|
||||||
import { Table, Button, Form, Input, Popconfirm, message, Card } from 'antd';
|
import { Table, Button, Form, Input, Popconfirm, message, Card, Spin } from 'antd';
|
||||||
import { getTagListAPI, addTagDataAPI, editTagDataAPI, delTagDataAPI, getTagDataAPI } from '@/api/Tag';
|
import { getTagListAPI, addTagDataAPI, editTagDataAPI, delTagDataAPI, getTagDataAPI } from '@/api/Tag';
|
||||||
import { Tag } from '@/types/app/tag';
|
import { Tag } from '@/types/app/tag';
|
||||||
import Title from '@/components/Title';
|
import Title from '@/components/Title';
|
||||||
@@ -8,6 +8,7 @@ import { ColumnsType } from 'antd/es/table';
|
|||||||
export default () => {
|
export default () => {
|
||||||
const [loading, setLoading] = useState<boolean>(false);
|
const [loading, setLoading] = useState<boolean>(false);
|
||||||
const [btnLoading, setBtnLoading] = useState(false)
|
const [btnLoading, setBtnLoading] = useState(false)
|
||||||
|
const [editLoading, setEditLoading] = useState(false)
|
||||||
|
|
||||||
const [form] = Form.useForm();
|
const [form] = Form.useForm();
|
||||||
|
|
||||||
@@ -32,38 +33,39 @@ export default () => {
|
|||||||
|
|
||||||
const getTagList = async () => {
|
const getTagList = async () => {
|
||||||
try {
|
try {
|
||||||
|
setLoading(true);
|
||||||
|
|
||||||
const { data } = await getTagListAPI();
|
const { data } = await getTagListAPI();
|
||||||
setList(data as Tag[]);
|
setList(data as Tag[]);
|
||||||
|
|
||||||
|
setLoading(false);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
setLoading(false);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setLoading(true);
|
|
||||||
getTagList();
|
getTagList();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const editTagData = async (record: Tag) => {
|
const editTagData = async (record: Tag) => {
|
||||||
setLoading(true);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
setEditLoading(true);
|
||||||
|
|
||||||
const { data } = await getTagDataAPI(record.id)
|
const { data } = await getTagDataAPI(record.id)
|
||||||
setTag(data);
|
setTag(data);
|
||||||
form.setFieldsValue(data);
|
form.setFieldsValue(data);
|
||||||
} catch (error) {
|
|
||||||
setLoading(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
setLoading(false);
|
setEditLoading(false);
|
||||||
|
} catch (error) {
|
||||||
|
setEditLoading(false);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const delTagData = async (id: number) => {
|
const delTagData = async (id: number) => {
|
||||||
|
try {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
|
|
||||||
try {
|
|
||||||
await delTagDataAPI(id);
|
await delTagDataAPI(id);
|
||||||
await getTagList();
|
await getTagList();
|
||||||
message.success('🎉 删除标签成功');
|
message.success('🎉 删除标签成功');
|
||||||
@@ -73,10 +75,10 @@ export default () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const onSubmit = async () => {
|
const onSubmit = async () => {
|
||||||
|
try {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
setBtnLoading(true);
|
setBtnLoading(true);
|
||||||
|
|
||||||
try {
|
|
||||||
form.validateFields().then(async (values: Tag) => {
|
form.validateFields().then(async (values: Tag) => {
|
||||||
if (tag.id) {
|
if (tag.id) {
|
||||||
await editTagDataAPI({ ...tag, ...values });
|
await editTagDataAPI({ ...tag, ...values });
|
||||||
@@ -91,12 +93,13 @@ export default () => {
|
|||||||
form.setFieldsValue({ name: '' })
|
form.setFieldsValue({ name: '' })
|
||||||
setTag({} as Tag);
|
setTag({} as Tag);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
setLoading(false);
|
||||||
|
setBtnLoading(false);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
setBtnLoading(false);
|
setBtnLoading(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
setBtnLoading(false);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -104,6 +107,7 @@ export default () => {
|
|||||||
<Title value="标签管理" />
|
<Title value="标签管理" />
|
||||||
|
|
||||||
<div className='flex md:justify-between flex-col md:flex-row mx-auto mt-2'>
|
<div className='flex md:justify-between flex-col md:flex-row mx-auto mt-2'>
|
||||||
|
<Spin spinning={editLoading}>
|
||||||
<Card className="w-full md:w-[40%] h-[calc(100vh-180px)]">
|
<Card className="w-full md:w-[40%] h-[calc(100vh-180px)]">
|
||||||
<Form
|
<Form
|
||||||
form={form}
|
form={form}
|
||||||
@@ -121,6 +125,7 @@ export default () => {
|
|||||||
</Form.Item>
|
</Form.Item>
|
||||||
</Form>
|
</Form>
|
||||||
</Card>
|
</Card>
|
||||||
|
</Spin>
|
||||||
|
|
||||||
<Card className="w-full md:w-[59%] [&>.ant-card-body]:!p-0 mt-2 md:mt-0">
|
<Card className="w-full md:w-[59%] [&>.ant-card-body]:!p-0 mt-2 md:mt-0">
|
||||||
<Table
|
<Table
|
||||||
|
|||||||
@@ -111,33 +111,31 @@ export default () => {
|
|||||||
|
|
||||||
const getUserList = async () => {
|
const getUserList = async () => {
|
||||||
try {
|
try {
|
||||||
|
setLoading(true);
|
||||||
|
|
||||||
const { data } = await getUserListAPI();
|
const { data } = await getUserListAPI();
|
||||||
setUserList(data as User[]);
|
setUserList(data as User[]);
|
||||||
|
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
setLoading(false);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const getRoleList = async () => {
|
const getRoleList = async () => {
|
||||||
const { data } = await getRoleListAPI();
|
const { data } = await getRoleListAPI();
|
||||||
console.log(data);
|
|
||||||
|
|
||||||
setRoleList(data);
|
setRoleList(data);
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setLoading(true);
|
|
||||||
getUserList();
|
getUserList();
|
||||||
getRoleList()
|
getRoleList()
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const delUserData = async (id: number) => {
|
const delUserData = async (id: number) => {
|
||||||
|
try {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
|
|
||||||
try {
|
|
||||||
await delUserDataAPI(id);
|
await delUserDataAPI(id);
|
||||||
await getUserList();
|
await getUserList();
|
||||||
notification.success({ message: '🎉 删除用户成功' });
|
notification.success({ message: '🎉 删除用户成功' });
|
||||||
@@ -147,18 +145,18 @@ export default () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const editUserData = async (id: number) => {
|
const editUserData = async (id: number) => {
|
||||||
|
try {
|
||||||
setEditLoading(true);
|
setEditLoading(true);
|
||||||
|
|
||||||
try {
|
|
||||||
setDrawerVisible(true);
|
setDrawerVisible(true);
|
||||||
const { data } = await getUserDataAPI(id)
|
const { data } = await getUserDataAPI(id)
|
||||||
setUser(data);
|
setUser(data);
|
||||||
form.setFieldsValue(data);
|
form.setFieldsValue(data);
|
||||||
|
|
||||||
|
setEditLoading(false);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
setEditLoading(false);
|
setEditLoading(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
setEditLoading(false);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const reset = () => {
|
const reset = () => {
|
||||||
@@ -167,9 +165,9 @@ export default () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const onSubmit = async () => {
|
const onSubmit = async () => {
|
||||||
|
try {
|
||||||
setBtnLoading(true)
|
setBtnLoading(true)
|
||||||
|
|
||||||
try {
|
|
||||||
form.validateFields().then(async (values: User) => {
|
form.validateFields().then(async (values: User) => {
|
||||||
if (user.id) {
|
if (user.id) {
|
||||||
await editUserDataAPI({ ...user, ...values });
|
await editUserDataAPI({ ...user, ...values });
|
||||||
@@ -183,17 +181,17 @@ export default () => {
|
|||||||
setDrawerVisible(false);
|
setDrawerVisible(false);
|
||||||
reset()
|
reset()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
setBtnLoading(false)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
setBtnLoading(false)
|
setBtnLoading(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
setBtnLoading(false)
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const onFilterSubmit = async (values: FilterForm) => {
|
const onFilterSubmit = async (values: FilterForm) => {
|
||||||
|
try {
|
||||||
setLoading(true)
|
setLoading(true)
|
||||||
|
|
||||||
try {
|
|
||||||
const query: FilterUser = {
|
const query: FilterUser = {
|
||||||
key: values.name,
|
key: values.name,
|
||||||
roleId: values.role,
|
roleId: values.role,
|
||||||
@@ -202,12 +200,12 @@ export default () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const { data } = await getUserListAPI({ query });
|
const { data } = await getUserListAPI({ query });
|
||||||
setUserList(data as User[]);
|
setUserList(data);
|
||||||
|
|
||||||
|
setLoading(false)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
setLoading(false)
|
setLoading(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
setLoading(false)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -17,13 +17,15 @@ export default () => {
|
|||||||
|
|
||||||
const getWallList = async () => {
|
const getWallList = async () => {
|
||||||
try {
|
try {
|
||||||
|
setLoading(true)
|
||||||
|
|
||||||
const { data } = await getWallListAPI();
|
const { data } = await getWallListAPI();
|
||||||
setList(data)
|
setList(data)
|
||||||
|
|
||||||
|
setLoading(false)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
setLoading(false)
|
setLoading(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
setLoading(false)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const delWallData = async (id: number) => {
|
const delWallData = async (id: number) => {
|
||||||
@@ -48,7 +50,6 @@ export default () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setLoading(true)
|
|
||||||
getWallList();
|
getWallList();
|
||||||
getCateList()
|
getCateList()
|
||||||
}, []);
|
}, []);
|
||||||
@@ -118,9 +119,9 @@ export default () => {
|
|||||||
const { RangePicker } = DatePicker;
|
const { RangePicker } = DatePicker;
|
||||||
|
|
||||||
const onFilterSubmit = async (values: FilterForm) => {
|
const onFilterSubmit = async (values: FilterForm) => {
|
||||||
|
try {
|
||||||
setLoading(true)
|
setLoading(true)
|
||||||
|
|
||||||
try {
|
|
||||||
const query: FilterWall = {
|
const query: FilterWall = {
|
||||||
key: values.content,
|
key: values.content,
|
||||||
cateId: values.cateId,
|
cateId: values.cateId,
|
||||||
@@ -130,11 +131,11 @@ export default () => {
|
|||||||
|
|
||||||
const { data } = await getWallListAPI({ query });
|
const { data } = await getWallListAPI({ query });
|
||||||
setList(data)
|
setList(data)
|
||||||
|
|
||||||
|
setLoading(false)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
setLoading(false)
|
setLoading(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
setLoading(false)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -27,17 +27,19 @@ export default () => {
|
|||||||
// 获取网站列表
|
// 获取网站列表
|
||||||
const getLinkList = async () => {
|
const getLinkList = async () => {
|
||||||
try {
|
try {
|
||||||
|
setLoading(true);
|
||||||
|
|
||||||
const { data } = await getLinkListAPI();
|
const { data } = await getLinkListAPI();
|
||||||
data.sort((a, b) => a.order - b.order)
|
data.sort((a, b) => a.order - b.order)
|
||||||
data.sort((a, b) => a.type.order - b.type.order)
|
data.sort((a, b) => a.type.order - b.type.order)
|
||||||
|
|
||||||
setList(data);
|
setList(data);
|
||||||
setListTemp(data);
|
setListTemp(data);
|
||||||
|
|
||||||
|
setLoading(false)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
setLoading(false)
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// 获取网站类型列表
|
// 获取网站类型列表
|
||||||
@@ -47,7 +49,6 @@ export default () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setLoading(true);
|
|
||||||
getLinkList();
|
getLinkList();
|
||||||
getWebTypeList();
|
getWebTypeList();
|
||||||
}, []);
|
}, []);
|
||||||
@@ -57,9 +58,9 @@ export default () => {
|
|||||||
}, [search, list]);
|
}, [search, list]);
|
||||||
|
|
||||||
const deleteLinkData = async (id: number) => {
|
const deleteLinkData = async (id: number) => {
|
||||||
|
try {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
|
|
||||||
try {
|
|
||||||
await delLinkDataAPI(id);
|
await delLinkDataAPI(id);
|
||||||
await getLinkList();
|
await getLinkList();
|
||||||
message.success('🎉 删除网站成功');
|
message.success('🎉 删除网站成功');
|
||||||
@@ -69,20 +70,19 @@ export default () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const editLinkData = async (record: Web) => {
|
const editLinkData = async (record: Web) => {
|
||||||
setEditLoading(true)
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
setEditLoading(true)
|
||||||
setTab('operate');
|
setTab('operate');
|
||||||
setIsMethod("edit");
|
setIsMethod("edit");
|
||||||
|
|
||||||
const { data } = await getLinkDataAPI(record.id)
|
const { data } = await getLinkDataAPI(record.id)
|
||||||
setLink(data);
|
setLink(data);
|
||||||
form.setFieldsValue(data);
|
form.setFieldsValue(data);
|
||||||
|
|
||||||
|
setEditLoading(false)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
setEditLoading(false)
|
setEditLoading(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
setEditLoading(false)
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// 做一些初始化的事情
|
// 做一些初始化的事情
|
||||||
@@ -98,9 +98,9 @@ export default () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const submit = async () => {
|
const submit = async () => {
|
||||||
|
try {
|
||||||
setBtnLoading(true)
|
setBtnLoading(true)
|
||||||
|
|
||||||
try {
|
|
||||||
form.validateFields().then(async (values: Web) => {
|
form.validateFields().then(async (values: Web) => {
|
||||||
if (isMethod === "edit") {
|
if (isMethod === "edit") {
|
||||||
await editLinkDataAPI({ ...link, ...values });
|
await editLinkDataAPI({ ...link, ...values });
|
||||||
@@ -114,11 +114,11 @@ export default () => {
|
|||||||
reset()
|
reset()
|
||||||
setTab('list');
|
setTab('list');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
setBtnLoading(false)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
setBtnLoading(false)
|
setBtnLoading(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
setBtnLoading(false)
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const { Option } = Select;
|
const { Option } = Select;
|
||||||
@@ -137,7 +137,7 @@ export default () => {
|
|||||||
label: '网站列表',
|
label: '网站列表',
|
||||||
key: 'list',
|
key: 'list',
|
||||||
children: (
|
children: (
|
||||||
<>
|
<div>
|
||||||
<div className="w-[300px] mx-auto">
|
<div className="w-[300px] mx-auto">
|
||||||
<Input
|
<Input
|
||||||
size="large"
|
size="large"
|
||||||
@@ -179,14 +179,14 @@ export default () => {
|
|||||||
<Empty description="暂无数据" className='my-7' />
|
<Empty description="暂无数据" className='my-7' />
|
||||||
)}
|
)}
|
||||||
</Spin>
|
</Spin>
|
||||||
</>
|
</div>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: isMethod === "edit" ? '编辑网站' : '新增网站',
|
label: isMethod === "edit" ? '编辑网站' : '新增网站',
|
||||||
key: 'operate',
|
key: 'operate',
|
||||||
children: (
|
children: (
|
||||||
<>
|
<div>
|
||||||
<h2 className="text-xl pb-4 text-center">{isMethod === "edit" ? '编辑网站' : '新增网站'}</h2>
|
<h2 className="text-xl pb-4 text-center">{isMethod === "edit" ? '编辑网站' : '新增网站'}</h2>
|
||||||
|
|
||||||
<Spin spinning={editLoading}>
|
<Spin spinning={editLoading}>
|
||||||
@@ -232,7 +232,7 @@ export default () => {
|
|||||||
</Form>
|
</Form>
|
||||||
</div>
|
</div>
|
||||||
</Spin>
|
</Spin>
|
||||||
</>
|
</div>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -27,6 +27,8 @@ export default () => {
|
|||||||
// 重新获取最新数据
|
// 重新获取最新数据
|
||||||
const fetchData = async (type: Menu) => {
|
const fetchData = async (type: Menu) => {
|
||||||
try {
|
try {
|
||||||
|
setLoading(true)
|
||||||
|
|
||||||
if (type === "comment") {
|
if (type === "comment") {
|
||||||
const { data } = await getCommentListAPI({ query: { status: 0 }, pattern: "list" });
|
const { data } = await getCommentListAPI({ query: { status: 0 }, pattern: "list" });
|
||||||
setCommentList(data);
|
setCommentList(data);
|
||||||
@@ -37,15 +39,14 @@ export default () => {
|
|||||||
const { data } = await getWallListAPI({ query: { status: 0 } });
|
const { data } = await getWallListAPI({ query: { status: 0 } });
|
||||||
setWallList(data);
|
setWallList(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setLoading(false)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
setLoading(false)
|
setLoading(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
setLoading(false)
|
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setLoading(true)
|
|
||||||
fetchData(active);
|
fetchData(active);
|
||||||
}, [active]);
|
}, [active]);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user