import type { AuthAuthorizationPageItem, PagedListWarp, VmUserInfo } from "./AuthModels";
export interface ImageMetadata {
url: string;
width: number;
height: number;
frames: number;
hash?: string;
size: number;
format?: unknown;
}
export interface UserCenterProfile {
account: string;
displayName: string;
avatar?: string;
email?: string;
sign?: string;
sex: number;
}
export interface UserCenterSecurity {
hasTwoFactor: boolean;
hasPasskey: boolean;
isFullyBound: boolean;
passkeyCount: number;
recommendations: string[];
}
export interface AccountSessionResponse {
id: string;
account: string;
sessionId: string;
device: string;
deviceName?: string;
deviceType?: string;
browserName?: string;
browserVersion?: string;
osName?: string;
osVersion?: string;
platform?: string;
screenWidth?: number;
screenHeight?: number;
language?: string;
ipAddress: string;
latitude?: number;
longitude?: number;
locationAccuracy?: number;
locationSource?: string;
country?: string;
region?: string;
city?: string;
timeZone?: string;
isp?: string;
locationUpdatedTime?: string;
method: number;
revoked: boolean;
userAgent?: string;
createTime?: string;
revokedTime?: string;
lastActiveTime?: string;
isCurrent: boolean;
methodName: string;
statusName: string;
isSuccess: boolean;
}
export interface ArticleMiniResponse {
id: string;
title: string;
introduction?: string;
mainImage?: string;
commentCount: number;
viewCount: number;
imagesAddress: string[];
tags: string[];
author?: VmUserInfo;
from?: string;
createTime: string;
lastUpdateTime: string;
mainImageMetadata?: ImageMetadata;
images: ImageMetadata[];
}
export interface ArticleResponse extends ArticleMiniResponse {
markdown: string;
adWeight: number;
categories: string[];
}
export interface MumbleResponse {
id: string;
markdown: string;
createTime: string;
lastUpdateTime: string;
like: number;
commentCount: number;
images: ImageMetadata[];
}
export interface VmTimeline {
id?: string;
title?: string;
content?: string;
date: string;
more?: string;
createTime: string;
lastUpdateTime: string;
images: ImageMetadata[];
}
export interface PictureRecordResponse {
id?: string;
uploadTime: string;
tags: string[];
description?: string;
category: number;
width: number;
height: number;
accessUrl?: string;
length: number;
}
export interface ArticleEditPayload {
title: string;
markdown: string;
tags: string[];
introduction?: string;
from?: string;
publishTime?: string;
categories: string[];
adWeight: number;
mainImageMetadata?: ImageMetadata | null;
images: ImageMetadata[];
}
export interface MumbleEditPayload {
markdown: string;
images: ImageMetadata[];
}
export interface TimelineEditPayload {
title: string;
content?: string;
date: string;
more?: string;
images: ImageMetadata[];
}
export interface AlbumEditPayload {
albumFile?: File;
description?: string;
tags?: string[];
}
export type UserCenterAuthorizationPage = PagedListWarp<AuthAuthorizationPageItem>;
export type AccountSessionPage = PagedListWarp<AccountSessionResponse>;
export type UserCenterArticlePage = PagedListWarp<ArticleMiniResponse>;
export type UserCenterMumblePage = PagedListWarp<MumbleResponse>;
export type UserCenterTimelinePage = PagedListWarp<VmTimeline>;
export type UserCenterAlbumPage = PagedListWarp<PictureRecordResponse>;
⚠⚠ 以下内容为AI分析的结果,请根据实际情况进行判断。
代码解释
这是一个 TypeScript 类型定义文件,主要定义了用户中心相关的数据模型和接口。以下是详细说明:
主要接口类型
1. ImageMetadata - 图片元数据
定义图片的基本信息,包括:
url: 图片地址width/height: 尺寸frames: 帧数(可能用于 GIF 等动图)hash: 哈希值(可选,用于验证)size: 文件大小format: 格式(类型未指定)
2. UserCenterProfile - 用户中心个人资料
用户基本信息:
account: 账号displayName: 显示名称avatar: 头像(可选)email: 邮箱(可选)sign: 个性签名(可选)sex: 性别(数字枚举)
3. UserCenterSecurity - 安全设置
用户安全相关信息:
hasTwoFactor: 是否启用双因素认证hasPasskey: 是否有通行密钥isFullyBound: 是否完全绑定passkeyCount: 通行密钥数量recommendations: 安全建议列表
4. AccountSessionResponse - 账户会话信息
详细的会话记录,包括:
- 基本信息:id、账号、sessionId
- 设备信息:设备名称、类型、浏览器、操作系统
- 屏幕信息:分辨率、语言
- 地理位置:IP、经纬度、国家/地区/城市、ISP等
- 会话状态:登录方式、是否撤销、是否当前会话、活跃时间等
5. ArticleMiniResponse - 文章简略信息
文章列表展示用的精简数据:
- 基本属性:id、标题、简介、主图
- 统计数据:评论数、浏览数
- 关联数据:图片列表、标签、作者信息
- 时间信息:创建和更新时间
6. ArticleResponse - 文章完整信息
继承自 ArticleMiniResponse,额外包含:
markdown: 文章正文内容adWeight: 广告权重categories: 分类列表
7. MumbleResponse - 碎碎念/动态
类似微博的短内容:
- markdown 内容
- 点赞数、评论数
- 图片列表
- 时间信息
8. VmTimeline - 时间线条目
时间轴展示内容:
- 标题、内容、日期
- 更多信息链接
- 图片列表
9. PictureRecordResponse - 图片记录
相册中的图片信息:
- 上传时间、标签、描述
- 分类、尺寸、访问链接
- 文件大小
编辑负载类型(Payload)
定义了四种内容的编辑数据结构:
- ArticleEditPayload: 文章编辑数据
- MumbleEditPayload: 动态编辑数据
- TimelineEditPayload: 时间线编辑数据
- AlbumEditPayload: 相册编辑数据(包含文件上传)
分页类型别名
使用泛型 PagedListWarp 包装各种列表数据,定义了六种分页类型:
- 授权页面、会话列表、文章列表、动态列表、时间线列表、相册列表
设计特点
- 类型安全:充分利用 TypeScript 的类型系统
- 可选字段:大量使用
?标记可选属性,增加灵活性 - 继承复用:
ArticleResponse继承ArticleMiniResponse - 语义化命名:接口名称清晰表达用途
AI 正在分析代码…
评论加载中...