Răsfoiți Sursa

fix: dom title

Sendya 4 ani în urmă
părinte
comite
5005af1185
2 a modificat fișierele cu 9 adăugiri și 1 ștergeri
  1. 7 0
      src/App.vue
  2. 2 1
      src/permission.js

+ 7 - 0
src/App.vue

@@ -7,6 +7,9 @@
 </template>
 
 <script>
+import { domTitle, setDocumentTitle } from '@/utils/domUtil'
+import { i18nRender } from '@/locales'
+
 export default {
   data () {
     return {
@@ -14,6 +17,10 @@ export default {
   },
   computed: {
     locale () {
+      // 只是为了切换语言时,更新标题
+      const { title } = this.$route.meta
+      title && (setDocumentTitle(`${i18nRender(title)} - ${domTitle}`))
+
       return this.$i18n.getLocaleMessage(this.$store.getters.lang).antLocale
     }
   },

+ 2 - 1
src/permission.js

@@ -6,6 +6,7 @@ import '@/components/NProgress/nprogress.less' // progress bar custom style
 import notification from 'ant-design-vue/es/notification'
 import { setDocumentTitle, domTitle } from '@/utils/domUtil'
 import { ACCESS_TOKEN } from '@/store/mutation-types'
+import { i18nRender } from '@/locales'
 
 NProgress.configure({ showSpinner: false }) // NProgress Configuration
 
@@ -15,7 +16,7 @@ const defaultRoutePath = '/dashboard/workplace'
 
 router.beforeEach((to, from, next) => {
   NProgress.start() // start progress bar
-  to.meta && (typeof to.meta.title !== 'undefined' && setDocumentTitle(`${to.meta.title} - ${domTitle}`))
+  to.meta && (typeof to.meta.title !== 'undefined' && setDocumentTitle(`${i18nRender(to.meta.title)} - ${domTitle}`))
   /* has token */
   if (storage.get(ACCESS_TOKEN)) {
     if (to.path === loginRoutePath) {