Commit 589cbe51 authored by littleforest's avatar littleforest
parents bd776721 fd5aa690
...@@ -17,7 +17,7 @@ export default defineConfig({ ...@@ -17,7 +17,7 @@ export default defineConfig({
layout: { layout: {
// https://umijs.org/zh-CN/plugins/plugin-layout // https://umijs.org/zh-CN/plugins/plugin-layout
locale: true, locale: true,
siderWidth: 208, siderWidth: 240,
...defaultSettings, ...defaultSettings,
}, },
// https://umijs.org/zh-CN/plugins/plugin-locale // https://umijs.org/zh-CN/plugins/plugin-locale
...@@ -42,6 +42,14 @@ export default defineConfig({ ...@@ -42,6 +42,14 @@ export default defineConfig({
// 如果不想要 configProvide 动态设置主题需要把这个设置为 default // 如果不想要 configProvide 动态设置主题需要把这个设置为 default
// 只有设置为 variable, 才能使用 configProvide 动态设置主色调 // 只有设置为 variable, 才能使用 configProvide 动态设置主色调
// https://ant.design/docs/react/customize-theme-variable-cn // https://ant.design/docs/react/customize-theme-variable-cn
'@primary-color': '#009b95', // 全局主色
'@link-color': '#009b95', // 链接色
'@heading-color': 'rgba(0, 0, 0, 0.85)', // 标题色
'@text-color': 'rgba(0, 0, 0, 0.65)', // 主文本色
'@text-color-secondary': 'rgba(0, 0, 0, 0.45)', // 次文本色
'@disabled-color': 'rgba(0, 0, 0, 0.25)', // 失效色
'@border-radius-base': '4px', // 组件/浮层圆角
'@box-shadow-base': '0 2px 8px rgba(0, 0, 0, 0.15)', // 浮层阴影
'root-entry-name': 'variable', 'root-entry-name': 'variable',
}, },
// esbuild is father build tools // esbuild is father build tools
......
...@@ -29,7 +29,6 @@ export const layout = ({ initialState, setInitialState }) => { ...@@ -29,7 +29,6 @@ export const layout = ({ initialState, setInitialState }) => {
return { return {
rightContentRender: () => <RightContent />, rightContentRender: () => <RightContent />,
disableContentMargin: false, disableContentMargin: false,
footerRender: () => <Footer />, footerRender: () => <Footer />,
menuHeaderRender: undefined, menuHeaderRender: undefined,
// 自定义 403 页面 // 自定义 403 页面
......
...@@ -97,3 +97,14 @@ ol { ...@@ -97,3 +97,14 @@ ol {
font-size: 12px !important; font-size: 12px !important;
} }
} }
.ant-btn:active,
.ant-btn:focus {
background-color: #009b95 !important;
border-color: #009b95 !important;
}
.ant-btn:hover {
background-color: #009b95 !important;
border-color: #009b95 !important;
}
import { DeleteOutlined, EditOutlined, PlusOutlined } from '@ant-design/icons'; import { DeleteOutlined, EditOutlined, PlusOutlined } from '@ant-design/icons';
import { ActionType, PageContainer } from '@ant-design/pro-components'; import { ActionType, PageContainer } from '@ant-design/pro-components';
import { ProTable } from '@ant-design/pro-components'; import { ProTable } from '@ant-design/pro-components';
import { Button, message } from 'antd'; import { Button, Space, message } from 'antd';
import { isEmpty } from 'lodash'; import { isEmpty } from 'lodash';
import { useEffect, useRef, useState } from 'react'; import { useEffect, useRef, useState } from 'react';
import styles from './index.less'; import styles from './index.less';
import EditPromptModal from '@/components/EditAndAddPromptModal'; import EditPromptModal from '@/components/EditAndAddPromptModal';
import DeletePromptModal from '@/components/DeletePromptModal'; import DeletePromptModal from '@/components/DeletePromptModal';
import { pagePromptWords, createPromptWords, updatePromptWords, deletePromptWords, typePromptWords } from '@/services/chatGLM/api'; import {
pagePromptWords,
createPromptWords,
updatePromptWords,
deletePromptWords,
typePromptWords,
} from '@/services/chatGLM/api';
interface IPromptList { interface IPromptList {
id: string; id: string;
...@@ -31,18 +37,16 @@ interface ILoading { ...@@ -31,18 +37,16 @@ interface ILoading {
} }
const PromptWord = () => { const PromptWord = () => {
const actionRef = useRef<ActionType>(); const actionRef = useRef<ActionType>();
const [allLoading, setAllLoading] = useState<ILoading>({ const [allLoading, setAllLoading] = useState<ILoading>({
editModalLoading: false, editModalLoading: false,
createModalLoading: false, createModalLoading: false,
deleteModalLoading: false, deleteModalLoading: false,
listLoading: false listLoading: false,
}); });
const [editAndAddModalOpen, setEditAndDeleteModalOpen] = useState(false); const [editAndAddModalOpen, setEditAndDeleteModalOpen] = useState(false);
const [deleteModalOpen, setDeleteModalOpen] = useState(false); const [deleteModalOpen, setDeleteModalOpen] = useState(false);
const [promptList, setPromptList] = useState<IPromptList[]>([]);
const [modalType, setModalType] = useState<'create' | 'edit' | ''>(''); const [modalType, setModalType] = useState<'create' | 'edit' | ''>('');
const [types, setTypes] = useState<string[]>([]); const [types, setTypes] = useState<string[]>([]);
...@@ -60,10 +64,10 @@ const PromptWord = () => { ...@@ -60,10 +64,10 @@ const PromptWord = () => {
options: types.map((type) => { options: types.map((type) => {
return { return {
label: type, label: type,
value: type value: type,
} };
}) }),
} },
}, },
{ {
title: '提示词语', title: '提示词语',
...@@ -72,7 +76,7 @@ const PromptWord = () => { ...@@ -72,7 +76,7 @@ const PromptWord = () => {
dataIndex: 'content', dataIndex: 'content',
ellipsis: true, ellipsis: true,
search: true, search: true,
order: 2 order: 2,
}, },
{ {
title: '创建时间', title: '创建时间',
...@@ -88,28 +92,31 @@ const PromptWord = () => { ...@@ -88,28 +92,31 @@ const PromptWord = () => {
key: 'option', key: 'option',
render: (_: unknown, record: IPromptList) => ( render: (_: unknown, record: IPromptList) => (
<div className={styles.table_action}> <div className={styles.table_action}>
<div <Space wrap>
className={styles.table_action_edit} <div
onClick={() => { className={styles.table_action_edit}
setCurrentRaw(record); onClick={() => {
setEditAndDeleteModalOpen(true); setCurrentRaw(record);
setModalType('edit'); setEditAndDeleteModalOpen(true);
}} setModalType('edit');
> }}
<EditOutlined /> >
<span>编辑</span> <Button size="small" type="link">
</div> 编辑
<span style={{ margin: '0 9px' }}>|</span> </Button>
<div </div>
className={styles.table_action_delete} <div
onClick={() => { className={styles.table_action_delete}
setDeleteModalOpen(true); onClick={() => {
setCurrentRaw(record); setDeleteModalOpen(true);
}} setCurrentRaw(record);
> }}
<DeleteOutlined /> >
<span>删除</span> <Button size="small" type="link" danger>
</div> 删除
</Button>
</div>
</Space>
</div> </div>
), ),
}, },
...@@ -119,7 +126,7 @@ const PromptWord = () => { ...@@ -119,7 +126,7 @@ const PromptWord = () => {
const data = await typePromptWords(); const data = await typePromptWords();
setTypes(data); setTypes(data);
}; };
useEffect(() => { useEffect(() => {
fetchTypes(); fetchTypes();
}, []); }, []);
...@@ -130,13 +137,13 @@ const PromptWord = () => { ...@@ -130,13 +137,13 @@ const PromptWord = () => {
await updatePromptWords({ await updatePromptWords({
id: currentRow.id, id: currentRow.id,
content: editValue.content, content: editValue.content,
type: editValue.type type: editValue.type,
}); });
setAllLoading({ ...allLoading, editModalLoading: false }); setAllLoading({ ...allLoading, editModalLoading: false });
actionRef.current?.reload(); actionRef.current?.reload();
} catch(error) { } catch (error) {
setAllLoading({ ...allLoading, editModalLoading: false }); setAllLoading({ ...allLoading, editModalLoading: false });
message.error('编辑提示用语失败,请重试!') message.error('编辑提示用语失败,请重试!');
} }
}; };
...@@ -145,13 +152,13 @@ const PromptWord = () => { ...@@ -145,13 +152,13 @@ const PromptWord = () => {
try { try {
await createPromptWords({ await createPromptWords({
content: createValue.content, content: createValue.content,
type: createValue.type type: createValue.type,
}) });
setAllLoading({ ...allLoading, createModalLoading: false }); setAllLoading({ ...allLoading, createModalLoading: false });
actionRef.current?.reload(); actionRef.current?.reload();
} catch(error) { } catch (error) {
setAllLoading({ ...allLoading, createModalLoading: false }); setAllLoading({ ...allLoading, createModalLoading: false });
message.error('新增提示用语失败,请重试!') message.error('新增提示用语失败,请重试!');
} }
}; };
...@@ -160,28 +167,28 @@ const PromptWord = () => { ...@@ -160,28 +167,28 @@ const PromptWord = () => {
try { try {
await deletePromptWords({ await deletePromptWords({
id: currentRow.id id: currentRow.id,
}); });
setAllLoading({ ...allLoading, deleteModalLoading: false }); setAllLoading({ ...allLoading, deleteModalLoading: false });
actionRef.current?.reload(); actionRef.current?.reload();
} catch(error) { } catch (error) {
setAllLoading({ ...allLoading, deleteModalLoading: false }); setAllLoading({ ...allLoading, deleteModalLoading: false });
message.error('删除提示用语失败,请重试!') message.error('删除提示用语失败,请重试!');
} }
}; };
return ( return (
<PageContainer> <PageContainer>
<DeletePromptModal <DeletePromptModal
open={deleteModalOpen} open={deleteModalOpen}
setOpen={setDeleteModalOpen} setOpen={setDeleteModalOpen}
title='删除提示用语' title="删除提示用语"
tip='确定要删除这段提示词语吗?' tip="确定要删除这段提示词语吗?"
content='一旦删除后,用户无法看到这一条提示词,建议谨慎操作。' content="一旦删除后,用户无法看到这一条提示词,建议谨慎操作。"
handleDeletePrompt={handleDeletePrompt} handleDeletePrompt={handleDeletePrompt}
loading={allLoading.deleteModalLoading} loading={allLoading.deleteModalLoading}
/> />
<EditPromptModal <EditPromptModal
open={editAndAddModalOpen} open={editAndAddModalOpen}
setOpen={setEditAndDeleteModalOpen} setOpen={setEditAndDeleteModalOpen}
types={types} types={types}
...@@ -189,7 +196,9 @@ const PromptWord = () => { ...@@ -189,7 +196,9 @@ const PromptWord = () => {
handleEditPrompt={handleEditPrompt} handleEditPrompt={handleEditPrompt}
oldRow={currentRow} oldRow={currentRow}
handleCreatePrompt={handleCreatePrompt} handleCreatePrompt={handleCreatePrompt}
loading={modalType === 'create' ? allLoading.createModalLoading : allLoading.editModalLoading} loading={
modalType === 'create' ? allLoading.createModalLoading : allLoading.editModalLoading
}
/> />
<ProTable <ProTable
request={async (params = { pageSize: 10, current: 0 }) => { request={async (params = { pageSize: 10, current: 0 }) => {
...@@ -197,9 +206,9 @@ const PromptWord = () => { ...@@ -197,9 +206,9 @@ const PromptWord = () => {
const promptListParams = { const promptListParams = {
filter: params?.promptWord || '', filter: params?.promptWord || '',
type: params?.type || '', type: params?.type || '',
pageIndex: params?.current as number - 1, pageIndex: (params?.current as number) - 1,
pageSize: params?.pageSize, pageSize: params?.pageSize,
} };
try { try {
const response = await pagePromptWords(promptListParams); const response = await pagePromptWords(promptListParams);
setAllLoading({ ...allLoading, listLoading: false }); setAllLoading({ ...allLoading, listLoading: false });
...@@ -207,15 +216,15 @@ const PromptWord = () => { ...@@ -207,15 +216,15 @@ const PromptWord = () => {
data: response.items, data: response.items,
total: response.totalCount, total: response.totalCount,
success: !isEmpty(response), success: !isEmpty(response),
} };
} catch(error) { } catch (error) {
setAllLoading({ ...allLoading, listLoading: false }); setAllLoading({ ...allLoading, listLoading: false });
message.error('请求列表失败,请重试!'); message.error('请求列表失败,请重试!');
return { return {
data: [], data: [],
total: 0, total: 0,
success: false, success: false,
} };
} }
}} }}
actionRef={actionRef} actionRef={actionRef}
......
...@@ -110,58 +110,61 @@ const UserManage = () => { ...@@ -110,58 +110,61 @@ const UserManage = () => {
title: '创建时间', title: '创建时间',
dataIndex: 'creationTime', dataIndex: 'creationTime',
hideInSearch: true, hideInSearch: true,
valueType: 'date',
},
{
title: '备注',
hideInSearch: true,
dataIndex: 'creationTime',
valueType: 'date',
}, },
{ {
title: '操作', title: '操作',
valueType: 'option', valueType: 'option',
key: 'option', key: 'option',
render: (_text, record, _, _action) => [ width: '20%',
<a render: (_text, record, _, _action) => (
key="editable" <>
onClick={() => { <Button
setAccountModalName('编辑账号'); size="small"
setEditMessage({ id: record.id }); type="link"
const data = { key="edit"
id: record.id, onClick={() => {
Name: record.name, setAccountModalName('编辑账号');
UserName: record.userName, setEditMessage({ id: record.id });
Role: record.roles, const data = {
isActive: record.isActive, id: record.id,
}; Name: record.name,
accountForm.setFieldsValue(data); UserName: record.userName,
showModal(); Role: record.roles,
}} isActive: record.isActive,
> };
编辑 accountForm.setFieldsValue(data);
</a>, showModal();
<a }}
onClick={() => { >
setResetPassword({ 编辑
id: record.id, </Button>
}); <Button
setIsModalResetPassword(true); size="small"
}} type="link"
key="reset" onClick={() => {
> setResetPassword({
重置 id: record.id,
</a>, });
<a setIsModalResetPassword(true);
key="remove" }}
onClick={() => { key="reset"
setDeleteMessage(record); >
setIsModalDeleteAccountOpen(true); 重置
}} </Button>
> <Button
删除 size="small"
</a>, type="link"
], danger
key="remove"
onClick={() => {
setDeleteMessage(record);
setIsModalDeleteAccountOpen(true);
}}
>
删除
</Button>
</>
),
}, },
]; ];
...@@ -445,7 +448,6 @@ const UserManage = () => { ...@@ -445,7 +448,6 @@ const UserManage = () => {
pageSize: 9, pageSize: 9,
}} }}
options={false} options={false}
dateFormatter="string"
headerTitle="账号列表" headerTitle="账号列表"
toolBarRender={() => [ toolBarRender={() => [
<Button <Button
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment