|
@@ -44,10 +44,8 @@
|
|
|
<script>
|
|
|
import useStore from '@/store'
|
|
|
import { useRoute } from 'vue-router'
|
|
|
-
|
|
|
const { user } = useStore()
|
|
|
const route = useRoute()
|
|
|
-
|
|
|
export default {
|
|
|
data() {
|
|
|
return {
|
|
@@ -68,6 +66,8 @@ export default {
|
|
|
watch: {
|
|
|
'$route.query': {
|
|
|
handler(query) {
|
|
|
+ if (query?.token) {
|
|
|
+ }
|
|
|
user.$patch({
|
|
|
loginQuery: query
|
|
|
})
|
|
@@ -76,7 +76,36 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
mounted() {
|
|
|
- if (route.query.token) {}
|
|
|
+ const currentUrl = window.location.href
|
|
|
+ const queryIndex = currentUrl.indexOf('?')
|
|
|
+ const hashIndex = currentUrl.indexOf('#')
|
|
|
+ // https://boot.aizuda.com/?token=4T6pF9V4fNnG8Jh3MpLeXQ==#/login?redirect=/dashboard
|
|
|
+
|
|
|
+ // 检查是否有两个问号
|
|
|
+ if (queryIndex !== -1 && hashIndex !== -1 && currentUrl.indexOf('?', queryIndex + 1) !== -1) {
|
|
|
+ // 提取 token
|
|
|
+ const token = currentUrl.substring(queryIndex + 7, hashIndex)
|
|
|
+ const protocol = window.location.protocol // 获取协议,例如 "https:"
|
|
|
+ const hostname = window.location.hostname // 获取域名,例如 "www.baidu.com"
|
|
|
+ const port = window.location.port // 获取端口号,如果没有指定端口则为空字符串
|
|
|
+
|
|
|
+ // 构建完整的协议+域名+端口
|
|
|
+ const baseUrl = `${protocol}//${hostname}${port ? `:${port}` : ''}`
|
|
|
+
|
|
|
+ // 构建新的 URL
|
|
|
+ const newUrl = `${baseUrl}/#/login?redirect=/dashboard&token=${token}`
|
|
|
+ // 更新浏览器地址栏
|
|
|
+ window.location.replace(newUrl)
|
|
|
+ return // 确保不执行后续代码
|
|
|
+ }
|
|
|
+ alert('-----', route)
|
|
|
+ const { token } = route.query
|
|
|
+ if (token) {
|
|
|
+ this.loading = true
|
|
|
+ user.loginTokenEv({ token }).finally(() => {
|
|
|
+ this.loading = false
|
|
|
+ })
|
|
|
+ }
|
|
|
},
|
|
|
methods: {
|
|
|
async login() {
|
|
@@ -90,8 +119,6 @@ export default {
|
|
|
})
|
|
|
},
|
|
|
giteeLogin() {
|
|
|
- alert('暂未开放')
|
|
|
- return
|
|
|
const jumpUrl = `https://star.aizuda.com/v1/auth-check?platform=eui&t=${new Date().getTime()}`
|
|
|
window.open(jumpUrl, '_blank')
|
|
|
}
|