Merge branch 'dev-lint' into dev-lint-commet

This commit is contained in:
tnt group
2022-09-22 10:08:25 +08:00
20 changed files with 84 additions and 88 deletions
+6 -7
View File
@@ -1,11 +1,10 @@
/**
* * 存储本地会话数据
* @param k 键名
* @param v 键值(无需stringiiy
* @returns RemovableRef
*/
export const setLocalStorage = <T>(k: string, v: T) => {
export const setLocalStorage = <T>(k: string, v: T) => {
try {
window.localStorage.setItem(k, JSON.stringify(v))
} catch (error) {
@@ -18,7 +17,7 @@
* @param k 键名
* @returns any
*/
export const getLocalStorage = (k: string) => {
export const getLocalStorage = (k: string) => {
const item = window.localStorage.getItem(k)
try {
return item ? JSON.parse(item) : item
@@ -29,9 +28,9 @@
/**
* * 清除本地会话数据
* @param name
* @param name
*/
export const clearLocalStorage = (name: string) => {
export const clearLocalStorage = (name: string) => {
window.localStorage.removeItem(name)
}
@@ -64,8 +63,8 @@ export const getSessionStorage: (k: string) => any = (k: string) => {
/**
* * 清除本地会话数据
* @param name
* @param name
*/
export const clearSessioStorage = (name: string) => {
window.sessionStorage.removeItem(name)
}
}
+6 -3
View File
@@ -135,11 +135,13 @@ export const fileTobase64 = (file: File, callback: Function) => {
/**
* * 挂载监听
*/
// eslint-disable-next-line no-undef
export const addEventListener = <K extends keyof WindowEventMap>(
target: HTMLElement | Document,
type: K,
listener: any,
delay?: number,
// eslint-disable-next-line no-undef
options?: boolean | AddEventListenerOptions | undefined
) => {
if (!target) return
@@ -156,6 +158,7 @@ export const addEventListener = <K extends keyof WindowEventMap>(
/**
* * 卸载监听
*/
// eslint-disable-next-line no-undef
export const removeEventListener = <K extends keyof WindowEventMap>(
target: HTMLElement | Document,
type: K,
@@ -245,12 +248,12 @@ export const intervalUnitHandle = (num: number, unit: RequestHttpIntervalEnum) =
/**
* * 对象转换 cookie 格式
* @param obj
* @param obj
* @returns string
*/
export const objToCookie = (obj: RequestParamsObjType) => {
if(!obj) return ''
if (!obj) return ''
let str = ''
for (const key in obj) {
str += key + '=' + obj[key] + ';'