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.

93 lines
2.9 KiB

3 months ago
  1. <template>
  2. <div id="app">
  3. <router-view v-if="isRouterAlive" />
  4. <Setings ref="setingsRef" />
  5. </div>
  6. </template>
  7. <script>
  8. // +----------------------------------------------------------------------
  9. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  10. // +----------------------------------------------------------------------
  11. // | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
  12. // +----------------------------------------------------------------------
  13. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  14. // +----------------------------------------------------------------------
  15. // | Author: CRMEB Team <admin@crmeb.com>
  16. // +----------------------------------------------------------------------
  17. import { Local } from '@/utils/storage.js';
  18. import Setings from '@/layout/navBars/breadcrumb/setings.vue';
  19. export default {
  20. name: 'App',
  21. components: { Setings },
  22. provide() {
  23. return {
  24. reload: this.reload,
  25. };
  26. },
  27. data() {
  28. return {
  29. isRouterAlive: true,
  30. };
  31. },
  32. watch: {
  33. // 监听路由 控制侧边栏显示 标记当前顶栏菜单(如需要)
  34. $route(to, from) {
  35. const onRoutes = to.meta.activeMenu ? to.meta.activeMenu : to.meta.path;
  36. this.$store.commit('menu/setActivePath', onRoutes);
  37. if (to.name == 'crud_crud') {
  38. this.$store.state.user.oneLvRoutes.map((e) => {
  39. if (e.path === to.path) {
  40. to.meta.title = e.title;
  41. }
  42. });
  43. }
  44. //优惠券、秒杀活动
  45. if (['creatProduct', 'CreatCoupon', 'CreatSeckill', 'CreatTag', 'border', 'articleCreat'].includes(to.name)) {
  46. let route = to.matched[1].path.split(':')[0];
  47. this.$store.state.user.oneLvRoutes.map((e) => {
  48. if (route.indexOf(e.path) != -1) {
  49. to.meta.title = `${e.title} ${to.params.id ? 'ID:' + to.params.id : ''}`;
  50. }
  51. });
  52. }
  53. //个人中心、修改密码
  54. if (['MaintainUser', 'MaintainUpdate'].includes(to.name)) {
  55. this.bus.$emit('oneCatName', '控制台');
  56. }
  57. },
  58. },
  59. mounted() {
  60. this.openSetingsDrawer();
  61. this.getLayoutThemeConfig();
  62. },
  63. methods: {
  64. reload() {
  65. this.isRouterAlive = false;
  66. this.$nextTick(function () {
  67. this.isRouterAlive = true;
  68. });
  69. },
  70. // 布局配置弹窗打开
  71. openSetingsDrawer() {
  72. this.bus.$on('openSetingsDrawer', () => {
  73. this.$refs.setingsRef.openDrawer();
  74. });
  75. },
  76. // 获取缓存中的布局配置
  77. getLayoutThemeConfig() {
  78. if (Local.get('JavaPlatThemeConfigPrev')) {
  79. this.$store.dispatch('themeConfig/setThemeConfig', Local.get('JavaPlatThemeConfigPrev'));
  80. document.documentElement.style.cssText = Local.get('JavaPlatThemeConfigStyle');
  81. } else {
  82. Local.set('JavaPlatThemeConfigPrev', this.$store.state.themeConfig.themeConfig);
  83. }
  84. },
  85. },
  86. destroyed() {
  87. this.bus.$off('openSetingsDrawer');
  88. },
  89. };
  90. </script>