feat(projects): 菜单数据及组件接入

This commit is contained in:
Soybean
2021-09-15 07:35:38 +08:00
parent 57e00e6417
commit 3226a724be
25 changed files with 361 additions and 95 deletions

View File

@ -1,2 +1,2 @@
export { getToken, setToken, getUserInfo, getLoginModuleRegExp } from './user';
export { getToken, setToken, removeToken, getUserInfo, getLoginModuleRegExp } from './user';
export { getLoginRedirectUrl, toLoginRedirectUrl, toHomeByLocation } from './location';

View File

@ -1,6 +1,6 @@
import { EnumStorageKey } from '@/enum';
import type { LoginModuleType } from '@/interface';
import { setLocal, getLocal } from '../storage';
import { setLocal, getLocal, removeLocal } from '../storage';
/** 设置token */
export function getToken() {
@ -12,6 +12,10 @@ export function setToken(token: string) {
setLocal(EnumStorageKey.token, token);
}
export function removeToken() {
removeLocal(EnumStorageKey.token);
}
export function getUserInfo() {}
/** 获取登录模块的正则字符串 */

12
src/utils/common/icon.ts Normal file
View File

@ -0,0 +1,12 @@
import { h } from 'vue';
import type { Component } from 'vue';
import { NIcon } from 'naive-ui';
/** 动态渲染vicon */
export function dynamicIconRender(icon: Component) {
return () => {
return h(NIcon, null, {
default: () => h(icon)
});
};
}

View File

@ -13,3 +13,5 @@ export {
} from './typeof';
export { brightenColor, darkenColor } from './color';
export { dynamicIconRender } from './icon';

View File

@ -1,6 +1,7 @@
export {
setToken,
getToken,
removeToken,
getUserInfo,
getLoginModuleRegExp,
getLoginRedirectUrl,
@ -21,7 +22,8 @@ export {
isSet,
isMap,
brightenColor,
darkenColor
darkenColor,
dynamicIconRender
} from './common';
export { setLocal, getLocal, setSession, getSession } from './storage';

View File

@ -1,2 +1,2 @@
export { setLocal, getLocal } from './local';
export { setLocal, getLocal, removeLocal } from './local';
export { setSession, getSession } from './session';

View File

@ -1,12 +1,16 @@
export function setLocal(key: string, value: unknown) {
const json = JSON.stringify(value);
localStorage.setItem(key, json);
window.localStorage.setItem(key, json);
}
export function getLocal<T>(key: string) {
const json = localStorage.getItem(key);
const json = window.localStorage.getItem(key);
if (json) {
return JSON.parse(json) as T;
}
return json;
}
export function removeLocal(key: string) {
window.localStorage.removeItem(key);
}