From 956a36378b4b308aac2f75eb7579fc71cd28b65d Mon Sep 17 00:00:00 2001 From: mackt <1033530438@qq.com> Date: Sun, 24 Mar 2024 20:30:56 +0800 Subject: [PATCH] feat: request function --- src/hooks/index.ts | 12 ++--- src/services/server/about.ts | 6 +++ src/services/server/index.ts | 3 ++ src/services/server/journal.ts | 87 ++++++++++++++++++++++++++++++++++ src/services/server/music.ts | 0 src/types/reqeust.d.ts | 5 ++ src/types/tag.d.ts | 16 +++++++ 7 files changed, 123 insertions(+), 6 deletions(-) create mode 100644 src/services/server/about.ts create mode 100644 src/services/server/index.ts create mode 100644 src/services/server/journal.ts create mode 100644 src/services/server/music.ts create mode 100644 src/types/reqeust.d.ts create mode 100644 src/types/tag.d.ts diff --git a/src/hooks/index.ts b/src/hooks/index.ts index 1c4e226..5e5eb7b 100644 --- a/src/hooks/index.ts +++ b/src/hooks/index.ts @@ -1,9 +1,9 @@ -export { default as useUserInfo } from './useUserInfo'; -export { default as useVerify } from './useVerify'; -export { default as useDisclosure } from './useDisclosure'; -export { default as useMediaQuery } from './useMediaQuery'; -export { default as useChangeRoute } from './useChangeRoute'; -export { default as useUrlQuery } from './useUrlQuery'; +// export { default as useUserInfo } from './useUserInfo'; +// export { default as useVerify } from './useVerify'; +// export { default as useDisclosure } from './useDisclosure'; +// export { default as useMediaQuery } from './useMediaQuery'; +// export { default as useChangeRoute } from './useChangeRoute'; +// export { default as useUrlQuery } from './useUrlQuery'; export { default as useDebounce } from './useDebounce'; export { default as useTitle } from './useTitle'; diff --git a/src/services/server/about.ts b/src/services/server/about.ts new file mode 100644 index 0000000..f534f33 --- /dev/null +++ b/src/services/server/about.ts @@ -0,0 +1,6 @@ +import { request, verifyResponse } from '@/utils'; + +export const apiThanks = async () => { + const res = await request('/luoo-user/my/thanks'); + return verifyResponse(res); +}; diff --git a/src/services/server/index.ts b/src/services/server/index.ts new file mode 100644 index 0000000..3b7394a --- /dev/null +++ b/src/services/server/index.ts @@ -0,0 +1,3 @@ +export * from './about'; +export * from './journal'; +// export * from './music'; diff --git a/src/services/server/journal.ts b/src/services/server/journal.ts new file mode 100644 index 0000000..fb4c83e --- /dev/null +++ b/src/services/server/journal.ts @@ -0,0 +1,87 @@ +// 期刊 +import { request, verifyResponse } from '@/utils'; + +export interface journalList { + total: number; + row: JournalInfo[]; +} + +export interface Comment { + _id: string; + avatar: string; + commentCount: number; + content: string; + journalId: string; + location: string; + nickName: string; + parentId: string; + publishTime: string; + state: number; + thumbupCount: number; + userId: string; +} + +export interface JournalInfo { + /** 期刊评论top5 */ + commentList: Comment[]; + /** 文案 */ + content: string; + /** 编辑日期 */ + date: string; + /** 编辑人 */ + editor: string; + /** 已收藏 */ + haveCollect: boolean; + id: string; + /** 期刊封面 */ + image: string; + /** 期刊发布于 */ + ipLocation: string; + /** 剘刊号 */ + journalNo: string; + /** 概要 */ + summary: string; + /** 期刊标签 */ + tags: string[]; + /** 期刊名 */ + title: string; + /** 期刊总评论数,大于99,显示99+ */ + totalCommentReply: string; + /** 期刊总评论数 int */ + totalCommentReplyInt: number; +} + +/** + * @description 查询期刊信息 默认10条 + */ +export const getJournalList = async () => { + const result = await request('/luoo-music/journal/list'); + return result; +}; + +/** + * @description 获取期刊筛选条件 + */ +export const getJournalFilter = async () => { + const result = await request('/luoo-music/journal/filter'); + return result; +}; + +/** + * @description 查询标签信息 + * @level 标签层级 + * @parentId 父标签id + * @state 状态 + */ +export const apiTagName = async ({ + level = 1, + parentId = '', + state = 1, +}: { + level?: number; + parentId?: string; + state?: number; +}) => { + const result = await request(`/luoo-tag/tag/name?level=${level}&parentId=${parentId}&state=${state}`); + return verifyResponse(result); +}; diff --git a/src/services/server/music.ts b/src/services/server/music.ts new file mode 100644 index 0000000..e69de29 diff --git a/src/types/reqeust.d.ts b/src/types/reqeust.d.ts new file mode 100644 index 0000000..6aea924 --- /dev/null +++ b/src/types/reqeust.d.ts @@ -0,0 +1,5 @@ +declare interface FetchResponse { + code: number; + message: string; + data: T; +} diff --git a/src/types/tag.d.ts b/src/types/tag.d.ts new file mode 100644 index 0000000..88e1621 --- /dev/null +++ b/src/types/tag.d.ts @@ -0,0 +1,16 @@ +declare interface TagName { + /** ID */ + id: string; + /** 是否显示 */ + isShow: number; + /** 等级 */ + level: number; + /** 中文名称 */ + nameCh: string; + /** 英文名称 */ + nameEn: string; + /** 父类别ID */ + parentId: string; + /** 状态 */ + state: number; +}