diff --git a/web/src/api/auth.ts b/web/src/api/auth.ts index e6513e92..904e9bba 100644 --- a/web/src/api/auth.ts +++ b/web/src/api/auth.ts @@ -1,29 +1,16 @@ -import request from '@/utils/request'; +import { request } from '@/utils/request'; - -/** - * 用户登录 - * @param {Object} params - * - @param {string} username - * - @param {string} password - * @returns Promise - */ -export const userLogin = (params: NetParams.AuthUserLogin = {}) => { +/** 用户登录 */ +export const userLogin = (params: NetParams.AuthUserLogin): Promise => { return request({ method: 'post', url: '/auth/login', data: params, - }) as unknown as Promise; + }); }; -/** - * 注册用户 - * @param {Object} params - * - @param {string} username - * - @param {string} password - * @returns Promise - */ -export const userRegister = (params = {}) => { +/** 注册用户 */ +export const userRegister = (params: NetParams.AuthUserRegister): Promise => { return request({ method: 'post', url: '/auth/register', @@ -31,12 +18,8 @@ export const userRegister = (params = {}) => { }); }; -/** - * 用户信息 - * @param {Object} params - * @returns Promise - */ -export const userInfo = (token = '') => { +/** 用户信息 */ +export const userInfo = (token: NetParams.AuthUserInfo = ""): Promise => { return request({ method: 'get', url: '/user/info', @@ -46,14 +29,8 @@ export const userInfo = (token = '') => { }); }; -/** - * 修改用户密码 - * @param {Object} params - * - @param {string} password 新密码 - * - @param {string} old_password 旧密码 - * @returns Promise - */ -export const updateUserPassword = (data: any) => { +/** 修改用户密码,该接口暂时未使用 */ +export const updateUserPassword = (data: NetParams.AuthUpdateUserPassword): Promise => { return request({ method: 'post', url: '/api/user/password', diff --git a/web/src/api/post.ts b/web/src/api/post.ts index 3488eed5..49386cc6 100644 --- a/web/src/api/post.ts +++ b/web/src/api/post.ts @@ -1,132 +1,88 @@ -import request from '@/utils/request'; +import { request } from '@/utils/request'; -/** - * 获取动态列表 - * @param {Object} params - * @returns Promise - */ -export const getPosts = (params: NetParams.PostGetPosts) => { +/** 获取动态列表 */ +export const getPosts = (params: NetParams.PostGetPosts): Promise => { return request({ method: 'get', url: '/posts', params - }) as unknown as Promise; + }); }; -/** - * 获取标签列表 - * @param {Object} params - * @returns Promise - */ -export const getTags = (params: NetParams.PostGetTags) => { +/** 获取标签列表 */ +export const getTags = (params: NetParams.PostGetTags): Promise => { return request({ method: 'get', url: '/tags', params - }) as unknown as Promise; + }); }; -/** - * 获取动态详情 - * @param {Object} params - * @returns Promise - */ -export const getPost = (params: NetParams.PostGetPost) => { +/** 获取动态详情 */ +export const getPost = (params: NetParams.PostGetPost): Promise => { return request({ method: 'get', url: '/post', params - }) as unknown as Promise; + }); }; -/** - * 获取动态点赞状态 - * @param {Object} params - * @returns Promise - */ -export const getPostStar = (params: NetParams.PostPostStar) => { +/** 获取动态点赞状态 */ +export const getPostStar = (params: NetParams.PostPostStar): Promise => { return request({ method: 'get', url: '/post/star', params - }) as unknown as Promise; + }); }; -/** - * 动态点赞 - * @param {Object} data - * @returns Promise - */ -export const postStar = (data: NetParams.PostPostStar) => { +/** 动态点赞 */ +export const postStar = (data: NetParams.PostPostStar): Promise => { return request({ method: 'post', url: '/post/star', data - }) as unknown as Promise; + }); }; -/** - * 获取动态收藏状态 - * @param {Object} params - * @returns Promise - */ -export const getPostCollection = (params: NetParams.PostGetPostCollection) => { +/** 获取动态收藏状态 */ +export const getPostCollection = (params: NetParams.PostGetPostCollection): Promise => { return request({ method: 'get', url: '/post/collection', params - }) as unknown as Promise; + }); }; -/** - * 动态收藏 - * @param {Object} data - * @returns Promise - */ -export const postCollection = (data: NetParams.PostPostCollection) => { +/** 动态收藏 */ +export const postCollection = (data: NetParams.PostPostCollection): Promise => { return request({ method: 'post', url: '/post/collection', data - }) as unknown as Promise; + }); }; -/** - * 获取动态评论列表 - * @param {Object} params - * @returns Promise - */ -export const getPostComments = (params: NetParams.PostGetPostComments) => { +/** 获取动态评论列表 */ +export const getPostComments = (params: NetParams.PostGetPostComments): Promise => { return request({ method: 'get', url: '/post/comments', params - }) as unknown as Promise; + }); }; -/** - * 发布动态 - * @param {Object} data - * - @param {array} contents 内容 - * - @param {array} users at用户 - * - @param {array} tags 话题 - * @returns Promise - */ -export const createPost = (data: NetParams.PostCreatePost) => { +/** 发布动态 */ +export const createPost = (data: NetParams.PostCreatePost): Promise => { return request({ method: 'post', url: '/post', data - }) as unknown as Promise; + }); }; -/** - * 删除动态 - * @param {Object} data - * - @param {number} id - * @returns Promise - */ -export const deletePost = (data: any) => { +/** 删除动态 */ +export const deletePost = (data: NetParams.PostDeletePost): Promise => { return request({ method: 'delete', url: '/post', @@ -134,42 +90,26 @@ export const deletePost = (data: any) => { }); }; -/** - * 锁定/解锁动态 - * @param {Object} data - * - @param {number} id - * @returns Promise - */ -export const lockPost = (data: NetParams.PostLockPost) => { +/** 锁定/解锁动态 */ +export const lockPost = (data: NetParams.PostLockPost): Promise => { return request({ method: 'post', url: '/post/lock', data - }) as unknown as Promise; + }); }; -/** - * 置顶/取消置顶动态 - * @param {Object} data - * - @param {number} id - * @returns Promise - */ -export const stickPost = (data: NetParams.PostStickPost) => { +/** 置顶/取消置顶动态 */ +export const stickPost = (data: NetParams.PostStickPost): Promise => { return request({ method: 'post', url: '/post/stick', data - }) as unknown as Promise; + }); }; -/** - * 发布动态评论 - * @param {Object} data - * - @param {array} contents 内容 - * - @param {array} users at用户 - * @returns Promise - */ -export const createComment = (data: any) => { +/** 发布动态评论 */ +export const createComment = (data: NetParams.PostCreateComment): Promise => { return request({ method: 'post', url: '/post/comment', @@ -177,13 +117,8 @@ export const createComment = (data: any) => { }); }; -/** - * 删除评论 - * @param {Object} data - * - @param {number} id - * @returns Promise - */ -export const deleteComment = (data: any) => { +/** 删除评论 */ +export const deleteComment = (data: NetParams.PostDeleteComment): Promise => { return request({ method: 'delete', url: '/post/comment', @@ -191,15 +126,8 @@ export const deleteComment = (data: any) => { }); }; -/** - * 发布评论回复 - * @param {Object} data - * - @param {string} content 内容 - * - @param {number} comment_id 评论ID - * - @param {number} at_user_id at用户ID - * @returns Promise - */ -export const createCommentReply = (data: any) => { +/** 发布评论回复 */ +export const createCommentReply = (data: NetParams.PostCreateCommentReply): Promise => { return request({ method: 'post', url: '/post/comment/reply', @@ -207,16 +135,11 @@ export const createCommentReply = (data: any) => { }); }; -/** - * 删除评论回复 - * @param {Object} data - * - @param {number} id 评论ID - * @returns Promise - */ -export const deleteCommentReply = (data: any) => { +/** 删除评论回复 */ +export const deleteCommentReply = (data: NetParams.PostDeleteCommentReply): Promise => { return request({ method: 'delete', url: '/post/comment/reply', data }); -}; \ No newline at end of file +}; diff --git a/web/src/api/user.ts b/web/src/api/user.ts index 46cfe889..2828290c 100644 --- a/web/src/api/user.ts +++ b/web/src/api/user.ts @@ -1,16 +1,12 @@ -import request from '@/utils/request'; +import { request } from '@/utils/request'; -/** - * 获取验证码 - * @param {Object} params - * @returns Promise - */ -export const getCaptcha = (params: NetParams.UserGetCaptcha = {}) => { +/** 获取验证码 */ +export const getCaptcha = (params: NetParams.UserGetCaptcha = {}): Promise => { return request({ method: 'get', url: '/captcha', params - }) as unknown as Promise; + }); }; /** @@ -31,12 +27,12 @@ export const sendCaptcha = (data: any) => { * @param {Object} data * @returns Promise */ -export const sendUserWhisper = (data: NetParams.UserWhisper) => { +export const sendUserWhisper = (data: NetParams.UserWhisper): Promise => { return request({ method: 'post', url: '/user/whisper', data - }) as unknown as Promise; + }); }; /** @@ -44,20 +40,16 @@ export const sendUserWhisper = (data: NetParams.UserWhisper) => { * @param {Object} data * @returns Promise */ -export const bindUserPhone = (data: NetParams.UserBindUserPhone) => { +export const bindUserPhone = (data: NetParams.UserBindUserPhone): Promise => { return request({ method: 'post', url: '/user/phone', data - }) as unknown as Promise; + }); }; -/** - * 更改密码 - * @param {Object} data - * @returns Promise - */ -export const changePassword = (data: any) => { +/** 更改密码 */ +export const changePassword = (data: NetParams.UserChangePassword): Promise => { return request({ method: 'post', url: '/user/password', @@ -65,12 +57,8 @@ export const changePassword = (data: any) => { }); }; -/** - * 更改昵称 - * @param {Object} data - * @returns Promise - */ -export const changeNickname = (data: any) => { +/** 更改昵称 */ +export const changeNickname = (data: NetParams.UserChangeNickname): Promise => { return request({ method: 'post', url: '/user/nickname', @@ -91,30 +79,22 @@ export const changeAvatar = (data: any) => { }); }; -/** - * 获取未读消息数 - * @param {Object} params - * @returns Promise - */ -export const getUnreadMsgCount = (params: NetParams.UserGetUnreadMsgCount = {}) => { +/** 获取未读消息数 */ +export const getUnreadMsgCount = (params: NetParams.UserGetUnreadMsgCount = {}): Promise => { return request({ method: 'get', url: '/user/msgcount/unread', params - }) as unknown as Promise; + }); }; -/** - * 获取消息列表 - * @param {Object} params - * @returns Promise - */ -export const getMessages = (params: NetParams.UserGetMessages) => { +/** 获取消息列表 */ +export const getMessages = (params: NetParams.UserGetMessages): Promise => { return request({ method: 'get', url: '/user/messages', params - }) as unknown as Promise; + }); }; /** @@ -130,69 +110,49 @@ export const readMessage = (data: any) => { }); }; -/** - * 获取收藏列表 - * @param {Object} params - * @returns Promise - */ -export const getCollections = (params: NetParams.UserGetCollections) => { +/** 获取收藏列表 */ +export const getCollections = (params: NetParams.UserGetCollections): Promise => { return request({ method: 'get', url: '/user/collections', params - }) as unknown as Promise; + }); }; -/** - * 获取点赞列表 - * @param {Object} params - * @returns Promise - */ -export const getStars = (params: NetParams.UserGetStars) => { +/** 获取点赞列表 */ +export const getStars = (params: NetParams.UserGetStars): Promise => { return request({ method: 'get', url: '/user/stars', params - }) as unknown as Promise; + }); }; -/** - * 获取用户基础信息 - * @param {Object} params - * @returns Promise - */ -export const getUserProfile = (params: NetParams.UserGetUserProfile) => { +/** 获取用户基础信息 */ +export const getUserProfile = (params: NetParams.UserGetUserProfile): Promise => { return request({ method: 'get', url: '/user/profile', params - }) as unknown as Promise; + }); }; -/** - * 获取点赞列表 - * @param {Object} params - * @returns Promise - */ -export const getUserPosts = (params: NetParams.UserGetUserPosts) => { +/** 获取用户帖子列表 */ +export const getUserPosts = (params: NetParams.UserGetUserPosts): Promise => { return request({ method: 'get', url: '/user/posts', params - }) as unknown as Promise; + }); }; -/** - * 获取账单列表 - * @param {Object} params - * @returns Promise - */ -export const getBills = (params: NetParams.UserGetBills) => { +/** 获取账单列表 */ +export const getBills = (params: NetParams.UserGetBills): Promise => { return request({ method: 'get', url: '/user/wallet/bills', params - }) as unknown as Promise; + }); }; /** @@ -200,12 +160,12 @@ export const getBills = (params: NetParams.UserGetBills) => { * @param {Object} data * @returns Promise */ -export const reqRecharge = (data: NetParams.UserReqRecharge) => { +export const reqRecharge = (data: NetParams.UserReqRecharge): Promise => { return request({ method: 'post', url: '/user/recharge', data - }) as unknown as Promise; + }); }; /** @@ -213,12 +173,12 @@ export const reqRecharge = (data: NetParams.UserReqRecharge) => { * @param {Object} params * @returns Promise */ -export const getRecharge = (params: NetParams.UserGetRecharge) => { +export const getRecharge = (params: NetParams.UserGetRecharge): Promise => { return request({ method: 'get', url: '/user/recharge', params - }) as unknown as Promise; + }); }; /** @@ -226,12 +186,12 @@ export const getRecharge = (params: NetParams.UserGetRecharge) => { * @param {Object} params * @returns Promise */ -export const getSuggestUsers = (params: { k: string }) => { +export const getSuggestUsers = (params: { k: string }): Promise => { return request({ method: 'get', url: '/suggest/users', params - }) as unknown as Promise; + }); }; /** @@ -239,12 +199,12 @@ export const getSuggestUsers = (params: { k: string }) => { * @param {Object} params * @returns Promise */ -export const getSuggestTags = (params: { k: string }) => { +export const getSuggestTags = (params: { k: string }): Promise => { return request({ method: 'get', url: '/suggest/tags', params - }) as unknown as Promise; + }); }; /** @@ -252,12 +212,12 @@ export const getSuggestTags = (params: { k: string }) => { * @param {Object} params * @returns Promise */ -export const precheckAttachment = (params: NetParams.UserPrecheckAttachment) => { +export const precheckAttachment = (params: NetParams.UserPrecheckAttachment): Promise => { return request({ method: 'get', url: '/attachment/precheck', params - }) as unknown as Promise; + }); }; /** @@ -265,10 +225,10 @@ export const precheckAttachment = (params: NetParams.UserPrecheckAttachment) => * @param {Object} params * @returns Promise */ -export const getAttachment = (params: NetParams.UserGetAttachment) => { +export const getAttachment = (params: NetParams.UserGetAttachment): Promise => { return request({ method: 'get', url: '/attachment', params - }) as unknown as Promise; + }); }; diff --git a/web/src/components/comment-item.vue b/web/src/components/comment-item.vue index ad93562a..b1799e05 100644 --- a/web/src/components/comment-item.vue +++ b/web/src/components/comment-item.vue @@ -120,13 +120,13 @@ const props = withDefaults(defineProps<{ }>(), {}) const comment = computed(() => { - let comment = Object.assign( + let comment: Item.CommentComponentProps = Object.assign( { texts: [], imgs: [], }, props.comment - ) as {texts: Item.CommentProps[], imgs: Item.CommentProps[]} & Item.CommentProps; + ); comment.contents.map((content :any) => { if (+content.type === 1 || +content.type === 2) { comment.texts.push(content); diff --git a/web/src/components/compose-comment.vue b/web/src/components/compose-comment.vue index 3bcb36fd..ea23f264 100644 --- a/web/src/components/compose-comment.vue +++ b/web/src/components/compose-comment.vue @@ -265,7 +265,7 @@ const finishUpload = ({ file, event }: any): any => { imageContents.value.push({ id: file.id, content: data.data.content, - }); + } as Item.CommentItemProps); } } } catch (error) { diff --git a/web/src/components/compose.vue b/web/src/components/compose.vue index 7fa46214..db8fca0c 100644 --- a/web/src/components/compose.vue +++ b/web/src/components/compose.vue @@ -265,7 +265,7 @@ const uploadType = ref('public/image'); const fileQueue = ref([]); const imageContents = ref([]); const videoContents = ref([]); -const attachmentContents = ref([]); +const attachmentContents = ref([]); const uploadGateway = import.meta.env.VITE_HOST + '/attachment'; const uploadToken = ref(); @@ -402,19 +402,19 @@ const finishUpload = ({ file, event }: any): any => { imageContents.value.push({ id: file.id, content: data.data.content, - }); + } as Item.CommentItemProps); } if (uploadType.value === 'public/video') { videoContents.value.push({ id: file.id, content: data.data.content, - }); + } as Item.CommentItemProps); } if (uploadType.value === 'attachment') { attachmentContents.value.push({ id: file.id, content: data.data.content, - }); + } as Item.AttachmentProps); } } } catch (error) { diff --git a/web/src/components/post-attachment.vue b/web/src/components/post-attachment.vue index c806ac9f..a3d01bf8 100644 --- a/web/src/components/post-attachment.vue +++ b/web/src/components/post-attachment.vue @@ -42,7 +42,7 @@ import { precheckAttachment, getAttachment } from '@/api/user'; const props = withDefaults( defineProps<{ - attachments: Item.AttachmentProps[]; + attachments: Item.PostItemProps[]; price?: number; }>(), { @@ -54,7 +54,7 @@ const showDownloadModal = ref(false); const downloadTip = ref(''); const attachmentID = ref(0); -const download = (attachment: Item.AttachmentProps) => { +const download = (attachment: Item.PostItemProps) => { showDownloadModal.value = true; attachmentID.value = attachment.id; diff --git a/web/src/components/post-detail.vue b/web/src/components/post-detail.vue index 5bfc9a43..af283e9c 100644 --- a/web/src/components/post-detail.vue +++ b/web/src/components/post-detail.vue @@ -197,7 +197,7 @@ const emit = defineEmits<{ const post = computed({ get: () => { - let post: Required = Object.assign( + let post: Item.PostComponentProps = Object.assign( { texts: [], imgs: [], diff --git a/web/src/components/post-image.vue b/web/src/components/post-image.vue index 3a136b6e..179ed462 100644 --- a/web/src/components/post-image.vue +++ b/web/src/components/post-image.vue @@ -230,7 +230,7 @@ const defaultImg = const thumbnail = '?x-oss-process=image/resize,m_fill,w_300,h_300,limit_0/auto-orient,1/format,png'; const props = withDefaults(defineProps<{ - imgs: Item.PostProps[], + imgs: Item.PostItemProps[], }>(), { imgs: () => [] }); diff --git a/web/src/components/post-item.vue b/web/src/components/post-item.vue index 9ae3ad55..06dfd018 100644 --- a/web/src/components/post-item.vue +++ b/web/src/components/post-item.vue @@ -101,7 +101,7 @@ const props = withDefaults(defineProps<{ }>(), {}); const post = computed(() => { - let post: Required = Object.assign( + let post: Item.PostComponentProps = Object.assign( { texts: [], imgs: [], diff --git a/web/src/components/post-link.vue b/web/src/components/post-link.vue index b5713695..16864089 100644 --- a/web/src/components/post-link.vue +++ b/web/src/components/post-link.vue @@ -17,7 +17,7 @@