From 8cec3721f8d95602d5b9e6ffda5cf74ea966dde3 Mon Sep 17 00:00:00 2001 From: zhouhaibin Date: Wed, 18 Dec 2024 11:24:23 +0800 Subject: [PATCH] =?UTF-8?q?=E7=89=88=E6=9C=AC=E5=8D=87=E7=BA=A7=E8=87=B31.?= =?UTF-8?q?4.5=20=E5=8C=B9=E9=85=8D5.2.3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 32 +++++++++++ README.md | 12 ++--- internal/vite-config/package.json | 2 +- package.json | 17 +++--- packages/hooks/package.json | 2 +- src/api/monitor/online/index.ts | 2 +- src/api/system/tenant/index.ts | 13 +++++ .../Application/src/AppTenantToggle.vue | 22 ++++---- .../Table/src/components/settings/index.vue | 2 +- src/layouts/default/menu/index.vue | 9 ++++ src/layouts/default/sider/MixSider.vue | 10 +++- src/locales/lang/en/menu.json | 54 +++++++++++++++++++ src/locales/lang/zh-CN/menu.json | 54 +++++++++++++++++++ src/logics/error-handle/index.ts | 42 ++++++++++++++- src/router/helper/menuHelper.ts | 5 -- src/router/helper/routeHelper.ts | 26 ++++++--- src/router/routes/modules/dashboard.ts | 2 + src/store/modules/dict.ts | 12 ++++- src/utils/dict.ts | 42 +++++++-------- .../monitor/cache/components/MemoryChart.vue | 3 ++ .../monitor/logininfor/LoginInfoModal.vue | 3 +- src/views/system/config/config.data.ts | 2 +- src/views/system/dict/type/DictType.vue | 13 ++--- src/views/system/menu/index.vue | 6 +++ src/views/system/menu/menu.data.ts | 5 ++ src/views/system/post/index.vue | 2 +- src/views/system/role/RoleAuthModal.vue | 2 +- src/views/system/role/RoleDrawer.vue | 13 ++++- src/views/system/role/role.data.ts | 1 + src/views/system/tenant/index.vue | 18 ++++++- .../tenantPackage/TenantPackageDrawer.vue | 6 +++ src/views/system/user/DeptTree.vue | 1 + src/views/system/user/UserDrawer.vue | 22 ++++++-- src/views/system/user/user.data.ts | 4 ++ src/views/tool/gen/ImportTableModal.vue | 22 ++++---- .../components/UserSelectModal/index.vue | 1 + .../演示使用自行删除/wechat/index.vue | 8 +-- 37 files changed, 390 insertions(+), 102 deletions(-) create mode 100644 src/locales/lang/en/menu.json create mode 100644 src/locales/lang/zh-CN/menu.json diff --git a/CHANGELOG.md b/CHANGELOG.md index 3091e80..b386809 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,35 @@ +# 1.4.6 + +**Other** + +- 升级部分核心依赖 如ant-design-vue/vue等 + +# 1.4.5 + +**Refactor** + +使用其他方案重构`路由参数`的处理 + +**Fix** + +超级管理员切换租户后 字典丢失并且不会重新加载 + +部门树超过屏幕高度后无法滚动 -> 设置固定高度 + +用户管理 更新时岗位选择option无法正常显示 + +**Feature** + +某些人不按规范使用也从不看控制台导致的页面白屏 增加提示信息 + +增加菜单名称i18n功能 + +**Other** + +升级ant-design-vue至最新版本(v4.2.5) + +用户管理 优化岗位选择placeholder + # 1.4.4 **Feature** diff --git a/README.md b/README.md index 2cb5e99..82caace 100644 --- a/README.md +++ b/README.md @@ -2,11 +2,11 @@ ## 提示 -该仓库为老版本 **[vben2]** 目前follow后端版本 vben5官方组件完善后此仓库不再进行开发 +

该仓库为老版本[vben2]已不再进行维护/更新

