App.vue 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <template>
  2. <div id="app">
  3. <router-view />
  4. </div>
  5. </template>
  6. <script>
  7. import { mapGetters } from "vuex";
  8. import store from "./store/index";
  9. export default {
  10. data() {
  11. return {
  12. system: null,
  13. };
  14. },
  15. computed: {
  16. ...mapGetters({
  17. searchValue: "searchValue",
  18. isRouterAlive: "isRouterAlive",
  19. }),
  20. },
  21. methods: {},
  22. created() {
  23. store.state._this = this;
  24. },
  25. watch: {
  26. $route(val) {
  27. this.system = JSON.parse(sessionStorage.getItem("module_info"));
  28. if (this.system) {
  29. // 假设 this.system 是一个数组,每个元素有 modules 属性,每个 module 有 apps 属性
  30. this.system.forEach(sys => {
  31. const md = sys.modules.find(module =>
  32. module.apps.some(app => app.name === val.name)
  33. );
  34. if (md) {
  35. sessionStorage.setItem("active_modules", JSON.stringify(md));
  36. this.$store.dispatch("setActiveApp", {
  37. app: md.apps.find(app => app.name === val.name),
  38. val: this.searchValue,
  39. });
  40. this.$store.dispatch("setSSystemModules", sys.modules);
  41. }
  42. });
  43. }
  44. },
  45. },
  46. };
  47. </script>
  48. <style>
  49. body {
  50. font: 16px/1.5 Helvetica Neue, Helvetica, Arial, Microsoft Yahei,
  51. Hiragino Sans GB, Heiti SC, WenQuanYi Micro Hei, sans-serif;
  52. font-family: "微软雅黑";
  53. min-width: 1200px;
  54. }
  55. .rightBar {
  56. width: 60px;
  57. height: 100vh;
  58. background: rgba(255, 255, 255, 0.5);
  59. box-shadow: 0 2px 5px rgb(0 0 0 / 10%);
  60. }
  61. .el-drawer__header {
  62. padding: 10px !important;
  63. margin-bottom: 0 !important;
  64. font-size: 16px !important;
  65. font-family: PingFang SC-Bold, PingFang SC;
  66. font-weight: bold !important;
  67. color: #333333 !important;
  68. }
  69. </style>