perf: fix some types and delete some redundant

This commit is contained in:
xiaoxian521
2021-04-28 16:48:03 +08:00
parent 8cb2d896ad
commit 89162dee1e
14 changed files with 59 additions and 65 deletions

View File

@@ -1,11 +1,12 @@
// 延迟函数
export const delay = (timeout: number) => new Promise(resolve => setTimeout(resolve, timeout))
export const delay = (timeout: number) =>
new Promise((resolve) => setTimeout(resolve, timeout));
// 防抖函数
export const debounce = (fn: () => any, timeout: number) => {
let timmer: any
export const debounce = (fn: () => Fn, timeout: number) => {
let timmer: TimeoutHandle;
return () => {
timmer ? clearTimeout(timmer) : null
timmer = setTimeout(fn, timeout)
}
}
timmer ? clearTimeout(timmer) : null;
timmer = setTimeout(fn, timeout);
};
};

View File

@@ -1,18 +1,18 @@
interface deviceInter {
match: any
match: Fn;
}
// 检测设备类型(手机返回true,反之)
export const deviceDetection = () => {
let sUserAgent: deviceInter = navigator.userAgent.toLowerCase()
let bIsIpad = sUserAgent.match(/ipad/i) == "ipad"
let bIsIphoneOs = sUserAgent.match(/iphone os/i) == "iphone os"
let bIsMidp = sUserAgent.match(/midp/i) == "midp"
let bIsUc7 = sUserAgent.match(/rv:1.2.3.4/i) == "rv:1.2.3.4"
let bIsUc = sUserAgent.match(/ucweb/i) == "ucweb"
let bIsAndroid = sUserAgent.match(/android/i) == "android"
let bIsCE = sUserAgent.match(/windows ce/i) == "windows ce"
let bIsWM = sUserAgent.match(/windows mobile/i) == "windows mobile"
let sUserAgent: deviceInter = navigator.userAgent.toLowerCase();
let bIsIpad = sUserAgent.match(/ipad/i) == "ipad";
let bIsIphoneOs = sUserAgent.match(/iphone os/i) == "iphone os";
let bIsMidp = sUserAgent.match(/midp/i) == "midp";
let bIsUc7 = sUserAgent.match(/rv:1.2.3.4/i) == "rv:1.2.3.4";
let bIsUc = sUserAgent.match(/ucweb/i) == "ucweb";
let bIsAndroid = sUserAgent.match(/android/i) == "android";
let bIsCE = sUserAgent.match(/windows ce/i) == "windows ce";
let bIsWM = sUserAgent.match(/windows mobile/i) == "windows mobile";
return bIsIphoneOs ||
bIsMidp ||
bIsUc7 ||
@@ -21,5 +21,5 @@ export const deviceDetection = () => {
bIsCE ||
bIsWM
? true
: false
};
: false;
};