Skip to content

Commit 5005af1

Browse files
committed
fix: dom title
1 parent 4269ffd commit 5005af1

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/App.vue

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,20 @@
77
</template>
88

99
<script>
10+
import { domTitle, setDocumentTitle } from '@/utils/domUtil'
11+
import { i18nRender } from '@/locales'
12+
1013
export default {
1114
data () {
1215
return {
1316
}
1417
},
1518
computed: {
1619
locale () {
20+
// 只是为了切换语言时,更新标题
21+
const { title } = this.$route.meta
22+
title && (setDocumentTitle(`${i18nRender(title)} - ${domTitle}`))
23+
1724
return this.$i18n.getLocaleMessage(this.$store.getters.lang).antLocale
1825
}
1926
},

src/permission.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import '@/components/NProgress/nprogress.less' // progress bar custom style
66
import notification from 'ant-design-vue/es/notification'
77
import { setDocumentTitle, domTitle } from '@/utils/domUtil'
88
import { ACCESS_TOKEN } from '@/store/mutation-types'
9+
import { i18nRender } from '@/locales'
910

1011
NProgress.configure({ showSpinner: false }) // NProgress Configuration
1112

@@ -15,7 +16,7 @@ const defaultRoutePath = '/dashboard/workplace'
1516

1617
router.beforeEach((to, from, next) => {
1718
NProgress.start() // start progress bar
18-
to.meta && (typeof to.meta.title !== 'undefined' && setDocumentTitle(`${to.meta.title} - ${domTitle}`))
19+
to.meta && (typeof to.meta.title !== 'undefined' && setDocumentTitle(`${i18nRender(to.meta.title)} - ${domTitle}`))
1920
/* has token */
2021
if (storage.get(ACCESS_TOKEN)) {
2122
if (to.path === loginRoutePath) {

0 commit comments

Comments
 (0)