wangting
2023-07-21 deed4fd12c523bdcd711958a845e0cbfb9b63610
Source/UBCS-WEB/src/router/avue-router.js
@@ -23,23 +23,18 @@
    return result.join('&');
  }
  let titileName;
  this.$router.$avueRouter = {
    //全局配置
    $website: this.$store.getters.website,
    group: '',
    meta: {},
    safe: this,
    tianyuan:'',
    // 设置标题
    setTitle: (title) => {
      titileName=title
      const defaultTitle = this.$vue.$t('title');
      this.$router.$avueRouter.tianyuan=title
      title = title ? `${title}-${defaultTitle}` : defaultTitle;
      document.title = title;
    },
    closeTag: (value) => {
      let tag = value || this.$store.getters.tag;
      if (typeof value === 'string') {
@@ -90,11 +85,13 @@
    },
    //动态路由
    // 路由是专门的一个接口获取
    /**
     * aMenu: 接受到的动态路由数据 menu的结构外层有父级path 里面有一个childen 记录页面的路由
     * first: 为了区分外界 调用formatRoutes 和 当前文件调用 formatRoutes
     */
      /**
       * aMenu: 接受到的动态路由数据 menu的结构外层有父级path 里面有一个childen 记录页面的路由
       * first: 为了区分外界 调用formatRoutes 和 当前文件调用 formatRoutes
      */
    formatRoutes: function (aMenu = [], first) {
      // window.console.log('aMenu')
      // window.console.log(aMenu)
      const aRouter = []
      // 获取到全局配置中的 props
      const propsConfig = this.$website.menu.props;
@@ -127,7 +124,7 @@
          icon = oMenu[propsDefault.icon],
          children = oMenu[propsDefault.children],
          meta = oMenu[propsDefault.meta] || {};
        // meta中 keepalive 的处理
          // meta中 keepalive 的处理
        meta = Object.assign(meta, (function () {
          if (option.keepAlive === true) {
            return {
@@ -182,12 +179,11 @@
            /**
             * 这里是重点,当有子路由的时候 会再去执行 formatRoutes 方法,然后又会有一个新的 aMenu for循环。
             * 最后返回的是一个数组 aRouter 这个数组就会作为 childen的值被 return
             */
            */
            return this.formatRoutes(children, false)
          })()
        }
        aRouter.push(oRouter)
        // console.log(aRouter)
      }
      // for循环结束
      // 这个first 卡的其实就是首路由