remove 18n waring

去除 18n 警告
This commit is contained in:
chanunlang 2019-05-09 15:28:34 +08:00
parent 0bf339b6db
commit c6de74080c
1 changed files with 32 additions and 10 deletions

View File

@ -22,6 +22,7 @@
// make search results more in line with expectations
import Fuse from 'fuse.js'
import path from 'path'
import i18n from '@/lang'
export default {
name: 'HeaderSearch',
@ -37,9 +38,15 @@ export default {
computed: {
routes() {
return this.$store.getters.permission_routes
},
lang() {
return this.$store.getters.language
}
},
watch: {
lang() {
this.searchPool = this.generateRoutes(this.routes)
},
routes() {
this.searchPool = this.generateRoutes(this.routes)
},
@ -85,13 +92,16 @@ export default {
distance: 100,
maxPatternLength: 32,
minMatchCharLength: 1,
keys: [{
name: 'title',
weight: 0.7
}, {
name: 'path',
weight: 0.3
}]
keys: [
{
name: 'title',
weight: 0.7
},
{
name: 'path',
weight: 0.3
}
]
})
},
// Filter out the routes that can be displayed in the sidebar
@ -101,7 +111,9 @@ export default {
for (const router of routes) {
// skip hidden router
if (router.hidden) { continue }
if (router.hidden) {
continue
}
const data = {
path: path.resolve(basePath, router.path),
@ -109,7 +121,13 @@ export default {
}
if (router.meta && router.meta.title) {
data.title = [...data.title, router.meta.title]
// generate internationalized title
const metaTile = `route.${router.meta.title}`
const i18ntitle = i18n.te(metaTile)
? i18n.t(metaTile)
: router.meta.title
data.title = [...data.title, i18ntitle]
if (router.redirect !== 'noRedirect') {
// only push the routes with title
@ -120,7 +138,11 @@ export default {
// recursive child routes
if (router.children) {
const tempRoutes = this.generateRoutes(router.children, data.path, data.title)
const tempRoutes = this.generateRoutes(
router.children,
data.path,
data.title
)
if (tempRoutes.length >= 1) {
res = [...res, ...tempRoutes]
}