mirror of
https://gitee.com/dromara/go-view.git
synced 2026-04-23 00:00:12 +08:00
处理弹窗的放大缩小
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
|
||||
/**
|
||||
* * 存储本地会话数据
|
||||
* @param k 键名
|
||||
* @param v 键值
|
||||
* @returns RemovableRef
|
||||
*/
|
||||
export const setLocalStorage = <T>(k: string, v: T) => {
|
||||
try {
|
||||
window.localStorage.setItem(k, JSON.stringify(v))
|
||||
} catch (error) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* * 获取本地会话数据
|
||||
* @returns any
|
||||
*/
|
||||
export const getLocalStorage: (k: string) => any = (k: string) => {
|
||||
const item = window.localStorage.getItem(k)
|
||||
try {
|
||||
return item ? JSON.parse(item) : item
|
||||
} catch (err) {
|
||||
return item
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* * 存储临时会话数据
|
||||
* @param k 键名
|
||||
* @param v 键值
|
||||
* @returns RemovableRef
|
||||
*/
|
||||
export const setSessionStorage = <T>(k: string, v: T) => {
|
||||
try {
|
||||
window.sessionStorage.setItem(k, JSON.stringify(v))
|
||||
} catch (error) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* * 获取临时会话数据
|
||||
* @returns any
|
||||
*/
|
||||
export const getSessionStorage: (k: string) => any = (k: string) => {
|
||||
const item = window.sessionStorage.getItem(k)
|
||||
try {
|
||||
return item ? JSON.parse(item) : item
|
||||
} catch (err) {
|
||||
return item
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user