忽略平台传递的参数,使用原始地址(?orilink)

配置为如:
https://board.tosofts.com/#/aj/sKHsTZpg?_ori_link
实际访问:
https://board.tosofts.com/#/aj/sKHsTZpg
说明添加

?_ori_link

使用代码

that.$link.toLinkUrl(url,that,{
  method: "route",//location/open/modal
  params: {},
  query: {},
  target: null,
  args:null
})

后台tab切换

 this.$root.$emit("on-change-content-tabs", {
        label: "DevOpsBuild",
        name: "40118624204808560641",
        attrs: {
          label: "DevOpsBuild",
          "row-primary-key": "label",
        },
        menuName:"DevOpsBuild",
        meta: {
          primaryId: [],
          modulesHide: ["form"],
          mkey: "bs-devops",
          field: "manager",
          menuId: "40118624204808560641",
          auth: true,
          tab: {
            component: "devops-build",
          },
        },
      });

使用代码 弹出框

 {
        link: {
            url: "url",
            option: {
                style:"border: none; width: 100%; height: calc(100vh - 60px)",
                class:"bs-root-dialog",
                title:"弹出框",
                method:"bs-dialog",// "modal-dialog",
                args: null,
                params: {},
                query: {
                    "_k": "1"
                }
            }
        },
        sortId: 5,
        name: "弹出框",
        meta: {
            imgUrl: null,
            icon: null,
            attrs: {},
        },
    }

组件弹出框

that.$link.toLinkUrl('component', that, {
                            method: "bs-dialog",
                            component: "auth-popedom-role",
                            scopeRow: {
                                roleId: "de",
                                roleName: "开发管理者"
                            },
                            value: {
                                selectionRows: [
                                    {
                                        roleId: "de",
                                        roleName: "开发管理者"
                                    }, 
                                    {
                                        roleId: "in",
                                        roleName: "系统管理员"
                                    }
                                ]
                            },
                            params: {},
                            query: {},
                            class: "bs-auth-api",
                            title: "开发权限",
                            style: window.$appNavs.dialog.style,
                            // style: "border: none; width:calc(100vw - 80px); height: calc(100vh - 50px)",
                            // class: "bs-root-dialog-p0",
                            target: null,
                            args: null
                        });

源码刨析

 if (!option.method) option.method = "route";

  let queryUrl = "";

  if (option.method !== "route") {
    let querys = [];
    if (option && option.query) {
      Object.keys(option.query).forEach(temp => {
        querys.push(`${temp}=${option.query[temp]}`)
      });
    }
    if(querys.length>0){
      queryUrl = "?" + querys.join('&');
    }   
  }

  if (that && option && option.method === "openIE") {
    window.location.href = "openIE:" + url + queryUrl;
  } else if (that && option && option.method === "replace-state") {
    // replaceState和pushState原理一样使用也一样:
    // 最常用的方法:window.history.replaceState(null,null,'download?id=1');
    // 完整使用:var oState= {title: '下载' };
    // window.history.replaceState(oState, '下载', 'download?id=1');
    // 特点:replaceState不会加入到历史记录里面,用history.go(-1)
    // 会跳过当前页面相当于是history.go(-2)。  
    //:state:一个与指定网址相关的状态对象,popstate事件触发时,
    //该对象会传入回调函数。如果不需要这个对象,
    //此处可以填null。title:新页面的标题,
    window.history.replaceState(option.state, option.title, url + queryUrl);
  } else if (that && option && option.method === "push-state") {
    window.history.pushState(option.state, option.title, url + queryUrl);
  } else if (that && option && option.method === "bs-dialog") {
    let src = url + queryUrl;
    if(url==="component"){
      src="component";
    }
    let bsDialog = JSON.parse(JSON.stringify(option));
    bsDialog.src = src;
    bsDialog.visible = true;
    that.$store.dispatch("bsDialog", bsDialog);

  } else if (that && option && option.method === "modal-dialog") {
    //dialogWidth:1920px; dialogHeight:1080px; 
    let args = "status:no; directories:yes;scrollbars:no;Resizable=no;help=no"
    let returnValue = window.open(url + queryUrl, option.target, option.args || args);
    if (returnValue == undefined) {
      returnValue = window.returnValue;
    }
    return returnValue;
    //子串口调用
    //   if (window.opener != undefined) {
    //     //for chrome
    //     window.opener.returnValue = "opener returnValue";
    // }
    // else {
    //     window.returnValue = "window returnValue";
    // }
    // window.close();
  } else if (that && option && (option.method === "blank" || option.method === "open")) {
    // 1.该名称由字母、数字和下划线字符组成。 
    // 2."_top"、"_blank"、"_self"具有特殊意义的名称。 
    //   _blank:在新窗口显示目标网页 
    //   _self:在当前窗口显示目标网页 
    //   _top:框架网页中在上部窗口中显示目标网页 
    // 3.相同 name 的窗口只能创建一个,要想创建多个窗口则 name 不能相同。 
    // 4.name 不能包含有空格。 
    // ———————————————— window.open('url','_top','width=600,height=400,top=100,left=0');  
    window.open(url + queryUrl, option.target || '_blank', option.args);
  } else if (that && option && option.method === "route") {
    that.$router.push({
      path: url,
      query: option.query,
      params: option.params
    });
  } else if (that && option && option.method === "replace") {
    window.location.replace(url + queryUrl);
  } else if (that && option && option.method === "location") {
    window.location.href = url + queryUrl;
  }
文档更新时间: 2023-03-23 13:30   作者:admin