單頁面登陸——編碼傳參(oa會對#號會進行截斷)

/**
 * querystring有四種方法:注意queryString與query-string不是同一個依賴包
 *  querystring.stringify 序列化;
 *  querystring.parse 反序列化;
 *  querystring.escape 編碼;//encodeURIComponent(),不使用escape()只編譯漢字,encodeURI()不編譯特殊符號
 *  querystring.unescape 解碼;//decodeURIComponent,對應:unescape()、decodeURI()
 *query-string:字符串與對象互轉(簡寫qs)
 *  qs.stringify:{foo: false}//=> 'foo=false'
 *  qs.parse:'likes=cake&name=bob&likes=icecream'//=> {likes: ['cake', 'icecream'], name: 'bob'}
 */緩存

【清除本地緩存】:cookie

let keys = document.cookie.match(/[^ =;]+(?=\=)/g);//清除當前域名下cookie
if (keys) {
  for (let i = keys.length; i--;) {
    document.cookie = keys[i] + '=0;path=/;expires=' + new Date(0).toUTCString();//清除當前域名下的cookie,例如:kp.oa.com
    document.cookie = keys[i] + '=0;path=/;domain=' + document.domain + ';expires=' + new Date(0).toUTCString();//清除當前域名下的,例如 .kp.oa.com
    document.cookie = keys[i] + '=0;path=/;domain=kevis.com;expires=' + new Date(0).toUTCString();//清除一級域名下的或指定的,例如 .oa.com
  }
}
localStorage.removeItem("usern"); //清除本地用戶信息
this.$store.dispatch("setUserCurinfo", null);//清除

let authObj = {
protocol: 'http:',
host: 'passport.oa.com',
pathname: '/modules/passport/signin.ashx',
query: {
url:`${location.href}`
}
};
console.log(`http://passport.oa.com/modules/passport/signout.ashx?url=${location.href}&title=HADES`,"模板字符串")
import _url from "url";
console.log(_url.format(authObj),"模板字符串")
注意點:oa系統不識別#後面的值,須要改變路由模式。
相關文章
相關標籤/搜索