App.vue 678 B

123456789101112131415161718192021222324252627282930313233343536
  1. <template>
  2. <div id="app">
  3. <router-view />
  4. </div>
  5. </template>
  6. <script>
  7. import { updateDocumentTitle } from '@/utils/document-title-util';
  8. export default {
  9. name: 'App',
  10. created() {
  11. // 恢复主题
  12. this.$store.dispatch('theme/recoverTheme');
  13. },
  14. methods: {
  15. /* 路由切换更新浏览器标题 */
  16. setDocumentTitle() {
  17. updateDocumentTitle(
  18. this.$route,
  19. (key) => this.$t(key),
  20. this.$store.state.theme.tabs
  21. );
  22. }
  23. },
  24. watch: {
  25. '$i18n.locale'() {
  26. this.setDocumentTitle();
  27. },
  28. $route() {
  29. this.setDocumentTitle();
  30. }
  31. }
  32. };
  33. </script>