@liujitcn/kratos-admin-core 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +168 -0
- package/build/getEnv.ts +46 -0
- package/build/plugins.ts +206 -0
- package/build/proxy.ts +29 -0
- package/dist/package/declarations/build/getEnv.d.ts +13 -0
- package/dist/package/declarations/build/plugins.d.ts +20 -0
- package/dist/package/declarations/build/proxy.d.ts +10 -0
- package/dist/package/declarations/index.d.ts +7 -0
- package/dist/package/declarations/src/App.vue.d.ts +3 -0
- package/dist/package/declarations/src/api/base/config.d.ts +7 -0
- package/dist/package/declarations/src/api/base/file.d.ts +11 -0
- package/dist/package/declarations/src/api/base/login.d.ts +18 -0
- package/dist/package/declarations/src/api/base/oauth.d.ts +12 -0
- package/dist/package/declarations/src/api/system/auth.d.ts +13 -0
- package/dist/package/declarations/src/api/system/base_dict.d.ts +8 -0
- package/dist/package/declarations/src/api/system/base_tenant.d.ts +9 -0
- package/dist/package/declarations/src/auth.d.ts +1 -0
- package/dist/package/declarations/src/bootstrap.d.ts +23 -0
- package/dist/package/declarations/src/components/Card/DataPanelCard.vue.d.ts +23 -0
- package/dist/package/declarations/src/components/CronExpression/index.vue.d.ts +15 -0
- package/dist/package/declarations/src/components/Dialog/FormDialog.vue.d.ts +74 -0
- package/dist/package/declarations/src/components/Dialog/ProDialog.vue.d.ts +58 -0
- package/dist/package/declarations/src/components/Dict/DictLabel.vue.d.ts +11 -0
- package/dist/package/declarations/src/components/Dict/index.vue.d.ts +30 -0
- package/dist/package/declarations/src/components/ECharts/config/index.d.ts +7 -0
- package/dist/package/declarations/src/components/ECharts/index.vue.d.ts +22 -0
- package/dist/package/declarations/src/components/ErrorMessage/index.vue.d.ts +12 -0
- package/dist/package/declarations/src/components/Grid/components/GridItem.vue.d.ts +34 -0
- package/dist/package/declarations/src/components/Grid/index.vue.d.ts +28 -0
- package/dist/package/declarations/src/components/Grid/interface/index.d.ts +7 -0
- package/dist/package/declarations/src/components/ImportExcel/index.vue.d.ts +26 -0
- package/dist/package/declarations/src/components/Loading/fullScreen.d.ts +5 -0
- package/dist/package/declarations/src/components/Loading/index.vue.d.ts +3 -0
- package/dist/package/declarations/src/components/PasswordStrength/index.vue.d.ts +13 -0
- package/dist/package/declarations/src/components/ProForm/components/DynamicList.vue.d.ts +15 -0
- package/dist/package/declarations/src/components/ProForm/components/KvList.vue.d.ts +26 -0
- package/dist/package/declarations/src/components/ProForm/components/ProFormItem.vue.d.ts +28 -0
- package/dist/package/declarations/src/components/ProForm/index.vue.d.ts +36 -0
- package/dist/package/declarations/src/components/ProForm/interface/index.d.ts +47 -0
- package/dist/package/declarations/src/components/ProTable/components/ColSetting.vue.d.ts +9 -0
- package/dist/package/declarations/src/components/ProTable/components/Pagination.vue.d.ts +15 -0
- package/dist/package/declarations/src/components/ProTable/components/TableColumn.vue.d.ts +9 -0
- package/dist/package/declarations/src/components/ProTable/interface/index.d.ts +187 -0
- package/dist/package/declarations/src/components/ProTable.d.ts +5 -0
- package/dist/package/declarations/src/components/SearchForm/components/SearchFormItem.vue.d.ts +21 -0
- package/dist/package/declarations/src/components/SearchForm/index.vue.d.ts +22 -0
- package/dist/package/declarations/src/components/SelectFilter/index.vue.d.ts +44 -0
- package/dist/package/declarations/src/components/SelectIcon/index.vue.d.ts +19 -0
- package/dist/package/declarations/src/components/SvgIcon/index.vue.d.ts +15 -0
- package/dist/package/declarations/src/components/SwitchDark/index.vue.d.ts +3 -0
- package/dist/package/declarations/src/components/TreeFilter/index.vue.d.ts +5866 -0
- package/dist/package/declarations/src/components/Upload/File.vue.d.ts +24 -0
- package/dist/package/declarations/src/components/Upload/Files.vue.d.ts +26 -0
- package/dist/package/declarations/src/components/Upload/Img.vue.d.ts +43 -0
- package/dist/package/declarations/src/components/Upload/Imgs.vue.d.ts +46 -0
- package/dist/package/declarations/src/components/WangEditor/index.vue.d.ts +29 -0
- package/dist/package/declarations/src/config/index.d.ts +6 -0
- package/dist/package/declarations/src/config/nprogress.d.ts +3 -0
- package/dist/package/declarations/src/directives/index.d.ts +5 -0
- package/dist/package/declarations/src/directives/modules/auth.d.ts +3 -0
- package/dist/package/declarations/src/directives/modules/copy.d.ts +8 -0
- package/dist/package/declarations/src/directives/modules/debounce.d.ts +8 -0
- package/dist/package/declarations/src/directives/modules/draggable.d.ts +3 -0
- package/dist/package/declarations/src/directives/modules/longpress.d.ts +7 -0
- package/dist/package/declarations/src/directives/modules/throttle.d.ts +3 -0
- package/dist/package/declarations/src/directives/modules/waterMarker.d.ts +5 -0
- package/dist/package/declarations/src/enums/httpEnum.d.ts +29 -0
- package/dist/package/declarations/src/format.d.ts +1 -0
- package/dist/package/declarations/src/hooks/interface/index.d.ts +36 -0
- package/dist/package/declarations/src/hooks/useAuthButtons.d.ts +8 -0
- package/dist/package/declarations/src/hooks/useDownload.d.ts +9 -0
- package/dist/package/declarations/src/hooks/useHandleData.d.ts +10 -0
- package/dist/package/declarations/src/hooks/useOnline.d.ts +6 -0
- package/dist/package/declarations/src/hooks/useSelection.d.ts +10 -0
- package/dist/package/declarations/src/hooks/useTable.d.ts +46 -0
- package/dist/package/declarations/src/hooks/useTheme.d.ts +12 -0
- package/dist/package/declarations/src/hooks/useTime.d.ts +13 -0
- package/dist/package/declarations/src/index.d.ts +3 -0
- package/dist/package/declarations/src/layouts/LayoutClassic/index.vue.d.ts +3 -0
- package/dist/package/declarations/src/layouts/LayoutColumns/index.vue.d.ts +3 -0
- package/dist/package/declarations/src/layouts/LayoutTransverse/index.vue.d.ts +3 -0
- package/dist/package/declarations/src/layouts/LayoutVertical/index.vue.d.ts +3 -0
- package/dist/package/declarations/src/layouts/components/Footer/index.vue.d.ts +3 -0
- package/dist/package/declarations/src/layouts/components/Header/ToolBarLeft.vue.d.ts +3 -0
- package/dist/package/declarations/src/layouts/components/Header/ToolBarRight.vue.d.ts +3 -0
- package/dist/package/declarations/src/layouts/components/Header/components/AssemblySize.vue.d.ts +3 -0
- package/dist/package/declarations/src/layouts/components/Header/components/Avatar.vue.d.ts +3 -0
- package/dist/package/declarations/src/layouts/components/Header/components/Breadcrumb.vue.d.ts +3 -0
- package/dist/package/declarations/src/layouts/components/Header/components/CollapseIcon.vue.d.ts +3 -0
- package/dist/package/declarations/src/layouts/components/Header/components/Fullscreen.vue.d.ts +3 -0
- package/dist/package/declarations/src/layouts/components/Header/components/InfoDialog.vue.d.ts +5 -0
- package/dist/package/declarations/src/layouts/components/Header/components/PasswordDialog.vue.d.ts +5 -0
- package/dist/package/declarations/src/layouts/components/Header/components/SearchMenu.vue.d.ts +3 -0
- package/dist/package/declarations/src/layouts/components/Header/components/ThemeSetting.vue.d.ts +3 -0
- package/dist/package/declarations/src/layouts/components/Main/components/Maximize.vue.d.ts +3 -0
- package/dist/package/declarations/src/layouts/components/Main/index.vue.d.ts +3 -0
- package/dist/package/declarations/src/layouts/components/Menu/SubMenu.vue.d.ts +7 -0
- package/dist/package/declarations/src/layouts/components/Tabs/components/MoreButton.vue.d.ts +3 -0
- package/dist/package/declarations/src/layouts/components/Tabs/index.vue.d.ts +3 -0
- package/dist/package/declarations/src/layouts/components/ThemeDrawer/index.vue.d.ts +3 -0
- package/dist/package/declarations/src/layouts/index.vue.d.ts +3 -0
- package/dist/package/declarations/src/layouts/indexAsync.vue.d.ts +3 -0
- package/dist/package/declarations/src/modules/index.d.ts +117 -0
- package/dist/package/declarations/src/modules/kratosAdmin.d.ts +4 -0
- package/dist/package/declarations/src/navigation.d.ts +2 -0
- package/dist/package/declarations/src/request.d.ts +2 -0
- package/dist/package/declarations/src/routers/index.d.ts +21 -0
- package/dist/package/declarations/src/routers/modules/dynamicRouter.d.ts +4 -0
- package/dist/package/declarations/src/routers/modules/staticRouter.d.ts +25 -0
- package/dist/package/declarations/src/rpc/base/v1/config.d.ts +23 -0
- package/dist/package/declarations/src/rpc/base/v1/file.d.ts +52 -0
- package/dist/package/declarations/src/rpc/base/v1/login.d.ts +107 -0
- package/dist/package/declarations/src/rpc/base/v1/oauth.d.ts +167 -0
- package/dist/package/declarations/src/rpc/common/v1/common.d.ts +57 -0
- package/dist/package/declarations/src/rpc/common/v1/enum.d.ts +58 -0
- package/dist/package/declarations/src/rpc/common/v1/types.d.ts +60 -0
- package/dist/package/declarations/src/rpc/google/protobuf/empty.d.ts +11 -0
- package/dist/package/declarations/src/rpc/google/protobuf/wrappers.d.ts +108 -0
- package/dist/package/declarations/src/rpc/system/admin/v1/auth.d.ts +156 -0
- package/dist/package/declarations/src/rpc/system/admin/v1/base_dict.d.ts +215 -0
- package/dist/package/declarations/src/rpc/system/admin/v1/base_tenant.d.ts +112 -0
- package/dist/package/declarations/src/rpc/system/common/v1/enum.d.ts +67 -0
- package/dist/package/declarations/src/security.d.ts +3 -0
- package/dist/package/declarations/src/stores/helper/persist.d.ts +9 -0
- package/dist/package/declarations/src/stores/index.d.ts +2 -0
- package/dist/package/declarations/src/stores/interface/index.d.ts +90 -0
- package/dist/package/declarations/src/stores/modules/auth.d.ts +168 -0
- package/dist/package/declarations/src/stores/modules/config.d.ts +26 -0
- package/dist/package/declarations/src/stores/modules/dict.d.ts +32 -0
- package/dist/package/declarations/src/stores/modules/global.d.ts +4 -0
- package/dist/package/declarations/src/stores/modules/keepAlive.d.ts +6 -0
- package/dist/package/declarations/src/stores/modules/tabs.d.ts +13 -0
- package/dist/package/declarations/src/stores/modules/user.d.ts +29 -0
- package/dist/package/declarations/src/stores/runtime.d.ts +4 -0
- package/dist/package/declarations/src/styles/theme/aside.d.ts +4 -0
- package/dist/package/declarations/src/styles/theme/header.d.ts +4 -0
- package/dist/package/declarations/src/styles/theme/menu.d.ts +4 -0
- package/dist/package/declarations/src/table.d.ts +1 -0
- package/dist/package/declarations/src/tenant.d.ts +1 -0
- package/dist/package/declarations/src/utils/color.d.ts +28 -0
- package/dist/package/declarations/src/utils/dict.d.ts +15 -0
- package/dist/package/declarations/src/utils/eleValidate.d.ts +4 -0
- package/dist/package/declarations/src/utils/errorHandler.d.ts +5 -0
- package/dist/package/declarations/src/utils/index.d.ts +192 -0
- package/dist/package/declarations/src/utils/is/index.d.ts +72 -0
- package/dist/package/declarations/src/utils/mittBus.d.ts +2 -0
- package/dist/package/declarations/src/utils/oauthProvider.d.ts +19 -0
- package/dist/package/declarations/src/utils/passwordCrypto.d.ts +6 -0
- package/dist/package/declarations/src/utils/passwordStrength.d.ts +36 -0
- package/dist/package/declarations/src/utils/proTable.d.ts +44 -0
- package/dist/package/declarations/src/utils/request.d.ts +11 -0
- package/dist/package/declarations/src/utils/router.d.ts +14 -0
- package/dist/package/declarations/src/utils/svg.d.ts +4 -0
- package/dist/package/declarations/src/utils/tenant.d.ts +6 -0
- package/dist/package/declarations/src/utils/utils.d.ts +12 -0
- package/dist/package/declarations/src/views/error/403.vue.d.ts +3 -0
- package/dist/package/declarations/src/views/error/404.vue.d.ts +3 -0
- package/dist/package/declarations/src/views/error/500.vue.d.ts +3 -0
- package/dist/package/declarations/src/views/error/pending.vue.d.ts +3 -0
- package/dist/package/declarations/src/views/login/components/LoginForm.vue.d.ts +4 -0
- package/dist/package/declarations/src/views/login/index.vue.d.ts +3 -0
- package/dist/package/declarations/vite.config.d.ts +13 -0
- package/dist/package/src/App.vue +25 -0
- package/dist/package/src/api/base/config.ts +19 -0
- package/dist/package/src/api/base/file.ts +75 -0
- package/dist/package/src/api/base/login.ts +81 -0
- package/dist/package/src/api/base/oauth.ts +50 -0
- package/dist/package/src/api/system/auth.ts +45 -0
- package/dist/package/src/api/system/base_dict.ts +19 -0
- package/dist/package/src/api/system/base_tenant.ts +20 -0
- package/dist/package/src/assets/fonts/DIN.otf +0 -0
- package/dist/package/src/assets/fonts/MetroDF.ttf +0 -0
- package/dist/package/src/assets/fonts/YouSheBiaoTiHei.ttf +0 -0
- package/dist/package/src/assets/fonts/font.scss +14 -0
- package/dist/package/src/assets/iconfont/iconfont.scss +47 -0
- package/dist/package/src/assets/iconfont/iconfont.ttf +0 -0
- package/dist/package/src/assets/images/403.png +0 -0
- package/dist/package/src/assets/images/404.png +0 -0
- package/dist/package/src/assets/images/500.png +0 -0
- package/dist/package/src/assets/images/avatar.png +0 -0
- package/dist/package/src/assets/images/login_bg.svg +33 -0
- package/dist/package/src/assets/images/login_left.png +0 -0
- package/dist/package/src/assets/images/logo.svg +1 -0
- package/dist/package/src/assets/images/notData.png +0 -0
- package/dist/package/src/assets/images/oauth/dingtalk.png +0 -0
- package/dist/package/src/assets/images/oauth/feishu.png +0 -0
- package/dist/package/src/assets/images/oauth/gitee.png +0 -0
- package/dist/package/src/assets/images/oauth/github.png +0 -0
- package/dist/package/src/assets/images/oauth/google.png +0 -0
- package/dist/package/src/assets/images/oauth/wechat.png +0 -0
- package/dist/package/src/assets/images/oauth/wechatwork.png +0 -0
- package/dist/package/src/auth.ts +1 -0
- package/dist/package/src/bootstrap.ts +69 -0
- package/dist/package/src/components/Card/DataPanelCard.vue +67 -0
- package/dist/package/src/components/CronExpression/index.vue +713 -0
- package/dist/package/src/components/Dialog/FormDialog.vue +160 -0
- package/dist/package/src/components/Dialog/ProDialog.vue +96 -0
- package/dist/package/src/components/Dict/DictLabel.vue +62 -0
- package/dist/package/src/components/Dict/index.vue +157 -0
- package/dist/package/src/components/ECharts/config/index.ts +45 -0
- package/dist/package/src/components/ECharts/index.vue +108 -0
- package/dist/package/src/components/ErrorMessage/index.vue +63 -0
- package/dist/package/src/components/Grid/components/GridItem.vue +69 -0
- package/dist/package/src/components/Grid/index.vue +169 -0
- package/dist/package/src/components/Grid/interface/index.ts +8 -0
- package/dist/package/src/components/ImportExcel/index.scss +3 -0
- package/dist/package/src/components/ImportExcel/index.vue +150 -0
- package/dist/package/src/components/Loading/fullScreen.ts +45 -0
- package/dist/package/src/components/Loading/index.scss +67 -0
- package/dist/package/src/components/Loading/index.vue +13 -0
- package/dist/package/src/components/PasswordStrength/index.vue +127 -0
- package/dist/package/src/components/ProForm/components/DynamicList.vue +59 -0
- package/dist/package/src/components/ProForm/components/KvList.vue +73 -0
- package/dist/package/src/components/ProForm/components/ProFormItem.vue +191 -0
- package/dist/package/src/components/ProForm/index.vue +120 -0
- package/dist/package/src/components/ProForm/interface/index.ts +74 -0
- package/dist/package/src/components/ProTable/components/ColSetting.vue +45 -0
- package/dist/package/src/components/ProTable/components/Pagination.vue +58 -0
- package/dist/package/src/components/ProTable/components/TableColumn.vue +234 -0
- package/dist/package/src/components/ProTable/index.vue +567 -0
- package/dist/package/src/components/ProTable/interface/index.ts +223 -0
- package/dist/package/src/components/ProTable.ts +8 -0
- package/dist/package/src/components/SearchForm/components/SearchFormItem.vue +168 -0
- package/dist/package/src/components/SearchForm/index.vue +105 -0
- package/dist/package/src/components/SelectFilter/index.scss +63 -0
- package/dist/package/src/components/SelectFilter/index.vue +113 -0
- package/dist/package/src/components/SelectIcon/index.scss +39 -0
- package/dist/package/src/components/SelectIcon/index.vue +105 -0
- package/dist/package/src/components/SvgIcon/index.vue +35 -0
- package/dist/package/src/components/SwitchDark/index.vue +12 -0
- package/dist/package/src/components/TreeFilter/index.scss +44 -0
- package/dist/package/src/components/TreeFilter/index.vue +207 -0
- package/dist/package/src/components/Upload/File.vue +201 -0
- package/dist/package/src/components/Upload/Files.vue +234 -0
- package/dist/package/src/components/Upload/Img.vue +306 -0
- package/dist/package/src/components/Upload/Imgs.vue +320 -0
- package/dist/package/src/components/WangEditor/index.scss +28 -0
- package/dist/package/src/components/WangEditor/index.vue +154 -0
- package/dist/package/src/config/index.ts +19 -0
- package/dist/package/src/config/nprogress.ts +12 -0
- package/dist/package/src/directives/index.ts +28 -0
- package/dist/package/src/directives/modules/auth.ts +25 -0
- package/dist/package/src/directives/modules/copy.ts +39 -0
- package/dist/package/src/directives/modules/debounce.ts +32 -0
- package/dist/package/src/directives/modules/draggable.ts +50 -0
- package/dist/package/src/directives/modules/longpress.ts +49 -0
- package/dist/package/src/directives/modules/throttle.ts +42 -0
- package/dist/package/src/directives/modules/waterMarker.ts +36 -0
- package/dist/package/src/enums/httpEnum.ts +35 -0
- package/dist/package/src/format.ts +1 -0
- package/dist/package/src/hooks/interface/index.ts +38 -0
- package/dist/package/src/hooks/useAuthButtons.ts +25 -0
- package/dist/package/src/hooks/useDownload.ts +44 -0
- package/dist/package/src/hooks/useHandleData.ts +38 -0
- package/dist/package/src/hooks/useOnline.ts +27 -0
- package/dist/package/src/hooks/useSelection.ts +34 -0
- package/dist/package/src/hooks/useTable.ts +151 -0
- package/dist/package/src/hooks/useTheme.ts +111 -0
- package/dist/package/src/hooks/useTime.ts +38 -0
- package/dist/package/src/index.ts +9 -0
- package/dist/package/src/layouts/LayoutClassic/index.scss +60 -0
- package/dist/package/src/layouts/LayoutClassic/index.vue +64 -0
- package/dist/package/src/layouts/LayoutColumns/index.scss +95 -0
- package/dist/package/src/layouts/LayoutColumns/index.vue +113 -0
- package/dist/package/src/layouts/LayoutTransverse/index.scss +60 -0
- package/dist/package/src/layouts/LayoutTransverse/index.vue +70 -0
- package/dist/package/src/layouts/LayoutVertical/index.scss +70 -0
- package/dist/package/src/layouts/LayoutVertical/index.vue +119 -0
- package/dist/package/src/layouts/components/Footer/index.scss +11 -0
- package/dist/package/src/layouts/components/Footer/index.vue +21 -0
- package/dist/package/src/layouts/components/Header/ToolBarLeft.vue +23 -0
- package/dist/package/src/layouts/components/Header/ToolBarRight.vue +44 -0
- package/dist/package/src/layouts/components/Header/components/AssemblySize.vue +39 -0
- package/dist/package/src/layouts/components/Header/components/Avatar.vue +226 -0
- package/dist/package/src/layouts/components/Header/components/Breadcrumb.vue +117 -0
- package/dist/package/src/layouts/components/Header/components/CollapseIcon.vue +21 -0
- package/dist/package/src/layouts/components/Header/components/Fullscreen.vue +28 -0
- package/dist/package/src/layouts/components/Header/components/InfoDialog.vue +22 -0
- package/dist/package/src/layouts/components/Header/components/PasswordDialog.vue +22 -0
- package/dist/package/src/layouts/components/Header/components/SearchMenu.vue +207 -0
- package/dist/package/src/layouts/components/Header/components/ThemeSetting.vue +14 -0
- package/dist/package/src/layouts/components/Main/components/Maximize.vue +39 -0
- package/dist/package/src/layouts/components/Main/index.scss +14 -0
- package/dist/package/src/layouts/components/Main/index.vue +90 -0
- package/dist/package/src/layouts/components/Menu/SubMenu.vue +132 -0
- package/dist/package/src/layouts/components/Tabs/components/MoreButton.vue +83 -0
- package/dist/package/src/layouts/components/Tabs/index.scss +69 -0
- package/dist/package/src/layouts/components/Tabs/index.vue +111 -0
- package/dist/package/src/layouts/components/ThemeDrawer/index.scss +137 -0
- package/dist/package/src/layouts/components/ThemeDrawer/index.vue +191 -0
- package/dist/package/src/layouts/index.vue +50 -0
- package/dist/package/src/layouts/indexAsync.vue +54 -0
- package/dist/package/src/modules/index.ts +233 -0
- package/dist/package/src/modules/kratosAdmin.ts +17 -0
- package/dist/package/src/navigation.ts +2 -0
- package/dist/package/src/request.ts +2 -0
- package/dist/package/src/routers/index.ts +143 -0
- package/dist/package/src/routers/modules/dynamicRouter.ts +160 -0
- package/dist/package/src/routers/modules/staticRouter.ts +73 -0
- package/dist/package/src/rpc/base/v1/config.ts +34 -0
- package/dist/package/src/rpc/base/v1/file.ts +66 -0
- package/dist/package/src/rpc/base/v1/login.ts +128 -0
- package/dist/package/src/rpc/base/v1/oauth.ts +199 -0
- package/dist/package/src/rpc/common/v1/common.ts +71 -0
- package/dist/package/src/rpc/common/v1/enum.ts +71 -0
- package/dist/package/src/rpc/common/v1/types.ts +77 -0
- package/dist/package/src/rpc/google/protobuf/empty.ts +19 -0
- package/dist/package/src/rpc/google/protobuf/wrappers.ts +124 -0
- package/dist/package/src/rpc/system/admin/v1/auth.ts +208 -0
- package/dist/package/src/rpc/system/admin/v1/base_dict.ts +249 -0
- package/dist/package/src/rpc/system/admin/v1/base_tenant.ts +134 -0
- package/dist/package/src/rpc/system/common/v1/enum.ts +80 -0
- package/dist/package/src/security.ts +3 -0
- package/dist/package/src/stores/helper/persist.ts +19 -0
- package/dist/package/src/stores/index.ts +8 -0
- package/dist/package/src/stores/interface/index.ts +102 -0
- package/dist/package/src/stores/modules/auth.ts +73 -0
- package/dist/package/src/stores/modules/config.ts +119 -0
- package/dist/package/src/stores/modules/dict.ts +65 -0
- package/dist/package/src/stores/modules/global.ts +54 -0
- package/dist/package/src/stores/modules/keepAlive.ts +22 -0
- package/dist/package/src/stores/modules/tabs.ts +77 -0
- package/dist/package/src/stores/modules/user.ts +109 -0
- package/dist/package/src/stores/runtime.ts +4 -0
- package/dist/package/src/styles/common.scss +144 -0
- package/dist/package/src/styles/element-dark.scss +46 -0
- package/dist/package/src/styles/element.scss +333 -0
- package/dist/package/src/styles/reset.scss +143 -0
- package/dist/package/src/styles/theme/aside.ts +16 -0
- package/dist/package/src/styles/theme/header.ts +25 -0
- package/dist/package/src/styles/theme/menu.ts +31 -0
- package/dist/package/src/styles/var.scss +2 -0
- package/dist/package/src/table.ts +1 -0
- package/dist/package/src/tenant.ts +1 -0
- package/dist/package/src/typings/global.d.ts +74 -0
- package/dist/package/src/typings/utils.d.ts +17 -0
- package/dist/package/src/typings/window.d.ts +8 -0
- package/dist/package/src/utils/color.ts +59 -0
- package/dist/package/src/utils/dict.ts +17 -0
- package/dist/package/src/utils/eleValidate.ts +14 -0
- package/dist/package/src/utils/errorHandler.ts +27 -0
- package/dist/package/src/utils/index.ts +403 -0
- package/dist/package/src/utils/is/index.ts +125 -0
- package/dist/package/src/utils/mittBus.ts +5 -0
- package/dist/package/src/utils/oauthProvider.ts +79 -0
- package/dist/package/src/utils/passwordCrypto.ts +71 -0
- package/dist/package/src/utils/passwordStrength.ts +86 -0
- package/dist/package/src/utils/proTable.ts +124 -0
- package/dist/package/src/utils/request.ts +296 -0
- package/dist/package/src/utils/router.ts +43 -0
- package/dist/package/src/utils/svg.ts +13 -0
- package/dist/package/src/utils/tenant.ts +10 -0
- package/dist/package/src/utils/utils.ts +40 -0
- package/dist/package/src/views/error/403.vue +8 -0
- package/dist/package/src/views/error/404.vue +8 -0
- package/dist/package/src/views/error/500.vue +8 -0
- package/dist/package/src/views/error/pending.vue +16 -0
- package/dist/package/src/views/login/components/LoginForm.vue +797 -0
- package/dist/package/src/views/login/index.scss +103 -0
- package/dist/package/src/views/login/index.vue +108 -0
- package/dist/package/src/vite-env.d.ts +3 -0
- package/dist/package/types/generated/auto-imports.d.ts +124 -0
- package/dist/package/types/generated/components.d.ts +151 -0
- package/package.json +199 -0
- package/tsconfig.json +21 -0
- package/types/generated/auto-imports.d.ts +124 -0
- package/types/generated/components.d.ts +151 -0
- package/vite.config.ts +239 -0
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
.icon-box {
|
|
2
|
+
width: 100%;
|
|
3
|
+
.el-button {
|
|
4
|
+
display: flex;
|
|
5
|
+
align-items: center;
|
|
6
|
+
justify-content: center;
|
|
7
|
+
font-size: 18px;
|
|
8
|
+
color: var(--el-text-color-regular);
|
|
9
|
+
}
|
|
10
|
+
:deep(.el-dialog__body) {
|
|
11
|
+
padding: 25px 20px 20px;
|
|
12
|
+
.el-input {
|
|
13
|
+
margin-bottom: 10px;
|
|
14
|
+
}
|
|
15
|
+
.icon-list {
|
|
16
|
+
display: grid;
|
|
17
|
+
grid-template-columns: repeat(auto-fill, 115px);
|
|
18
|
+
justify-content: space-evenly;
|
|
19
|
+
max-height: 70vh;
|
|
20
|
+
.icon-item {
|
|
21
|
+
display: flex;
|
|
22
|
+
flex-direction: column;
|
|
23
|
+
align-items: center;
|
|
24
|
+
width: 42px;
|
|
25
|
+
padding: 20px 30px;
|
|
26
|
+
cursor: pointer;
|
|
27
|
+
transition: all 0.2s;
|
|
28
|
+
&:hover {
|
|
29
|
+
transform: scale(1.3);
|
|
30
|
+
}
|
|
31
|
+
span {
|
|
32
|
+
margin-top: 5px;
|
|
33
|
+
line-height: 20px;
|
|
34
|
+
text-align: center;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="icon-box">
|
|
3
|
+
<el-input
|
|
4
|
+
ref="inputRef"
|
|
5
|
+
v-model="valueIcon"
|
|
6
|
+
v-bind="$attrs"
|
|
7
|
+
:placeholder="placeholder"
|
|
8
|
+
:clearable="clearable"
|
|
9
|
+
@clear="clearIcon"
|
|
10
|
+
@click="openDialog"
|
|
11
|
+
>
|
|
12
|
+
<template #append>
|
|
13
|
+
<el-button :icon="customIcons[iconValue]" />
|
|
14
|
+
</template>
|
|
15
|
+
</el-input>
|
|
16
|
+
<el-dialog v-model="dialogVisible" :title="placeholder" top="50px" width="66%">
|
|
17
|
+
<el-input v-model="inputValue" placeholder="搜索图标" size="large" :prefix-icon="Icons.Search" />
|
|
18
|
+
<el-scrollbar v-if="Object.keys(iconsList).length">
|
|
19
|
+
<div class="icon-list">
|
|
20
|
+
<div v-for="item in iconsList" :key="item" class="icon-item" @click="selectIcon(item)">
|
|
21
|
+
<component :is="item"></component>
|
|
22
|
+
<span>{{ item.name }}</span>
|
|
23
|
+
</div>
|
|
24
|
+
</div>
|
|
25
|
+
</el-scrollbar>
|
|
26
|
+
<el-empty v-else description="未搜索到您要找的图标~" />
|
|
27
|
+
</el-dialog>
|
|
28
|
+
</div>
|
|
29
|
+
</template>
|
|
30
|
+
|
|
31
|
+
<script setup lang="ts" name="SelectIcon">
|
|
32
|
+
import { ref, computed, watch } from "vue";
|
|
33
|
+
import * as Icons from "@element-plus/icons-vue";
|
|
34
|
+
|
|
35
|
+
/** 图标选择器组件属性。 */
|
|
36
|
+
interface SelectIconProps {
|
|
37
|
+
iconValue: string;
|
|
38
|
+
title?: string;
|
|
39
|
+
clearable?: boolean;
|
|
40
|
+
placeholder?: string;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const props = withDefaults(defineProps<SelectIconProps>(), {
|
|
44
|
+
iconValue: "",
|
|
45
|
+
title: "请选择图标",
|
|
46
|
+
clearable: true,
|
|
47
|
+
placeholder: "请选择图标"
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
// 重新接收一下,防止打包后 clearable 报错
|
|
51
|
+
const valueIcon = ref(props.iconValue);
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* 同步外部图标值到组件内部输入框,避免父组件重置后仍显示上次选择结果。
|
|
55
|
+
*/
|
|
56
|
+
watch(
|
|
57
|
+
() => props.iconValue,
|
|
58
|
+
value => {
|
|
59
|
+
valueIcon.value = value ?? "";
|
|
60
|
+
},
|
|
61
|
+
{ immediate: true }
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
// open Dialog
|
|
65
|
+
const dialogVisible = ref(false);
|
|
66
|
+
/** 打开图标选择弹窗。 */
|
|
67
|
+
const openDialog = () => (dialogVisible.value = true);
|
|
68
|
+
|
|
69
|
+
// 选择图标(触发更新父组件数据)
|
|
70
|
+
const emit = defineEmits<{
|
|
71
|
+
"update:iconValue": [value: string];
|
|
72
|
+
}>();
|
|
73
|
+
/** 选择图标并同步到外部绑定值。 */
|
|
74
|
+
const selectIcon = (item: any) => {
|
|
75
|
+
dialogVisible.value = false;
|
|
76
|
+
valueIcon.value = item.name;
|
|
77
|
+
emit("update:iconValue", item.name);
|
|
78
|
+
setTimeout(() => inputRef.value.blur(), 0);
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
// 清空图标
|
|
82
|
+
const inputRef = ref();
|
|
83
|
+
/** 清空当前已选择图标。 */
|
|
84
|
+
const clearIcon = () => {
|
|
85
|
+
valueIcon.value = "";
|
|
86
|
+
emit("update:iconValue", "");
|
|
87
|
+
setTimeout(() => inputRef.value.blur(), 0);
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
// 监听搜索框值
|
|
91
|
+
const inputValue = ref("");
|
|
92
|
+
const customIcons: { [key: string]: any } = Icons;
|
|
93
|
+
const iconsList = computed((): { [key: string]: any } => {
|
|
94
|
+
if (!inputValue.value) return Icons;
|
|
95
|
+
let result: { [key: string]: any } = {};
|
|
96
|
+
for (const key in customIcons) {
|
|
97
|
+
if (key.toLowerCase().indexOf(inputValue.value.toLowerCase()) > -1) result[key] = customIcons[key];
|
|
98
|
+
}
|
|
99
|
+
return result;
|
|
100
|
+
});
|
|
101
|
+
</script>
|
|
102
|
+
|
|
103
|
+
<style scoped lang="scss">
|
|
104
|
+
@use "./index.scss" as *;
|
|
105
|
+
</style>
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<svg :style="iconStyle" aria-hidden="true">
|
|
3
|
+
<use :xlink:href="symbolId" />
|
|
4
|
+
</svg>
|
|
5
|
+
</template>
|
|
6
|
+
|
|
7
|
+
<script setup lang="ts" name="SvgIcon">
|
|
8
|
+
import { computed, CSSProperties } from "vue";
|
|
9
|
+
|
|
10
|
+
/** SvgIcon 组件属性。 */
|
|
11
|
+
interface SvgProps {
|
|
12
|
+
iconClass: string; // 图标名称
|
|
13
|
+
prefix?: string; // 图标的前缀 ==> 非必传(默认为"icon")
|
|
14
|
+
size?: string | number; // 图标尺寸 ==> 非必传
|
|
15
|
+
iconStyle?: CSSProperties; // 图标的样式 ==> 非必传
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const props = withDefaults(defineProps<SvgProps>(), {
|
|
19
|
+
prefix: "icon",
|
|
20
|
+
size: "",
|
|
21
|
+
iconStyle: () => ({})
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
const iconStyle = computed<CSSProperties>(() => {
|
|
25
|
+
const style: CSSProperties = { ...props.iconStyle };
|
|
26
|
+
if (props.size !== "" && props.size !== undefined) {
|
|
27
|
+
const sizeValue = typeof props.size === "number" ? `${props.size}px` : props.size;
|
|
28
|
+
style.width = sizeValue;
|
|
29
|
+
style.height = sizeValue;
|
|
30
|
+
}
|
|
31
|
+
return style;
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
const symbolId = computed(() => `#${props.prefix}-${props.iconClass}`);
|
|
35
|
+
</script>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<el-switch v-model="globalStore.isDark" inline-prompt :active-icon="Sunny" :inactive-icon="Moon" @change="switchDark" />
|
|
3
|
+
</template>
|
|
4
|
+
|
|
5
|
+
<script setup lang="ts" name="SwitchDark">
|
|
6
|
+
import { useTheme } from "../../hooks/useTheme";
|
|
7
|
+
import { useGlobalStore } from "../../stores/modules/global";
|
|
8
|
+
import { Sunny, Moon } from "@element-plus/icons-vue";
|
|
9
|
+
|
|
10
|
+
const { switchDark } = useTheme();
|
|
11
|
+
const globalStore = useGlobalStore();
|
|
12
|
+
</script>
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
.filter {
|
|
2
|
+
box-sizing: border-box;
|
|
3
|
+
width: 220px;
|
|
4
|
+
height: 100%;
|
|
5
|
+
padding: 18px;
|
|
6
|
+
margin-right: 10px;
|
|
7
|
+
.title {
|
|
8
|
+
margin: 0 0 15px;
|
|
9
|
+
font-size: 18px;
|
|
10
|
+
font-weight: bold;
|
|
11
|
+
color: var(--el-color-info-dark-2);
|
|
12
|
+
letter-spacing: 0.5px;
|
|
13
|
+
}
|
|
14
|
+
.search {
|
|
15
|
+
display: flex;
|
|
16
|
+
align-items: center;
|
|
17
|
+
margin: 0 0 15px;
|
|
18
|
+
.el-icon {
|
|
19
|
+
cursor: pointer;
|
|
20
|
+
transform: rotate(90deg) translateY(-8px);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
.el-scrollbar {
|
|
24
|
+
:deep(.el-tree) {
|
|
25
|
+
height: 80%;
|
|
26
|
+
overflow: auto;
|
|
27
|
+
.el-tree-node__content {
|
|
28
|
+
height: 33px;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
:deep(.el-tree--highlight-current) {
|
|
32
|
+
.el-tree-node.is-current > .el-tree-node__content {
|
|
33
|
+
background-color: var(--el-color-primary);
|
|
34
|
+
.el-tree-node__label,
|
|
35
|
+
.el-tree-node__expand-icon {
|
|
36
|
+
color: white;
|
|
37
|
+
}
|
|
38
|
+
.is-leaf {
|
|
39
|
+
color: transparent;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="card filter">
|
|
3
|
+
<h4 v-if="title" class="title sle">
|
|
4
|
+
{{ title }}
|
|
5
|
+
</h4>
|
|
6
|
+
<div class="search">
|
|
7
|
+
<el-input v-model="filterText" placeholder="输入关键字进行过滤" clearable />
|
|
8
|
+
<el-dropdown trigger="click">
|
|
9
|
+
<el-icon size="20"><More /></el-icon>
|
|
10
|
+
<template #dropdown>
|
|
11
|
+
<el-dropdown-menu>
|
|
12
|
+
<el-dropdown-item v-if="!multiple" @click="resetSelected">重置选择</el-dropdown-item>
|
|
13
|
+
<el-dropdown-item @click="toggleTreeNodes(true)">展开全部</el-dropdown-item>
|
|
14
|
+
<el-dropdown-item @click="toggleTreeNodes(false)">折叠全部</el-dropdown-item>
|
|
15
|
+
</el-dropdown-menu>
|
|
16
|
+
</template>
|
|
17
|
+
</el-dropdown>
|
|
18
|
+
</div>
|
|
19
|
+
<el-scrollbar :style="{ height: title ? `calc(100% - 95px)` : `calc(100% - 56px)` }">
|
|
20
|
+
<el-tree
|
|
21
|
+
ref="treeRef"
|
|
22
|
+
:default-expand-all="!lazy"
|
|
23
|
+
:node-key="id"
|
|
24
|
+
:data="multiple || !showAll ? treeData : treeAllData"
|
|
25
|
+
:show-checkbox="multiple"
|
|
26
|
+
:check-strictly="false"
|
|
27
|
+
:current-node-key="!multiple ? selected : undefined"
|
|
28
|
+
:highlight-current="!multiple"
|
|
29
|
+
:expand-on-click-node="false"
|
|
30
|
+
:check-on-click-node="multiple"
|
|
31
|
+
:props="defaultProps"
|
|
32
|
+
:lazy="lazy"
|
|
33
|
+
:load="lazy ? loadTreeNode : undefined"
|
|
34
|
+
:filter-node-method="filterNode"
|
|
35
|
+
:default-checked-keys="multiple ? selected : []"
|
|
36
|
+
@node-click="handleNodeClick"
|
|
37
|
+
@check="handleCheckChange"
|
|
38
|
+
>
|
|
39
|
+
<template #default="scope">
|
|
40
|
+
<span class="el-tree-node__label">
|
|
41
|
+
<slot :row="scope">
|
|
42
|
+
{{ scope.node.label }}
|
|
43
|
+
</slot>
|
|
44
|
+
</span>
|
|
45
|
+
</template>
|
|
46
|
+
</el-tree>
|
|
47
|
+
</el-scrollbar>
|
|
48
|
+
</div>
|
|
49
|
+
</template>
|
|
50
|
+
|
|
51
|
+
<script setup lang="ts" name="TreeFilter">
|
|
52
|
+
import { ref, watch, onBeforeMount, nextTick } from "vue";
|
|
53
|
+
import { ElTree } from "element-plus";
|
|
54
|
+
|
|
55
|
+
// 接收父组件参数并设置默认值
|
|
56
|
+
interface TreeFilterProps {
|
|
57
|
+
requestApi?: (data?: any) => Promise<any>; // 请求分类数据的 api ==> 非必传
|
|
58
|
+
data?: { [key: string]: any }[]; // 分类数据,如果有分类数据,则不会执行 api 请求 ==> 非必传
|
|
59
|
+
title?: string; // treeFilter 标题 ==> 非必传
|
|
60
|
+
id?: string; // 选择的id ==> 非必传,默认为 “id”
|
|
61
|
+
label?: string; // 显示的label ==> 非必传,默认为 “label”
|
|
62
|
+
multiple?: boolean; // 是否为多选 ==> 非必传,默认为 false
|
|
63
|
+
defaultValue?: any; // 默认选中的值 ==> 非必传
|
|
64
|
+
showAll?: boolean; // 单选模式下是否展示“全部”节点 ==> 非必传,默认为 true
|
|
65
|
+
lazy?: boolean; // 是否按节点懒加载子节点
|
|
66
|
+
parentKey?: string; // 懒加载请求使用的父节点字段
|
|
67
|
+
}
|
|
68
|
+
const props = withDefaults(defineProps<TreeFilterProps>(), {
|
|
69
|
+
id: "id",
|
|
70
|
+
label: "label",
|
|
71
|
+
multiple: false,
|
|
72
|
+
showAll: true,
|
|
73
|
+
lazy: false,
|
|
74
|
+
parentKey: "parent_id"
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
const defaultProps = {
|
|
78
|
+
children: "children",
|
|
79
|
+
label: props.label
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
const treeRef = ref<InstanceType<typeof ElTree>>();
|
|
83
|
+
const treeData = ref<{ [key: string]: any }[]>([]);
|
|
84
|
+
const treeAllData = ref<{ [key: string]: any }[]>([]);
|
|
85
|
+
|
|
86
|
+
const selected = ref();
|
|
87
|
+
const setSelected = () => {
|
|
88
|
+
if (props.multiple) selected.value = Array.isArray(props.defaultValue) ? props.defaultValue : [props.defaultValue];
|
|
89
|
+
else selected.value = typeof props.defaultValue === "string" && props.defaultValue ? props.defaultValue : undefined;
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
const normalizeLazyNodes = (nodes: { [key: string]: any }[] = []) =>
|
|
93
|
+
nodes.map(node => ({
|
|
94
|
+
...node,
|
|
95
|
+
isLeaf: !node.has_children
|
|
96
|
+
}));
|
|
97
|
+
|
|
98
|
+
const updateTreeData = (data: { [key: string]: any }[]) => {
|
|
99
|
+
treeData.value = props.lazy ? normalizeLazyNodes(data) : data;
|
|
100
|
+
const allNode = { id: "", [props.label]: "全部", isLeaf: true };
|
|
101
|
+
treeAllData.value = props.showAll ? [allNode, ...treeData.value] : treeData.value;
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
onBeforeMount(async () => {
|
|
105
|
+
setSelected();
|
|
106
|
+
if (props.requestApi) {
|
|
107
|
+
const requestParams = props.lazy ? { [props.parentKey]: 0, lazy: true } : undefined;
|
|
108
|
+
const { data } = await props.requestApi(requestParams);
|
|
109
|
+
updateTreeData(data ?? []);
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
const loadTreeNode = async (node: { level: number; data?: { [key: string]: any } }, resolve: (data: { [key: string]: any }[]) => void) => {
|
|
114
|
+
if (!props.requestApi) {
|
|
115
|
+
resolve([]);
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
const parentId = node.level === 0 ? 0 : node.data?.[props.id];
|
|
119
|
+
try {
|
|
120
|
+
const { data } = await props.requestApi({ [props.parentKey]: parentId, lazy: true });
|
|
121
|
+
resolve(normalizeLazyNodes(data ?? []));
|
|
122
|
+
} catch {
|
|
123
|
+
resolve([]);
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
// 使用 nextTick 防止打包后赋值不生效,开发环境是正常的
|
|
128
|
+
watch(
|
|
129
|
+
() => props.defaultValue,
|
|
130
|
+
() => nextTick(() => setSelected()),
|
|
131
|
+
{ deep: true, immediate: true }
|
|
132
|
+
);
|
|
133
|
+
|
|
134
|
+
watch(
|
|
135
|
+
() => props.data,
|
|
136
|
+
() => {
|
|
137
|
+
if (props.data?.length) {
|
|
138
|
+
updateTreeData(props.data);
|
|
139
|
+
}
|
|
140
|
+
},
|
|
141
|
+
{ deep: true, immediate: true }
|
|
142
|
+
);
|
|
143
|
+
|
|
144
|
+
const filterText = ref("");
|
|
145
|
+
watch(filterText, val => {
|
|
146
|
+
treeRef.value!.filter(val);
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
// 过滤
|
|
150
|
+
const filterNode = (value: string, data: { [key: string]: any }, node: any) => {
|
|
151
|
+
if (!value) return true;
|
|
152
|
+
let parentNode = node.parent,
|
|
153
|
+
labels = [node.label],
|
|
154
|
+
level = 1;
|
|
155
|
+
while (level < node.level) {
|
|
156
|
+
labels = [...labels, parentNode.label];
|
|
157
|
+
parentNode = parentNode.parent;
|
|
158
|
+
level++;
|
|
159
|
+
}
|
|
160
|
+
return labels.some(label => label.indexOf(value) !== -1);
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
// 切换树节点的展开或折叠状态
|
|
164
|
+
const toggleTreeNodes = (isExpand: boolean) => {
|
|
165
|
+
let nodes = treeRef.value?.store.nodesMap;
|
|
166
|
+
if (!nodes) return;
|
|
167
|
+
for (const node in nodes) {
|
|
168
|
+
if (nodes.hasOwnProperty(node)) {
|
|
169
|
+
nodes[node].expanded = isExpand;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
// emit
|
|
175
|
+
const emit = defineEmits<{
|
|
176
|
+
change: [value: any];
|
|
177
|
+
}>();
|
|
178
|
+
|
|
179
|
+
// 单选
|
|
180
|
+
const handleNodeClick = (data: { [key: string]: any }) => {
|
|
181
|
+
if (props.multiple) return;
|
|
182
|
+
selected.value = data[props.id];
|
|
183
|
+
emit("change", data[props.id]);
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
// 多选
|
|
187
|
+
const handleCheckChange = () => {
|
|
188
|
+
emit("change", treeRef.value?.getCheckedKeys());
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
// 重置当前单选树筛选
|
|
192
|
+
const resetSelected = () => {
|
|
193
|
+
if (props.multiple) return;
|
|
194
|
+
selected.value = undefined;
|
|
195
|
+
nextTick(() => {
|
|
196
|
+
treeRef.value?.setCurrentKey(null);
|
|
197
|
+
});
|
|
198
|
+
emit("change", "");
|
|
199
|
+
};
|
|
200
|
+
|
|
201
|
+
// 暴露给父组件使用
|
|
202
|
+
defineExpose({ treeData, treeAllData, treeRef });
|
|
203
|
+
</script>
|
|
204
|
+
|
|
205
|
+
<style scoped lang="scss">
|
|
206
|
+
@use "./index.scss" as *;
|
|
207
|
+
</style>
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="upload-file-box">
|
|
3
|
+
<el-upload
|
|
4
|
+
action="#"
|
|
5
|
+
:class="['upload-file', selfDisabled ? 'disabled' : '']"
|
|
6
|
+
:multiple="false"
|
|
7
|
+
:disabled="selfDisabled"
|
|
8
|
+
:show-file-list="false"
|
|
9
|
+
:http-request="handleHttpUpload"
|
|
10
|
+
:before-upload="beforeUpload"
|
|
11
|
+
:on-success="uploadSuccess"
|
|
12
|
+
:on-error="uploadError"
|
|
13
|
+
:accept="fileType.join(',')"
|
|
14
|
+
>
|
|
15
|
+
<el-button type="primary" :disabled="selfDisabled">上传文件</el-button>
|
|
16
|
+
</el-upload>
|
|
17
|
+
|
|
18
|
+
<div v-if="fileInfo?.url" class="file-card">
|
|
19
|
+
<div class="file-card__main">
|
|
20
|
+
<el-icon class="file-card__icon"><Document /></el-icon>
|
|
21
|
+
<div class="file-card__meta">
|
|
22
|
+
<div class="file-card__name">{{ fileInfo.name || "未命名文件" }}</div>
|
|
23
|
+
<div class="file-card__url">{{ fileInfo.url }}</div>
|
|
24
|
+
</div>
|
|
25
|
+
</div>
|
|
26
|
+
<div class="file-card__action">
|
|
27
|
+
<el-button link type="primary" :icon="Download" @click.stop="handleDownload">下载</el-button>
|
|
28
|
+
<el-button v-if="!selfDisabled" link type="danger" :icon="Delete" @click.stop="handleDelete">删除</el-button>
|
|
29
|
+
</div>
|
|
30
|
+
</div>
|
|
31
|
+
</div>
|
|
32
|
+
</template>
|
|
33
|
+
|
|
34
|
+
<script setup lang="ts" name="UploadFile">
|
|
35
|
+
import { computed, inject } from "vue";
|
|
36
|
+
import { Delete, Document, Download } from "@element-plus/icons-vue";
|
|
37
|
+
import { ElNotification, formContextKey, formItemContextKey } from "element-plus";
|
|
38
|
+
import type { UploadProps, UploadRequestOptions, UploadUserFile } from "element-plus";
|
|
39
|
+
import { defFileService } from "../../api/base/file";
|
|
40
|
+
import type { FileInfo } from "../../rpc/base/v1/file";
|
|
41
|
+
|
|
42
|
+
/** 单文件上传组件属性。 */
|
|
43
|
+
interface UploadFileProps {
|
|
44
|
+
fileInfo?: UploadUserFile;
|
|
45
|
+
api?: (file: File) => Promise<FileInfo>;
|
|
46
|
+
disabled?: boolean;
|
|
47
|
+
fileSize?: number;
|
|
48
|
+
fileType?: string[];
|
|
49
|
+
uploadType?: string;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const props = withDefaults(defineProps<UploadFileProps>(), {
|
|
53
|
+
fileInfo: undefined,
|
|
54
|
+
disabled: false,
|
|
55
|
+
fileSize: 20,
|
|
56
|
+
fileType: () => [],
|
|
57
|
+
uploadType: "file"
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
const emit = defineEmits<{
|
|
61
|
+
"update:fileInfo": [value: UploadUserFile | undefined];
|
|
62
|
+
}>();
|
|
63
|
+
|
|
64
|
+
const formContext = inject(formContextKey, void 0);
|
|
65
|
+
const formItemContext = inject(formItemContextKey, void 0);
|
|
66
|
+
/** Element Plus 上传错误回调要求的错误对象类型。 */
|
|
67
|
+
type UploadRequestError = Parameters<NonNullable<UploadRequestOptions["onError"]>>[0];
|
|
68
|
+
|
|
69
|
+
/** 兼容 Element Plus 上传组件要求的错误对象结构。 */
|
|
70
|
+
function buildUploadError(error: unknown): UploadRequestError {
|
|
71
|
+
const uploadError = error instanceof Error ? error : new Error("文件上传失败");
|
|
72
|
+
return Object.assign(uploadError, {
|
|
73
|
+
status: 500,
|
|
74
|
+
method: "POST",
|
|
75
|
+
url: "#"
|
|
76
|
+
}) as UploadRequestError;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** 计算当前组件是否禁用。 */
|
|
80
|
+
const selfDisabled = computed(() => {
|
|
81
|
+
return props.disabled || formContext?.disabled;
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
/** 上传前校验文件大小和格式。 */
|
|
85
|
+
const beforeUpload: UploadProps["beforeUpload"] = rawFile => {
|
|
86
|
+
const fileSizeValid = rawFile.size / 1024 / 1024 < props.fileSize;
|
|
87
|
+
const fileTypeValid = !props.fileType.length || props.fileType.includes(rawFile.type);
|
|
88
|
+
|
|
89
|
+
if (!fileTypeValid) {
|
|
90
|
+
ElNotification({
|
|
91
|
+
title: "温馨提示",
|
|
92
|
+
message: "上传文件不符合所需的格式!",
|
|
93
|
+
type: "warning"
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
if (!fileSizeValid) {
|
|
98
|
+
ElNotification({
|
|
99
|
+
title: "温馨提示",
|
|
100
|
+
message: `上传文件大小不能超过 ${props.fileSize}M!`,
|
|
101
|
+
type: "warning"
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
return fileSizeValid && fileTypeValid;
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
/** 执行自定义文件上传。 */
|
|
109
|
+
const handleHttpUpload = async (options: UploadRequestOptions) => {
|
|
110
|
+
try {
|
|
111
|
+
const api = props.api ?? (file => defFileService.UploadFile(file, props.uploadType));
|
|
112
|
+
const data = await api(options.file);
|
|
113
|
+
options.onSuccess(data);
|
|
114
|
+
} catch (error) {
|
|
115
|
+
options.onError(buildUploadError(error));
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
/** 处理单文件上传成功后的状态同步。 */
|
|
120
|
+
const uploadSuccess = (response: FileInfo | undefined) => {
|
|
121
|
+
if (!response) return;
|
|
122
|
+
emit("update:fileInfo", {
|
|
123
|
+
name: response.name,
|
|
124
|
+
url: response.url
|
|
125
|
+
});
|
|
126
|
+
formItemContext?.prop && formContext?.validateField([formItemContext.prop as string]);
|
|
127
|
+
ElNotification({
|
|
128
|
+
title: "温馨提示",
|
|
129
|
+
message: "文件上传成功!",
|
|
130
|
+
type: "success"
|
|
131
|
+
});
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
/** 处理文件上传失败提示。 */
|
|
135
|
+
const uploadError = () => {
|
|
136
|
+
ElNotification({
|
|
137
|
+
title: "温馨提示",
|
|
138
|
+
message: "文件上传失败,请您重新上传!",
|
|
139
|
+
type: "error"
|
|
140
|
+
});
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
/** 删除当前已上传文件。 */
|
|
144
|
+
function handleDelete() {
|
|
145
|
+
emit("update:fileInfo", undefined);
|
|
146
|
+
formItemContext?.prop && formContext?.validateField([formItemContext.prop as string]);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/** 下载当前已上传文件。 */
|
|
150
|
+
async function handleDownload() {
|
|
151
|
+
if (!props.fileInfo?.url) return;
|
|
152
|
+
await defFileService.DownloadFile(props.fileInfo.url, props.fileInfo.name ?? "download");
|
|
153
|
+
}
|
|
154
|
+
</script>
|
|
155
|
+
|
|
156
|
+
<style scoped lang="scss">
|
|
157
|
+
.upload-file-box {
|
|
158
|
+
width: 100%;
|
|
159
|
+
}
|
|
160
|
+
.file-card {
|
|
161
|
+
display: flex;
|
|
162
|
+
gap: 16px;
|
|
163
|
+
align-items: center;
|
|
164
|
+
justify-content: space-between;
|
|
165
|
+
padding: 12px 14px;
|
|
166
|
+
margin-top: 12px;
|
|
167
|
+
background: var(--el-fill-color-light);
|
|
168
|
+
border: 1px solid var(--el-border-color-light);
|
|
169
|
+
border-radius: 8px;
|
|
170
|
+
}
|
|
171
|
+
.file-card__main {
|
|
172
|
+
display: flex;
|
|
173
|
+
flex: 1;
|
|
174
|
+
gap: 12px;
|
|
175
|
+
min-width: 0;
|
|
176
|
+
}
|
|
177
|
+
.file-card__icon {
|
|
178
|
+
margin-top: 2px;
|
|
179
|
+
font-size: 18px;
|
|
180
|
+
color: var(--el-color-primary);
|
|
181
|
+
}
|
|
182
|
+
.file-card__meta {
|
|
183
|
+
min-width: 0;
|
|
184
|
+
}
|
|
185
|
+
.file-card__name {
|
|
186
|
+
font-size: 14px;
|
|
187
|
+
color: var(--el-text-color-primary);
|
|
188
|
+
}
|
|
189
|
+
.file-card__url {
|
|
190
|
+
overflow: hidden;
|
|
191
|
+
text-overflow: ellipsis;
|
|
192
|
+
font-size: 12px;
|
|
193
|
+
color: var(--el-text-color-secondary);
|
|
194
|
+
white-space: nowrap;
|
|
195
|
+
}
|
|
196
|
+
.file-card__action {
|
|
197
|
+
display: flex;
|
|
198
|
+
flex-shrink: 0;
|
|
199
|
+
gap: 8px;
|
|
200
|
+
}
|
|
201
|
+
</style>
|