58 lines
1.2 KiB
TypeScript
58 lines
1.2 KiB
TypeScript
/// <reference path="./types/index.d.ts" />
|
|
|
|
export interface VoteOption {
|
|
id: number;
|
|
name: string;
|
|
votes: number;
|
|
is_voted: boolean;
|
|
percentage?: number;
|
|
isSelected?: boolean;
|
|
}
|
|
|
|
export interface CardData {
|
|
article_id: number;
|
|
article_title: string;
|
|
vote_type: 'single' | 'multiple';
|
|
total_voters: number;
|
|
end_time: string;
|
|
is_ended: boolean;
|
|
publisher_id: string;
|
|
create_time: string;
|
|
options: VoteOption[];
|
|
user_has_voted: boolean;
|
|
user_voted_option_ids: number[] | null;
|
|
}
|
|
|
|
|
|
export interface Comment {
|
|
id: number;
|
|
article_id: number;
|
|
parent_id: number;
|
|
content: string;
|
|
likes_count: number;
|
|
created_at: string;
|
|
updated_at: string;
|
|
username: string;
|
|
avatar_url: string;
|
|
replies?: Comment[]; // 子评论可选
|
|
}
|
|
|
|
export interface CommentResponse {
|
|
data: Comment[];
|
|
message: string;
|
|
success: boolean;
|
|
}
|
|
|
|
|
|
interface IAppOption {
|
|
globalData: {
|
|
userInfo?: WechatMiniprogram.CustomUserInfo | null,
|
|
token: string,
|
|
rawCardData:CardData[],
|
|
processedCardsData:CardData[]
|
|
}
|
|
userInfoReadyCallback?: WechatMiniprogram.GetUserInfoSuccessCallback,
|
|
processVoteData(rawData: CardData[]): CardData[],
|
|
fetchRawCardData():void,
|
|
getComments(articleId: number):Comment[]
|
|
} |