From f12f2e0f0029e31929deac1207746dd3a4cfc794 Mon Sep 17 00:00:00 2001 From: Yvan <8574526@qq,com> Date: Thu, 8 Jan 2026 11:20:29 +0800 Subject: [PATCH] =?UTF-8?q?=E5=89=8D=E7=AB=AF=E9=87=8D=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/config/config.ts | 2 +- web/config/defaultSettings.ts | 38 +- web/config/routes.ts | 270 ++- web/package.json | 25 +- web/src/access.ts | 128 +- web/src/app.tsx | 190 +- web/src/assets/index.ts | 54 + web/src/components/ArrayCtrl/ArrayCtrl.tsx | 74 + web/src/components/ArrayCtrl/index.ts | 2 + web/src/components/BottomInfo/BottomInfo.tsx | 47 + web/src/components/BottomInfo/index.ts | 2 + web/src/components/Charts/BaseChart.tsx | 85 + web/src/components/Charts/LineChart.tsx | 61 + web/src/components/Charts/PieChart.tsx | 58 + web/src/components/Charts/index.ts | 6 + .../components/ErrorPreview/ErrorPreview.tsx | 71 + web/src/components/ErrorPreview/index.ts | 2 + .../components/ExportExcel/ExportExcel.tsx | 62 + .../components/ExportExcel/ImportExcel.tsx | 77 + web/src/components/ExportExcel/index.ts | 2 + web/src/components/Footer/index.tsx | 22 +- web/src/components/Logo/Logo.tsx | 66 + web/src/components/Logo/index.ts | 2 + web/src/components/Office/DocxViewer.tsx | 53 + web/src/components/Office/ExcelViewer.tsx | 53 + web/src/components/Office/PDFViewer.tsx | 46 + web/src/components/Office/index.ts | 3 + .../components/RichText/RichTextEditor.tsx | 47 + .../components/RichText/RichTextViewer.tsx | 44 + web/src/components/RichText/index.ts | 2 + web/src/components/SelectFile/SelectFile.tsx | 143 ++ web/src/components/SelectFile/index.ts | 2 + .../components/SelectImage/SelectImage.tsx | 137 ++ web/src/components/SelectImage/index.ts | 2 + web/src/components/SvgIcon/SvgIcon.tsx | 67 + web/src/components/SvgIcon/index.ts | 2 + web/src/components/Upload/CommonUpload.tsx | 103 + web/src/components/Upload/Cropper.tsx | 333 +++ web/src/components/Upload/ImageUpload.tsx | 111 + web/src/components/Upload/QRCode.tsx | 117 + web/src/components/Upload/index.ts | 7 + web/src/components/WarningBar/WarningBar.tsx | 51 + web/src/components/WarningBar/index.ts | 2 + web/src/components/index.ts | 34 +- web/src/global.less | 108 + web/src/hooks/.gitkeep | 1 + web/src/hooks/index.ts | 9 + web/src/hooks/useAccess.ts | 49 + web/src/hooks/useAuth.ts | 51 + web/src/hooks/useCharts.ts | 36 + web/src/hooks/useDictionary.ts | 69 + web/src/hooks/useResponsive.ts | 50 + web/src/hooks/useWindowResize.ts | 36 + web/src/layouts/BasicLayout.tsx | 91 + web/src/layouts/BlankLayout.tsx | 12 + web/src/layouts/UserLayout.less | 37 + web/src/layouts/UserLayout.tsx | 29 + web/src/layouts/components/HeaderTools.tsx | 105 + web/src/layouts/components/Screenfull.tsx | 50 + web/src/layouts/components/Search.tsx | 235 ++ web/src/layouts/components/SettingDrawer.less | 575 +++++ web/src/layouts/components/SettingDrawer.tsx | 515 +++++ web/src/layouts/components/Sidebar.tsx | 243 ++ web/src/layouts/components/Tabs.tsx | 109 + web/src/layouts/components/index.ts | 9 + web/src/layouts/index.ts | 6 + web/src/layouts/modes/CombinationMode.tsx | 295 +++ web/src/layouts/modes/HeadMode.tsx | 155 ++ web/src/layouts/modes/NormalMode.tsx | 217 ++ web/src/layouts/modes/index.ts | 6 + web/src/models/.gitkeep | 1 + web/src/models/app.ts | 228 ++ web/src/models/dictionary.ts | 133 ++ web/src/models/index.ts | 22 + web/src/models/router.ts | 271 +++ web/src/models/user.ts | 106 + web/src/pages/about/index.tsx | 283 +++ web/src/pages/dashboard/components/Banner.tsx | 37 + web/src/pages/dashboard/components/Charts.tsx | 39 + web/src/pages/dashboard/components/Notice.tsx | 63 + .../dashboard/components/PluginTable.tsx | 138 ++ .../pages/dashboard/components/QuickLinks.tsx | 85 + .../pages/dashboard/components/StatCards.tsx | 73 + web/src/pages/dashboard/components/index.ts | 9 + web/src/pages/dashboard/index.less | 44 + web/src/pages/dashboard/index.tsx | 58 + web/src/pages/error/403.tsx | 23 + web/src/pages/error/404.tsx | 23 + web/src/pages/error/500.tsx | 23 + web/src/pages/error/index.ts | 7 + web/src/pages/error/reload.tsx | 36 + web/src/pages/example/breakpoint/index.less | 120 + web/src/pages/example/breakpoint/index.tsx | 209 ++ web/src/pages/example/customer/index.less | 30 + web/src/pages/example/customer/index.tsx | 251 +++ web/src/pages/example/upload/index.less | 95 + web/src/pages/example/upload/index.tsx | 398 ++++ web/src/pages/example/upload/scanUpload.less | 69 + web/src/pages/example/upload/scanUpload.tsx | 119 + web/src/pages/init/index.tsx | 358 +++ web/src/pages/person/index.tsx | 484 ++++ web/src/pages/plugin/announcement/index.less | 55 + web/src/pages/plugin/announcement/index.tsx | 313 +++ web/src/pages/plugin/email/index.less | 17 + web/src/pages/plugin/email/index.tsx | 69 + .../pages/system/api/components/ApiForm.tsx | 136 ++ .../pages/system/api/components/ApiSync.tsx | 384 ++++ web/src/pages/system/api/index.tsx | 355 +++ .../authority/components/ApiPermission.tsx | 214 ++ .../authority/components/AuthorityForm.tsx | 204 ++ .../authority/components/BtnPermission.tsx | 110 + .../authority/components/DataPermission.tsx | 180 ++ .../authority/components/MenuPermission.tsx | 307 +++ web/src/pages/system/authority/index.tsx | 259 +++ .../dictionary/components/DetailForm.tsx | 80 + .../dictionary/components/DictionaryForm.tsx | 65 + web/src/pages/system/dictionary/detail.tsx | 334 +++ web/src/pages/system/dictionary/index.less | 151 ++ web/src/pages/system/dictionary/index.tsx | 330 +++ .../system/menu/components/IconSelector.tsx | 343 +++ .../system/menu/components/MenuButtons.tsx | 108 + .../pages/system/menu/components/MenuForm.tsx | 553 +++++ .../system/menu/components/MenuParams.tsx | 122 + web/src/pages/system/menu/index.tsx | 269 +++ .../operation/components/RecordDetail.tsx | 96 + web/src/pages/system/operation/index.less | 102 + web/src/pages/system/operation/index.tsx | 316 +++ .../system/params/components/ParamsForm.tsx | 49 + web/src/pages/system/params/index.less | 52 + web/src/pages/system/params/index.tsx | 357 +++ .../user/components/AuthoritySelect.tsx | 118 + .../pages/system/user/components/UserForm.tsx | 244 ++ web/src/pages/system/user/index.tsx | 387 ++++ web/src/pages/systemTools/autoCode/index.less | 78 + web/src/pages/systemTools/autoCode/index.tsx | 1997 +++++++++++++++++ .../systemTools/autoCodeAdmin/index.less | 13 + .../pages/systemTools/autoCodeAdmin/index.tsx | 514 +++++ .../systemTools/exportTemplate/index.less | 9 + .../systemTools/exportTemplate/index.tsx | 1168 ++++++++++ .../pages/systemTools/formCreate/index.less | 106 + .../pages/systemTools/formCreate/index.tsx | 170 ++ .../systemTools/installPlugin/index.less | 181 ++ .../pages/systemTools/installPlugin/index.tsx | 162 ++ web/src/pages/systemTools/pubPlug/index.less | 107 + web/src/pages/systemTools/pubPlug/index.tsx | 305 +++ web/src/pages/systemTools/sysError/index.less | 33 + web/src/pages/systemTools/sysError/index.tsx | 421 ++++ web/src/pages/systemTools/system/index.less | 33 + web/src/pages/systemTools/system/index.tsx | 723 ++++++ web/src/pages/systemTools/version/index.less | 162 ++ web/src/pages/systemTools/version/index.tsx | 831 +++++++ web/src/pages/user/login/index.less | 169 ++ web/src/pages/user/login/index.tsx | 705 +++--- web/src/requestErrorConfig.ts | 138 +- web/src/services/kratos/.gitkeep | 1 + web/src/services/kratos/announcement.ts | 108 + web/src/services/kratos/api.ts | 94 + web/src/services/kratos/attachmentCategory.ts | 29 + web/src/services/kratos/authority.ts | 53 + web/src/services/kratos/authorityBtn.ts | 26 + web/src/services/kratos/autoCode.ts | 195 ++ web/src/services/kratos/casbin.ts | 25 + web/src/services/kratos/customer.ts | 52 + web/src/services/kratos/dictionary.ts | 58 + web/src/services/kratos/dictionaryDetail.ts | 74 + web/src/services/kratos/email.ts | 26 + web/src/services/kratos/exportTemplate.ts | 83 + web/src/services/kratos/fileUpload.ts | 83 + web/src/services/kratos/github.ts | 28 + web/src/services/kratos/initdb.ts | 34 + web/src/services/kratos/jwt.ts | 14 + web/src/services/kratos/menu.ts | 82 + web/src/services/kratos/operationRecord.ts | 52 + web/src/services/kratos/params.ts | 60 + web/src/services/kratos/sysError.ts | 63 + web/src/services/kratos/system.ts | 95 + web/src/services/kratos/user.ts | 105 + web/src/services/kratos/version.ts | 61 + web/src/styles/.gitkeep | 1 + web/src/styles/transition.less | 140 ++ web/src/styles/variables.less | 78 + web/src/types/.gitkeep | 1 + web/src/types/api.d.ts | 178 ++ web/src/types/index.d.ts | 217 ++ web/src/utils/.gitkeep | 1 + web/src/utils/asyncRouter.ts | 211 ++ web/src/utils/auth.ts | 143 ++ web/src/utils/bus.ts | 15 + web/src/utils/closeThisPage.ts | 10 + web/src/utils/date.ts | 144 ++ web/src/utils/dictionary.ts | 206 ++ web/src/utils/doc.ts | 9 + web/src/utils/downloadImg.ts | 26 + web/src/utils/event.ts | 30 + web/src/utils/fmtRouterTitle.ts | 21 + web/src/utils/format.ts | 276 +++ web/src/utils/image.ts | 120 + web/src/utils/page.ts | 17 + web/src/utils/params.ts | 43 + web/src/utils/request.ts | 236 ++ web/src/utils/string.ts | 88 + 201 files changed, 27517 insertions(+), 537 deletions(-) create mode 100644 web/src/assets/index.ts create mode 100644 web/src/components/ArrayCtrl/ArrayCtrl.tsx create mode 100644 web/src/components/ArrayCtrl/index.ts create mode 100644 web/src/components/BottomInfo/BottomInfo.tsx create mode 100644 web/src/components/BottomInfo/index.ts create mode 100644 web/src/components/Charts/BaseChart.tsx create mode 100644 web/src/components/Charts/LineChart.tsx create mode 100644 web/src/components/Charts/PieChart.tsx create mode 100644 web/src/components/Charts/index.ts create mode 100644 web/src/components/ErrorPreview/ErrorPreview.tsx create mode 100644 web/src/components/ErrorPreview/index.ts create mode 100644 web/src/components/ExportExcel/ExportExcel.tsx create mode 100644 web/src/components/ExportExcel/ImportExcel.tsx create mode 100644 web/src/components/ExportExcel/index.ts create mode 100644 web/src/components/Logo/Logo.tsx create mode 100644 web/src/components/Logo/index.ts create mode 100644 web/src/components/Office/DocxViewer.tsx create mode 100644 web/src/components/Office/ExcelViewer.tsx create mode 100644 web/src/components/Office/PDFViewer.tsx create mode 100644 web/src/components/Office/index.ts create mode 100644 web/src/components/RichText/RichTextEditor.tsx create mode 100644 web/src/components/RichText/RichTextViewer.tsx create mode 100644 web/src/components/RichText/index.ts create mode 100644 web/src/components/SelectFile/SelectFile.tsx create mode 100644 web/src/components/SelectFile/index.ts create mode 100644 web/src/components/SelectImage/SelectImage.tsx create mode 100644 web/src/components/SelectImage/index.ts create mode 100644 web/src/components/SvgIcon/SvgIcon.tsx create mode 100644 web/src/components/SvgIcon/index.ts create mode 100644 web/src/components/Upload/CommonUpload.tsx create mode 100644 web/src/components/Upload/Cropper.tsx create mode 100644 web/src/components/Upload/ImageUpload.tsx create mode 100644 web/src/components/Upload/QRCode.tsx create mode 100644 web/src/components/Upload/index.ts create mode 100644 web/src/components/WarningBar/WarningBar.tsx create mode 100644 web/src/components/WarningBar/index.ts create mode 100644 web/src/hooks/.gitkeep create mode 100644 web/src/hooks/index.ts create mode 100644 web/src/hooks/useAccess.ts create mode 100644 web/src/hooks/useAuth.ts create mode 100644 web/src/hooks/useCharts.ts create mode 100644 web/src/hooks/useDictionary.ts create mode 100644 web/src/hooks/useResponsive.ts create mode 100644 web/src/hooks/useWindowResize.ts create mode 100644 web/src/layouts/BasicLayout.tsx create mode 100644 web/src/layouts/BlankLayout.tsx create mode 100644 web/src/layouts/UserLayout.less create mode 100644 web/src/layouts/UserLayout.tsx create mode 100644 web/src/layouts/components/HeaderTools.tsx create mode 100644 web/src/layouts/components/Screenfull.tsx create mode 100644 web/src/layouts/components/Search.tsx create mode 100644 web/src/layouts/components/SettingDrawer.less create mode 100644 web/src/layouts/components/SettingDrawer.tsx create mode 100644 web/src/layouts/components/Sidebar.tsx create mode 100644 web/src/layouts/components/Tabs.tsx create mode 100644 web/src/layouts/components/index.ts create mode 100644 web/src/layouts/index.ts create mode 100644 web/src/layouts/modes/CombinationMode.tsx create mode 100644 web/src/layouts/modes/HeadMode.tsx create mode 100644 web/src/layouts/modes/NormalMode.tsx create mode 100644 web/src/layouts/modes/index.ts create mode 100644 web/src/models/.gitkeep create mode 100644 web/src/models/app.ts create mode 100644 web/src/models/dictionary.ts create mode 100644 web/src/models/index.ts create mode 100644 web/src/models/router.ts create mode 100644 web/src/models/user.ts create mode 100644 web/src/pages/about/index.tsx create mode 100644 web/src/pages/dashboard/components/Banner.tsx create mode 100644 web/src/pages/dashboard/components/Charts.tsx create mode 100644 web/src/pages/dashboard/components/Notice.tsx create mode 100644 web/src/pages/dashboard/components/PluginTable.tsx create mode 100644 web/src/pages/dashboard/components/QuickLinks.tsx create mode 100644 web/src/pages/dashboard/components/StatCards.tsx create mode 100644 web/src/pages/dashboard/components/index.ts create mode 100644 web/src/pages/dashboard/index.less create mode 100644 web/src/pages/dashboard/index.tsx create mode 100644 web/src/pages/error/403.tsx create mode 100644 web/src/pages/error/404.tsx create mode 100644 web/src/pages/error/500.tsx create mode 100644 web/src/pages/error/index.ts create mode 100644 web/src/pages/error/reload.tsx create mode 100644 web/src/pages/example/breakpoint/index.less create mode 100644 web/src/pages/example/breakpoint/index.tsx create mode 100644 web/src/pages/example/customer/index.less create mode 100644 web/src/pages/example/customer/index.tsx create mode 100644 web/src/pages/example/upload/index.less create mode 100644 web/src/pages/example/upload/index.tsx create mode 100644 web/src/pages/example/upload/scanUpload.less create mode 100644 web/src/pages/example/upload/scanUpload.tsx create mode 100644 web/src/pages/init/index.tsx create mode 100644 web/src/pages/person/index.tsx create mode 100644 web/src/pages/plugin/announcement/index.less create mode 100644 web/src/pages/plugin/announcement/index.tsx create mode 100644 web/src/pages/plugin/email/index.less create mode 100644 web/src/pages/plugin/email/index.tsx create mode 100644 web/src/pages/system/api/components/ApiForm.tsx create mode 100644 web/src/pages/system/api/components/ApiSync.tsx create mode 100644 web/src/pages/system/api/index.tsx create mode 100644 web/src/pages/system/authority/components/ApiPermission.tsx create mode 100644 web/src/pages/system/authority/components/AuthorityForm.tsx create mode 100644 web/src/pages/system/authority/components/BtnPermission.tsx create mode 100644 web/src/pages/system/authority/components/DataPermission.tsx create mode 100644 web/src/pages/system/authority/components/MenuPermission.tsx create mode 100644 web/src/pages/system/authority/index.tsx create mode 100644 web/src/pages/system/dictionary/components/DetailForm.tsx create mode 100644 web/src/pages/system/dictionary/components/DictionaryForm.tsx create mode 100644 web/src/pages/system/dictionary/detail.tsx create mode 100644 web/src/pages/system/dictionary/index.less create mode 100644 web/src/pages/system/dictionary/index.tsx create mode 100644 web/src/pages/system/menu/components/IconSelector.tsx create mode 100644 web/src/pages/system/menu/components/MenuButtons.tsx create mode 100644 web/src/pages/system/menu/components/MenuForm.tsx create mode 100644 web/src/pages/system/menu/components/MenuParams.tsx create mode 100644 web/src/pages/system/menu/index.tsx create mode 100644 web/src/pages/system/operation/components/RecordDetail.tsx create mode 100644 web/src/pages/system/operation/index.less create mode 100644 web/src/pages/system/operation/index.tsx create mode 100644 web/src/pages/system/params/components/ParamsForm.tsx create mode 100644 web/src/pages/system/params/index.less create mode 100644 web/src/pages/system/params/index.tsx create mode 100644 web/src/pages/system/user/components/AuthoritySelect.tsx create mode 100644 web/src/pages/system/user/components/UserForm.tsx create mode 100644 web/src/pages/system/user/index.tsx create mode 100644 web/src/pages/systemTools/autoCode/index.less create mode 100644 web/src/pages/systemTools/autoCode/index.tsx create mode 100644 web/src/pages/systemTools/autoCodeAdmin/index.less create mode 100644 web/src/pages/systemTools/autoCodeAdmin/index.tsx create mode 100644 web/src/pages/systemTools/exportTemplate/index.less create mode 100644 web/src/pages/systemTools/exportTemplate/index.tsx create mode 100644 web/src/pages/systemTools/formCreate/index.less create mode 100644 web/src/pages/systemTools/formCreate/index.tsx create mode 100644 web/src/pages/systemTools/installPlugin/index.less create mode 100644 web/src/pages/systemTools/installPlugin/index.tsx create mode 100644 web/src/pages/systemTools/pubPlug/index.less create mode 100644 web/src/pages/systemTools/pubPlug/index.tsx create mode 100644 web/src/pages/systemTools/sysError/index.less create mode 100644 web/src/pages/systemTools/sysError/index.tsx create mode 100644 web/src/pages/systemTools/system/index.less create mode 100644 web/src/pages/systemTools/system/index.tsx create mode 100644 web/src/pages/systemTools/version/index.less create mode 100644 web/src/pages/systemTools/version/index.tsx create mode 100644 web/src/pages/user/login/index.less create mode 100644 web/src/services/kratos/.gitkeep create mode 100644 web/src/services/kratos/announcement.ts create mode 100644 web/src/services/kratos/api.ts create mode 100644 web/src/services/kratos/attachmentCategory.ts create mode 100644 web/src/services/kratos/authority.ts create mode 100644 web/src/services/kratos/authorityBtn.ts create mode 100644 web/src/services/kratos/autoCode.ts create mode 100644 web/src/services/kratos/casbin.ts create mode 100644 web/src/services/kratos/customer.ts create mode 100644 web/src/services/kratos/dictionary.ts create mode 100644 web/src/services/kratos/dictionaryDetail.ts create mode 100644 web/src/services/kratos/email.ts create mode 100644 web/src/services/kratos/exportTemplate.ts create mode 100644 web/src/services/kratos/fileUpload.ts create mode 100644 web/src/services/kratos/github.ts create mode 100644 web/src/services/kratos/initdb.ts create mode 100644 web/src/services/kratos/jwt.ts create mode 100644 web/src/services/kratos/menu.ts create mode 100644 web/src/services/kratos/operationRecord.ts create mode 100644 web/src/services/kratos/params.ts create mode 100644 web/src/services/kratos/sysError.ts create mode 100644 web/src/services/kratos/system.ts create mode 100644 web/src/services/kratos/user.ts create mode 100644 web/src/services/kratos/version.ts create mode 100644 web/src/styles/.gitkeep create mode 100644 web/src/styles/transition.less create mode 100644 web/src/styles/variables.less create mode 100644 web/src/types/.gitkeep create mode 100644 web/src/types/api.d.ts create mode 100644 web/src/types/index.d.ts create mode 100644 web/src/utils/.gitkeep create mode 100644 web/src/utils/asyncRouter.ts create mode 100644 web/src/utils/auth.ts create mode 100644 web/src/utils/bus.ts create mode 100644 web/src/utils/closeThisPage.ts create mode 100644 web/src/utils/date.ts create mode 100644 web/src/utils/dictionary.ts create mode 100644 web/src/utils/doc.ts create mode 100644 web/src/utils/downloadImg.ts create mode 100644 web/src/utils/event.ts create mode 100644 web/src/utils/fmtRouterTitle.ts create mode 100644 web/src/utils/format.ts create mode 100644 web/src/utils/image.ts create mode 100644 web/src/utils/page.ts create mode 100644 web/src/utils/params.ts create mode 100644 web/src/utils/request.ts create mode 100644 web/src/utils/string.ts diff --git a/web/config/config.ts b/web/config/config.ts index 1a98ebe..d0d731b 100644 --- a/web/config/config.ts +++ b/web/config/config.ts @@ -168,7 +168,7 @@ export default defineConfig({ mock: { include: ["mock/**/*", "src/pages/**/_mock.ts"], }, - utoopack: {}, + // utoopack: {}, requestRecord: {}, exportStatic: {}, define: { diff --git a/web/config/defaultSettings.ts b/web/config/defaultSettings.ts index 6710cad..fed2469 100644 --- a/web/config/defaultSettings.ts +++ b/web/config/defaultSettings.ts @@ -1,28 +1,50 @@ import type { ProLayoutProps } from '@ant-design/pro-components'; /** - * @name + * KRA - Default Settings + * 默认布局配置 */ const Settings: ProLayoutProps & { pwa?: boolean; logo?: string; } = { navTheme: 'light', - // 拂晓蓝 + // 主题色 - 拂晓蓝 colorPrimary: '#1890ff', + // 布局模式: side | top | mix layout: 'mix', + // 内容宽度: Fluid | Fixed contentWidth: 'Fluid', - fixedHeader: false, + // 固定头部 + fixedHeader: true, + // 固定侧边栏 fixSiderbar: true, + // 色弱模式 colorWeak: false, - title: 'Ant Design Pro', - pwa: true, - logo: 'https://gw.alipayobjects.com/zos/rmsportal/KDpgvguMpGfqaHPjicRK.svg', + // 标题 + title: 'Kratos Admin', + // PWA + pwa: false, + // Logo + logo: '/logo.svg', + // 图标字体 iconfontUrl: '', + // Token 配置 token: { - // 参见ts声明,demo 见文档,通过token 修改样式 - //https://procomponents.ant.design/components/layout#%E9%80%9A%E8%BF%87-token-%E4%BF%AE%E6%94%B9%E6%A0%B7%E5%BC%8F + // 侧边栏背景色 + sider: { + colorMenuBackground: '#fff', + colorTextMenu: 'rgba(0, 0, 0, 0.65)', + colorTextMenuSelected: '#1890ff', + colorBgMenuItemSelected: '#e6f7ff', + }, }, + // 分割菜单 + splitMenus: false, + // 页脚渲染 + footerRender: true, + // 菜单头部渲染 + menuHeaderRender: true, }; export default Settings; diff --git a/web/config/routes.ts b/web/config/routes.ts index c8fbf91..83f5e17 100644 --- a/web/config/routes.ts +++ b/web/config/routes.ts @@ -1,47 +1,255 @@ /** + * KRA - 路由配置 + * 对应 GVA 的路由结构 * @name umi 的路由配置 - * @description 只支持 path,component,routes,redirect,wrappers,name,icon 的配置 - * @param path path 只支持两种占位符配置,第一种是动态参数 :id 的形式,第二种是 * 通配符,通配符只能出现路由字符串的最后。 - * @param component 配置 location 和 path 匹配后用于渲染的 React 组件路径。可以是绝对路径,也可以是相对路径,如果是相对路径,会从 src/pages 开始找起。 - * @param routes 配置子路由,通常在需要为多个路径增加 layout 组件时使用。 - * @param redirect 配置路由跳转 - * @param wrappers 配置路由组件的包装组件,通过包装组件可以为当前的路由组件组合进更多的功能。 比如,可以用于路由级别的权限校验 - * @param name 配置路由的标题,默认读取国际化文件 menu.ts 中 menu.xxxx 的值,如配置 name 为 login,则读取 menu.ts 中 menu.login 的取值作为标题 - * @param icon 配置路由的图标,取值参考 https://ant.design/components/icon-cn, 注意去除风格后缀和大小写,如想要配置图标为 则取值应为 stepBackward 或 StepBackward,如想要配置图标为 则取值应为 user 或者 User * @doc https://umijs.org/docs/guides/routes */ export default [ + // 用户相关(无布局) { - path: "/user", + path: '/user', layout: false, routes: [ { - name: "login", - path: "/user/login", - component: "./user/login", + name: 'login', + path: '/user/login', + component: './user/login', }, ], }, + + // 数据库初始化(无布局) { - path: "/welcome", - name: "welcome", - icon: "smile", - component: "./Welcome", - }, - { - name: "admin", - icon: "crown", - path: "/admins", - access: "canAdmin", - component: "./admins", - }, - { - path: "/", - redirect: "/welcome", - }, - { - component: "404", + path: '/init', layout: false, - path: "./*", + component: './init', + }, + + // 错误页面(无布局) + { + path: '/error', + layout: false, + routes: [ + { path: '/error/403', component: './error/403' }, + { path: '/error/404', component: './error/404' }, + { path: '/error/500', component: './error/500' }, + { path: '/error/reload', component: './error/reload' }, + ], + }, + + // 仪表盘 + { + path: '/dashboard', + name: 'dashboard', + icon: 'dashboard', + component: './dashboard', + }, + + // 超级管理员 - 用户管理 + { + path: '/admin', + name: 'superAdmin', + icon: 'crown', + access: 'isAdmin', + routes: [ + { + path: '/admin/user', + name: 'user', + icon: 'user', + component: './system/user', + }, + { + path: '/admin/authority', + name: 'authority', + icon: 'team', + component: './system/authority', + }, + { + path: '/admin/menu', + name: 'menu', + icon: 'menu', + component: './system/menu', + }, + { + path: '/admin/api', + name: 'api', + icon: 'api', + component: './system/api', + }, + { + path: '/admin/operation', + name: 'operation', + icon: 'fileSearch', + component: './system/operation', + }, + { + path: '/admin/dictionary', + name: 'dictionary', + icon: 'book', + component: './system/dictionary', + }, + { + path: '/admin/dictionary/detail/:id', + name: 'dictionaryDetail', + component: './system/dictionary/detail', + hideInMenu: true, + }, + { + path: '/admin/params', + name: 'params', + icon: 'setting', + component: './system/params', + }, + ], + }, + + + // 系统工具 + { + path: '/systemTools', + name: 'systemTools', + icon: 'tool', + access: 'isAdmin', + routes: [ + { + path: '/systemTools/system', + name: 'system', + icon: 'setting', + component: './systemTools/system', + }, + { + path: '/systemTools/version', + name: 'version', + icon: 'info-circle', + component: './systemTools/version', + }, + { + path: '/systemTools/sysError', + name: 'sysError', + icon: 'warning', + component: './systemTools/sysError', + }, + { + path: '/systemTools/autoCode', + name: 'autoCode', + icon: 'code', + component: './systemTools/autoCode', + }, + { + path: '/systemTools/autoCodeAdmin', + name: 'autoCodeAdmin', + icon: 'database', + component: './systemTools/autoCodeAdmin', + }, + { + path: '/systemTools/exportTemplate', + name: 'exportTemplate', + icon: 'export', + component: './systemTools/exportTemplate', + }, + { + path: '/systemTools/formCreate', + name: 'formCreate', + icon: 'form', + component: './systemTools/formCreate', + }, + { + path: '/systemTools/installPlugin', + name: 'installPlugin', + icon: 'appstore-add', + component: './systemTools/installPlugin', + }, + { + path: '/systemTools/pubPlug', + name: 'pubPlug', + icon: 'cloud-upload', + component: './systemTools/pubPlug', + }, + ], + }, + + // 插件 + { + path: '/plugin', + name: 'plugin', + icon: 'appstore', + routes: [ + { + path: '/plugin/announcement', + name: 'announcement', + icon: 'notification', + component: './plugin/announcement', + }, + { + path: '/plugin/email', + name: 'email', + icon: 'mail', + component: './plugin/email', + }, + ], + }, + + // 示例 + { + path: '/example', + name: 'example', + icon: 'experiment', + routes: [ + { + path: '/example/customer', + name: 'customer', + icon: 'contacts', + component: './example/customer', + }, + { + path: '/example/upload', + name: 'upload', + icon: 'upload', + component: './example/upload', + }, + { + path: '/example/upload/scan', + name: 'scanUpload', + icon: 'scan', + component: './example/upload/scanUpload', + hideInMenu: true, + }, + { + path: '/example/breakpoint', + name: 'breakpoint', + icon: 'cloud-upload', + component: './example/breakpoint', + }, + ], + }, + + // 个人中心 + { + path: '/person', + name: 'person', + icon: 'user', + component: './person', + hideInMenu: true, + }, + + // 关于 + { + path: '/about', + name: 'about', + icon: 'info-circle', + component: './about', + }, + + // 默认重定向 + { + path: '/', + redirect: '/dashboard', + }, + + // 404 + { + path: '*', + layout: false, + component: './error/404', }, ]; diff --git a/web/package.json b/web/package.json index ed91c35..367485f 100644 --- a/web/package.json +++ b/web/package.json @@ -31,11 +31,13 @@ "test:update": "npm run jest -- -u", "tsc": "tsc --noEmit" }, - "browserslist": ["defaults"], + "browserslist": [ + "defaults" + ], "dependencies": { + "@ant-design/charts": "^2.2.1", "@ant-design/icons": "^6.1.0", "@ant-design/pro-components": "^2.8.9", - "@ant-design/charts": "^2.2.1", "antd": "^6.0.0", "antd-style": "^3.7.0", "axios": "^1.8.2", @@ -44,6 +46,7 @@ "echarts": "^5.5.1", "echarts-for-react": "^3.0.2", "lodash": "^4.17.21", + "mitt": "^3.0.1", "nprogress": "^0.2.0", "qs": "^6.13.0", "react": "^19.1.0", @@ -56,6 +59,7 @@ }, "devDependencies": { "@ant-design/pro-cli": "^3.3.0", + "@biomejs/biome": "^2.1.1", "@commitlint/cli": "^20.1.0", "@commitlint/config-conventional": "^20.0.0", "@testing-library/dom": "^10.4.0", @@ -63,6 +67,7 @@ "@types/express": "^5.0.3", "@types/jest": "^30.0.0", "@types/lodash": "^4.17.13", + "@types/node": "^24.0.13", "@types/nprogress": "^0.2.3", "@types/qs": "^6.9.17", "@types/react": "^19.1.8", @@ -82,16 +87,22 @@ "ts-node": "^10.9.2", "typescript": "^5.6.3", "umi-presets-pro": "^2.0.3", - "umi-serve": "^1.9.11", - "@biomejs/biome": "^2.1.1", - "@types/node": "^24.0.13" + "umi-serve": "^1.9.11" }, "engines": { "node": ">=20.0.0" }, "create-umi": { - "ignoreScript": ["docker*", "functions*", "site", "generateMock"], - "ignoreDependencies": ["netlify*", "serverless"], + "ignoreScript": [ + "docker*", + "functions*", + "site", + "generateMock" + ], + "ignoreDependencies": [ + "netlify*", + "serverless" + ], "ignore": [ ".dockerignore", ".git", diff --git a/web/src/access.ts b/web/src/access.ts index 373d9fa..cd2f577 100644 --- a/web/src/access.ts +++ b/web/src/access.ts @@ -1,11 +1,129 @@ /** + * KRA - Access Control + * 权限控制配置 * @see https://umijs.org/docs/max/access#access - * */ -export default function access( - initialState: { currentUser?: API.CurrentUser } | undefined, -) { + */ + +export interface UserAuthority { + authorityId: string | number; + authorityName: string; + defaultRouter?: string; +} + +export interface CurrentUser { + uuid?: string; + userName?: string; + nickName?: string; + headerImg?: string; + authority?: UserAuthority; + authorities?: UserAuthority[]; + access?: string; + // 按钮权限列表 + buttons?: string[]; + // 菜单权限列表 + menus?: string[]; +} + +export interface InitialState { + currentUser?: CurrentUser; + settings?: any; + loading?: boolean; +} + +export default function access(initialState: InitialState | undefined) { const { currentUser } = initialState ?? {}; + const authority = currentUser?.authority; + const authorities = currentUser?.authorities || []; + const buttons = currentUser?.buttons || []; + const menus = currentUser?.menus || []; + + // 获取所有角色ID + const authorityIds = authorities.map((a) => + typeof a.authorityId === 'string' ? parseInt(a.authorityId, 10) : a.authorityId + ); + + // 当前角色ID + const currentAuthorityId = authority?.authorityId + ? (typeof authority.authorityId === 'string' + ? parseInt(authority.authorityId, 10) + : authority.authorityId) + : 0; + + // 是否为超级管理员 (authorityId = 888) + const isSuperAdmin = currentAuthorityId === 888 || authorityIds.includes(888); + + // 是否为管理员 (authorityId <= 1000 通常为管理员角色) + const isAdmin = isSuperAdmin || currentAuthorityId <= 1000; + return { - canAdmin: currentUser && currentUser.access === 'admin', + // 是否已登录 + isLoggedIn: !!currentUser, + + // 是否为超级管理员 + isSuperAdmin, + + // 是否为管理员 + isAdmin, + + // 兼容旧版 canAdmin + canAdmin: isAdmin, + + // 当前角色ID + currentAuthorityId, + + // 所有角色ID列表 + authorityIds, + + // 按钮权限列表 + buttons, + + // 菜单权限列表 + menus, + + // 检查是否有指定角色 + hasAuthority: (authorityId: number) => { + if (isSuperAdmin) return true; + return authorityIds.includes(authorityId) || currentAuthorityId === authorityId; + }, + + // 检查是否有指定按钮权限 + hasButton: (buttonKey: string) => { + if (isSuperAdmin) return true; + return buttons.includes(buttonKey); + }, + + // 检查是否有指定菜单权限 + hasMenu: (menuPath: string) => { + if (isSuperAdmin) return true; + return menus.includes(menuPath); + }, + + // 检查路由访问权限 + canAccessRoute: (path: string) => { + if (isSuperAdmin) return true; + // 公开路由 + const publicRoutes = ['/user/login', '/user/register', '/init', '/404', '/403', '/500']; + if (publicRoutes.some((route) => path.startsWith(route))) { + return true; + } + // 检查菜单权限 + if (menus.length > 0) { + return menus.some((menu) => path.startsWith(menu)); + } + // 默认允许访问(如果没有配置菜单权限) + return true; + }, + + // 检查是否有任一指定权限 + hasAnyAuthority: (ids: number[]) => { + if (isSuperAdmin) return true; + return ids.some((id) => authorityIds.includes(id) || currentAuthorityId === id); + }, + + // 检查是否有所有指定权限 + hasAllAuthorities: (ids: number[]) => { + if (isSuperAdmin) return true; + return ids.every((id) => authorityIds.includes(id) || currentAuthorityId === id); + }, }; } diff --git a/web/src/app.tsx b/web/src/app.tsx index 2c1dd16..a445ff4 100644 --- a/web/src/app.tsx +++ b/web/src/app.tsx @@ -1,129 +1,144 @@ -import { - AvatarDropdown, - AvatarName, - Footer, - Question, - SelectLang, -} from "@/components"; -import { createAdminService } from "@/services/index"; -import { Admin } from "@/services/kratos/admin/v1/index"; -import { LinkOutlined } from "@ant-design/icons"; -import type { Settings as LayoutSettings } from "@ant-design/pro-components"; -import { SettingDrawer } from "@ant-design/pro-components"; -import type { RequestConfig, RunTimeLayoutConfig } from "@umijs/max"; -import { history, Link } from "@umijs/max"; -import defaultSettings from "../config/defaultSettings"; -import { errorConfig } from "./requestErrorConfig"; +/** + * KRA - App Configuration + * 应用运行时配置 + */ +import { AvatarDropdown, AvatarName, Footer, Question } from '@/components'; +import { getUserInfo } from '@/services/kratos/user'; +import { getToken, removeToken } from '@/utils/auth'; +import { UserOutlined } from '@ant-design/icons'; +import type { Settings as LayoutSettings } from '@ant-design/pro-components'; +import { SettingDrawer } from '@ant-design/pro-components'; +import type { RequestConfig, RunTimeLayoutConfig } from '@umijs/max'; +import { history } from '@umijs/max'; +import { message } from 'antd'; +import defaultSettings from '../config/defaultSettings'; +import { errorConfig } from './requestErrorConfig'; -const isDev = process.env.NODE_ENV === "development"; -const isDevOrTest = isDev || process.env.CI; -const loginPath = "/user/login"; - -const adminService = createAdminService(); +const isDev = process.env.NODE_ENV === 'development'; +const loginPath = '/user/login'; +const initPath = '/init'; +const whiteList = [loginPath, initPath, '/error/403', '/error/404', '/error/500']; /** + * 获取初始状态 * @see https://umijs.org/docs/api/runtime-config#getinitialstate - * */ + */ export async function getInitialState(): Promise<{ settings?: Partial; currentUser?: API.CurrentUser; loading?: boolean; - fetchUserInfo?: () => Promise; + fetchUserInfo?: () => Promise; }> { - const fetchUserInfo = async () => { + const fetchUserInfo = async (): Promise => { try { - return await adminService.Current({}); + const token = getToken(); + if (!token) { + return undefined; + } + const res = await getUserInfo(); + if (res.data?.code === 0 && res.data?.data?.userInfo) { + const userInfo = res.data.data.userInfo; + return { + uuid: userInfo.uuid, + userName: userInfo.userName, + nickName: userInfo.nickName, + name: userInfo.nickName || userInfo.userName, + avatar: userInfo.headerImg, + headerImg: userInfo.headerImg, + authority: userInfo.authority, + authorities: userInfo.authorities, + // 按钮权限(如果后端返回) + buttons: res.data.data.buttons || [], + // 菜单权限(如果后端返回) + menus: res.data.data.menus || [], + }; + } + return undefined; } catch (error) { - history.push(loginPath); + console.error('获取用户信息失败:', error); + return undefined; } - return undefined; }; - // 如果不是登录页面,执行 + + // 如果是白名单页面,不获取用户信息 const { location } = history; - if ( - ![loginPath, "/user/register", "/user/register-result"].includes( - location.pathname - ) - ) { - const currentUser = await fetchUserInfo(); + if (whiteList.some((path) => location.pathname.startsWith(path))) { return { fetchUserInfo, - currentUser, settings: defaultSettings as Partial, }; } + + // 获取用户信息 + const currentUser = await fetchUserInfo(); + if (!currentUser) { + // 未登录,跳转到登录页 + history.push(loginPath); + } + return { fetchUserInfo, + currentUser, settings: defaultSettings as Partial, }; } -// ProLayout 支持的api https://procomponents.ant.design/components/layout -export const layout: RunTimeLayoutConfig = ({ - initialState, - setInitialState, -}) => { + +/** + * ProLayout 配置 + * @see https://procomponents.ant.design/components/layout + */ +export const layout: RunTimeLayoutConfig = ({ initialState, setInitialState }) => { return { - actionsRender: () => [ - , - , - ], + // 右上角操作区 + actionsRender: () => [], + + // 头像配置 avatarProps: { - src: initialState?.currentUser?.avatar, + src: initialState?.currentUser?.avatar || initialState?.currentUser?.headerImg, title: , - render: (_, avatarChildren) => ( - {avatarChildren} - ), + icon: , + render: (_, avatarChildren) => {avatarChildren}, }, + + // 水印 waterMarkProps: { - content: initialState?.currentUser?.name, + content: initialState?.currentUser?.nickName || initialState?.currentUser?.userName, }, + + // 页脚 footerRender: () =>