Initial project

This commit is contained in:
Timi
2025-07-08 16:33:11 +08:00
parent 1a5a16be74
commit f862530142
80 changed files with 8301 additions and 129 deletions

24
src/types/Attachment.ts Normal file
View File

@ -0,0 +1,24 @@
import { Model } from "./Model";
export type Attachment = {
bizType: AttachmentBizType;
bizId: number;
attachType?: string;
mongoId: string;
lidTitle?: number;
name?: string;
size: number;
} & Model
export type AttachmentView = {
title?: string;
} & Attachment
export enum AttachmentBizType {
GIT_ISSUE,
GIT_MERGE,
GIT_RELEASE
}

78
src/types/Comment.ts Normal file
View File

@ -0,0 +1,78 @@
import { Model, Page } from "./Model";
import { UserView } from "./User";
/** 评论 */
export type Comment = {
bizType: CommentBizType;
bizId: number;
userId?: number;
nick?: string;
content: string;
} & Model
/** 评论视图 */
export type CommentView = {
/** 所属用户 */
user?: UserView;
/** 回复列表 */
replies: CommentReplyView[];
/** 回复分页 */
repliesPage: CommentReplyPage;
/** 用于绑定组件当前页下标 */
repliesCurrent: number;
/** 回复数量 */
repliesLength: number;
/** 关联文章 */
article?: object;
/** 关联 Git 仓库 */
repository?: object;
} & Comment;
export type CommentReply = {
replyId?: number;
commentId: number;
senderId?: number;
senderNick?: string;
receiverId?: number;
receiverNick?: string;
content: string;
} & Model;
export type CommentReplyView = {
comment: CommentView;
sender?: UserView;
receiver?: UserView;
} & CommentReply;
export type CommentPage = {
bizType?: CommentBizType;
bizId?: number;
} & Page;
export enum CommentReplyBizType {
COMMENT = "COMMENT",
SENDER = "SENDER",
RECEIVER = "RECEIVER"
}
export type CommentReplyPage = {
bizType: CommentReplyBizType
bizId?: number
} & Page;
export enum CommentBizType {
ARTICLE = "ARTICLE",
GIT_ISSUE = "GIT_ISSUE",
GIT_MERGE = "GIT_MERGE",
}

6
src/types/Developer.ts Normal file
View File

@ -0,0 +1,6 @@
/** 开发者配置 */
export type Developer = {
developerId?: number;
name?: string;
rsa?: string;
}

79
src/types/Model.ts Normal file
View File

@ -0,0 +1,79 @@
export enum RunEnv {
DEV = "DEV",
DEV_SSL = "DEV_SSL",
PROD = "PROD"
}
// 基本实体模型
export type Model = {
id?: number;
createdAt?: number;
updatedAt?: number;
deletedAt?: number;
}
export type Response = {
code: number;
msg?: string;
data: object;
}
export type Page = {
index: number;
size: number;
keyword?: string;
orderMap?: { [key: string]: OrderType };
}
export enum OrderType {
ASC = "ASC",
DESC = "DESC"
}
export type PageResult<T> = {
total: number;
list: T[];
}
// 携带验证码的请求体
export type CaptchaData<T> = {
from: string;
captcha: string;
data: T;
}
export enum CaptchaFrom {
LOGIN = "LOGIN",
REGISTER = "REGISTER",
/** 评论 */
COMMENT = "COMMENT",
/** 评论回复 */
COMMENT_REPLY = "COMMENT_REPLY",
/** Git 反馈 */
GIT_ISSUE = "GIT_ISSUE",
/** Git 合并请求 */
GIT_MERGE = "GIT_MERGE",
}
export enum ImageType {
AUTO = "ir-auto",
SMOOTH = "ir-smooth",
PIXELATED = "ir-pixelated"
}
export type KeyValue<T> = {
key: string;
value: T;
}
export type LabelValue<T> = {
label: string;
value: T;
}

28
src/types/Setting.ts Normal file
View File

@ -0,0 +1,28 @@
export enum SettingKey {
RUN_ENV = "RUN_ENV",
PUBLIC_RESOURCES = "PUBLIC_RESOURCES",
DOMAIN_ROOT = "DOMAIN_ROOT",
DOMAIN_API = "DOMAIN_API",
DOMAIN_GIT = "DOMAIN_GIT",
DOMAIN_BLOG = "DOMAIN_BLOG",
DOMAIN_SPACE = "DOMAIN_SPACE",
DOMAIN_DOWNLOAD = "DOMAIN_DOWNLOAD",
DOMAIN_RESOURCE = "DOMAIN_RESOURCE",
ENABLE_COMMENT = "ENABLE_COMMENT",
ENABLE_DEBUG = "ENABLE_DEBUG",
ENABLE_LOGIN = "ENABLE_LOGIN",
ENABLE_REGISTER = "ENABLE_REGISTER",
ENABLE_USER_UPDATE = "ENABLE_USER_UPDATE",
}
export type PublicResources = {
wechatReceiveQRCode: string;
user: PublicResourcesUser;
}
export type PublicResourcesUser = {
avatar: string;
wrapper: string;
}

6
src/types/Template.ts Normal file
View File

@ -0,0 +1,6 @@
export enum TemplateBizType {
GIT = "GIT",
FOREVER_MC = "FOREVER_MC"
}

89
src/types/User.ts Normal file
View File

@ -0,0 +1,89 @@
import { ImageType, Model } from "./Model";
import { AttachmentView } from "./Attachment";
export type User = {
name: string;
email?: string;
emailVerifyAt: number;
unmuteAt?: number;
unbanAt?: number;
} & Model;
export type UserView = {
profile: UserProfileView
} & User;
export enum UserAttachType {
AVATAR,
WRAPPER,
DEFAULT_AVATAR,
DEFAULT_WRAPPER,
}
export type UserProfile = {
userId: number;
avatarType: ImageType;
wrapperType: ImageType;
exp: number;
sex?: number;
birthdate?: number;
qq?: string;
description: string;
lastLoginIP?: string;
lastLoginAt?: number;
updatedAt?: number;
}
export type UserProfileView = {
attachmentList?: AttachmentView[]
} & UserProfile
export type UserToken = {
value: string;
expireAt: number;
}
export type RegisterRequest = {
name: string;
password: string;
email?: string;
}
export type LoginRequest = {
user: string;
password: string;
}
// 登录返回
export type LoginResponse = {
id: number;
token: string;
expireAt: number;
}
export type LoginUser = {
token?: LoginToken;
user?: UserView
}
export type LoginToken = {
id?: number;
} & UserToken;
export enum LoginType {
ALERT,
IFRAME,
REDIRECT
}
export type UserLevelType = {
exp: number; // 经验数值,和 UserData.exp 一样
value: number; // 经验对应等级,[0, 8]
percent: number; // 该经验在该等级的百分比 [0, 1]
nextLevelUp: number; // 下一级经验值
}