App.vue 953 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <template>
  2. <div id="app">
  3. <router-view />
  4. </div>
  5. </template>
  6. <script>
  7. import { updateDocumentTitle } from '@/utils/document-title-util';
  8. import { getPathAddress } from '@/api/system/file/index';
  9. export default {
  10. name: 'App',
  11. created() {
  12. console.log('我是子应用-----------');
  13. // 恢复主题
  14. this.$store.dispatch('theme/recoverTheme');
  15. if (!sessionStorage.filePath) {
  16. getPathAddress().then((res) => {
  17. console.log(res);
  18. sessionStorage.filePath = res;
  19. });
  20. }
  21. },
  22. methods: {
  23. /* 路由切换更新浏览器标题 */
  24. setDocumentTitle() {
  25. updateDocumentTitle(
  26. this.$route,
  27. (key) => this.$t(key),
  28. this.$store.state.theme.tabs
  29. );
  30. }
  31. },
  32. watch: {
  33. '$i18n.locale'() {
  34. this.setDocumentTitle();
  35. },
  36. $route() {
  37. this.setDocumentTitle();
  38. }
  39. }
  40. };
  41. </script>