-适配最新的 **[vben5]** 移步[gitee地址](https://gitee.com/dapppp/ruoyi-plus-vben5) vben5版本等待官方组件中 +最后支持后端版本 **5.2.3/2.2.3** -根据白嫖率会不定期关闭fork😅 +适配最新的 **[vben5]** 移步[gitee地址](https://gitee.com/dapppp/ruoyi-plus-vben5) ## 简介 @@ -15,7 +15,7 @@ | 组件/框架 | 版本 | | :------------- | :----- | | vben | 2.11.4 | -| ant-design-vue | 4.2.1 | +| ant-design-vue | 4.2.5 | | vue | 3.4.37 | 对应后端项目: **(分布式 5.X 分支 微服务 2.分支)** @@ -30,10 +30,6 @@ admin 账号: admin admin123 [预览地址点这里](http://plus.dapdap.top) -## WX Group - -暂不开放 - ## 文档 [vben 文档地址](https://doc.vvbin.cn/) diff --git a/internal/vite-config/package.json b/internal/vite-config/package.json index bee2112..5709986 100644 --- a/internal/vite-config/package.json +++ b/internal/vite-config/package.json @@ -39,7 +39,7 @@ "@types/fs-extra": "11.0.4", "@vitejs/plugin-vue": "5.0.4", "@vitejs/plugin-vue-jsx": "3.1.0", - "ant-design-vue": "4.2.1", + "ant-design-vue": "4.2.6", "dayjs": "1.11.10", "dotenv": "16.4.5", "fs-extra": "11.2.0", diff --git a/package.json b/package.json index 1b063b8..b9b3a04 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,7 @@ { + "$schema": "https://json.schemastore.org/tsconfig", "name": "ruoyi-plus-vben", - "version": "1.4.4", + "version": "1.4.5", "homepage": "https://gitee.com/dapppp/ruoyi-plus-vben.git", "bugs": { "url": "https://gitee.com/dapppp/ruoyi-plus-vben/issues" @@ -76,7 +77,7 @@ "@vue/shared": "3.4.37", "@vueuse/core": "^10.11.1", "@zxcvbn-ts/core": "3.0.4", - "ant-design-vue": "4.2.3", + "ant-design-vue": "4.2.6", "axios": "1.7.4", "bpmn-js": "17.5.0", "bpmn-js-token-simulation": "0.34.1", @@ -107,7 +108,7 @@ "tinymce": "7.3.0", "unocss": "0.62.1", "vditor": "3.10.5", - "vue": "3.4.37", + "vue": "3.5.13", "vue-i18n": "9.13.1", "vue-json-pretty": "2.4.0", "vue-router": "4.4.3", @@ -122,7 +123,7 @@ "devDependencies": { "@commitlint/cli": "19.3.0", "@commitlint/config-conventional": "19.2.2", - "@iconify/json": "2.2.203", + "@iconify/json": "2.2.276", "@purge-icons/generated": "0.10.0", "@types/codemirror": "5.60.15", "@types/crypto-js": "4.2.2", @@ -137,8 +138,8 @@ "@vben/ts-config": "workspace:*", "@vben/types": "workspace:*", "@vben/vite-config": "workspace:*", - "@vue/compiler-sfc": "3.4.37", - "@vue/test-utils": "2.4.5", + "@vue/compiler-sfc": "3.5.13", + "@vue/test-utils": "2.4.6", "conventional-changelog-cli": "4.1.0", "cross-env": "7.0.3", "cz-git": "1.9.1", @@ -153,8 +154,8 @@ "typescript": "5.5.4", "unbuild": "2.0.0", "vite": "5.4.0", - "vite-plugin-vue-devtools": "7.3.8", - "vue-tsc": "2.0.29" + "vite-plugin-vue-devtools": "7.6.5", + "vue-tsc": "2.1.10" }, "engines": { "node": ">=18.12.0", diff --git a/packages/hooks/package.json b/packages/hooks/package.json index 4a0f82f..f400c0b 100644 --- a/packages/hooks/package.json +++ b/packages/hooks/package.json @@ -32,7 +32,7 @@ "dependencies": { "@vueuse/core": "10.11.0", "lodash-es": "4.17.21", - "vue": "3.4.37" + "vue": "3.5.13" }, "devDependencies": { "@vben/types": "workspace:*" diff --git a/src/api/monitor/online/index.ts b/src/api/monitor/online/index.ts index 83fc497..db2c0e1 100644 --- a/src/api/monitor/online/index.ts +++ b/src/api/monitor/online/index.ts @@ -29,5 +29,5 @@ export function forceLogout(tokenId: string) { * @returns */ export function forceLogout2(tokenId: string) { - return defHttp.post({ url: Api.root + '/' + tokenId }); + return defHttp.post({ url: Api.root + 'myself/' + tokenId }); } diff --git a/src/api/system/tenant/index.ts b/src/api/system/tenant/index.ts index 034aa43..72448c5 100644 --- a/src/api/system/tenant/index.ts +++ b/src/api/system/tenant/index.ts @@ -10,6 +10,7 @@ enum Api { tenantDynamic = '/system/tenant/dynamic', tenantDynamicClear = '/system/tenant/dynamic/clear', tenantSyncPackage = '/system/tenant/syncTenantPackage', + dictSync = '/system/tenant/syncTenantDict', } export function tenantList(params?: PageQuery) { @@ -68,3 +69,15 @@ export function tenantSyncPackage(tenantId: string, packageId: string, showMsg = { successMessageMode: showMsg ? 'message' : 'none' }, ); } + +/** + * 同步租户字典 + * @param tenantId 租户ID + * @returns void + */ +export function dictSyncTenant(tenantId?: string) { + return defHttp.get( + { url: Api.dictSync, params: { tenantId } }, + { successMessageMode: 'message' }, + ); +} diff --git a/src/components/Application/src/AppTenantToggle.vue b/src/components/Application/src/AppTenantToggle.vue index ca01217..f06281b 100644 --- a/src/components/Application/src/AppTenantToggle.vue +++ b/src/components/Application/src/AppTenantToggle.vue @@ -45,6 +45,7 @@ import { storeToRefs } from 'pinia'; import { useAppInject } from '@/hooks/web/useAppInject'; import Icon from '@/components/Icon/Icon.vue'; + import type { SelectHandler } from 'ant-design-vue/es/vc-select/Select'; const SelectOption = Select.Option; @@ -76,37 +77,36 @@ const { closeAll } = useTabs(); const { createMessage } = useMessage(); - function close(checked: boolean) { + async function close(checked: boolean) { // store设置状态 setChecked(checked); // 需要关闭全部标签页 - closeAll(); + await closeAll(); // 切换完加载首页 go(PageEnum.BASE_HOME); } const dictStore = useDictStore(); - /** - * 为什么要用any ide报错😅 实际类型为string - */ - async function onSelected(tenantId: any, option: any) { + const onSelected: SelectHandler = async (tenantId: string, option: any) => { if (unref(lastSelected) === tenantId) { // createMessage.info('选择一致'); return; } await tenantDynamicToggle(tenantId); lastSelected.value = tenantId; - dictStore.resetCache(); createMessage.success('切换当前租户为: ' + option.title); - close(true); - } + await close(true); + // 需要放在宏队列处理 直接清空页面由于没有字典会有样式问题(标签变成unknown) + setTimeout(() => dictStore.resetCache()); + }; async function onDeselect() { await tenantDynamicClear(); - dictStore.resetCache(); createMessage.success('还原为默认租户'); lastSelected.value = ''; - close(false); + await close(false); + // 需要放在宏队列处理 直接清空页面由于没有字典会有样式问题(标签变成unknown) + setTimeout(() => dictStore.resetCache()); } diff --git a/src/components/Table/src/components/settings/index.vue b/src/components/Table/src/components/settings/index.vue index b9ec87e..342bf1b 100644 --- a/src/components/Table/src/components/settings/index.vue +++ b/src/components/Table/src/components/settings/index.vue @@ -39,7 +39,7 @@ redo: true, size: true, setting: true, - settingCache: true, + settingCache: false, fullScreen: false, ...props.setting, }; diff --git a/src/layouts/default/menu/index.vue b/src/layouts/default/menu/index.vue index 57a4a87..665f631 100644 --- a/src/layouts/default/menu/index.vue +++ b/src/layouts/default/menu/index.vue @@ -19,6 +19,8 @@ import { useRootSetting } from '@/hooks/setting/useRootSetting'; import { useAppInject } from '@/hooks/web/useAppInject'; import { useDesign } from '@/hooks/web/useDesign'; + import { useRouter } from 'vue-router'; + import { isPlainObject } from 'lodash-es'; export default defineComponent({ name: 'LayoutMenu', @@ -110,7 +112,14 @@ * @param menu */ + const currentRoutes = useRouter().getRoutes(); function handleMenuClick(path: string) { + // 路由参数的处理 + const found = currentRoutes.find((item) => item.path === path); + if (found && isPlainObject(found.meta.query)) { + go({ path: path as any, query: found.meta.query }); + return; + } go(path); } diff --git a/src/layouts/default/sider/MixSider.vue b/src/layouts/default/sider/MixSider.vue index 1ce110b..48fe7e7 100644 --- a/src/layouts/default/sider/MixSider.vue +++ b/src/layouts/default/sider/MixSider.vue @@ -87,7 +87,7 @@ import type { Menu } from '@/router/types'; import type { CSSProperties } from 'vue'; import { computed, onMounted, ref, unref, watch } from 'vue'; - import type { RouteLocationNormalized } from 'vue-router'; + import { useRouter, type RouteLocationNormalized } from 'vue-router'; import { ScrollContainer } from '@/components/Container'; import { SimpleMenu } from '@/components/SimpleMenu'; import Icon from '@/components/Icon/Icon.vue'; @@ -107,6 +107,7 @@ import { createAsyncComponent } from '@/utils/factory/createAsyncComponent'; import { theme } from 'ant-design-vue'; + import { isPlainObject } from 'lodash-es'; const SimpleMenuTag = createAsyncComponent( () => import('@/components/SimpleMenu/src/SimpleMenuTag.vue'), @@ -279,7 +280,14 @@ } } + const currentRoutes = useRouter().getRoutes(); function handleMenuClick(path: string) { + // 路由参数的处理 + const found = currentRoutes.find((item) => item.path === path); + if (found && isPlainObject(found.meta.query)) { + go({ path: path as any, query: found.meta.query }); + return; + } go(path); } diff --git a/src/locales/lang/en/menu.json b/src/locales/lang/en/menu.json new file mode 100644 index 0000000..021bc26 --- /dev/null +++ b/src/locales/lang/en/menu.json @@ -0,0 +1,54 @@ +{ + "system": { + "root": "System", + "user": "User", + "role": "Role", + "menu": "Menu", + "dept": "Department", + "post": "Post", + "dict": "Dictionary", + "config": "Parameter Settings", + "notice": "Notifications", + "log": { + "root": "Log", + "operation": "Operation Log", + "login": "Login Log" + }, + "oss": "File", + "client": "Client" + }, + "tenant": { + "root": "Tenant", + "package": "Package" + }, + "monitor": { + "root": "System Monitoring", + "online": "Online Users", + "cache": "Cache Monitoring", + "admin": "Admin Monitoring", + "job": "Task Scheduling Center" + }, + "tool": { + "root": "System Tools", + "gen": "Code Generation" + }, + "workflow": { + "root": "Workflow", + "category": "Process Category", + "model": "Model", + "define": "Process Definition", + "monitor": { + "root": "Process Monitoring", + "instance": "Process Instance", + "todo": "Pending Tasks" + }, + "form": "Form" + }, + "task": { + "root": "My Tasks", + "apply": "My Initiated Tasks", + "todo": "My Pending Tasks", + "done": "My Completed Tasks", + "cc": "My CC" + } +} diff --git a/src/locales/lang/zh-CN/menu.json b/src/locales/lang/zh-CN/menu.json new file mode 100644 index 0000000..ceff402 --- /dev/null +++ b/src/locales/lang/zh-CN/menu.json @@ -0,0 +1,54 @@ +{ + "system": { + "root": "系统管理", + "user": "用户管理", + "role": "角色管理", + "menu": "菜单管理", + "dept": "部门管理", + "post": "岗位管理", + "dict": "字典管理", + "config": "参数设置", + "notice": "通知公告", + "log": { + "root": "日志管理", + "operation": "操作日志", + "login": "登录日志" + }, + "oss": "文件管理", + "client": "客户端管理" + }, + "tenant": { + "root": "租户管理", + "package": "套餐管理" + }, + "monitor": { + "root": "系统监控", + "online": "在线用户", + "cache": "缓存监控", + "admin": "Admin监控", + "job": "任务调度中心" + }, + "tool": { + "root": "系统工具", + "gen": "代码生成" + }, + "workflow": { + "root": "工作流", + "category": "流程分类", + "model": "模型管理", + "define": "流程定义", + "monitor": { + "root": "流程监控", + "instance": "流程实例", + "todo": "待办任务" + }, + "form": "表单管理" + }, + "task": { + "root": "我的任务", + "apply": "我发起的", + "todo": "我的待办", + "done": "我的已办", + "cc": "我的抄送" + } +} diff --git a/src/logics/error-handle/index.ts b/src/logics/error-handle/index.ts index 8705528..776ff5a 100644 --- a/src/logics/error-handle/index.ts +++ b/src/logics/error-handle/index.ts @@ -7,8 +7,9 @@ import type { ErrorLogInfo } from '#/store'; import { useErrorLogStoreWithOut } from '@/store/modules/errorLog'; import { ErrorTypeEnum } from '@/enums/exceptionEnum'; -import { App } from 'vue'; +import { App, h } from 'vue'; import projectSetting from '@/settings/projectSetting'; +import { notification } from 'ant-design-vue'; /** * Handling error stack information @@ -76,6 +77,43 @@ function vueErrorHandler(err: unknown, vm: any, info: string) { }); } +/** + * 主要是处理 组件错误使用导致的白屏 + * @param msg + * @param vm + * @param trace + */ +function vueWarnHandler(msg: string, _vm: any, trace: string) { + console.warn(`[Vue warn msg]: ${msg}`); + console.warn(`[Vue warn trace]: ${trace}`); + if (msg.includes('Component inside ')) { + const msg1 = '我猜你现在白屏了💩'; + const msg2 = '不看文档就一直白屏吧🤣'; + const msg3 = '套一层
很难吗?🤗'; + const msg4 = + ' 仅支持单个元素或组件作为其插槽内容。如果内容是一个组件,这个组件必须仅有一个根元素。'; + for (let i = 0; i < 10; i++) { + notification.error({ + message: '错误', + description: h('div', null, [ + h('div', null, msg1), + h('div', null, msg2), + h('div', null, msg3), + h( + 'a', + { + href: 'https://cn.vuejs.org/guide/built-ins/transition#the-transition-component', + target: '_blank', + }, + msg4, + ), + ]), + duration: null, + }); + } + } +} + /** * Configure script error handling function */ @@ -165,6 +203,8 @@ function registerResourceErrorHandler() { * @param app */ export function setupErrorHandle(app: App) { + // 这个会影响堆栈打印 不需要可以注释/删除 + app.config.warnHandler = vueWarnHandler; const { useErrorHandle } = projectSetting; if (!useErrorHandle) { return; diff --git a/src/router/helper/menuHelper.ts b/src/router/helper/menuHelper.ts index 4f63226..63c5c59 100644 --- a/src/router/helper/menuHelper.ts +++ b/src/router/helper/menuHelper.ts @@ -5,7 +5,6 @@ import { cloneDeep } from 'lodash-es'; import { isHttpUrl } from '@/utils/is'; import { RouteParams } from 'vue-router'; import { toRaw } from 'vue'; -import { setObjToUrlParams } from '@/utils'; export function getAllParentPath(treeData: T[], path: string) { const menuList = findPath(treeData, (n) => n.path === path) as Menu[]; @@ -33,10 +32,6 @@ function joinParentPath(menus: Menu[], parentPath = '') { if (menu?.children?.length) { joinParentPath(menu.children, menu.meta?.hidePathForChildren ? parentPath : menu.path); } - // 添加query参数 - if (menu.meta && menu.meta.query) { - menu.path += setObjToUrlParams('', menu.meta.query); - } } } diff --git a/src/router/helper/routeHelper.ts b/src/router/helper/routeHelper.ts index 7d129ce..79fba32 100644 --- a/src/router/helper/routeHelper.ts +++ b/src/router/helper/routeHelper.ts @@ -2,11 +2,13 @@ import type { AppRouteModule, AppRouteRecordRaw } from '@/router/types'; import type { Router, RouteRecordNormalized } from 'vue-router'; import { getParentLayout, LAYOUT, EXCEPTION_COMPONENT } from '@/router/constant'; -import { cloneDeep, omit } from 'lodash-es'; +import { cloneDeep, isPlainObject, omit } from 'lodash-es'; import { warn } from '@/utils/log'; import { createRouter, createWebHashHistory } from 'vue-router'; import type { Menu } from '@/api/auth/model'; import { createCustomNameComponent } from '@/utils/factory/createCustomNameComponent'; +import { setObjToUrlParams } from '@/utils'; +import { useMessage } from '@/hooks/web/useMessage'; export type LayoutMapKey = 'LAYOUT'; const IFRAME = () => import('@/layouts/components/iframe/FrameBlank.vue'); @@ -60,7 +62,10 @@ export function transformToAppRoutes(menuList: Menu[]) { const query = JSON.parse(item.query); appRoute.meta.query = query; } catch (e) { - console.error('错误的路由参数类型, 必须为json格式', e); + const message = `[${item.path}]错误的路由参数类型, 必须为json格式`; + const { createMessage } = useMessage(); + createMessage.error(message); + console.error(message, e); } } /** @@ -98,15 +103,24 @@ export function transformToAppRoutes(menuList: Menu[]) { /** * 主要适配顶部 & 分割菜单 添加redirect到一级路由 - * 点击时默认跳转到第一个子路由 就不会显示为白屏 + * 点击时默认跳转到第一个子路由 就不会显示为白屏(默认Layout) * @param appRoutes 路由列表 由上面的transformToAppRoutes转换而来 - * @warning 顶部 & 分割菜单 无法使用路由参数 - * @warning 顶部 & 分割菜单 无法使用路由参数 - * @warning 顶部 & 分割菜单 无法使用路由参数 */ export function addRootRedirect(appRoutes: AppRouteRecordRaw[]) { appRoutes.forEach((item) => { if (item.children && item.children.length > 0) { + /** + * 处理顶部 & 分割菜单点击顶部菜单时 + * 由于默认会跳转到第一个子路由 + * 如果第一个子菜单带路由参数 拼接上路由参数 + */ + const query = item.children[0].meta?.query; + if (isPlainObject(query)) { + const redirect = setObjToUrlParams(`${item.path}/${item.children[0].path}`, query); + item.redirect = redirect; + return; + } + // 不包含query 直接拼接 item.redirect = `${item.path}/${item.children[0].path}`; } }); diff --git a/src/router/routes/modules/dashboard.ts b/src/router/routes/modules/dashboard.ts index 4bc9c28..c694a59 100644 --- a/src/router/routes/modules/dashboard.ts +++ b/src/router/routes/modules/dashboard.ts @@ -20,6 +20,7 @@ const dashboard: AppRouteModule = { component: () => import('@/layouts/local/dashboard/analysis/index.vue'), meta: { // affix: true, + icon: 'ant-design:area-chart-outlined', title: t('routes.dashboard.analysis'), }, }, @@ -28,6 +29,7 @@ const dashboard: AppRouteModule = { name: 'Workbench', component: () => import('@/layouts/local/dashboard/workbench/index.vue'), meta: { + icon: 'ant-design:desktop-outlined', title: t('routes.dashboard.workbench'), }, }, diff --git a/src/store/modules/dict.ts b/src/store/modules/dict.ts index 65dbd02..f2b6d4c 100644 --- a/src/store/modules/dict.ts +++ b/src/store/modules/dict.ts @@ -33,8 +33,16 @@ export const useDictStore = defineStore('dict', { }, actions: { setDictInfo(dictName: string, dictValue: DictData[]): void { - this.dictMap.set(dictName, dictValue); - this.dictOptionsMap.set(dictName, dictToOptions(dictValue)); + if (this.dictMap.has(dictName) && this.dictMap.get(dictName)?.length === 0) { + this.dictMap.get(dictName)?.push(...dictValue); + } else { + this.dictMap.set(dictName, dictValue); + } + if (this.dictOptionsMap.has(dictName) && this.dictOptionsMap.get(dictName)?.length === 0) { + this.dictOptionsMap.get(dictName)?.push(...dictToOptions(dictValue)); + } else { + this.dictOptionsMap.set(dictName, dictToOptions(dictValue)); + } }, getDict(dictName: string): DictData[] { if (!dictName) return []; diff --git a/src/utils/dict.ts b/src/utils/dict.ts index bfa0fdd..80586aa 100644 --- a/src/utils/dict.ts +++ b/src/utils/dict.ts @@ -1,4 +1,4 @@ -import { useDictStoreWithOut, Option, dictToOptions } from '@/store/modules/dict'; +import { useDictStoreWithOut, Option } from '@/store/modules/dict'; import { dictDataInfo } from '@/api/system/dict/dictData'; import { DictData } from '@/api/system/dict/dictData.model'; @@ -7,25 +7,27 @@ import { DictData } from '@/api/system/dict/dictData.model'; * * 主要解决多次请求重复api的问题(不能用abortController 会导致除了第一个其他的获取的全为空) * 比如在一个页面 index表单 modal drawer总共会请求三次 但是获取的都是一样的数据 + * + * todo 移动到store */ -const dictRequestCache = new Map>(); +const dictRequestCache = new Map>(); export function getDict(dictName: string): DictData[] { const { getDict, setDictInfo } = useDictStoreWithOut(); // 这里拿到 - const dictList: DictData[] = getDict(dictName); - if (dictList.length === 0) { - // 检查请求状态缓存 - if (!dictRequestCache[dictName]) { - dictRequestCache[dictName] = dictDataInfo(dictName).then((resp) => { + const dictList = getDict(dictName); + // 检查请求状态缓存 + if (dictList.length === 0 && !dictRequestCache.has(dictName)) { + dictRequestCache.set( + dictName, + dictDataInfo(dictName).then((resp) => { // 缓存到store 这样就不用重复获取了 + // 内部处理了push的逻辑 这里不用push setDictInfo(dictName, resp); - // 这里不可用dictList = resp - dictList.push(...resp); // 移除请求状态缓存 dictRequestCache.delete(dictName); - }); - } + }), + ); } return dictList; } @@ -33,20 +35,18 @@ export function getDict(dictName: string): DictData[] { export function getDictOptions(dictName: string): Option[] { const { getDictOptions, setDictInfo } = useDictStoreWithOut(); const dictOptionList = getDictOptions(dictName); - if (dictOptionList.length === 0) { - // 检查请求状态缓存 - if (!dictRequestCache[dictName]) { - dictRequestCache[dictName] = dictDataInfo(dictName).then((resp) => { + // 检查请求状态缓存 + if (dictOptionList.length === 0 && !dictRequestCache.has(dictName)) { + dictRequestCache.set( + dictName, + dictDataInfo(dictName).then((resp) => { // 缓存到store 这样就不用重复获取了 + // 内部处理了push的逻辑 这里不用push setDictInfo(dictName, resp); - // 转为options - const option = dictToOptions(resp); - // 这里不可用dictOptionList = option - dictOptionList.push(...option); // 移除请求状态缓存 dictRequestCache.delete(dictName); - }); - } + }), + ); } return dictOptionList; } diff --git a/src/views/monitor/cache/components/MemoryChart.vue b/src/views/monitor/cache/components/MemoryChart.vue index 4ebc27c..b19afa8 100644 --- a/src/views/monitor/cache/components/MemoryChart.vue +++ b/src/views/monitor/cache/components/MemoryChart.vue @@ -52,6 +52,9 @@ }, series: [ { + progress: { + show: true, + }, animation: true, animationDuration: 1000, name: '峰值', diff --git a/src/views/monitor/logininfor/LoginInfoModal.vue b/src/views/monitor/logininfor/LoginInfoModal.vue index 7e1c955..0e9d850 100644 --- a/src/views/monitor/logininfor/LoginInfoModal.vue +++ b/src/views/monitor/logininfor/LoginInfoModal.vue @@ -1,7 +1,6 @@ diff --git a/src/views/system/config/config.data.ts b/src/views/system/config/config.data.ts index beb31ee..4e8fb06 100644 --- a/src/views/system/config/config.data.ts +++ b/src/views/system/config/config.data.ts @@ -85,7 +85,7 @@ export const modalSchemas: FormSchema[] = [ { field: 'configValue', label: '参数键值', - component: 'Input', + component: 'InputTextArea', required: true, }, { diff --git a/src/views/system/dict/type/DictType.vue b/src/views/system/dict/type/DictType.vue index 1f47015..1b8240f 100644 --- a/src/views/system/dict/type/DictType.vue +++ b/src/views/system/dict/type/DictType.vue @@ -3,13 +3,15 @@