提交 0511ead5 authored 作者: lidongxu's avatar lidongxu

fix(login): 修复 state 获取不到值的问题

url.js 里的代码还是得自己写,AI 靠不住
上级 466c5dda
// 封装从 URL 的查询参数找到要求的 key 对应的值
export function getQueryString(name) {
// 先尝试从 search 中获取查询参数
let search = window.location.search.substr(1);
// 再尝试从 hash 中获取查询参数
const hashIndex = window.location.href.indexOf('?', window.location.href.indexOf('#'));
if (hashIndex !== -1) {
search += '&' + window.location.href.slice(hashIndex + 1);
}
var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i');
var r = search.match(reg);
if (r != null) {
return decodeURIComponent(r[2]);
} else {
return null;
}
const urlList = window.location.href.split('?').slice(1);
const queryObj = {}
urlList.forEach(item => {
const list = item.split('&')
list.forEach(o =>{
const [key, value] = o.split('=')
queryObj[key] = value
})
})
return decodeURIComponent(queryObj[name]) || null
}
\ No newline at end of file
......@@ -145,6 +145,7 @@ async function checkAutoLogin() {
const state = getQueryString('state')
const code = getQueryString('code')
console.log(state, code)
if (state === 'fs') {
// 飞书网页授权回调-自动登录
loginByType('fs', { code })
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论