44 lines
845 B
TypeScript
44 lines
845 B
TypeScript
export function cacheGet(key: string): string {
|
|
return localStorage.getItem(key) || ''
|
|
}
|
|
|
|
export function cacheSet(key: string, value: string) {
|
|
localStorage.setItem(key, value)
|
|
}
|
|
|
|
export function cacheClear(key: string) {
|
|
localStorage.removeItem(key)
|
|
}
|
|
|
|
export function cacheDeleteAll() {
|
|
localStorage.clear()
|
|
}
|
|
|
|
export interface UserInfo {
|
|
id?: string
|
|
avatar?: string
|
|
gender?: string
|
|
nickName?: string
|
|
username?: string
|
|
position?: string
|
|
deptName?: string
|
|
mobile?: string
|
|
bizMail?: string
|
|
email?: string
|
|
corpName?: string
|
|
effectivePoint?: string
|
|
totalPoint?: string
|
|
}
|
|
|
|
export function getUserInfo(): UserInfo | null {
|
|
const res = localStorage.getItem('userInfo')
|
|
if (!res) {
|
|
return null
|
|
} else {
|
|
return JSON.parse(res)
|
|
}
|
|
}
|
|
export function getToken() {
|
|
return localStorage.getItem('token')
|
|
}
|