多租户商城-客户PC端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
1.1 KiB

3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
  1. <template>
  2. <div id="app">
  3. <router-view v-if="isRouterAlive"></router-view>
  4. </div>
  5. </template>
  6. <script>
  7. import { getAllLangInfo } from "@/api/nav";
  8. export default {
  9. name: 'App',
  10. provide () {
  11. return {
  12. reload: this.reload
  13. }
  14. },
  15. data () {
  16. return {
  17. isRouterAlive: true
  18. }
  19. },
  20. created () {
  21. // 在页面刷新时将vuex里的信息保存到localStorage里
  22. window.addEventListener('beforeunload', () => {
  23. localStorage.setItem('messageStore', JSON.stringify(this.$store.state))
  24. })
  25. // 在页面加载时读取localStorage里的状态信息
  26. localStorage.getItem('messageStore') && this.$store.replaceState(Object.assign(this.$store.state, JSON.parse(localStorage.getItem('messageStore'))))
  27. this.initLanguage();
  28. },
  29. methods: {
  30. initLanguage(){
  31. getAllLangInfo().then((res) => {
  32. i18n.mergeLocaleMessage('en',res.data.en);
  33. i18n.mergeLocaleMessage('zh', res.data.zh);
  34. });
  35. },
  36. reload () {
  37. this.isRouterAlive = false
  38. this.$nextTick(function () {
  39. this.isRouterAlive = true
  40. })
  41. }
  42. }
  43. }
  44. </script>