doum
17 小时以前 4e598bff548c0e4a89f30e1523bdfb8b59d97741
admin/src/main.js
@@ -45,16 +45,10 @@
        return
      }
      await this.initRoutes()
    },
    async topMenuCurrent () {
      if (this.topMenuCurrent == null) {
        return
      }
      await this.chagneRoutes()
    }
  },
  methods: {
    ...mapMutations(['switchCollapseMenu', 'setHomePage', 'setTopMenuCurrent', 'setTopMenuCurrent','cleartagsview']),
    ...mapMutations(['switchCollapseMenu', 'setHomePage', 'setTopMenuCurrent', 'setTopMenuCurrent']),
    // 初始化本地配置
    initLocalConfig () {
      // 菜单状态配置
@@ -85,13 +79,9 @@
          })
          storeTopMenus.push.apply(storeTopMenus, topList)
          var topCurrent = null
          var tlist =[]
          topList.forEach(item => {
            if (item.linkType === 0 ) {
              if (topCurrent == null) {
                topCurrent = item
              }
              tlist.push(...item.children)
            if (item.linkType === 0 && topCurrent == null) {
              topCurrent = item
            }
          })
          this.setTopMenuCurrent(topCurrent)
@@ -106,7 +96,7 @@
          console.log('menus', this.menuData.list)
          storeMenus.push.apply(storeMenus, this.menuData.list)
          // 添加路由
          this.__addRouters(tlist)
          this.__addRouters(storeMenus)
          // 404
          router.addRoute({
            path: '*',
@@ -129,16 +119,6 @@
        .finally(() => {
          this.loading = false
        })
    },
    async chagneRoutes () {
      // 重置菜单
      this.cleartagsview('/index')
      console.log('menus', this.menuData.list)
      // 添加路由
      // this.__addRouters(this.menuData.list)
      if(this.topMenuCurrent.homeUrl){
        await this.$router.push({path: this.topMenuCurrent.homeUrl, query: {}})
      }
    },
    // 新建路由
    __addRouters (routes, parents = []) {