Refactor code structure for improved readability and maintainability
This commit is contained in:
29
pages/web.ts
29
pages/web.ts
@@ -2,19 +2,30 @@
|
||||
import '../src/main.ts'
|
||||
//
|
||||
|
||||
import { loginEmitter, createMessage, checkPluginLogin, queryLogin } from '../src/main.ts'
|
||||
import { loginEmitter, createMessage, redirectHome, checkPluginLogin, queryLogin } from '../src/main.ts'
|
||||
|
||||
// const message = createMessage();
|
||||
loginEmitter.once('login-success', async (data) => {
|
||||
console.log('登录成功,接收到的数据:');
|
||||
const res = await checkPluginLogin()
|
||||
if (res.code === 400 && res.data.redirectUrl) {
|
||||
window.open(res.data.redirectUrl, '_self');
|
||||
} else if (res.code === 400 && !res.data.redirectUrl) {
|
||||
|
||||
const me = await queryLogin.getMe();
|
||||
console.log('用户信息:', me);
|
||||
window.open('/root/home/', '_self');
|
||||
// const local = await queryLogin.checkLocalUser()
|
||||
// console.log('本地用户信息:', local);
|
||||
if (res.code === 400) {
|
||||
if (res.data.redirectUrl) {
|
||||
window.open(res.data.redirectUrl, '_self');
|
||||
} else {
|
||||
const me = await queryLogin.getMe();
|
||||
console.log('用户信息:', me);
|
||||
window.open('/root/home/', '_self');
|
||||
}
|
||||
} else {
|
||||
redirectHome()
|
||||
}
|
||||
})
|
||||
|
||||
const test = async () => {
|
||||
const me = await queryLogin.getToken();
|
||||
console.log('获取token:', me);
|
||||
}
|
||||
setTimeout(() => {
|
||||
test()
|
||||
}, 2000)
|
||||
Reference in New Issue
Block a user