From 2d7509153585c5cf937a336fa8e3ac64a3afd4e7 Mon Sep 17 00:00:00 2001 From: dark Date: Mon, 22 Apr 2024 01:22:55 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=E8=8F=9C=E5=8D=95=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=EF=BC=8C=E5=A2=9E=E5=8A=A0=E5=A4=9A=E8=AF=AD=E8=A8=80?= =?UTF-8?q?=20=E6=B7=BB=E5=8A=A0=E8=A7=92=E8=89=B2=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/locales/lang/en-US.ts | 95 ++++++++++++++----------- src/locales/lang/pages/system/menus/en-US.ts | 3 + src/locales/lang/pages/system/menus/zh-CN.ts | 24 +++++++ src/locales/lang/zh-CN.ts | 94 +++++++++++++----------- src/pages/system/menus/index.tsx | 45 ++++++++---- src/pages/system/menus/store.ts | 13 ++-- src/pages/system/roles/index.tsx | 102 +++++++++++++++++++++++++-- src/pages/system/roles/store.ts | 25 +++++++ src/pages/system/roles/style.ts | 22 ++++++ src/service/base.ts | 4 +- src/service/system.ts | 32 +++++---- vite.config.ts | 2 +- 12 files changed, 337 insertions(+), 124 deletions(-) create mode 100644 src/locales/lang/pages/system/menus/en-US.ts create mode 100644 src/locales/lang/pages/system/menus/zh-CN.ts create mode 100644 src/pages/system/roles/store.ts create mode 100644 src/pages/system/roles/style.ts diff --git a/src/locales/lang/en-US.ts b/src/locales/lang/en-US.ts index c964dce..94286ee 100644 --- a/src/locales/lang/en-US.ts +++ b/src/locales/lang/en-US.ts @@ -1,50 +1,63 @@ import antdEN from 'antd/locale/en_US' +import menus from './pages/system/menus/en-US' + export default { - ...antdEN, + ...antdEN, - error: { - '404': { - title: 'not fund', - message: 'Sorry, not found this page.' + error: { + '404': { + title: 'not fund', + message: 'Sorry, not found this page.' + }, + '403': { + title: 'not authorized', + message: 'Sorry, you are not authorized to access this page.' + }, + 'error': { + title: 'error info', + }, + }, + route: { + goBack: 'Go Back', + }, + app: { + header: { + logout: 'logout', + } }, - '403': { - title: 'not authorized', - message: 'Sorry, you are not authorized to access this page.' + login: { + title: 'Account Password Login', + username: 'Username', + usernameMsg: 'Please enter your username', + password: 'Password', + passwordMsg: 'Please enter your password', + code: 'Verification Code', + codeMsg: 'Please enter the verification code', + submit: 'Login', + success: 'Login success' }, - 'error': { - title: 'error info', + home: { + welcome: 'Welcome to' }, - }, - route: { - goBack: 'Go Back', - }, - app: { - header: { - logout: 'logout', + system: { + menus, + }, + + errorTitle: 'Error', + successTitle: 'Success', + success: 'Submit Success', + fail: 'Submit Fail', + saveSuccess: 'Save Success', + saveFail: 'Save Fail', + + tabs: { + refresh: 'Refresh', + maximize: 'Maximize', + closeCurrent: 'Close current', + closeLeft: 'Close Left', + closeRight: 'Close Right', + closeOther: 'Close other', + closeAll: 'Close All' } - }, - login:{ - title: 'Account Password Login', - username: 'Username', - usernameMsg: 'Please enter your username', - password: 'Password', - passwordMsg: 'Please enter your password', - code: 'Verification Code', - codeMsg: 'Please enter the verification code', - submit: 'Login', - success: 'Login success' - }, - home: { - welcome: 'Welcome to' - }, - tabs: { - refresh: 'Refresh', - maximize: 'Maximize', - closeCurrent: 'Close current', - closeLeft: 'Close Left', - closeRight: 'Close Right', - closeOther: 'Close other', - closeAll: 'Close All' - } } diff --git a/src/locales/lang/pages/system/menus/en-US.ts b/src/locales/lang/pages/system/menus/en-US.ts new file mode 100644 index 0000000..5c933b1 --- /dev/null +++ b/src/locales/lang/pages/system/menus/en-US.ts @@ -0,0 +1,3 @@ +export default { + +} \ No newline at end of file diff --git a/src/locales/lang/pages/system/menus/zh-CN.ts b/src/locales/lang/pages/system/menus/zh-CN.ts new file mode 100644 index 0000000..e1b5538 --- /dev/null +++ b/src/locales/lang/pages/system/menus/zh-CN.ts @@ -0,0 +1,24 @@ +export default { + title: '菜单', + setting: '配置', + saveSuccess: '保存成功', + form:{ + title: '菜单名称', + parent: '上级菜单', + type:'类型', + typeOptions: { + menu: '菜单', + iframe: 'iframe', + link: '外链', + button: '按钮', + }, + name: '别名', + icon: '图标', + sort: '排序', + path: '路由', + component: '视图', + componentHelp: '视图路径,相对于src/pages,菜单组可以不填', + save: '保存', + }, + button: '按钮' +} \ No newline at end of file diff --git a/src/locales/lang/zh-CN.ts b/src/locales/lang/zh-CN.ts index d38f419..2e0d13c 100644 --- a/src/locales/lang/zh-CN.ts +++ b/src/locales/lang/zh-CN.ts @@ -1,49 +1,61 @@ import antdZh from 'antd/locale/zh_CN' +import menus from './pages/system/menus/zh-CN.ts' + export default { - ...antdZh, - error: { - '404': { - title: '无法找到', - message: '找不到此页面' + ...antdZh, + error: { + '404': { + title: '无法找到', + message: '找不到此页面' + }, + '403': { + title: '没有权限', + message: '对不起,您没有权限查看此页面。' + }, + 'error': { + title: '错误信息', + }, + }, + route: { + goBack: '返回', + }, + app: { + header: { + logout: '退出登录', + } }, - '403': { - title: '没有权限', - message: '对不起,您没有权限查看此页面。' + login: { + title: '账户密码登录', + username: '用户名', + usernameMsg: '请输入用户名', + password: '密码', + passwordMsg: '请输入密码', + code: '验证码', + codeMsg: '请输入验证码', + submit: '登录', + success: '登录成功' }, - 'error': { - title: '错误信息', + home: { + welcome: '欢迎使用' + }, + + system: { + menus, }, - }, - route: { - goBack: '返回', - }, - app: { - header: { - logout: '退出登录', + errorTitle: '错误', + successTitle: '成功', + success: '提交成功', + fail: '提交失败', + saveSuccess: '保存成功', + saveFail: '保存失败', + tabs: { + refresh: '刷新', + maximize: '最大化', + closeCurrent: '关闭当前', + closeLeft: '关闭左侧', + closeRight: '关闭右侧', + closeOther: '关闭其它', + closeAll: '关闭所有' } - }, - login:{ - title: '账户密码登录', - username: '用户名', - usernameMsg: '请输入用户名', - password: '密码', - passwordMsg: '请输入密码', - code: '验证码', - codeMsg: '请输入验证码', - submit: '登录', - success: '登录成功' - }, - home: { - welcome: '欢迎使用' - }, - tabs: { - refresh: '刷新', - maximize: '最大化', - closeCurrent: '关闭当前', - closeLeft: '关闭左侧', - closeRight: '关闭右侧', - closeOther: '关闭其它', - closeAll: '关闭所有' - } } diff --git a/src/pages/system/menus/index.tsx b/src/pages/system/menus/index.tsx index 1b8a629..7484454 100644 --- a/src/pages/system/menus/index.tsx +++ b/src/pages/system/menus/index.tsx @@ -1,10 +1,8 @@ import { useTranslation } from '@/i18n.ts' import { PageContainer, ProCard } from '@ant-design/pro-components' -import { Button, Form, Input, message, Radio, TreeSelect } from 'antd' +import { Button, Form, Input, message, Radio, TreeSelect, InputNumber, notification } from 'antd' import { useAtomValue } from 'jotai' import { menuDataAtom, saveOrUpdateMenuAtom, selectedMenuAtom } from './store.ts' -import { createLazyFileRoute } from '@tanstack/react-router' -import { NumberPicker } from '@formily/antd-v5' import IconPicker from '@/components/icon/picker' import ButtonTable from './components/ButtonTable.tsx' import { Flexbox } from 'react-layout-kit' @@ -14,6 +12,7 @@ import { MenuItem } from '@/types' import MenuTree from './components/MenuTree.tsx' import BatchButton from '@/pages/system/menus/components/BatchButton.tsx' import { useEffect } from 'react' +import { createLazyFileRoute } from '@tanstack/react-router' const Menus = () => { @@ -21,19 +20,26 @@ const Menus = () => { const { styles } = useStyle() const { t } = useTranslation() const [ form ] = Form.useForm() - const { mutate, isPending, isSuccess, isError } = useAtomValue(saveOrUpdateMenuAtom) + const { mutate, isPending, isSuccess, error, isError } = useAtomValue(saveOrUpdateMenuAtom) const { data = [] } = useAtomValue(menuDataAtom) const currentMenu = useAtomValue(selectedMenuAtom) ?? {} useEffect(() => { if (isSuccess) { - message.success(t('system.menus.saveSuccess', '保存成功')) + message.success(t('saveSuccess', '保存成功')) + } + + if (isError) { + notification.error({ + message: t('errorTitle', '错误'), + description: (error as any).message ?? t('saveFail', '保存失败'), + }) } + }, [ isError, isSuccess ]) return ( - + @@ -62,7 +68,7 @@ const Menus = () => { className={styles.formSetting} > -