兰宝车间质量管理系统-前端
src/layout/components/TopBar/search.vue
@@ -3,12 +3,12 @@
    <el-dialog v-model="state.isShowSearch" destroy-on-close :show-close="false">
      <template #footer>
        <el-autocomplete
          ref="layoutMenuAutocompleteRef"
          v-model="state.menuQuery"
          :fetch-suggestions="menuSearch"
          placeholder="搜索"
          ref="layoutMenuAutocompleteRef"
          @select="onHandleSelect"
          :fit-input-width="true"
          @select="onHandleSelect"
        >
          <template #prefix>
            <svg-icon class-name="search-icon" icon-class="search" />
@@ -29,12 +29,12 @@
import { getNormalPath } from '@/utils/ruoyi';
import { isHttp } from '@/utils/validate';
import usePermissionStore from '@/store/modules/permission';
import { RouteOption } from 'vue-router';
import { RouteRecordRaw } from 'vue-router';
type Router = Array<{
   path: string;
   icon: string;
   title: string[];
}>
}>;
type SearchState<T = any> = {
   isShowSearch: boolean;
   menuQuery: string;
@@ -47,7 +47,7 @@
const state = reactive<SearchState>({
   isShowSearch: false,
   menuQuery: '',
   menuList: [],
  menuList: []
});
// 搜索弹窗打开
@@ -75,9 +75,9 @@
// Filter out the routes that can be displayed in the sidebar
// And generate the internationalized title
const generateRoutes = (routes: RouteOption[], basePath = '', prefixTitle: string[] = []) => {
   let res: Router = []
   routes.forEach(r => {
const generateRoutes = (routes: RouteRecordRaw[], basePath = '', prefixTitle: string[] = []) => {
  let res: Router = [];
  routes.forEach((r) => {
        // skip hidden router
      if (!r.hidden) {
         const p = r.path.length > 0 && r.path[0] === '/' ? r.path : '/' + r.path;
@@ -85,7 +85,7 @@
               path: !isHttp(r.path) ? getNormalPath(basePath + p) : r.path,
               icon: r.meta?.icon,
               title: [...prefixTitle]
            }
      };
            if (r.meta && r.meta.title) {
               data.title = [...data.title, r.meta.title];
               if (r.redirect !== 'noRedirect') {
@@ -102,27 +102,26 @@
                  }
            }
      }
   })
  });
   res.forEach((item: any) => {
      if (item.title instanceof Array) {
         item.title = item.title.join('/');
      }
   });
   return res;
}
};
// 当前菜单选中时
const onHandleSelect = (val: any) => {
   const paths = val.path;
   if (isHttp(paths)) {
      // http(s):// 路径新窗口打开
      const pindex = paths.indexOf("http");
      window.open(paths.substring(pindex, paths.length), "_blank");
    const pindex = paths.indexOf('http');
    window.open(paths.substring(pindex, paths.length), '_blank');
   } else {
      router.push(paths);
   }
   state.menuQuery = ''
  state.menuQuery = '';
   closeSearch();
};
// 暴露变量