Refactor code structure for improved readability and maintainability

This commit is contained in:
2026-02-24 03:57:07 +08:00
parent 2759ac42aa
commit 9107aa3d7e
8 changed files with 326 additions and 1062 deletions

View File

@@ -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)