From cc9b67d4676dd51a6b2d88e92607aca2629ee54d Mon Sep 17 00:00:00 2001
From: 疯狂的狮子Li <15040126243@163.com>
Date: 星期五, 22 十二月 2023 13:26:26 +0800
Subject: [PATCH] !72 发布 vue 版本 5.1.2 与 cloud 版本 2.1.2 Merge pull request !72 from 疯狂的狮子Li/temp

---
 src/components/HeaderSearch/index.vue |   74 +++++++++++++++++++++---------------
 1 files changed, 43 insertions(+), 31 deletions(-)

diff --git a/src/components/HeaderSearch/index.vue b/src/components/HeaderSearch/index.vue
index e6b9531..b922c6c 100644
--- a/src/components/HeaderSearch/index.vue
+++ b/src/components/HeaderSearch/index.vue
@@ -1,9 +1,29 @@
-<script setup lang="ts">
-import Fuse from 'fuse.js'
-import { getNormalPath } from '@/utils/ruoyi'
-import { isHttp } from '@/utils/validate'
-import usePermissionStore from '@/store/modules/permission'
-import { RouteOption } from 'vue-router'
+<template>
+  <div :class="{ 'show': show }" class="header-search">
+    <svg-icon class-name="search-icon" icon-class="search" @click.stop="click"/>
+    <el-select
+      ref="headerSearchSelectRef"
+      v-model="search"
+      :remote-method="querySearch"
+      filterable
+      default-first-option
+      remote
+      placeholder="Search"
+      class="header-search-select"
+      @change="change"
+    >
+      <el-option v-for="option in options" :key="option.item.path" :value="option.item"
+                 :label="option.item.title.join(' > ')"/>
+    </el-select>
+  </div>
+</template>
+
+<script setup lang="ts" name="HeaderSearch">
+import Fuse from 'fuse.js';
+import {getNormalPath} from '@/utils/ruoyi';
+import {isHttp} from '@/utils/validate';
+import usePermissionStore from '@/store/modules/permission';
+import {RouteOption} from 'vue-router';
 
 type Router = Array<{
   path: string;
@@ -15,7 +35,7 @@
 const searchPool = ref<Router>([]);
 const show = ref(false);
 const fuse = ref();
-const headerSearchSelectRef = ref(ElSelect);
+const headerSearchSelectRef = ref<ElSelectInstance>();
 const router = useRouter();
 const routes = computed(() => usePermissionStore().routes);
 
@@ -32,12 +52,17 @@
 }
 const change = (val: any) => {
   const path = val.path;
+  const query = val.query;
   if (isHttp(path)) {
     // http(s):// 璺緞鏂扮獥鍙f墦寮�
     const pindex = path.indexOf("http");
     window.open(path.substr(pindex, path.length), "_blank");
   } else {
-    router.push(path)
+    if (query) {
+      router.push({ path: path, query: JSON.parse(query) });
+    } else {
+      router.push(path)
+    }
   }
   search.value = ''
   options.value = []
@@ -71,7 +96,8 @@
       const p = r.path.length > 0 && r.path[0] === '/' ? r.path : '/' + r.path;
       const data = {
         path: !isHttp(r.path) ? getNormalPath(basePath + p) : r.path,
-        title: [...prefixTitle]
+        title: [...prefixTitle],
+        query: ''
       }
       if (r.meta && r.meta.title) {
         data.title = [...data.title, r.meta.title];
@@ -81,6 +107,11 @@
           res.push(data);
         }
       }
+
+      if (r.query) {
+        data.query = r.query
+      }
+
       // recursive child routes
       if (r.children) {
         const tempRoutes = generateRoutes(r.children, data.path, data.title);
@@ -104,9 +135,9 @@
   searchPool.value = generateRoutes(routes.value);
 })
 
-watchEffect(() => {
-  searchPool.value = generateRoutes(routes.value)
-})
+// watchEffect(() => {
+//     searchPool.value = generateRoutes(routes.value)
+// })
 
 watch(show, (value) => {
   if (value) {
@@ -120,25 +151,6 @@
   initFuse(list)
 })
 </script>
-
-<template>
-	<div :class="{ 'show': show }" class="header-search">
-		<svg-icon class-name="search-icon" icon-class="search" @click.stop="click" />
-		<el-select
-			ref="headerSearchSelectRef"
-			v-model="search"
-			:remote-method="querySearch"
-			filterable
-			default-first-option
-			remote
-			placeholder="Search"
-			class="header-search-select"
-			@change="change"
-		>
-			<el-option v-for="option in options" :key="option.item.path" :value="option.item" :label="option.item.title.join(' > ')" />
-		</el-select>
-	</div>
-</template>
 
 <style lang="scss" scoped>
 .header-search {

--
Gitblit v1.9.3