mirror of
https://gitee.com/lab1024/smart-admin.git
synced 2025-11-11 21:23:47 +08:00
v3.15.0【新增】升级SaToken到最新版本;【新增】重磅优化 数据字典;【新增】升级wangEditor-next;【新增】优化缓存实现redis与caffeine
This commit is contained in:
@@ -1,53 +1,57 @@
|
||||
import { defineStore } from 'pinia';
|
||||
import { dictApi } from '/@/api/support/dict-api';
|
||||
import { smartSentry } from '/@/lib/smart-sentry';
|
||||
import { DICT_SPLIT } from '/@/constants/support/dict-const.js';
|
||||
import _ from 'lodash';
|
||||
|
||||
export const useDictStore = defineStore({
|
||||
id: 'dict',
|
||||
state: () => ({
|
||||
dict: new Array(),
|
||||
// 字典集合
|
||||
dictMap: new Map(),
|
||||
}),
|
||||
|
||||
actions: {
|
||||
// 获取字典
|
||||
getDict(keyCode) {
|
||||
if (keyCode == null && keyCode == '') {
|
||||
return null;
|
||||
// 获取字典数据
|
||||
getDictData(dictCode) {
|
||||
if (!dictCode) {
|
||||
return [];
|
||||
}
|
||||
try {
|
||||
for (let i = 0; i < this.dict.length; i++) {
|
||||
if (this.dict[i].keyCode == keyCode) {
|
||||
return this.dict[i].value;
|
||||
}
|
||||
let dictDataList = this.dictMap.get(dictCode);
|
||||
return dictDataList ? dictDataList : [];
|
||||
},
|
||||
|
||||
// 获取字典的值名称
|
||||
getDataLabels(dictCode, dataValue) {
|
||||
if (!dataValue) {
|
||||
return '';
|
||||
}
|
||||
let dict = this.getDictData(dictCode);
|
||||
if (dict.length === 0) {
|
||||
return '';
|
||||
}
|
||||
|
||||
let valueArray = dataValue.split(DICT_SPLIT);
|
||||
let result = [];
|
||||
for (let item of valueArray) {
|
||||
let target = _.find(dict, { dataValue: item });
|
||||
if (target) {
|
||||
result.push(target.dataLabel);
|
||||
}
|
||||
} catch (e) {
|
||||
return null;
|
||||
}
|
||||
return result.join(DICT_SPLIT);
|
||||
},
|
||||
// 设置字典
|
||||
setDict(keyCode, value) {
|
||||
if (keyCode !== null && keyCode !== '') {
|
||||
this.dict.push({
|
||||
key: keyCode,
|
||||
value: value,
|
||||
});
|
||||
}
|
||||
},
|
||||
// 删除字典
|
||||
removeDict(keyCode) {
|
||||
let flag = false;
|
||||
try {
|
||||
for (let i = 0; i < this.dict.length; i++) {
|
||||
if (this.dict[i].keyCode == keyCode) {
|
||||
this.dict.splice(i, 1);
|
||||
return true;
|
||||
}
|
||||
// 初始化字典
|
||||
initData(dictDataList){
|
||||
this.dictMap.clear();
|
||||
for (let data of dictDataList) {
|
||||
let dataArray = this.dictMap.get(data.dictCode);
|
||||
if (!dataArray) {
|
||||
dataArray = [];
|
||||
this.dictMap.set(data.dictCode, dataArray);
|
||||
}
|
||||
} catch (e) {
|
||||
flag = false;
|
||||
dataArray.push(data);
|
||||
}
|
||||
return false;
|
||||
},
|
||||
// 清空字典
|
||||
cleanDict() {
|
||||
this.dict = new Array();
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
@@ -124,6 +124,10 @@ export const useUserStore = defineStore({
|
||||
localRemove(localKey.USER_TOKEN);
|
||||
localRemove(localKey.USER_POINTS);
|
||||
localRemove(localKey.USER_TAG_NAV);
|
||||
localRemove(localKey.APP_CONFIG);
|
||||
localRemove(localKey.HOME_QUICK_ENTRY);
|
||||
localRemove(localKey.NOTICE_READ);
|
||||
localRemove(localKey.TO_BE_DONE);
|
||||
},
|
||||
// 查询未读消息数量
|
||||
async queryUnreadMessageCount() {
|
||||
@@ -179,9 +183,11 @@ export const useUserStore = defineStore({
|
||||
// 获取待办工作数
|
||||
this.queryToBeDoneList();
|
||||
},
|
||||
|
||||
setToken(token) {
|
||||
this.token = token;
|
||||
},
|
||||
|
||||
//设置标签页
|
||||
setTagNav(route, from) {
|
||||
if (_.isNull(this.tagNav)) {
|
||||
@@ -206,7 +212,7 @@ export const useUserStore = defineStore({
|
||||
// @ts-ignore
|
||||
menuTitle: route.meta.title,
|
||||
menuQuery: route.query,
|
||||
menuIcon:route.meta?.icon,
|
||||
menuIcon:route.meta?.icon,
|
||||
// @ts-ignore
|
||||
fromMenuName: from.name,
|
||||
fromMenuQuery: from.query,
|
||||
|
||||
Reference in New Issue
Block a user