refactor(user): persist compact user cache
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
export * from "./avatar_data";
|
||||
export * from "./credits_data";
|
||||
export * from "./credits_history_data";
|
||||
export * from "./persisted_user";
|
||||
export * from "./personality_traits";
|
||||
export * from "./recent_memory";
|
||||
export * from "./update_profile_request";
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
/**
|
||||
* 本地持久化用户模型。
|
||||
*
|
||||
* 后端 UserSchema 保持完整,用于接口解析;本 schema 只描述本地缓存真正
|
||||
* 会用到的字段,避免把完整 profile 长期写入 localStorage。
|
||||
*/
|
||||
import { z } from "zod";
|
||||
|
||||
import { numberOrZero, stringOrEmpty } from "../nullable-defaults";
|
||||
|
||||
export const PersistedUserSchema = z.object({
|
||||
id: stringOrEmpty,
|
||||
username: stringOrEmpty,
|
||||
countryCode: stringOrEmpty,
|
||||
dailyFreeChatLimit: numberOrZero,
|
||||
dailyFreeChatRemaining: numberOrZero,
|
||||
dailyFreePrivateLimit: numberOrZero,
|
||||
dailyFreePrivateRemaining: numberOrZero,
|
||||
});
|
||||
|
||||
export type PersistedUserInput = z.input<typeof PersistedUserSchema>;
|
||||
export type PersistedUserData = z.output<typeof PersistedUserSchema>;
|
||||
Reference in New Issue
Block a user