mirror of
https://github.com/pure-admin/pure-admin-thin.git
synced 2025-12-18 00:00:37 +08:00
feat: 完成通知公告页面
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { RouteRecordName } from "vue-router";
|
||||
import { DictionaryData } from "../../api/common";
|
||||
|
||||
export type cacheType = {
|
||||
mode: string;
|
||||
@@ -38,4 +39,8 @@ export type setType = {
|
||||
export type userType = {
|
||||
username?: string;
|
||||
roles?: Array<string>;
|
||||
/** 字典ListMap 用于下拉框直接展示 */
|
||||
dictionaryList: Map<String, Array<DictionaryData>>;
|
||||
/** 字典MapMap 用于匹配值展示 */
|
||||
dictionaryMap: Map<String, Map<String, DictionaryData>>;
|
||||
};
|
||||
|
||||
@@ -5,8 +5,12 @@ import { routerArrays } from "@/layout/types";
|
||||
import { router, resetRouter } from "@/router";
|
||||
import { storageSession } from "@pureadmin/utils";
|
||||
import { useMultiTagsStoreHook } from "@/store/modules/multiTags";
|
||||
import { type removeToken, sessionKey } from "@/utils/auth";
|
||||
import { TokenDTO } from "@/api/common";
|
||||
import { removeToken, sessionKey } from "@/utils/auth";
|
||||
import { DictionaryData, TokenDTO } from "@/api/common";
|
||||
import { storageLocal } from "@pureadmin/utils";
|
||||
|
||||
const dictionaryListKey = "ag-dictionary-list";
|
||||
const dictionaryMapKey = "ag-dictionary-map";
|
||||
|
||||
export const useUserStore = defineStore({
|
||||
id: "ag-user",
|
||||
@@ -18,17 +22,53 @@ export const useUserStore = defineStore({
|
||||
// 页面级别权限
|
||||
roles: storageSession().getItem<TokenDTO>(sessionKey)?.currentUser.roleKey
|
||||
? [storageSession().getItem<TokenDTO>(sessionKey)?.currentUser.roleKey]
|
||||
: []
|
||||
: [],
|
||||
dictionaryList:
|
||||
storageLocal().getItem<Map<String, Array<DictionaryData>>>(
|
||||
dictionaryListKey
|
||||
) ?? new Map(),
|
||||
dictionaryMap:
|
||||
storageLocal().getItem<Map<String, Map<String, DictionaryData>>>(
|
||||
dictionaryMapKey
|
||||
) ?? new Map()
|
||||
}),
|
||||
actions: {
|
||||
/** 存储用户名 */
|
||||
SET_USERNAME(username: string) {
|
||||
/** TODO 这里不是应该再进一步存到sessionStorage中吗 */
|
||||
this.username = username;
|
||||
},
|
||||
/** 存储角色 */
|
||||
SET_ROLES(roles: Array<string>) {
|
||||
this.roles = roles;
|
||||
},
|
||||
/** 存储系统内的字典值 并拆分为Map形式和List形式 */
|
||||
SET_DICTIONARY(dictionary: Map<String, Array<DictionaryData>>) {
|
||||
/** 由于localStorage不能存储Map对象,所以用Obj来装载数据 */
|
||||
const dictionaryMapTmp = {};
|
||||
|
||||
for (const obj in dictionary) {
|
||||
dictionaryMapTmp[obj] = dictionary[obj].reduce((map, dict) => {
|
||||
map[dict.value] = dict;
|
||||
return map;
|
||||
}, {});
|
||||
}
|
||||
|
||||
/** 将字典分成List形式和Map形式 List便于下拉框展示 Map便于匹配值 */
|
||||
this.dictionaryList = dictionary;
|
||||
this.dictionaryMap = dictionaryMapTmp;
|
||||
|
||||
storageLocal().setItem<Map<String, Array<DictionaryData>>>(
|
||||
dictionaryListKey,
|
||||
dictionary
|
||||
);
|
||||
|
||||
storageLocal().setItem<Map<String, Map<String, DictionaryData>>>(
|
||||
dictionaryMapKey,
|
||||
dictionaryMapTmp as Map<String, Map<String, DictionaryData>>
|
||||
);
|
||||
},
|
||||
|
||||
/** 前端登出(不调用接口) */
|
||||
logOut() {
|
||||
this.username = "";
|
||||
|
||||
Reference in New Issue
Block a user