处理弹窗的放大缩小

This commit is contained in:
MTrun
2021-12-20 13:36:54 +08:00
parent f37ed1f3d3
commit 8dc4769b64
19 changed files with 345 additions and 106 deletions
+54
View File
@@ -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
}
}