Compare commits

...

5 Commits

Author SHA1 Message Date
56f874991d migrate Article api from blog 2025-07-22 13:14:20 +08:00
3546e88f2c migrate Article type from blog 2025-07-22 12:58:22 +08:00
04ac9d4753 remove showOn attr for EmptyTips 2025-07-15 17:50:31 +08:00
9ca80322d0 add margin attr for Loading component 2025-07-12 00:59:39 +08:00
7fa6bdbb95 add white tui-color 2025-07-12 00:47:36 +08:00
6 changed files with 125 additions and 6 deletions

26
src/api/ArticleAPI.ts Normal file
View File

@ -0,0 +1,26 @@
import { ArticleView, axios } from "timi-web";
/**
* 获取文章
*
* @param id 文章 ID
* @returns 文章数据
*/
async function view(id: number): Promise<ArticleView<any>> {
return axios.get(`/article/${id}`);
}
/**
* 喜欢文章后端有限调用1240ms 一次
*
* @param id 文章 ID
* @returns 最新喜欢数量
*/
async function like(id: number): Promise<number> {
return axios.get(`/article/like/${id}`);
}
export default {
view,
like,
};

View File

@ -8,6 +8,7 @@
orange: #E7913B;
gray: #666;
light-gray: #AAA;
white: #FFF;
dark-white: #E7EAEF;
yellow: #FF0;
purple: PURPLE;

View File

@ -1,5 +1,5 @@
<template>
<div v-show="showOn" class="tui-empty-tips gray" v-text="content"></div>
<div class="tui-empty-tips gray" v-text="content"></div>
</template>
<script lang="ts" setup>
@ -9,10 +9,8 @@ defineOptions({
});
withDefaults(defineProps<{
showOn: boolean;
content?: string,
}>(), {
showOn: true,
content: "没有更多数据"
});
</script>

View File

@ -24,14 +24,16 @@ const props = withDefaults(defineProps<{
showOn?: boolean;
size?: number;
filled?: boolean;
margin?: string | number;
}>(), {
tips: "加载中..",
delay: 260,
showOn: true,
size: 24,
filled: false
filled: false,
margin: 0
});
const { tips, delay, showOn, size, filled } = toRefs(props);
const { tips, delay, showOn, size, filled, margin } = toRefs(props);
// ---------- 尺寸参数 ----------
@ -40,10 +42,12 @@ const style = computed(() => {
const height = Math.round(base);
const width = Math.round(base * (8 / 24));
const gap = Math.round(base * (3 / 24));
const marginValue = typeof margin.value === "string" ? margin.value : `${margin.value}px`;
return {
"--loading-height": `${height}px`,
"--rect-width": `${width}px`,
"--rect-gap": `${gap}px`
"--rect-gap": `${gap}px`,
"margin": marginValue
};
});

View File

@ -5,6 +5,7 @@ import components from "./components";
import Network from "./utils/Network";
import UserAPI from "./api/UserAPI";
import CommonAPI from "./api/CommonAPI";
import ArticleAPI from "./api/ArticleAPI";
import CommentAPI from "./api/CommentAPI";
import DeveloperAPI from "./api/DeveloperAPI";
@ -34,6 +35,7 @@ import "./assets/style/timi-web.less";
export * from "./components";
export * from "./types/Model";
export * from "./types/Article";
export * from "./types/User";
export * from "./types/Comment";
export * from "./types/Setting";
@ -66,6 +68,7 @@ export {
UserAPI,
CommonAPI,
ArticleAPI,
CommentAPI,
DeveloperAPI,

87
src/types/Article.ts Normal file
View File

@ -0,0 +1,87 @@
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;
attachmentList: AttachmentView[];
} & Article<E>;
export enum ArticleType {
/** 公版 */
PUBLIC,
/** 音乐 */
MUSIC,
/** 软件 */
SOFTWARE
}
export enum ArticleAttachType {
COVER,
}
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;
}