From 91b807ccfc9b87ea72601ba886c64adbcc17115c Mon Sep 17 00:00:00 2001 From: zhangdaiscott Date: Tue, 13 Oct 2026 05:58:29 -0400 Subject: [PATCH] =?UTF-8?q?--author:scott--date:20261013--for:=E3=80=90iss?= =?UTF-8?q?ues/9838=E3=80=91=E5=AD=97=E5=85=B8=E5=89=8D=E7=AB=AF=E7=BC=93?= =?UTF-8?q?=E5=AD=98=E5=A2=9E=E5=8A=A0=E7=89=88=E6=9C=AC=E5=8F=B7=EF=BC=8C?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E5=91=98=E4=BF=AE=E6=94=B9=E5=AD=97=E5=85=B8?= =?UTF-8?q?=E5=90=8E=E5=85=B6=E4=BB=96=E7=94=A8=E6=88=B7=E5=88=B7=E6=96=B0?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E8=87=AA=E5=8A=A8=E5=90=8C=E6=AD=A5=E6=9C=80?= =?UTF-8?q?=E6=96=B0=E5=AD=97=E5=85=B8=EF=BC=88=E5=AD=97=E5=85=B8=E6=9C=AA?= =?UTF-8?q?=E5=8F=98=E4=B8=8D=E9=87=8D=E5=A4=8D=E6=8B=89=E5=8F=96=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5.5 --- .../jeecg/common/constant/CommonConstant.java | 5 ++++ .../system/controller/LoginController.java | 6 ++++ .../system/controller/SysDictController.java | 19 +++++++++++- .../controller/SysDictItemController.java | 7 +++++ .../controller/SysPermissionController.java | 6 ++++ .../controller/ThirdLoginController.java | 3 ++ .../system/service/ISysDictService.java | 15 ++++++++++ .../service/impl/SysDictServiceImpl.java | 26 ++++++++++++++++ jeecgboot-vue3/src/api/sys/model/userModel.ts | 2 ++ jeecgboot-vue3/src/enums/cacheEnum.ts | 2 ++ .../src/store/modules/permission.ts | 6 +++- jeecgboot-vue3/src/store/modules/user.ts | 30 ++++++++++++++++--- jeecgboot-vue3/src/utils/cache/memory.ts | 4 +-- jeecgboot-vue3/src/utils/cache/persistent.ts | 2 ++ .../system/dict/components/DictItemList.vue | 5 +++- .../src/views/system/dict/index.vue | 10 +++++-- 16 files changed, 136 insertions(+), 12 deletions(-) diff --git a/jeecg-boot/jeecg-boot-base-core/src/main/java/org/jeecg/common/constant/CommonConstant.java b/jeecg-boot/jeecg-boot-base-core/src/main/java/org/jeecg/common/constant/CommonConstant.java index b23c3b2b1..7a55987aa 100644 --- a/jeecg-boot/jeecg-boot-base-core/src/main/java/org/jeecg/common/constant/CommonConstant.java +++ b/jeecg-boot/jeecg-boot-base-core/src/main/java/org/jeecg/common/constant/CommonConstant.java @@ -746,4 +746,9 @@ public interface CommonConstant { * 发送短信方式:阿里云 */ String SMS_SEND_TYPE_ALI_YUN = "aliyun"; + + /** + * 系统字典版本号(Redis key),字典变更时更新,前端据此判断是否需要重新拉取字典缓存 + */ + String SYS_DICT_VERSION = "sys:cache:dict:version"; } diff --git a/jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/controller/LoginController.java b/jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/controller/LoginController.java index 0a078ab27..ee36b49fc 100644 --- a/jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/controller/LoginController.java +++ b/jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/controller/LoginController.java @@ -164,6 +164,9 @@ public class LoginController { log.debug("2 获取用户信息耗时 (首页面配置)" + (System.currentTimeMillis() - start) + "毫秒"); obj.put("userInfo",sysUser); + //update-begin---author:scott ---date:20261013 for:【issues/9838】返回字典版本号;先取版本号再查字典,避免期间字典变更导致前端拿到新版本号+旧数据----------- + obj.put("dictVersion", sysDictService.getDictVersion()); + //update-end---author:scott ---date:20261013 for:【issues/9838】返回字典版本号;先取版本号再查字典,避免期间字典变更导致前端拿到新版本号+旧数据----------- obj.put("sysAllDictItems", sysDictService.queryAllDictItems()); log.debug("3 获取用户信息耗时 (字典数据)" + (System.currentTimeMillis() - start) + "毫秒"); @@ -561,6 +564,9 @@ public class LoginController { // 5.vue3版本不加载字典数据,vue2下加载字典 String vue3Version = request.getHeader(CommonConstant.VERSION); if(oConvertUtils.isEmpty(vue3Version)){ + //update-begin---author:scott ---date:20261013 for:【issues/9838】返回字典版本号;先取版本号再查字典,避免期间字典变更导致前端拿到新版本号+旧数据----------- + obj.put("dictVersion", sysDictService.getDictVersion()); + //update-end---author:scott ---date:20261013 for:【issues/9838】返回字典版本号;先取版本号再查字典,避免期间字典变更导致前端拿到新版本号+旧数据----------- obj.put("sysAllDictItems", sysDictService.queryAllDictItems()); } diff --git a/jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/controller/SysDictController.java b/jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/controller/SysDictController.java index 24d006097..2886117dd 100644 --- a/jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/controller/SysDictController.java +++ b/jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/controller/SysDictController.java @@ -399,6 +399,7 @@ public class SysDictController { sysDict.setCreateTime(new Date()); sysDict.setDelFlag(CommonConstant.DEL_FLAG_0); sysDictService.save(sysDict); + sysDictService.refreshDictVersion(); result.success("保存成功!"); } catch (Exception e) { log.error(e.getMessage(),e); @@ -472,6 +473,9 @@ public class SysDictController { log.error("第 {} 个字典[{}]处理异常: {}", i + 1, sysDictPage.getDictCode(), e.getMessage(), e); } } + if (successCount > 0) { + sysDictService.refreshDictVersion(); + } Map returnMap = new HashMap<>(); returnMap.put("successCount", successCount); returnMap.put("failCount", failCount); @@ -511,6 +515,7 @@ public class SysDictController { sysDict.setUpdateTime(new Date()); boolean ok = sysDictService.updateById(sysDict); if(ok) { + sysDictService.refreshDictVersion(); result.success("编辑成功!"); } } @@ -529,6 +534,7 @@ public class SysDictController { Result result = new Result(); boolean ok = sysDictService.removeById(id); if(ok) { + sysDictService.refreshDictVersion(); result.success("删除成功!"); }else{ result.error500("删除失败!"); @@ -550,6 +556,7 @@ public class SysDictController { result.error500("参数不识别!"); }else { sysDictService.removeByIds(Arrays.asList(ids.split(","))); + sysDictService.refreshDictVersion(); result.success("删除成功!"); } return result; @@ -589,7 +596,9 @@ public class SysDictController { redisUtil.removeAll(CacheConstant.SYS_DEPART_IDS_CACHE); redisUtil.removeAll("jmreport:cache:dict"); redisUtil.removeAll("jmreport:cache:dictTable"); - + // 刷新字典版本号(兜底:直接改库后手动刷新缓存,其他用户刷新页面也能同步) + sysDictService.refreshDictVersion(); + // 清除当前用户的授权缓存信息 Subject currentUser = SecurityUtils.getSubject(); if (currentUser.isAuthenticated()) { @@ -704,6 +713,9 @@ public class SysDictController { errorMessage.add("第 " + lineNumber + " 行:字典编码已经存在,忽略导入。"); } } + if (successLines > 0) { + sysDictService.refreshDictVersion(); + } return ImportExcelUtil.imporReturnRes(errorLines,successLines,errorMessage); } catch (Exception e) { log.error(e.getMessage(),e); @@ -743,6 +755,7 @@ public class SysDictController { public Result deletePhysic(@PathVariable("id") String id) { try { sysDictService.deleteOneDictPhysically(id); + sysDictService.refreshDictVersion(); return Result.ok("删除成功!"); } catch (Exception e) { e.printStackTrace(); @@ -760,6 +773,7 @@ public class SysDictController { public Result back(@PathVariable("id") String id) { try { sysDictService.updateDictDelFlag(0,id); + sysDictService.refreshDictVersion(); return Result.ok("操作成功!"); } catch (Exception e) { e.printStackTrace(); @@ -779,6 +793,7 @@ public class SysDictController { String ids = jsonObject.getString("ids"); if (StringUtils.isNotBlank(ids)) { sysDictService.revertLogicDeleted(Arrays.asList(ids.split(","))); + sysDictService.refreshDictVersion(); return Result.ok("操作成功!"); } } catch (Exception e) { @@ -848,6 +863,7 @@ public class SysDictController { sysDictVo.setLowAppId(lowAppId); sysDictVo.setTenantId(oConvertUtils.getInteger(tenantId, null)); sysDictService.addDictByLowAppId(sysDictVo); + sysDictService.refreshDictVersion(); return Result.ok("添加成功"); } @@ -856,6 +872,7 @@ public class SysDictController { String lowAppId = oConvertUtils.getString(TokenUtils.getLowAppIdByRequest(request)); sysDictVo.setLowAppId(lowAppId); sysDictService.editDictByLowAppId(sysDictVo); + sysDictService.refreshDictVersion(); return Result.ok("编辑成功"); } diff --git a/jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/controller/SysDictItemController.java b/jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/controller/SysDictItemController.java index d0fcd649b..be64e9f73 100644 --- a/jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/controller/SysDictItemController.java +++ b/jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/controller/SysDictItemController.java @@ -18,6 +18,7 @@ import org.jeecg.common.system.query.QueryGenerator; import org.jeecg.common.util.oConvertUtils; import org.jeecg.modules.system.entity.SysDictItem; import org.jeecg.modules.system.service.ISysDictItemService; +import org.jeecg.modules.system.service.ISysDictService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.cache.annotation.CacheEvict; import org.springframework.web.bind.annotation.RequestBody; @@ -48,6 +49,8 @@ public class SysDictItemController { @Autowired private ISysDictItemService sysDictItemService; + @Autowired + private ISysDictService sysDictService; /** * @功能:查询字典数据 @@ -82,6 +85,7 @@ public class SysDictItemController { try { sysDictItem.setCreateTime(new Date()); sysDictItemService.save(sysDictItem); + sysDictService.refreshDictVersion(); result.success("保存成功!"); } catch (Exception e) { log.error(e.getMessage(),e); @@ -108,6 +112,7 @@ public class SysDictItemController { boolean ok = sysDictItemService.updateById(sysDictItem); //TODO 返回false说明什么? if(ok) { + sysDictService.refreshDictVersion(); result.success("编辑成功!"); } } @@ -130,6 +135,7 @@ public class SysDictItemController { }else { boolean ok = sysDictItemService.removeById(id); if(ok) { + sysDictService.refreshDictVersion(); result.success("删除成功!"); } } @@ -150,6 +156,7 @@ public class SysDictItemController { result.error500("参数不识别!"); }else { this.sysDictItemService.removeByIds(Arrays.asList(ids.split(","))); + sysDictService.refreshDictVersion(); result.success("删除成功!"); } return result; diff --git a/jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/controller/SysPermissionController.java b/jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/controller/SysPermissionController.java index 743fe810b..4e2c03e28 100644 --- a/jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/controller/SysPermissionController.java +++ b/jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/controller/SysPermissionController.java @@ -71,6 +71,9 @@ public class SysPermissionController { @Autowired private ShiroRealm shiroRealm; + @Autowired + private ISysDictService sysDictService; + /** * 子菜单 */ @@ -337,6 +340,9 @@ public class SysPermissionController { json.put("allAuth", allauthjsonArray); //数据源安全模式 json.put("sysSafeMode", jeecgBaseConfig.getFirewall()!=null? jeecgBaseConfig.getFirewall().getDataSourceSafe(): false); + //update-begin---author:scott ---date:20261013 for:【issues/9838】返回字典版本号,前端刷新页面时比对,变化才重新拉取字典缓存----------- + json.put("dictVersion", sysDictService.getDictVersion()); + //update-end---author:scott ---date:20261013 for:【issues/9838】返回字典版本号,前端刷新页面时比对,变化才重新拉取字典缓存----------- result.setResult(json); } catch (Exception e) { result.error500("查询失败:" + e.getMessage()); diff --git a/jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/controller/ThirdLoginController.java b/jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/controller/ThirdLoginController.java index b105dfc6c..b4b6c079b 100644 --- a/jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/controller/ThirdLoginController.java +++ b/jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/controller/ThirdLoginController.java @@ -370,6 +370,9 @@ public class ThirdLoginController { //用户登录信息 obj.put("userInfo", sysUser); //获取字典缓存【解决 #jeecg-boot/issues/3998】 + //update-begin---author:scott ---date:20261013 for:【issues/9838】返回字典版本号;先取版本号再查字典,避免期间字典变更导致前端拿到新版本号+旧数据----------- + obj.put("dictVersion", sysDictService.getDictVersion()); + //update-end---author:scott ---date:20261013 for:【issues/9838】返回字典版本号;先取版本号再查字典,避免期间字典变更导致前端拿到新版本号+旧数据----------- obj.put("sysAllDictItems", sysDictService.queryAllDictItems()); //token 信息 obj.put("token", token); diff --git a/jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/ISysDictService.java b/jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/ISysDictService.java index 0980ee0aa..72ada79d7 100644 --- a/jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/ISysDictService.java +++ b/jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/ISysDictService.java @@ -59,6 +59,21 @@ public interface ISysDictService extends IService { */ public Map> queryAllDictItems(); + /** + * 获取系统字典版本号(前端据此判断本地字典缓存是否过期) + * @return + * @author scott + * @since 2026-10-13 【issues/9838】管理员修改字典后,其他用户刷新页面自动同步最新字典 + */ + String getDictVersion(); + + /** + * 刷新系统字典版本号(字典或字典项变更后调用) + * @author scott + * @since 2026-10-13 【issues/9838】管理员修改字典后,其他用户刷新页面自动同步最新字典 + */ + void refreshDictVersion(); + /** * 查通过查询指定table的 text code 获取字典 * @param tableFilterSql diff --git a/jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/impl/SysDictServiceImpl.java b/jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/impl/SysDictServiceImpl.java index 2624943f3..ed3c0f3f3 100644 --- a/jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/impl/SysDictServiceImpl.java +++ b/jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/impl/SysDictServiceImpl.java @@ -236,6 +236,32 @@ public class SysDictServiceImpl extends ServiceImpl impl return sysAllDictItems; } + /** + * 获取系统字典版本号,Redis 中不存在时初始化 + * @author scott + * @since 2026-10-13 【issues/9838】管理员修改字典后,其他用户刷新页面自动同步最新字典 + */ + @Override + public String getDictVersion() { + Object version = redisUtil.get(CommonConstant.SYS_DICT_VERSION); + if (oConvertUtils.isEmpty(version)) { + // Redis 中不存在(首次或被清理)时初始化,前端会因版本不一致重新拉取一次字典 + version = String.valueOf(System.currentTimeMillis()); + redisUtil.set(CommonConstant.SYS_DICT_VERSION, version); + } + return version.toString(); + } + + /** + * 刷新系统字典版本号(写入当前时间戳) + * @author scott + * @since 2026-10-13 【issues/9838】管理员修改字典后,其他用户刷新页面自动同步最新字典 + */ + @Override + public void refreshDictVersion() { + redisUtil.set(CommonConstant.SYS_DICT_VERSION, String.valueOf(System.currentTimeMillis())); + } + /** * 通过查询指定code 获取字典值text * @param code diff --git a/jeecgboot-vue3/src/api/sys/model/userModel.ts b/jeecgboot-vue3/src/api/sys/model/userModel.ts index 732610ee9..ba7e08e15 100644 --- a/jeecgboot-vue3/src/api/sys/model/userModel.ts +++ b/jeecgboot-vue3/src/api/sys/model/userModel.ts @@ -45,6 +45,8 @@ export interface GetUserInfoModel { userInfo?: any; // 缓存字典项 sysAllDictItems?: any; + // 字典版本号 + dictVersion?: string; // 三级等保强密码开关 enableStrongPwd?: boolean; } diff --git a/jeecgboot-vue3/src/enums/cacheEnum.ts b/jeecgboot-vue3/src/enums/cacheEnum.ts index 929d31283..b00b3f1c2 100644 --- a/jeecgboot-vue3/src/enums/cacheEnum.ts +++ b/jeecgboot-vue3/src/enums/cacheEnum.ts @@ -11,6 +11,8 @@ export const ROLES_KEY = 'ROLES__KEY__'; // dict info key export const DB_DICT_DATA_KEY = 'UI_CACHE_DB_DICT_DATA'; +// dict version key(与字典数据成对存储,用于判断本地字典是否过期) +export const DB_DICT_VERSION_KEY = 'UI_CACHE_DB_DICT_VERSION'; // project config key export const PROJ_CFG_KEY = 'PROJ__CFG__KEY__'; diff --git a/jeecgboot-vue3/src/store/modules/permission.ts b/jeecgboot-vue3/src/store/modules/permission.ts index af8e3f28d..227d24736 100644 --- a/jeecgboot-vue3/src/store/modules/permission.ts +++ b/jeecgboot-vue3/src/store/modules/permission.ts @@ -126,7 +126,11 @@ export const usePermissionStore = defineStore('app-permission', { const codeList = systemPermission.codeList; this.setPermCodeList(codeList); this.setAuthData(systemPermission); - + // 代码逻辑说明: 【issues/9838】字典版本号变化时后台刷新字典缓存,不阻塞菜单构建 + useUserStore() + .refreshDictItemsIfChanged(systemPermission.dictVersion) + .catch((e) => console.warn('刷新字典缓存失败', e)); + //菜单路由 const routeList = systemPermission.menu; return routeList; diff --git a/jeecgboot-vue3/src/store/modules/user.ts b/jeecgboot-vue3/src/store/modules/user.ts index 6553fc4ac..f1f7c56b4 100644 --- a/jeecgboot-vue3/src/store/modules/user.ts +++ b/jeecgboot-vue3/src/store/modules/user.ts @@ -4,10 +4,11 @@ import { defineStore } from 'pinia'; import { store } from '/@/store'; import { RoleEnum } from '/@/enums/roleEnum'; import { PageEnum } from '/@/enums/pageEnum'; -import { ROLES_KEY, TOKEN_KEY, USER_INFO_KEY, LOGIN_INFO_KEY, DB_DICT_DATA_KEY, TENANT_ID, OAUTH2_THIRD_LOGIN_TENANT_ID } from '/@/enums/cacheEnum'; +import { ROLES_KEY, TOKEN_KEY, USER_INFO_KEY, LOGIN_INFO_KEY, DB_DICT_DATA_KEY, DB_DICT_VERSION_KEY, TENANT_ID, OAUTH2_THIRD_LOGIN_TENANT_ID } from '/@/enums/cacheEnum'; import { getAuthCache, setAuthCache, removeAuthCache } from '/@/utils/auth'; import { GetUserInfoModel, LoginParams, ThirdLoginParams } from '/@/api/sys/model/userModel'; import { doLogout, getUserInfo, loginApi, phoneLoginApi, thirdLogin } from '/@/api/sys/user'; +import { queryAllDictItems } from '/@/views/system/dict/dict.api'; import { useI18n } from '/@/hooks/web/useI18n'; import { useMessage } from '/@/hooks/web/useMessage'; import { router } from '/@/router'; @@ -116,9 +117,30 @@ export const useUserStore = defineStore('app-user', { this.loginInfo = info; setAuthCache(LOGIN_INFO_KEY, info); }, - setAllDictItems(dictItems) { + /** + * 设置全量字典缓存 + * @param dictItems 字典数据 + * @param dictVersion 字典版本号,与字典数据成对存储;不传则清空,下次刷新页面会重新拉取一次字典 + */ + setAllDictItems(dictItems, dictVersion?: string | null) { this.dictItems = dictItems; setAuthCache(DB_DICT_DATA_KEY, dictItems); + setAuthCache(DB_DICT_VERSION_KEY, dictVersion ?? null); + }, + /** + * 后端字典版本号与本地不一致时,后台重新拉取全量字典 + * @param dictVersion 后端返回的字典版本号 + * @author scott + * @since 2026-10-13 【issues/9838】管理员修改字典后,其他用户刷新页面即可同步最新字典 + */ + async refreshDictItemsIfChanged(dictVersion?: string) { + if (!dictVersion || dictVersion === getAuthCache(DB_DICT_VERSION_KEY)) { + return; + } + const res = await queryAllDictItems(); + if (res?.success && res.result) { + this.setAllDictItems(res.result, dictVersion); + } }, setAllDictItemsByLocal() { // 代码逻辑说明: 【QQYUN-8572】表格行选择卡顿问题(customRender中字典引起的) @@ -260,7 +282,7 @@ export const useUserStore = defineStore('app-user', { if (!this.getToken) { return null; } - const { userInfo, sysAllDictItems, enableStrongPwd } = await getUserInfo(); + const { userInfo, sysAllDictItems, dictVersion, enableStrongPwd } = await getUserInfo(); if (userInfo) { const { roles = [] } = userInfo; if (isArray(roles)) { @@ -278,7 +300,7 @@ export const useUserStore = defineStore('app-user', { * @updateDate:2021-09-08 */ if (sysAllDictItems) { - this.setAllDictItems(sysAllDictItems); + this.setAllDictItems(sysAllDictItems, dictVersion); } this.enableStrongPwd = enableStrongPwd ?? false; return userInfo; diff --git a/jeecgboot-vue3/src/utils/cache/memory.ts b/jeecgboot-vue3/src/utils/cache/memory.ts index a4d89f0b5..9c96d7ab2 100644 --- a/jeecgboot-vue3/src/utils/cache/memory.ts +++ b/jeecgboot-vue3/src/utils/cache/memory.ts @@ -1,4 +1,4 @@ -import { TOKEN_KEY, ROLES_KEY, USER_INFO_KEY, DB_DICT_DATA_KEY, TENANT_ID, LOGIN_INFO_KEY, PROJ_CFG_KEY } from '/@/enums/cacheEnum'; +import { TOKEN_KEY, ROLES_KEY, USER_INFO_KEY, DB_DICT_DATA_KEY, DB_DICT_VERSION_KEY, TENANT_ID, LOGIN_INFO_KEY, PROJ_CFG_KEY } from '/@/enums/cacheEnum'; import { omit } from 'lodash-es'; export interface Cache { @@ -103,7 +103,7 @@ export class Memory { }); // 代码逻辑说明: 不删除登录用户的租户id,其他缓存信息都清除---- this.cache = { - ...omit(this.cache, [TOKEN_KEY, USER_INFO_KEY, ROLES_KEY, DB_DICT_DATA_KEY, TENANT_ID, LOGIN_INFO_KEY, PROJ_CFG_KEY]), + ...omit(this.cache, [TOKEN_KEY, USER_INFO_KEY, ROLES_KEY, DB_DICT_DATA_KEY, DB_DICT_VERSION_KEY, TENANT_ID, LOGIN_INFO_KEY, PROJ_CFG_KEY]), }; } } diff --git a/jeecgboot-vue3/src/utils/cache/persistent.ts b/jeecgboot-vue3/src/utils/cache/persistent.ts index a89b4f90c..f341683f0 100644 --- a/jeecgboot-vue3/src/utils/cache/persistent.ts +++ b/jeecgboot-vue3/src/utils/cache/persistent.ts @@ -14,6 +14,7 @@ import { APP_SESSION_CACHE_KEY, MULTIPLE_TABS_KEY, DB_DICT_DATA_KEY, + DB_DICT_VERSION_KEY, TENANT_ID, LOGIN_INFO_KEY, OAUTH2_THIRD_LOGIN_TENANT_ID, @@ -32,6 +33,7 @@ interface BasicStore { [PROJ_CFG_KEY]: ProjectConfig; [MULTIPLE_TABS_KEY]: RouteLocationNormalized[]; [DB_DICT_DATA_KEY]: string; + [DB_DICT_VERSION_KEY]: string; [TENANT_ID]: string; [LOGIN_INFO_KEY]: LoginInfo; [OAUTH2_THIRD_LOGIN_TENANT_ID]: string diff --git a/jeecgboot-vue3/src/views/system/dict/components/DictItemList.vue b/jeecgboot-vue3/src/views/system/dict/components/DictItemList.vue index 3c374232c..ac03f9b75 100644 --- a/jeecgboot-vue3/src/views/system/dict/components/DictItemList.vue +++ b/jeecgboot-vue3/src/views/system/dict/components/DictItemList.vue @@ -110,7 +110,10 @@ * 删除 */ async function handleDelete(record) { - await deleteItem({ id: record.id }, reload); + await deleteItem({ id: record.id }, () => { + reload(); + doRefreshDictCache(); + }); } /** diff --git a/jeecgboot-vue3/src/views/system/dict/index.vue b/jeecgboot-vue3/src/views/system/dict/index.vue index 6bbe0086c..9b180edf7 100644 --- a/jeecgboot-vue3/src/views/system/dict/index.vue +++ b/jeecgboot-vue3/src/views/system/dict/index.vue @@ -120,7 +120,10 @@ * 删除事件 */ async function handleDelete(record) { - await deleteDict({ id: record.id }, reload); + await deleteDict({ id: record.id }, () => { + reload(); + handlerRefreshCache(false); + }); } /** * 批量删除事件 @@ -131,6 +134,7 @@ reload(); selectedRowKeys.value = []; selectedRows.value = []; + handlerRefreshCache(false); }); } /** @@ -141,9 +145,9 @@ updateTableDataRecord(values.id, values); } else { reload(); - // 代码逻辑说明: 新增字典后同步刷新字典缓存,避免新增字典后页面引用不到 - await handlerRefreshCache(false); } + // 代码逻辑说明: 新增/编辑字典后同步刷新字典缓存,避免页面引用不到或显示旧值 + await handlerRefreshCache(false); } /** * 刷新缓存