Commit e1d11319 authored by Ylg's avatar Ylg

resove conflict

parents 221fce5b 5208b584
......@@ -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
......
......@@ -5,7 +5,7 @@
"description": "An out-of-box UI solution for enterprise applications",
"scripts": {
"analyze": "cross-env ANALYZE=1 umi build",
"build": "umi build",
"build": "SET NODE_OPTIONS=--openssl-legacy-provider && umi build",
"deploy": "npm run build && npm run gh-pages",
"dev": "npm run start:dev",
"gh-pages": "gh-pages -d dist",
......
......@@ -29,7 +29,6 @@ export const layout = ({ initialState, setInitialState }) => {
return {
rightContentRender: () => <RightContent />,
disableContentMargin: false,
footerRender: () => <Footer />,
menuHeaderRender: undefined,
// 自定义 403 页面
......
import { Form, Modal, Select } from "antd";
import TextArea from "antd/lib/input/TextArea";
import { useEffect, useState } from "react";
import { Form, Modal, Select } from 'antd';
import TextArea from 'antd/lib/input/TextArea';
import { useEffect, useState } from 'react';
import styles from './index.less';
import { IFormValue } from "@/pages/PromptWord";
import type { IFormValue } from '@/pages/PromptWord';
interface IEditPromptModalProps {
open: boolean;
......@@ -16,34 +16,35 @@ interface IEditPromptModalProps {
}
const EditPromptModal = (props: IEditPromptModalProps) => {
const { open, setOpen, types, modalType, handleEditPrompt, loading, oldRow, handleCreatePrompt } = props;
const { open, setOpen, types, modalType, handleEditPrompt, loading, oldRow, handleCreatePrompt } =
props;
const [currentSelectValue, setCurrentSelectValue] = useState<string | null>("请选择");
const [currentSelectValue, setCurrentSelectValue] = useState<string | null>('请选择');
const [textAreaValue, setTextAreaValue] = useState('');
useEffect(() => {
if(modalType === 'create') {
if (modalType === 'create') {
setTextAreaValue('');
setCurrentSelectValue('');
} else {
setTextAreaValue(oldRow.content);
setCurrentSelectValue(oldRow.type || '请选择');
}
}, [open])
}, [open]);
const handleSavePrompt = async () => {
if(modalType === 'create') {
if (modalType === 'create') {
await handleCreatePrompt({
type: currentSelectValue,
content: textAreaValue,
});
}
}
if(modalType === 'edit') {
if (modalType === 'edit') {
await handleEditPrompt({
type: currentSelectValue,
content: textAreaValue,
})
});
}
setOpen(false);
......@@ -60,39 +61,36 @@ const EditPromptModal = (props: IEditPromptModalProps) => {
confirmLoading={loading}
wrapClassName={styles.modal}
title={modalType === 'create' ? '新增提示用语' : '编辑提示用语'}
okText='保存'
onOk={handleSavePrompt}
okText="保存"
onOk={handleSavePrompt}
onCancel={() => {
setCurrentSelectValue('请选择');
setOpen(false);
}}
}}
width={574}
bodyStyle={{
padding: '20px'
padding: '20px',
}}
>
<Form
labelAlign="right"
{...layout}
>
<Form.Item
label="类型:"
>
<Form labelAlign="right" {...layout}>
<Form.Item label="类型:">
<Select
onChange={(value: string) => {
setCurrentSelectValue(value);
}}
value={currentSelectValue}
>
{types.map(item => <Select.Option value={item} key={item}>{item}</Select.Option>)}
onChange={(value: string) => {
setCurrentSelectValue(value);
}}
value={currentSelectValue}
>
{types.map((item) => (
<Select.Option value={item} key={item}>
{item}
</Select.Option>
))}
</Select>
</Form.Item>
<Form.Item
label="提示词语"
>
<TextArea
<Form.Item label="提示词语">
<TextArea
style={{
height: '200px'
height: '200px',
}}
value={textAreaValue}
onChange={(e) => {
......@@ -102,7 +100,7 @@ const EditPromptModal = (props: IEditPromptModalProps) => {
</Form.Item>
</Form>
</Modal>
)
}
);
};
export default EditPromptModal;
\ No newline at end of file
export default EditPromptModal;
import { Modal } from "antd";
import { Modal } from 'antd';
import styles from './index.less';
import { Exclamtion } from "../Icons/Icons";
import { Exclamtion } from '../Icons/Icons';
interface IDeletePromptModalProps {
title: string;
open: boolean;
......@@ -12,25 +12,17 @@ interface IDeletePromptModalProps {
}
const DeletePromptModal = (props: IDeletePromptModalProps) => {
const {
title,
open,
setOpen,
tip,
content,
loading,
handleDeletePrompt,
} = props;
const { title, open, setOpen, tip, content, loading, handleDeletePrompt } = props;
const handleSavePrompt = async () => {
await handleDeletePrompt();
setOpen(false);
}
};
return (
<Modal
title={title}
okText='确认'
okText="确认"
open={open}
onOk={handleSavePrompt}
onCancel={() => {
......@@ -41,11 +33,9 @@ const DeletePromptModal = (props: IDeletePromptModalProps) => {
<div className={styles.deleteTitle}>
<Exclamtion /> {tip}
</div>
<div className={styles.deleteContent}>
{content}
</div>
<div className={styles.deleteContent}>{content}</div>
</Modal>
)
}
);
};
export default DeletePromptModal;
\ No newline at end of file
export default DeletePromptModal;
......@@ -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;
}
......@@ -81,6 +81,7 @@
color: #ffffff;
font-size: 18px;
line-height: 25px;
cursor: pointer;
}
.footer {
......
......@@ -133,7 +133,7 @@ const Chat: React.FC = () => {
/>
</Col>
<Col>AI改变世界</Col>
<Col pull={1}></Col>
<Col pull={1} />
</Row>
);
};
......@@ -162,13 +162,11 @@ const Chat: React.FC = () => {
span={24}
className={styles.chatFooterItem}
hidden={!access.roles?.find((x) => ['管理员', 'admin'].includes(x))}
onClick={() => {
history.push('/');
}}
>
<Space
wrap
onClick={() => {
history.push('/');
}}
>
<Space wrap>
<SettingOutlined />
后台管理
</Space>
......@@ -219,7 +217,7 @@ const Chat: React.FC = () => {
</Col>
{promptLoading && (
<Col span={24}>
<PageLoading></PageLoading>
<PageLoading />
</Col>
)}
<Col span={'24'} style={{ padding: isMobile ? '' : '0 100px' }}>
......
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,14 +37,13 @@ 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);
......@@ -48,8 +53,7 @@ const PromptWord = () => {
const columns: any[] = [
{
title: '类型',
width: '20%',
title: '提示类型',
key: 'type',
dataIndex: 'type',
valueType: 'select',
......@@ -58,10 +62,10 @@ const PromptWord = () => {
options: types.map((type) => {
return {
label: type,
value: type
}
})
}
value: type,
};
}),
},
},
{
title: '提示词语',
......@@ -70,7 +74,7 @@ const PromptWord = () => {
dataIndex: 'content',
ellipsis: true,
search: true,
order: 2
order: 2,
},
{
title: '创建时间',
......@@ -86,28 +90,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>
),
},
......@@ -117,7 +124,7 @@ const PromptWord = () => {
const data = await typePromptWords();
setTypes(data);
};
useEffect(() => {
fetchTypes();
}, []);
......@@ -128,13 +135,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('编辑提示用语失败,请重试!');
}
};
......@@ -143,13 +150,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('新增提示用语失败,请重试!');
}
};
......@@ -158,28 +165,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}
......@@ -187,7 +194,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 }) => {
......@@ -195,9 +204,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 });
......@@ -205,15 +214,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}
......@@ -224,7 +233,6 @@ const PromptWord = () => {
pageSize: 10,
}}
options={false}
dateFormatter="string"
headerTitle="账号列表"
toolBarRender={() => [
<Button
......
......@@ -13,7 +13,7 @@ import { ProTable } from '@ant-design/pro-components';
import { Button, Col, Divider, Form, Input, Modal, Radio, Row, Switch, message } from 'antd';
import classNames from 'classnames';
import { isEmpty } from 'lodash';
import { useRef, useState } from 'react';
import { useRef, useState, useEffect } from 'react';
import styles from './index.less';
import { Exclamtion } from '@/components/Icons/Icons';
......@@ -51,20 +51,26 @@ const UserManage = () => {
const [accountForm] = Form.useForm();
const [resetPasswordForm] = Form.useForm();
const showModal = () => {
useEffect(() => {
getRole().then((res) => {
if (!isEmpty(res)) {
setRoles(res);
setIsModalAccountOpen(true);
}
});
}, []);
const showModal = () => {
if (!isEmpty(roles)) {
setIsModalAccountOpen(true);
}
};
const columns: any[] = [
{
title: '用户',
title: '用户账号',
dataIndex: 'name',
ellipsis: true,
width: '20%',
},
{
title: '用户账号',
......@@ -92,11 +98,11 @@ const UserManage = () => {
status: 'Error',
},
},
render(text, record) {
render(_text, record) {
return (
<div className={styles.isActive}>
<span className={classNames(styles.dot, record.isActive ? styles.green : styles.red)} />
<div>{record.isActive ? '启' : '禁用'}</div>
<div>{record.isActive ? '启' : '禁用'}</div>
</div>
);
},
......@@ -105,58 +111,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>
</>
),
},
];
......@@ -171,19 +180,14 @@ const UserManage = () => {
const createdAccount = (values: any) => {
setLoading(true);
const data = {
role: values.roles,
Phone: values.phoneNumber,
Password: values,
};
CreatedAccount(values)
.then((res) => {
.then(() => {
setLoading(false);
setIsModalAccountOpen(false);
accountForm.resetFields();
actionRef.current?.reload();
})
.catch((error) => {
.catch(() => {
setLoading(false);
});
};
......@@ -195,14 +199,14 @@ const UserManage = () => {
id: editMessage.id,
};
postEditUser(data)
.then((res) => {
.then(() => {
setLoading(false);
setIsModalAccountOpen(false);
message.success('编辑成功');
accountForm.resetFields();
actionRef.current?.reload();
})
.catch((error) => {
.catch(() => {
setLoading(false);
});
};
......@@ -244,12 +248,12 @@ const UserManage = () => {
postDeleteUser({
id: deleteMessage.id,
})
.then((res) => {
.then(() => {
setIsModalDeleteAccountOpen(false);
actionRef.current?.reload();
message.success('删除成功');
})
.catch((err) => {
.catch(() => {
setIsModalDeleteAccountOpen(false);
});
};
......@@ -261,14 +265,14 @@ const UserManage = () => {
Password: values?.newPassword,
};
postResetUser(data)
.then((res) => {
.then(() => {
setResetLoading(false);
setIsModalResetPassword(false);
actionRef.current?.reload();
resetPasswordForm.resetFields();
message.success('重置成功');
})
.catch((err) => {
.catch(() => {
setResetLoading(false);
});
};
......@@ -422,9 +426,6 @@ const UserManage = () => {
</Form>
</Modal>
<ProTable
columns={columns}
actionRef={actionRef}
cardBordered
request={async (params = { pageSize: 10, current: 0 }, sort, filter) => {
console.log(sort, filter, params);
const defaultParams = {
......@@ -440,13 +441,14 @@ const UserManage = () => {
success: !isEmpty(response),
};
}}
actionRef={actionRef}
columns={columns}
cardBordered
rowKey="id"
pagination={{
pageSize: 9,
onChange: (page) => {},
pageSize: 10,
}}
options={false}
dateFormatter="string"
headerTitle="账号列表"
toolBarRender={() => [
<Button
......
......@@ -23,7 +23,11 @@
content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"
/>
<title>Ant Design Pro</title>
<link rel="icon" href="<%= context.config.publicPath +'favicon.ico'%>" type="image/x-icon" />
<link
rel="icon"
href="https://baibaomen.oss-cn-hangzhou.aliyuncs.com/zhensheng/favicon.ico"
type="image/x-icon"
/>
</head>
<body>
<noscript>
......
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