|
|
@ -28,6 +28,7 @@ import api from '@/api'
|
|
|
|
import {useRoute, useRouter} from 'vue-router'
|
|
|
|
import {useRoute, useRouter} from 'vue-router'
|
|
|
|
import {store} from '@/store'
|
|
|
|
import {store} from '@/store'
|
|
|
|
import {modelsApp} from '@/models'
|
|
|
|
import {modelsApp} from '@/models'
|
|
|
|
|
|
|
|
import util from '@/libs/util'
|
|
|
|
|
|
|
|
|
|
|
|
let msg = useMessage()
|
|
|
|
let msg = useMessage()
|
|
|
|
const route = useRoute()
|
|
|
|
const route = useRoute()
|
|
|
@ -69,17 +70,7 @@ function login() {
|
|
|
|
api.user.login(data.value.username, data.value.password).Start((url: string) => {
|
|
|
|
api.user.login(data.value.username, data.value.password).Start((url: string) => {
|
|
|
|
msg.success('登录成功')
|
|
|
|
msg.success('登录成功')
|
|
|
|
store.dispatch('user/fetchUserData')
|
|
|
|
store.dispatch('user/fetchUserData')
|
|
|
|
let target = url
|
|
|
|
redirect(route.query.redirect as string)
|
|
|
|
if (route.query.redirect) {
|
|
|
|
|
|
|
|
target = route.query.redirect as string
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (target && target.startsWith('http')) {
|
|
|
|
|
|
|
|
window.location.href = target
|
|
|
|
|
|
|
|
} else if (target) {
|
|
|
|
|
|
|
|
router.push(target)
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
router.push({name: 'home'})
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}, e => {
|
|
|
|
}, e => {
|
|
|
|
console.log(e)
|
|
|
|
console.log(e)
|
|
|
|
msg.warning('登录失败:' + e)
|
|
|
|
msg.warning('登录失败:' + e)
|
|
|
@ -88,17 +79,26 @@ function login() {
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function redirect() {
|
|
|
|
function redirect(url?: string) {
|
|
|
|
console.log(uuid.value)
|
|
|
|
|
|
|
|
if (uuid.value !== store.state.oauuid) {
|
|
|
|
if (uuid.value !== store.state.oauuid) {
|
|
|
|
api.app.get(uuid.value as string).Start((app: modelsApp) => {
|
|
|
|
api.app.get(uuid.value as string).Start((app: modelsApp) => {
|
|
|
|
console.log(app.UserRefreshUrl)
|
|
|
|
console.log(app.UserRefreshUrl)
|
|
|
|
api.token(uuid.value as string).get().Start(e => {
|
|
|
|
api.token(uuid.value as string).get().Start(e => {
|
|
|
|
let url = app.UserRefreshUrl.replaceAll('$token', e)
|
|
|
|
if (!url) {
|
|
|
|
console.log(url)
|
|
|
|
url = app.UserRefreshUrl
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
e = encodeURIComponent(e)
|
|
|
|
|
|
|
|
url = url.replaceAll('$token', e)
|
|
|
|
window.location.href = url
|
|
|
|
window.location.href = url
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
}, e => {
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
} else if (util.checkLogin()) {
|
|
|
|
|
|
|
|
if (url) {
|
|
|
|
|
|
|
|
router.push(url)
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
router.push({name: 'home'})
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|