import { AttachmentView, Model } from "timi-web";

// 文章
export type Article<E extends ArticleMusicExtendData | ArticleSoftwareExtendData> = {
	title?: string;
	type: ArticleType;
	digest?: string;
	data?: string;
	extendData?: E;
	reads: number;
	likes: number;
	showComment: boolean;
	canComment: boolean;
	canRanking: boolean;
} & Model;

export type ArticleView<E extends ArticleMusicExtendData | ArticleSoftwareExtendData> = {
	comments?: number;
	clazz: ArticleClass;
	labels: ArticleLabel[];
	attachmentList: AttachmentView[];
} & Article<E>;

export enum ArticleType {

	/** 公版 */
	PUBLIC,

	/** 音乐 */
	MUSIC,

	/** 软件 */
	SOFTWARE
}

export enum ArticleAttachType {

	COVER,
}

// 文章分类
export type ArticleClass = {
	name?: string;
	isOther?: boolean;
	order?: number;

	count?: number;
} & Model;

// 文章标签
export type ArticleLabel = {
	name?: string;
	count?: number;
} & Model;

// 每周排行
export type ArticleRanking = {
	title?: string;
	count?: number;
	recentAt?: number;
} & Model;

export type ArticleMusicExtendData = {
	title: string;
	list: ArticleMusicItem[];
	info: {
		key: string;
		value: string;
	}[];
}

export type ArticleSoftwareExtendData = {
	url?: string;
	downloads: ArticleSoftwareDownload[];
	format: string;
	runtime: ArticleSoftwareRuntime[];
	size: number;
	version: string;
	password?: string;
}

export enum ArticleSoftwareDownloadType {

	TIMI_MONGO,

	TIMI_COS,

	URL
}

export enum ArticleSoftwareRuntime {

	JVM,

	WINDOWS,

	LINUX,

	MAC_OS
}

export type ArticleSoftwareDownload = {
	type: ArticleSoftwareDownloadType;
	value: string;
}

export type ArticleMusicItem = {
	title: string;
	audio?: string;
	video?: string;
}
