bill 1 anno fa
parent
commit
cd68479d01

+ 14 - 12
src/util/index.ts

@@ -11,10 +11,7 @@ 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)) {
@@ -39,6 +36,17 @@ export const copyText = (text: string) => {
   document.body.removeChild(input);
 };
 
+// 防抖
+export const debounce = <T extends (...args: any) => any>(fn: T, delay: number = 160) => {
+  let timeout: any;
+
+  return function <This>(this: This, ...args: Parameters<T>) {
+    clearTimeout(timeout);
+    timeout = setTimeout(() => {
+      fn.apply(this, args);
+    }, delay);
+  };
+};
 export const throttle = <Args extends any[]>(
   fn: (...args: Args) => void,
   deley: number
@@ -161,10 +169,7 @@ 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;
@@ -229,10 +234,7 @@ 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,

+ 1 - 1
src/view/case/draw/selectFuseImage.vue

@@ -61,7 +61,7 @@ import { QuiskExpose } from "@/helper/mount";
 export type FuseImage = { blob: Blob | null; taggings: CaseTagging[] };
 const props = defineProps<{ caseId: number }>();
 
-const fuseUrl = computed(() => getQuery(props.caseId, true));
+const fuseUrl = computed(() => getQuery(props.caseId, true, true));
 
 const taggings = ref<CaseTagging[]>([]);
 const transferSource = computed(() =>

+ 5 - 3
src/view/case/draw/selectMapImage.vue

@@ -20,6 +20,7 @@ import AMapLoader from "@amap/amap-jsapi-loader";
 import { Search } from "@element-plus/icons-vue";
 import { ref, watchEffect } from "vue";
 import { QuiskExpose } from "@/helper/mount";
+import { debounce } from "@/util";
 
 export type MapImage = { blob: Blob | null };
 type MapInfo = { lat: number; lng: number; zoom: number };
@@ -74,10 +75,11 @@ watchEffect(async (onCleanup) => {
   });
 });
 
+const search = debounce((keyword: string) => {
+  searchAMap.value.search(keyword);
+}, 1000);
 watchEffect(() => {
-  if (searchAMap.value) {
-    searchAMap.value.search(keyword.value);
-  }
+  searchAMap.value && search(keyword.value);
 });
 
 defineExpose<QuiskExpose>({

+ 9 - 3
src/view/case/help.ts

@@ -91,12 +91,18 @@ export const checkScenesOpen = async (caseId: number, url: URL | string) => {
   }
 };
 
-export const getQuery = (caseId: number, share: boolean = false) =>
-  `${getFuseCodeLink(caseId, true)}${share ? "&share=1" : ""}#show/summary`;
+export const getQuery = (
+  caseId: number,
+  share: boolean = false,
+  single: boolean = false
+) =>
+  `${getFuseCodeLink(caseId, true)}${share ? "&share=1" : ""}${
+    single ? "single=1" : ""
+  }#show/summary`;
 
 // 查看
 export const gotoQuery = (caseId: number) => {
-  checkScenesOpen(caseId, getQuery(caseId, false));
+  checkScenesOpen(caseId, getQuery(caseId, true));
 };
 
 export enum FuseImageType {