|
@@ -11,7 +11,10 @@ export const dateFormat = (date: Date, fmt: string) => {
|
|
|
S: date.getMilliseconds(), //毫秒
|
|
|
};
|
|
|
if (/(y+)/.test(fmt)) {
|
|
|
- fmt = fmt.replace(RegExp.$1, (date.getFullYear() + "").substr(4 - RegExp.$1.length));
|
|
|
+ fmt = fmt.replace(
|
|
|
+ RegExp.$1,
|
|
|
+ (date.getFullYear() + "").substr(4 - RegExp.$1.length)
|
|
|
+ );
|
|
|
}
|
|
|
for (var k in o) {
|
|
|
if (new RegExp("(" + k + ")").test(fmt)) {
|
|
@@ -37,7 +40,10 @@ export const copyText = (text: string) => {
|
|
|
};
|
|
|
|
|
|
// 防抖
|
|
|
-export const debounce = <T extends (...args: any) => any>(fn: T, delay: number = 160) => {
|
|
|
+export const debounce = <T extends (...args: any) => any>(
|
|
|
+ fn: T,
|
|
|
+ delay: number = 160
|
|
|
+) => {
|
|
|
let timeout: any;
|
|
|
|
|
|
return function <This>(this: This, ...args: Parameters<T>) {
|
|
@@ -47,6 +53,7 @@ export const debounce = <T extends (...args: any) => any>(fn: T, delay: number =
|
|
|
}, delay);
|
|
|
};
|
|
|
};
|
|
|
+
|
|
|
export const throttle = <Args extends any[]>(
|
|
|
fn: (...args: Args) => void,
|
|
|
deley: number
|
|
@@ -169,7 +176,10 @@ export function encodePwd(str: string, strv = "") {
|
|
|
if (strv) {
|
|
|
const strv1 = strv.substring(0, NUM);
|
|
|
const strv2 = strv.substring(NUM);
|
|
|
- return [front + str2 + middle + str1 + end, front + strv2 + middle + strv1 + end];
|
|
|
+ return [
|
|
|
+ front + str2 + middle + str1 + end,
|
|
|
+ front + strv2 + middle + strv1 + end,
|
|
|
+ ];
|
|
|
}
|
|
|
|
|
|
return front + str2 + middle + str1 + end;
|
|
@@ -234,7 +244,10 @@ export const drawImage = (
|
|
|
) => {
|
|
|
let dWidth = bg_w / imgWidth; // canvas与图片的宽度比例
|
|
|
let dHeight = bg_h / imgHeight; // canvas与图片的高度比例
|
|
|
- if ((imgWidth > bg_w && imgHeight > bg_h) || (imgWidth < bg_w && imgHeight < bg_h)) {
|
|
|
+ if (
|
|
|
+ (imgWidth > bg_w && imgHeight > bg_h) ||
|
|
|
+ (imgWidth < bg_w && imgHeight < bg_h)
|
|
|
+ ) {
|
|
|
if (dWidth > dHeight) {
|
|
|
ctx.drawImage(
|
|
|
imgPath,
|