App.vue 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <template>
  2. <div id="app">
  3. <div class="head">
  4. <div class="logo">
  5. <img style="height: 40px;margin-top: 10px;" class="left nav-icon" src="https://x.cocorobo.cn/icons/logo.png" />
  6. <!-- <span
  7. style="
  8. font-size: 28px;
  9. font-family: 'GT Walsheim Pro Trial Bold';
  10. font-weight: bold;
  11. color: #fff;
  12. "
  13. >CocoBlockly</span
  14. > -->
  15. </div>
  16. </div>
  17. <div>
  18. <!-- main 内容 -->
  19. <keep-alive v-if="$route.meta.keepAlive">
  20. <!-- 这里是会被缓存的视图组件 -->
  21. <router-view v-if="$route.meta.keepAlive" />
  22. </keep-alive>
  23. <!-- 这里是不被缓存的视图组件 -->
  24. <router-view v-if="!$route.meta.keepAlive" />
  25. </div>
  26. </div>
  27. </template>
  28. <script>
  29. export default {
  30. name: "App",
  31. created() {
  32. //在页面加载时读取sessionStorage里的状态信息
  33. if (sessionStorage.getItem("store")) {
  34. this.$store.replaceState(
  35. Object.assign(
  36. {},
  37. this.$store.state,
  38. JSON.parse(sessionStorage.getItem("store"))
  39. )
  40. );
  41. }
  42. //在页面刷新时将vuex里的信息保存到sessionStorage里
  43. window.addEventListener("beforeunload", () => {
  44. sessionStorage.setItem("store", JSON.stringify(this.$store.state));
  45. });
  46. },
  47. };
  48. </script>
  49. <style>
  50. * {
  51. margin: 0;
  52. padding: 0;
  53. }
  54. body {
  55. font-family: "Helvetica Neue", Helvetica, "PingFang SC", "Hiragino Sans GB",
  56. "Microsoft YaHei", "微软雅黑", Arial, sans-serif;
  57. }
  58. #app {
  59. height: 100%;
  60. width: 100%;
  61. /* background: #e6eaf0; */
  62. /* min-width: 1380px; */
  63. background: #fff;
  64. min-width: 1000px;
  65. }
  66. .head {
  67. height: 67.5px;
  68. width: 100%;
  69. background-color: #2c4fcd;
  70. display: flex;
  71. align-items: center;
  72. min-width: 1000px;
  73. }
  74. .logo {
  75. margin-left: 20px;
  76. }
  77. </style>