feat: 封装一些函数,补充页面样式

Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
2026-04-25 15:42:48 +08:00
parent aa53691dc7
commit 7d1cc2da1a
18 changed files with 394 additions and 235 deletions
+3
View File
@@ -107,6 +107,7 @@ export default defineEventHandler(async (event) => {
const normalizeLoginResponse = (
response: NewApiLoginResponse | undefined
): { message: string; user: IUserLoginData | null } => {
consola.info("user data", response);
if (isUser(response)) {
return {
message: "登录成功",
@@ -152,6 +153,7 @@ const pickUserBasicData = (user: INewApiLoginUserData): IUserLoginData => {
};
};
/** 判断值是否为合法的 NewAPI 登录用户对象,所有必需字段均须类型正确 */
const isUser = (value: unknown): value is INewApiLoginUserData => {
return (
isRecord(value) &&
@@ -164,6 +166,7 @@ const isUser = (value: unknown): value is INewApiLoginUserData => {
);
};
/** 判断值是否为非 null 的普通对象,用于后续安全访问属性 */
const isRecord = (value: unknown): value is Record<string, unknown> => {
return value !== null && typeof value === "object";
};