提交 fe88cb99 authored 作者: lidongxu's avatar lidongxu

feat(login): 完善登录页面_合并几种登录方式

同上
上级 d759592f
...@@ -2,6 +2,7 @@ export * from './generator' ...@@ -2,6 +2,7 @@ export * from './generator'
export * from './auth' export * from './auth'
export * from './color' export * from './color'
export * from './date' export * from './date'
export * from './device'
export * from './dict' export * from './dict'
export * from './dynamicTitle' export * from './dynamicTitle'
export * from './errorCode' export * from './errorCode'
...@@ -12,8 +13,8 @@ export * from './route' ...@@ -12,8 +13,8 @@ export * from './route'
export * from './ruoyi' export * from './ruoyi'
export * from './scroll-to' export * from './scroll-to'
export * from './theme' export * from './theme'
export * from './url'
export * from './validate' export * from './validate'
export * from './device'
/** /**
* @param {string} url * @param {string} url
......
// 封装从 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;
}
}
\ No newline at end of file
...@@ -72,7 +72,7 @@ ...@@ -72,7 +72,7 @@
<script setup> <script setup>
import { fsOAuthUrl, fsClientAuth } from "@/api" import { fsOAuthUrl, fsClientAuth } from "@/api"
import Cookies from "js-cookie" import Cookies from "js-cookie"
import { encrypt, decrypt } from "@/utils" import { encrypt, decrypt, getQueryString } from "@/utils"
import useUserStore from '@/store/modules/user' import useUserStore from '@/store/modules/user'
const userStore = useUserStore() const userStore = useUserStore()
...@@ -136,27 +136,21 @@ function handleLogin() { ...@@ -136,27 +136,21 @@ function handleLogin() {
// 自动登录 // 自动登录
async function checkAutoLogin() { async function checkAutoLogin() {
// 飞书客户端内-免登录
if (window.h5sdk) { if (window.h5sdk) {
// 飞书客户端内-自动登录
autoLoginLoading.value = true autoLoginLoading.value = true
const code = await fsClientAuth() const code = await fsClientAuth()
return loginByType('fs', { code })
}
const state = getQueryString('state')
const code = getQueryString('code')
if (state === 'fs') {
// 飞书网页授权回调-自动登录
loginByType('fs', { code }) loginByType('fs', { code })
} else { } else if (state === 'STATE') {
// 飞书网页授权回调-免登录 // 勤策系统网页跳过-自动登录
const params = new URLSearchParams(window.location.search); loginByType('qc', code)
const code = params.get('code');
const state = params.get('state');
if (state === 'fs') {
loginByType('fs', { code })
}
// 勤策
// const url = window.location.href.split('?')[2]
// if (url) {
// const params = new URLSearchParams(url);
// const state = params.get('state');
// state === 'STATE' && loginByType('qc', url)
// }
} }
} }
checkAutoLogin() checkAutoLogin()
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论