answer/ui/src/common/interface.ts

514 lines
9.5 KiB
TypeScript
Raw Normal View History

2022-09-27 17:59:05 +08:00
export interface FormValue<T = any> {
value: T;
isInvalid: boolean;
errorMsg: string;
2022-10-28 20:01:00 +08:00
[prop: string]: any;
2022-09-27 17:59:05 +08:00
}
export interface FormDataType {
[prop: string]: FormValue;
}
export interface Paging {
page: number;
page_size?: number;
}
export type ReportType = 'question' | 'answer' | 'comment' | 'user';
export type ReportAction = 'close' | 'flag' | 'review';
export interface ReportParams {
type: ReportType;
action: ReportAction;
}
export interface TagBase {
display_name: string;
slug_name: string;
2022-11-16 12:06:33 +08:00
recommend: boolean;
reserved: boolean;
}
export interface Tag extends TagBase {
main_tag_slug_name?: string;
original_text?: string;
parsed_text?: string;
}
export interface SynonymsTag extends Tag {
tag_id: string;
tag?: string;
}
export interface TagInfo extends TagBase {
tag_id: string;
original_text: string;
parsed_text: string;
follow_count: number;
question_count: number;
is_follower: boolean;
member_actions;
created_at?;
updated_at?;
main_tag_slug_name?: string;
excerpt?;
}
export interface QuestionParams {
title: string;
content: string;
html: string;
tags: Tag[];
}
export interface ListResult<T = any> {
count: number;
list: T[];
}
export interface AnswerParams {
content: string;
html: string;
question_id: string;
id: string;
edit_summary?: string;
}
export interface LoginReqParams {
e_mail: string;
/** password */
pass: string;
captcha_id?: string;
captcha_code?: string;
}
export interface RegisterReqParams extends LoginReqParams {
name: string;
}
export interface ModifyPasswordReq {
old_pass: string;
pass: string;
}
/** User */
export interface ModifyUserReq {
display_name: string;
username?: string;
2022-10-28 20:01:00 +08:00
avatar: any;
bio: string;
bio_html?: string;
location: string;
website: string;
}
export interface UserInfoBase {
2022-10-28 20:01:00 +08:00
avatar: any;
username: string;
display_name: string;
rank: number;
website: string;
location: string;
ip_info?: string;
/** 'forbidden' | 'normal' | 'delete'
*/
status?: string;
/** roles */
2022-10-29 20:43:52 +08:00
is_admin?: boolean;
}
export interface UserInfoRes extends UserInfoBase {
bio: string;
bio_html: string;
create_time?: string;
/**
* value = 1 active;
* value = 2 inactivated
*/
mail_status: number;
language: string;
2022-11-22 17:41:48 +08:00
is_admin: boolean;
e_mail?: string;
[prop: string]: any;
}
2022-11-14 18:52:11 +08:00
export type UploadType = 'post' | 'avatar' | 'branding';
export interface UploadReq {
file: FormData;
}
export interface ImgCodeReq {
captcha_id?: string;
captcha_code?: string;
}
export interface ImgCodeRes {
captcha_id: string;
captcha_img: string;
verify: boolean;
}
export interface PasswordResetReq extends ImgCodeReq {
e_mail: string;
}
export interface CheckImgReq {
action: 'login' | 'e_mail' | 'find_pass';
}
export interface SetNoticeReq {
notice_switch: boolean;
}
2022-11-25 17:55:13 +08:00
export interface NotificationStatus {
inbox: number;
achievement: number;
revision: number;
can_revision: boolean;
}
export interface QuestionDetailRes {
id: string;
title: string;
content: string;
html: string;
tags: any[];
view_count: number;
unique_view_count?: number;
answer_count: number;
favorites_count: number;
follow_counts: 0;
accepted_answer_id: string;
last_answer_id: string;
create_time: string;
update_time: string;
user_info: UserInfoBase;
answered: boolean;
collected: boolean;
[prop: string]: any;
}
export interface AnswersReq extends Paging {
order?: 'default' | 'updated';
question_id: string;
}
export interface AnswerItem {
id: string;
question_id: string;
content: string;
html: string;
create_time: string;
update_time: string;
user_info: UserInfoBase;
[prop: string]: any;
}
export interface PostAnswerReq {
content: string;
html: string;
question_id: string;
}
export interface PageUser {
id?;
displayName;
userName?;
avatar_url?;
}
export interface LangsType {
label: string;
value: string;
}
/**
* @description interface for Question
*/
export type QuestionOrderBy =
| 'newest'
| 'active'
| 'frequent'
| 'score'
| 'unanswered';
export interface QueryQuestionsReq extends Paging {
order: QuestionOrderBy;
tag?: string;
}
export type AdminQuestionStatus = 'available' | 'closed' | 'deleted';
export type AdminContentsFilterBy = 'normal' | 'closed' | 'deleted';
export interface AdminContentsReq extends Paging {
status: AdminContentsFilterBy;
query?: string;
}
/**
* @description interface for Answer
*/
export type AdminAnswerStatus = 'available' | 'deleted';
/**
* @description interface for Users
*/
2022-11-28 16:00:29 +08:00
export type UserFilterBy =
| 'all'
| 'staff'
| 'inactive'
| 'suspended'
| 'deleted';
/**
* @description interface for Flags
*/
export type FlagStatus = 'pending' | 'completed';
export type FlagType = 'all' | 'question' | 'answer' | 'comment';
export interface AdminFlagsReq extends Paging {
status: FlagStatus;
object_type: FlagType;
}
/**
* @description interface for Admin Settings
*/
export interface AdminSettingsGeneral {
name: string;
short_description: string;
description: string;
2022-11-03 17:20:27 +08:00
site_url: string;
contact_email: string;
}
2022-12-07 17:24:30 +08:00
export interface HelmetBase {
pageTitle?: string;
2022-12-01 11:28:16 +08:00
description?: string;
keywords?: string;
2022-12-07 17:24:30 +08:00
}
export interface HelmetUpdate extends Omit<HelmetBase, 'pageTitle'> {
title?: string;
subtitle?: string;
2022-12-01 11:28:16 +08:00
}
export interface AdminSettingsInterface {
language: string;
2022-11-02 17:26:55 +08:00
time_zone?: string;
}
export interface AdminSettingsSmtp {
encryption: string;
from_email: string;
from_name: string;
smtp_authentication: boolean;
smtp_host: string;
smtp_password?: string;
smtp_port: number;
smtp_username?: string;
test_email_recipient?: string;
}
export interface SiteSettings {
2022-12-07 17:24:30 +08:00
branding: AdminSettingBranding;
general: AdminSettingsGeneral;
interface: AdminSettingsInterface;
login: AdminSettingsLogin;
2022-12-13 16:43:29 +08:00
custom_css_html: AdminSettingsCustom;
theme: AdminSettingsTheme;
site_seo: AdminSettingsSeo;
}
2022-12-07 17:24:30 +08:00
export interface AdminSettingBranding {
2022-11-15 15:44:29 +08:00
logo: string;
square_icon: string;
mobile_logo?: string;
favicon?: string;
}
2022-11-11 10:22:00 +08:00
export interface AdminSettingsLegal {
privacy_policy_original_text?: string;
privacy_policy_parsed_text?: string;
terms_of_service_original_text?: string;
terms_of_service_parsed_text?: string;
2022-11-11 10:22:00 +08:00
}
export interface AdminSettingsWrite {
2022-11-16 12:06:33 +08:00
recommend_tags: string[];
2022-11-15 10:43:21 +08:00
required_tag: string;
2022-11-16 12:06:33 +08:00
reserved_tags: string[];
2022-11-11 10:22:00 +08:00
}
2022-12-06 10:35:06 +08:00
export interface AdminSettingsSeo {
robots: string;
/**
* 0: not set
* 1with title
* 2: no title
*/
permalink: number;
2022-12-06 10:35:06 +08:00
}
export type themeConfig = {
navbar_style: string;
primary_color: string;
[k: string]: string | number;
};
export interface AdminSettingsTheme {
theme: string;
theme_options?: { label: string; value: string }[];
theme_config: Record<string, themeConfig>;
}
export interface AdminSettingsCustom {
custom_css: string;
custom_head: string;
custom_header: string;
custom_footer: string;
}
export interface AdminSettingsLogin {
allow_new_registrations: boolean;
login_required: boolean;
}
/**
* @description interface for Activity
*/
export interface FollowParams {
is_cancel: boolean;
object_id: string;
}
/**
* @description search request params
*/
export interface SearchParams {
q: string;
order: string;
page: number;
size?: number;
}
/**
* @description search response data
*/
export interface SearchResItem {
object_type: string;
object: {
id: string;
question_id?: string;
title: string;
excerpt: string;
created_at: number;
user_info: UserInfoBase;
vote_count: number;
answer_count: number;
accepted: boolean;
tags: TagBase[];
status?: string;
};
}
export interface SearchRes extends ListResult<SearchResItem> {
extra: any;
}
2022-11-02 18:16:27 +08:00
export interface AdminDashboard {
info: {
question_count: number;
answer_count: number;
comment_count: number;
vote_count: number;
user_count: number;
report_count: number;
uploading_files: boolean;
smtp: boolean;
time_zone: string;
occupying_storage_space: string;
app_start_time: number;
https: boolean;
version_info: {
remote_version: string;
version: string;
};
2022-11-02 18:16:27 +08:00
};
}
2022-11-22 17:41:48 +08:00
export interface TimelineReq {
show_vote: boolean;
2022-11-23 15:21:36 +08:00
object_id: string;
2022-11-22 17:41:48 +08:00
}
export interface TimelineItem {
activity_id: number;
revision_id: number;
created_at: number;
activity_type: string;
username: string;
user_display_name: string;
comment: string;
object_id: string;
object_type: string;
cancelled: boolean;
cancelled_at: any;
}
export interface TimelineObject {
title: string;
object_type: string;
question_id: string;
answer_id: string;
main_tag_slug_name?: string;
2022-11-29 11:20:48 +08:00
display_name?: string;
2022-11-22 17:41:48 +08:00
}
export interface TimelineRes {
object_info: TimelineObject;
timeline: TimelineItem[];
}
2022-11-25 17:55:13 +08:00
export interface ReviewItem {
type: 'question' | 'answer' | 'tag';
info: {
object_id: string;
title: string;
content: string;
html: string;
tags: Tag[];
};
unreviewed_info: {
id: string;
use_id: string;
object_id: string;
title: string;
status: 0 | 1;
create_at: number;
user_info: UserInfoBase;
reason: string;
content: Tag | QuestionDetailRes | AnswerItem;
};
}
export interface ReviewResp {
count: number;
list: ReviewItem[];
}
export interface UserRoleItem {
id: number;
name: string;
description: string;
}
export interface MemberActionItem {
action: string;
name: string;
type: string;
}
2022-12-13 18:39:41 +08:00
export interface User {
username: string;
rank: number;
vote_count: number;
display_name: string;
avatar: string;
}