Compare commits
5 Commits
f862530142
...
56f874991d
| Author | SHA1 | Date | |
|---|---|---|---|
| 56f874991d | |||
| 3546e88f2c | |||
| 04ac9d4753 | |||
| 9ca80322d0 | |||
| 7fa6bdbb95 |
26
src/api/ArticleAPI.ts
Normal file
26
src/api/ArticleAPI.ts
Normal 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,
|
||||||
|
};
|
||||||
@ -8,6 +8,7 @@
|
|||||||
orange: #E7913B;
|
orange: #E7913B;
|
||||||
gray: #666;
|
gray: #666;
|
||||||
light-gray: #AAA;
|
light-gray: #AAA;
|
||||||
|
white: #FFF;
|
||||||
dark-white: #E7EAEF;
|
dark-white: #E7EAEF;
|
||||||
yellow: #FF0;
|
yellow: #FF0;
|
||||||
purple: PURPLE;
|
purple: PURPLE;
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
<template>
|
<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>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
@ -9,10 +9,8 @@ defineOptions({
|
|||||||
});
|
});
|
||||||
|
|
||||||
withDefaults(defineProps<{
|
withDefaults(defineProps<{
|
||||||
showOn: boolean;
|
|
||||||
content?: string,
|
content?: string,
|
||||||
}>(), {
|
}>(), {
|
||||||
showOn: true,
|
|
||||||
content: "没有更多数据"
|
content: "没有更多数据"
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@ -24,14 +24,16 @@ const props = withDefaults(defineProps<{
|
|||||||
showOn?: boolean;
|
showOn?: boolean;
|
||||||
size?: number;
|
size?: number;
|
||||||
filled?: boolean;
|
filled?: boolean;
|
||||||
|
margin?: string | number;
|
||||||
}>(), {
|
}>(), {
|
||||||
tips: "加载中..",
|
tips: "加载中..",
|
||||||
delay: 260,
|
delay: 260,
|
||||||
showOn: true,
|
showOn: true,
|
||||||
size: 24,
|
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 height = Math.round(base);
|
||||||
const width = Math.round(base * (8 / 24));
|
const width = Math.round(base * (8 / 24));
|
||||||
const gap = Math.round(base * (3 / 24));
|
const gap = Math.round(base * (3 / 24));
|
||||||
|
const marginValue = typeof margin.value === "string" ? margin.value : `${margin.value}px`;
|
||||||
return {
|
return {
|
||||||
"--loading-height": `${height}px`,
|
"--loading-height": `${height}px`,
|
||||||
"--rect-width": `${width}px`,
|
"--rect-width": `${width}px`,
|
||||||
"--rect-gap": `${gap}px`
|
"--rect-gap": `${gap}px`,
|
||||||
|
"margin": marginValue
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -5,6 +5,7 @@ import components from "./components";
|
|||||||
import Network from "./utils/Network";
|
import Network from "./utils/Network";
|
||||||
import UserAPI from "./api/UserAPI";
|
import UserAPI from "./api/UserAPI";
|
||||||
import CommonAPI from "./api/CommonAPI";
|
import CommonAPI from "./api/CommonAPI";
|
||||||
|
import ArticleAPI from "./api/ArticleAPI";
|
||||||
import CommentAPI from "./api/CommentAPI";
|
import CommentAPI from "./api/CommentAPI";
|
||||||
import DeveloperAPI from "./api/DeveloperAPI";
|
import DeveloperAPI from "./api/DeveloperAPI";
|
||||||
|
|
||||||
@ -34,6 +35,7 @@ import "./assets/style/timi-web.less";
|
|||||||
export * from "./components";
|
export * from "./components";
|
||||||
|
|
||||||
export * from "./types/Model";
|
export * from "./types/Model";
|
||||||
|
export * from "./types/Article";
|
||||||
export * from "./types/User";
|
export * from "./types/User";
|
||||||
export * from "./types/Comment";
|
export * from "./types/Comment";
|
||||||
export * from "./types/Setting";
|
export * from "./types/Setting";
|
||||||
@ -66,6 +68,7 @@ export {
|
|||||||
|
|
||||||
UserAPI,
|
UserAPI,
|
||||||
CommonAPI,
|
CommonAPI,
|
||||||
|
ArticleAPI,
|
||||||
CommentAPI,
|
CommentAPI,
|
||||||
DeveloperAPI,
|
DeveloperAPI,
|
||||||
|
|
||||||
|
|||||||
87
src/types/Article.ts
Normal file
87
src/types/Article.ts
Normal 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;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user