生产环境字典慢的问题

pull/755/merge
zhangdaiscott 2023-09-10 23:41:33 +08:00
parent 5030560028
commit ba6a02d872
2 changed files with 13 additions and 5 deletions

View File

@ -1,15 +1,19 @@
import { getAuthCache } from '/@/utils/auth';
import { DB_DICT_DATA_KEY } from '/@/enums/cacheEnum';
import { defHttp } from '/@/utils/http/axios';
import { useUserStore } from '/@/store/modules/user';
/**
*
* @param code
*/
export const getDictItemsByCode = (code) => {
if (getAuthCache(DB_DICT_DATA_KEY) && getAuthCache(DB_DICT_DATA_KEY)[code]) {
return getAuthCache(DB_DICT_DATA_KEY)[code];
// update-begin--author:liaozhiyang---date:20230908---for【QQYUN-6417】生产环境字典慢的问题
const userStore = useUserStore();
const dictItems = userStore.getAllDictItems;
if (typeof dictItems === 'object' && dictItems[code]) {
return dictItems[code];
}
// update-end--author:liaozhiyang---date:20230908---for【QQYUN-6417】生产环境字典慢的问题
};
/**
*

View File

@ -51,6 +51,7 @@
import { columns, searchFormSchema } from './dict.data';
import { list, deleteDict, batchDeleteDict, getExportUrl, getImportUrl, refreshCache, queryAllDictItems } from './dict.api';
import { DB_DICT_DATA_KEY } from '/src/enums/cacheEnum';
import { useUserStore } from '/@/store/modules/user';
const { createMessage } = useMessage();
//model
@ -146,7 +147,10 @@
if (result.success) {
const res = await queryAllDictItems();
removeAuthCache(DB_DICT_DATA_KEY);
setAuthCache(DB_DICT_DATA_KEY, res.result);
// update-begin--author:liaozhiyang---date:20230908---forQQYUN-6417
const userStore = useUserStore();
userStore.setAllDictItems(res.result);
// update-end--author:liaozhiyang---date:20230908---forQQYUN-6417
createMessage.success('刷新缓存完成!');
} else {
createMessage.error('刷新缓存失败!');