{"remainingRequest":"/data/jenkins/workspace/mer.mall2.baibaodun.cn/node_modules/vue-loader/lib/index.js??vue-loader-options!/data/jenkins/workspace/mer.mall2.baibaodun.cn/src/components/HeaderSearch/index.vue?vue&type=script&lang=js","dependencies":[{"path":"/data/jenkins/workspace/mer.mall2.baibaodun.cn/src/components/HeaderSearch/index.vue","mtime":1720764823949},{"path":"/data/jenkins/workspace/mer.mall2.baibaodun.cn/node_modules/babel-loader/lib/index.js","mtime":456789000000},{"path":"/data/jenkins/workspace/mer.mall2.baibaodun.cn/node_modules/cache-loader/dist/cjs.js","mtime":499162500000},{"path":"/data/jenkins/workspace/mer.mall2.baibaodun.cn/node_modules/vue-loader/lib/index.js","mtime":499162500000}],"contextDependencies":[],"result":["//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n\n// +----------------------------------------------------------------------\n// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]\n// +----------------------------------------------------------------------\n// | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.\n// +----------------------------------------------------------------------\n// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权\n// +----------------------------------------------------------------------\n// | Author: CRMEB Team \n// +----------------------------------------------------------------------\n\n// fuse is a lightweight fuzzy-search module\n// make search results more in line with expectations\nimport Fuse from 'fuse.js';\nimport path from 'path';\nimport { mapGetters } from 'vuex';\nexport default {\n name: 'HeaderSearch',\n data() {\n return {\n search: '',\n options: [],\n searchPool: [],\n show: false,\n fuse: undefined,\n };\n },\n computed: {\n ...mapGetters(['permission_routes']),\n // routes() {\n // return this.$product.getters.permission_routes\n // }\n },\n watch: {\n routes(n) {\n this.searchPool = this.generateRoutes(this.permission_routes);\n },\n searchPool(list) {\n this.initFuse(list);\n },\n show(value) {\n if (value) {\n document.body.addEventListener('click', this.close);\n } else {\n document.body.removeEventListener('click', this.close);\n }\n },\n },\n mounted() {\n this.searchPool = this.generateRoutes(this.permission_routes);\n },\n methods: {\n click() {\n this.show = !this.show;\n if (this.show) {\n this.$refs.headerSearchSelect && this.$refs.headerSearchSelect.focus();\n }\n },\n close() {\n this.$refs.headerSearchSelect && this.$refs.headerSearchSelect.blur();\n this.options = [];\n this.show = false;\n },\n change(val) {\n this.$router.push(val.path);\n this.search = '';\n this.options = [];\n this.$nextTick(() => {\n this.show = false;\n });\n },\n initFuse(list) {\n this.fuse = new Fuse(list, {\n shouldSort: true,\n threshold: 0.4,\n location: 0,\n distance: 100,\n maxPatternLength: 32,\n minMatchCharLength: 1,\n keys: [\n {\n name: 'name',\n weight: 0.7,\n },\n {\n name: 'url',\n weight: 0.3,\n },\n ],\n });\n },\n // Filter out the routes that can be displayed in the sidebar\n // And generate the internationalized title\n generateRoutes(routes, basePath = '/', prefixTitle = []) {\n let res = [];\n for (const router of routes) {\n // skip hidden router\n if (router.hidden) {\n continue;\n }\n\n const data = {\n path: path.resolve(basePath, router.url),\n name: [...prefixTitle],\n children: router.child || [],\n };\n\n if (router.name) {\n data.name = [...data.name, router.name];\n\n if (router.redirect !== 'noRedirect') {\n // only push the routes with title\n // special case: need to exclude parent router without redirect\n res.push(data);\n }\n }\n\n // recursive child routes\n if (router.child) {\n const tempRoutes = this.generateRoutes(router.child, data.url, data.name);\n if (tempRoutes.length >= 1) {\n res = [...res, ...tempRoutes];\n }\n }\n }\n return res;\n },\n querySearch(query) {\n if (query !== '') {\n this.options = this.fuse.search(query);\n } else {\n this.options = [];\n }\n },\n },\n};\n",null]}