This commit is contained in:
Pan 2019-04-02 16:56:52 +08:00
parent 55fa5acb85
commit dd18f51afe
6 changed files with 8 additions and 60 deletions

View File

@ -2,16 +2,14 @@
<el-breadcrumb class="app-breadcrumb" separator="/"> <el-breadcrumb class="app-breadcrumb" separator="/">
<transition-group name="breadcrumb"> <transition-group name="breadcrumb">
<el-breadcrumb-item v-for="(item,index) in levelList" :key="item.path"> <el-breadcrumb-item v-for="(item,index) in levelList" :key="item.path">
<span v-if="item.redirect==='noredirect'||index==levelList.length-1" class="no-redirect">{{ <span v-if="item.redirect==='noredirect'||index==levelList.length-1" class="no-redirect">{{ item.meta.title }}</span>
generateTitle(item.meta.title) }}</span> <a v-else @click.prevent="handleLink(item)">{{ item.meta.title }}</a>
<a v-else @click.prevent="handleLink(item)">{{ generateTitle(item.meta.title) }}</a>
</el-breadcrumb-item> </el-breadcrumb-item>
</transition-group> </transition-group>
</el-breadcrumb> </el-breadcrumb>
</template> </template>
<script> <script>
import { generateTitle } from '@/utils/i18n'
import pathToRegexp from 'path-to-regexp' import pathToRegexp from 'path-to-regexp'
export default { export default {
@ -29,7 +27,6 @@ export default {
this.getBreadcrumb() this.getBreadcrumb()
}, },
methods: { methods: {
generateTitle,
getBreadcrumb() { getBreadcrumb() {
let matched = this.$route.matched.filter(item => item.name) let matched = this.$route.matched.filter(item => item.name)

View File

@ -22,7 +22,6 @@
// make search results more in line with expectations // make search results more in line with expectations
import Fuse from 'fuse.js' import Fuse from 'fuse.js'
import path from 'path' import path from 'path'
import i18n from '@/lang'
export default { export default {
name: 'HeaderSearch', name: 'HeaderSearch',
@ -116,10 +115,7 @@ export default {
} }
if (router.meta && router.meta.title) { if (router.meta && router.meta.title) {
// generate internationalized title data.title = [...data.title, router.meta.title]
const i18ntitle = i18n.t(`route.${router.meta.title}`)
data.title = [...data.title, i18ntitle]
if (router.redirect !== 'noredirect') { if (router.redirect !== 'noredirect') {
// only push the routes with title // only push the routes with title

View File

@ -1,38 +0,0 @@
<template>
<el-dropdown trigger="click" class="international" @command="handleSetLanguage">
<div>
<svg-icon class-name="international-icon" icon-class="language" />
</div>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item :disabled="language==='zh'" command="zh">
中文
</el-dropdown-item>
<el-dropdown-item :disabled="language==='en'" command="en">
English
</el-dropdown-item>
<el-dropdown-item :disabled="language==='es'" command="es">
Español
</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</template>
<script>
export default {
computed: {
language() {
return this.$store.getters.language
}
},
methods: {
handleSetLanguage(lang) {
this.$i18n.locale = lang
this.$store.dispatch('app/setLanguage', lang)
this.$message({
message: 'Switch Language Success',
type: 'success'
})
}
}
}
</script>

View File

@ -3,14 +3,14 @@
<template v-if="hasOneShowingChild(item.children,item) && (!onlyOneChild.children||onlyOneChild.noShowingChildren)&&!item.alwaysShow"> <template v-if="hasOneShowingChild(item.children,item) && (!onlyOneChild.children||onlyOneChild.noShowingChildren)&&!item.alwaysShow">
<app-link v-if="onlyOneChild.meta" :to="resolvePath(onlyOneChild.path)"> <app-link v-if="onlyOneChild.meta" :to="resolvePath(onlyOneChild.path)">
<el-menu-item :index="resolvePath(onlyOneChild.path)" :class="{'submenu-title-noDropdown':!isNest}"> <el-menu-item :index="resolvePath(onlyOneChild.path)" :class="{'submenu-title-noDropdown':!isNest}">
<item :icon="onlyOneChild.meta.icon||(item.meta&&item.meta.icon)" :title="generateTitle(onlyOneChild.meta.title)" /> <item :icon="onlyOneChild.meta.icon||(item.meta&&item.meta.icon)" :title="onlyOneChild.meta.title" />
</el-menu-item> </el-menu-item>
</app-link> </app-link>
</template> </template>
<el-submenu v-else ref="subMenu" :index="resolvePath(item.path)" popper-append-to-body> <el-submenu v-else ref="subMenu" :index="resolvePath(item.path)" popper-append-to-body>
<template slot="title"> <template slot="title">
<item v-if="item.meta" :icon="item.meta && item.meta.icon" :title="generateTitle(item.meta.title)" /> <item v-if="item.meta" :icon="item.meta && item.meta.icon" :title="item.meta.title" />
</template> </template>
<sidebar-item <sidebar-item
v-for="child in item.children" v-for="child in item.children"
@ -26,7 +26,6 @@
<script> <script>
import path from 'path' import path from 'path'
import { generateTitle } from '@/utils/i18n'
import { isExternal } from '@/utils/validate' import { isExternal } from '@/utils/validate'
import Item from './Item' import Item from './Item'
import AppLink from './Link' import AppLink from './Link'
@ -87,9 +86,7 @@ export default {
return routePath return routePath
} }
return path.resolve(this.basePath, routePath) return path.resolve(this.basePath, routePath)
}, }
generateTitle
} }
} }
</script> </script>

View File

@ -12,7 +12,7 @@
@click.middle.native="closeSelectedTag(tag)" @click.middle.native="closeSelectedTag(tag)"
@contextmenu.prevent.native="openMenu(tag,$event)" @contextmenu.prevent.native="openMenu(tag,$event)"
> >
{{ generateTitle(tag.title) }} {{ tag.title }}
<span v-if="!tag.meta.affix" class="el-icon-close" @click.prevent.stop="closeSelectedTag(tag)" /> <span v-if="!tag.meta.affix" class="el-icon-close" @click.prevent.stop="closeSelectedTag(tag)" />
</router-link> </router-link>
</scroll-pane> </scroll-pane>
@ -36,7 +36,6 @@
<script> <script>
import ScrollPane from './ScrollPane' import ScrollPane from './ScrollPane'
import { generateTitle } from '@/utils/i18n'
import path from 'path' import path from 'path'
export default { export default {
@ -76,7 +75,6 @@ export default {
this.addTags() this.addTags()
}, },
methods: { methods: {
generateTitle, // generateTitle by vue-i18n
isActive(route) { isActive(route) {
return route.path === this.$route.path return route.path === this.$route.path
}, },

View File

@ -6,7 +6,6 @@
<h3 class="title"> <h3 class="title">
{{ $t('login.title') }} {{ $t('login.title') }}
</h3> </h3>
<lang-select class="set-language" />
</div> </div>
<el-form-item prop="username"> <el-form-item prop="username">
@ -76,12 +75,11 @@
<script> <script>
import { validUsername } from '@/utils/validate' import { validUsername } from '@/utils/validate'
import LangSelect from '@/components/LangSelect'
import SocialSign from './socialsignin' import SocialSign from './socialsignin'
export default { export default {
name: 'Login', name: 'Login',
components: { LangSelect, SocialSign }, components: { SocialSign },
data() { data() {
const validateUsername = (rule, value, callback) => { const validateUsername = (rule, value, callback) => {
if (!validUsername(value)) { if (!validUsername(value)) {