<template>
  <div id="app">
    <router-view />
  </div>
</template>

<script>
  import { updateDocumentTitle } from '@/utils/document-title-util';
  import { getPathAddress } from '@/api/system/file/index';
  export default {
    name: 'App',
    created() {
      console.log('我是子应用-----------');
      // 恢复主题
      this.$store.dispatch('theme/recoverTheme');
      if (!sessionStorage.filePath) {
        getPathAddress().then((res) => {
          console.log(res);
          sessionStorage.filePath = res;
        });
      }
    },
    methods: {
      /* 路由切换更新浏览器标题 */
      setDocumentTitle() {
        updateDocumentTitle(
          this.$route,
          (key) => this.$t(key),
          this.$store.state.theme.tabs
        );
      }
    },
    watch: {
      '$i18n.locale'() {
        this.setDocumentTitle();
      },
      $route() {
        this.setDocumentTitle();
      }
    }
  };
</script>
