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

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

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