Commit 589cbe51 authored by littleforest's avatar littleforest
parents bd776721 fd5aa690
......@@ -17,7 +17,7 @@ export default defineConfig({
layout: {
// https://umijs.org/zh-CN/plugins/plugin-layout
locale: true,
siderWidth: 208,
siderWidth: 240,
...defaultSettings,
},
// https://umijs.org/zh-CN/plugins/plugin-locale
......@@ -42,6 +42,14 @@ export default defineConfig({
// 如果不想要 configProvide 动态设置主题需要把这个设置为 default
// 只有设置为 variable, 才能使用 configProvide 动态设置主色调
// 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',
},
// esbuild is father build tools
......
......@@ -29,7 +29,6 @@ export const layout = ({ initialState, setInitialState }) => {
return {
rightContentRender: () => <RightContent />,
disableContentMargin: false,
footerRender: () => <Footer />,
menuHeaderRender: undefined,
// 自定义 403 页面
......
......@@ -97,3 +97,14 @@ ol {
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 { ActionType, PageContainer } 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 { useEffect, useRef, useState } from 'react';
import styles from './index.less';
import EditPromptModal from '@/components/EditAndAddPromptModal';
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 {
id: string;
......@@ -31,18 +37,16 @@ interface ILoading {
}
const PromptWord = () => {
const actionRef = useRef<ActionType>();
const [allLoading, setAllLoading] = useState<ILoading>({
editModalLoading: false,
createModalLoading: false,
deleteModalLoading: false,
listLoading: false
listLoading: false,
});
const [editAndAddModalOpen, setEditAndDeleteModalOpen] = useState(false);
const [deleteModalOpen, setDeleteModalOpen] = useState(false);
const [promptList, setPromptList] = useState<IPromptList[]>([]);
const [modalType, setModalType] = useState<'create' | 'edit' | ''>('');
const [types, setTypes] = useState<string[]>([]);
......@@ -60,10 +64,10 @@ const PromptWord = () => {
options: types.map((type) => {
return {
label: type,
value: type
}
})
}
value: type,
};
}),
},
},
{
title: '提示词语',
......@@ -72,7 +76,7 @@ const PromptWord = () => {
dataIndex: 'content',
ellipsis: true,
search: true,
order: 2
order: 2,
},
{
title: '创建时间',
......@@ -88,28 +92,31 @@ const PromptWord = () => {
key: 'option',
render: (_: unknown, record: IPromptList) => (
<div className={styles.table_action}>
<div
className={styles.table_action_edit}
onClick={() => {
setCurrentRaw(record);
setEditAndDeleteModalOpen(true);
setModalType('edit');
}}
>
<EditOutlined />
<span>编辑</span>
</div>
<span style={{ margin: '0 9px' }}>|</span>
<div
className={styles.table_action_delete}
onClick={() => {
setDeleteModalOpen(true);
setCurrentRaw(record);
}}
>
<DeleteOutlined />
<span>删除</span>
</div>
<Space wrap>
<div
className={styles.table_action_edit}
onClick={() => {
setCurrentRaw(record);
setEditAndDeleteModalOpen(true);
setModalType('edit');
}}
>
<Button size="small" type="link">
编辑
</Button>
</div>
<div
className={styles.table_action_delete}
onClick={() => {
setDeleteModalOpen(true);
setCurrentRaw(record);
}}
>
<Button size="small" type="link" danger>
删除
</Button>
</div>
</Space>
</div>
),
},
......@@ -119,7 +126,7 @@ const PromptWord = () => {
const data = await typePromptWords();
setTypes(data);
};
useEffect(() => {
fetchTypes();
}, []);
......@@ -130,13 +137,13 @@ const PromptWord = () => {
await updatePromptWords({
id: currentRow.id,
content: editValue.content,
type: editValue.type
type: editValue.type,
});
setAllLoading({ ...allLoading, editModalLoading: false });
actionRef.current?.reload();
} catch(error) {
} catch (error) {
setAllLoading({ ...allLoading, editModalLoading: false });
message.error('编辑提示用语失败,请重试!')
message.error('编辑提示用语失败,请重试!');
}
};
......@@ -145,13 +152,13 @@ const PromptWord = () => {
try {
await createPromptWords({
content: createValue.content,
type: createValue.type
})
type: createValue.type,
});
setAllLoading({ ...allLoading, createModalLoading: false });
actionRef.current?.reload();
} catch(error) {
} catch (error) {
setAllLoading({ ...allLoading, createModalLoading: false });
message.error('新增提示用语失败,请重试!')
message.error('新增提示用语失败,请重试!');
}
};
......@@ -160,28 +167,28 @@ const PromptWord = () => {
try {
await deletePromptWords({
id: currentRow.id
id: currentRow.id,
});
setAllLoading({ ...allLoading, deleteModalLoading: false });
actionRef.current?.reload();
} catch(error) {
} catch (error) {
setAllLoading({ ...allLoading, deleteModalLoading: false });
message.error('删除提示用语失败,请重试!')
message.error('删除提示用语失败,请重试!');
}
};
return (
<PageContainer>
<DeletePromptModal
<DeletePromptModal
open={deleteModalOpen}
setOpen={setDeleteModalOpen}
title='删除提示用语'
tip='确定要删除这段提示词语吗?'
content='一旦删除后,用户无法看到这一条提示词,建议谨慎操作。'
title="删除提示用语"
tip="确定要删除这段提示词语吗?"
content="一旦删除后,用户无法看到这一条提示词,建议谨慎操作。"
handleDeletePrompt={handleDeletePrompt}
loading={allLoading.deleteModalLoading}
/>
<EditPromptModal
<EditPromptModal
open={editAndAddModalOpen}
setOpen={setEditAndDeleteModalOpen}
types={types}
......@@ -189,7 +196,9 @@ const PromptWord = () => {
handleEditPrompt={handleEditPrompt}
oldRow={currentRow}
handleCreatePrompt={handleCreatePrompt}
loading={modalType === 'create' ? allLoading.createModalLoading : allLoading.editModalLoading}
loading={
modalType === 'create' ? allLoading.createModalLoading : allLoading.editModalLoading
}
/>
<ProTable
request={async (params = { pageSize: 10, current: 0 }) => {
......@@ -197,9 +206,9 @@ const PromptWord = () => {
const promptListParams = {
filter: params?.promptWord || '',
type: params?.type || '',
pageIndex: params?.current as number - 1,
pageIndex: (params?.current as number) - 1,
pageSize: params?.pageSize,
}
};
try {
const response = await pagePromptWords(promptListParams);
setAllLoading({ ...allLoading, listLoading: false });
......@@ -207,15 +216,15 @@ const PromptWord = () => {
data: response.items,
total: response.totalCount,
success: !isEmpty(response),
}
} catch(error) {
};
} catch (error) {
setAllLoading({ ...allLoading, listLoading: false });
message.error('请求列表失败,请重试!');
return {
data: [],
total: 0,
success: false,
}
};
}
}}
actionRef={actionRef}
......
......@@ -110,58 +110,61 @@ const UserManage = () => {
title: '创建时间',
dataIndex: 'creationTime',
hideInSearch: true,
valueType: 'date',
},
{
title: '备注',
hideInSearch: true,
dataIndex: 'creationTime',
valueType: 'date',
},
{
title: '操作',
valueType: 'option',
key: 'option',
render: (_text, record, _, _action) => [
<a
key="editable"
onClick={() => {
setAccountModalName('编辑账号');
setEditMessage({ id: record.id });
const data = {
id: record.id,
Name: record.name,
UserName: record.userName,
Role: record.roles,
isActive: record.isActive,
};
accountForm.setFieldsValue(data);
showModal();
}}
>
编辑
</a>,
<a
onClick={() => {
setResetPassword({
id: record.id,
});
setIsModalResetPassword(true);
}}
key="reset"
>
重置
</a>,
<a
key="remove"
onClick={() => {
setDeleteMessage(record);
setIsModalDeleteAccountOpen(true);
}}
>
删除
</a>,
],
width: '20%',
render: (_text, record, _, _action) => (
<>
<Button
size="small"
type="link"
key="edit"
onClick={() => {
setAccountModalName('编辑账号');
setEditMessage({ id: record.id });
const data = {
id: record.id,
Name: record.name,
UserName: record.userName,
Role: record.roles,
isActive: record.isActive,
};
accountForm.setFieldsValue(data);
showModal();
}}
>
编辑
</Button>
<Button
size="small"
type="link"
onClick={() => {
setResetPassword({
id: record.id,
});
setIsModalResetPassword(true);
}}
key="reset"
>
重置
</Button>
<Button
size="small"
type="link"
danger
key="remove"
onClick={() => {
setDeleteMessage(record);
setIsModalDeleteAccountOpen(true);
}}
>
删除
</Button>
</>
),
},
];
......@@ -445,7 +448,6 @@ const UserManage = () => {
pageSize: 9,
}}
options={false}
dateFormatter="string"
headerTitle="账号列表"
toolBarRender={() => [
<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