loulijun2021
2022-12-27 72fd6cbea51457ebf411ef12b9de161019d1803b
src/components/HeaderSearch/index.vue
@@ -1,6 +1,6 @@
<template>
  <div :class="{'show':show}" class="header-search">
    <svg-icon class-name="search-icon" icon-class="search" style="color:#A7A7A7;" @click.stop="click" />
    <svg-icon class-name="search-icon" icon-class="search" style="color:#A7A7A7;" @click.stop="click"/>
    <el-select
      ref="headerSearchSelect"
      v-model="search"
@@ -13,7 +13,8 @@
      @change="change"
    >
      <el-option v-for="item in options" :key="item.path" :value="item" :label="item.item.title.join('>')" />
      <el-option v-show="item.item.title.length>1" v-for="item in options" :key="item.path" :value="item"
                 :label="item.item.title.join('>')"/>
    </el-select>
  </div>
</template>
@@ -57,8 +58,6 @@
  },
  mounted() {
    this.searchPool = this.generateRoutes(this.routes)
    console.log(this.searchPool)
  },
  methods: {
    click() {
@@ -73,7 +72,6 @@
      this.show = false
    },
    change(val) {
      console.log(val, 1)
      this.$router.push(val.item.path)
      this.search = ''
      this.options = []
@@ -101,12 +99,13 @@
    // Filter out the routes that can be displayed in the sidebar
    // And generate the internationalized title
    generateRoutes(routes, basePath = '/', prefixTitle = []) {
      // console.log(routes, 1)
      let res = []
      for (const router of routes) {
        // skip hidden router
        if (router.hidden) { continue }
        if (router.hidden) {
          continue
        }
        const data = {
          path: path.resolve(basePath, router.path),
@@ -131,7 +130,6 @@
          }
        }
      }
      // console.log(res, 2)
      return res
    },
    querySearch(query) {
@@ -155,7 +153,7 @@
    vertical-align: middle;
  }
  .svg-icon:hover{
  .svg-icon:hover {
    color: #42b983 !important;
  }