This commit is contained in:
2025-11-27 19:20:46 +08:00
parent 7cba8ae8b1
commit 2838d6163e
37 changed files with 2553 additions and 256 deletions

View File

@@ -0,0 +1,31 @@
import http from 'http';
import { getLoginUser } from '@/modules/auth.ts';
import { getUserConfig } from '@/modules/fm-manager/index.ts';
/**
* 重定向到用户首页
* @param req
* @param res
*/
export const rediretHome = async (req: http.IncomingMessage, res: http.ServerResponse) => {
const user = await getLoginUser(req);
if (!user?.token) {
res.writeHead(302, { Location: '/root/login/' });
res.end();
return;
}
let redirectURL = '/root/center/';
try {
const token = user.token;
const resConfig = await getUserConfig(token);
if (resConfig.code === 200) {
const configData = resConfig.data?.data as any;
redirectURL = configData?.redirectURL || redirectURL;
}
} catch (error) {
console.error('get resConfig user.json', error);
} finally {
res.writeHead(302, { Location: redirectURL });
res.end();
}
};