From 5e752e5ab9a4b18f594dd53cf68f7a99a1235123 Mon Sep 17 00:00:00 2001 From: TimSpan Date: Fri, 25 Oct 2024 11:03:29 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=8C=E6=AD=A5=20=E7=A6=BB=E7=BA=BF?= =?UTF-8?q?=E5=9C=B0=E5=9B=BE=E5=92=8C=E5=9C=A8=E7=BA=BF=E5=9C=B0=E5=9B=BE?= =?UTF-8?q?=20=E9=A1=B5=E9=9D=A2=E7=9A=84=E4=BB=A3=E7=A0=81=E3=80=81?= =?UTF-8?q?=E4=BF=9D=E6=8C=81=E9=A3=8E=E6=A0=BC=E4=B8=80=E8=87=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/url.ts | 1 + src/utils/throttle.ts | 19 + src/views/index.vue | 25 +- src/views/login.vue | 10 +- src/views/page/index.vue | 681 +++++++++++++++++++++------------- src/views/page/indexMim.vue | 9 +- src/views/page/offLineMap.vue | 130 +++---- 7 files changed, 502 insertions(+), 373 deletions(-) create mode 100644 src/url.ts create mode 100644 src/utils/throttle.ts diff --git a/src/url.ts b/src/url.ts new file mode 100644 index 00000000..03ed96bb --- /dev/null +++ b/src/url.ts @@ -0,0 +1 @@ +export const reqUrl = ' https://www.hndyjqrh.cn' \ No newline at end of file diff --git a/src/utils/throttle.ts b/src/utils/throttle.ts new file mode 100644 index 00000000..07b8d039 --- /dev/null +++ b/src/utils/throttle.ts @@ -0,0 +1,19 @@ +export const throttle = (func: (...args: any[]) => void, limit: number) => { + let lastFunc: ReturnType; + let lastRan: number | undefined; + + return function (this: any, ...args: any[]) { // 为 this 添加类型注解 + if (!lastRan) { + func.apply(this, args); + lastRan = Date.now(); + } else { + clearTimeout(lastFunc); + lastFunc = setTimeout(() => { + if (Date.now() - (lastRan as number) >= limit) { + func.apply(this, args); + lastRan = Date.now(); + } + }, limit - (Date.now() - (lastRan as number))); + } + }; +}; \ No newline at end of file diff --git a/src/views/index.vue b/src/views/index.vue index 80c9956b..3419d989 100644 --- a/src/views/index.vue +++ b/src/views/index.vue @@ -11,7 +11,8 @@
  • - 安保力量 + + 安保力量
  • @@ -58,12 +59,12 @@ diff --git a/src/views/page/indexMim.vue b/src/views/page/indexMim.vue index 84d27c90..9b538002 100644 --- a/src/views/page/indexMim.vue +++ b/src/views/page/indexMim.vue @@ -177,6 +177,7 @@