Skip to content

Commit

Permalink
前端完善TS
Browse files Browse the repository at this point in the history
  • Loading branch information
orziz committed May 27, 2022
1 parent 1018de0 commit aee6edc
Show file tree
Hide file tree
Showing 26 changed files with 395 additions and 201 deletions.
34 changes: 17 additions & 17 deletions paopao-web/src/api/post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import request from '@/utils/request';
* @param {Object} params
* @returns Promise
*/
export const getPosts = (params: any) => {
export const getPosts = (params: NetParams.PostGetPosts) => {
return request({
method: 'get',
url: '/posts',
Expand All @@ -18,90 +18,90 @@ export const getPosts = (params: any) => {
* @param {Object} params
* @returns Promise
*/
export const getTags = (params: any) => {
export const getTags = (params: NetParams.PostGetTags) => {
return request({
method: 'get',
url: '/tags',
params
});
}) as unknown as Promise<NetReq.PostGetTags>;
};

/**
* 获取动态详情
* @param {Object} params
* @returns Promise
*/
export const getPost = (params: any) => {
export const getPost = (params: NetParams.PostGetPost) => {
return request({
method: 'get',
url: '/post',
params
});
}) as unknown as Promise<NetReq.PostGetPost>;
};

/**
* 获取动态点赞状态
* @param {Object} params
* @returns Promise
*/
export const getPostStar = (params: any) => {
export const getPostStar = (params: NetParams.PostPostStar) => {
return request({
method: 'get',
url: '/post/star',
params
});
}) as unknown as Promise<NetReq.PostGetPostStar>;
};

/**
* 动态点赞
* @param {Object} data
* @returns Promise
*/
export const postStar = (data: any) => {
export const postStar = (data: NetParams.PostPostStar) => {
return request({
method: 'post',
url: '/post/star',
data
});
}) as unknown as Promise<NetReq.PostPostStar>;
};

/**
* 获取动态收藏状态
* @param {Object} params
* @returns Promise
*/
export const getPostCollection = (params: any) => {
export const getPostCollection = (params: NetParams.PostGetPostCollection) => {
return request({
method: 'get',
url: '/post/collection',
params
});
}) as unknown as Promise<NetReq.PostGetPostCollection>;
};

/**
* 动态收藏
* @param {Object} data
* @returns Promise
*/
export const postCollection = (data: any) => {
export const postCollection = (data: NetParams.PostPostCollection) => {
return request({
method: 'post',
url: '/post/collection',
data
});
}) as unknown as Promise<NetReq.PostPostCollection>;
};

/**
* 获取动态评论列表
* @param {Object} params
* @returns Promise
*/
export const getPostComments = (params: any) => {
export const getPostComments = (params: NetParams.PostGetPostComments) => {
return request({
method: 'get',
url: '/post/comments',
params
});
}) as unknown as Promise<NetReq.PostGetPostComments>;
};

/**
Expand Down Expand Up @@ -140,12 +140,12 @@ export const deletePost = (data: any) => {
* - @param {number} id
* @returns Promise
*/
export const lockPost = (data: any) => {
export const lockPost = (data: NetParams.PostLockPost) => {
return request({
method: 'post',
url: '/post/lock',
data
});
}) as unknown as Promise<NetReq.PostLockPost>;
};

/**
Expand Down
50 changes: 25 additions & 25 deletions paopao-web/src/api/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import request from '@/utils/request';
* @param {Object} params
* @returns Promise
*/
export const getCaptcha = (params: any) => {
export const getCaptcha = (params: NetParams.UserGetCaptcha = {}) => {
return request({
method: 'get',
url: '/captcha',
params
});
}) as unknown as Promise<NetReq.UserGetCaptcha>;
};

/**
Expand All @@ -31,12 +31,12 @@ export const sendCaptcha = (data: any) => {
* @param {Object} data
* @returns Promise
*/
export const bindUserPhone = (data: any) => {
export const bindUserPhone = (data: NetParams.UserBindUserPhone) => {
return request({
method: 'post',
url: '/user/phone',
data
});
}) as unknown as Promise<NetParams.UserBindUserPhone>;
};

/**
Expand Down Expand Up @@ -83,25 +83,25 @@ export const changeAvatar = (data: any) => {
* @param {Object} params
* @returns Promise
*/
export const getUnreadMsgCount = (params: any) => {
export const getUnreadMsgCount = (params: NetParams.UserGetUnreadMsgCount = {}) => {
return request({
method: 'get',
url: '/user/msgcount/unread',
params
});
}) as unknown as Promise<NetReq.UserGetUnreadMsgCount>;
};

/**
* 获取消息列表
* @param {Object} params
* @returns Promise
*/
export const getMessages = (params: any) => {
export const getMessages = (params: NetParams.UserGetMessages) => {
return request({
method: 'get',
url: '/user/messages',
params
});
}) as unknown as Promise<NetReq.UserGetMessages>;
};

/**
Expand All @@ -122,7 +122,7 @@ export const readMessage = (data: any) => {
* @param {Object} params
* @returns Promise
*/
export const getCollections = (params: any) => {
export const getCollections = (params: NetParams.UserGetCollections) => {
return request({
method: 'get',
url: '/user/collections',
Expand All @@ -135,77 +135,77 @@ export const getCollections = (params: any) => {
* @param {Object} params
* @returns Promise
*/
export const getStars = (params: any) => {
export const getStars = (params: NetParams.UserGetStars) => {
return request({
method: 'get',
url: '/user/stars',
params
});
}) as unknown as Promise<NetReq.UserGetStars>;
};

/**
* 获取用户基础信息
* @param {Object} params
* @returns Promise
*/
export const getUserProfile = (params: any) => {
export const getUserProfile = (params: NetParams.UserGetUserProfile) => {
return request({
method: 'get',
url: '/user/profile',
params
});
}) as unknown as Promise<NetReq.UserGetUserProfile>;
};

/**
* 获取点赞列表
* @param {Object} params
* @returns Promise
*/
export const getUserPosts = (params: any) => {
export const getUserPosts = (params: NetParams.UserGetUserPosts) => {
return request({
method: 'get',
url: '/user/posts',
params
});
}) as unknown as Promise<NetReq.UserGetUserPosts>;
};

/**
* 获取账单列表
* @param {Object} params
* @returns Promise
*/
export const getBills = (params: any) => {
export const getBills = (params: NetParams.UserGetBills) => {
return request({
method: 'get',
url: '/user/wallet/bills',
params
});
}) as unknown as Promise<NetReq.UserGetBills>;
};

/**
* 发起充值请求
* @param {Object} data
* @returns Promise
*/
export const reqRecharge = (data: any) => {
export const reqRecharge = (data: NetParams.UserReqRecharge) => {
return request({
method: 'post',
url: '/user/recharge',
data
});
}) as unknown as Promise<NetReq.UserReqRecharge>;
};

/**
* 获取充值状态
* @param {Object} params
* @returns Promise
*/
export const getRecharge = (params: any) => {
export const getRecharge = (params: NetParams.UserGetRecharge) => {
return request({
method: 'get',
url: '/user/recharge',
params
});
}) as unknown as Promise<NetReq.UserGetRecharge>;
};

/**
Expand Down Expand Up @@ -239,23 +239,23 @@ export const getSuggestTags = (params: {k: string}) => {
* @param {Object} params
* @returns Promise
*/
export const precheckAttachment = (params: any) => {
export const precheckAttachment = (params: NetParams.UserPrecheckAttachment) => {
return request({
method: 'get',
url: '/attachment/precheck',
params
});
}) as unknown as Promise<NetReq.UserPrecheckAttachment>;
};

/**
* 获取附件
* @param {Object} params
* @returns Promise
*/
export const getAttachment = (params: any) => {
export const getAttachment = (params: NetParams.UserGetAttachment) => {
return request({
method: 'get',
url: '/attachment',
params
});
}) as unknown as Promise<NetReq.UserGetAttachment>;
};
16 changes: 6 additions & 10 deletions paopao-web/src/components/compose-comment.vue
Original file line number Diff line number Diff line change
Expand Up @@ -168,18 +168,14 @@ import { createComment } from '@/api/post';
import { getSuggestUsers } from '@/api/user';
import { parsePostTag } from '@/utils/content';
import type { MentionOption, UploadFileInfo, UploadInst } from 'naive-ui';
import { FileInfo } from 'naive-ui/lib/upload/src/interface';

const emit = defineEmits(['post-success']);
const props = defineProps({
lock: {
type: Number,
default: 0,
},
postId: {
type: Number,
default: 0,
},
const props = withDefaults(defineProps<{
lock: number,
postId: number,
}>(), {
lock: 0,
postId: 0
});

const store = useStore();
Expand Down
11 changes: 5 additions & 6 deletions paopao-web/src/components/message-skeleton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@
</div>
</template>

<script setup>
const props = defineProps({
num: {
type: Number,
default: 1,
},
<script setup lang="ts">
const props = withDefaults(defineProps<{
num: number
}>(), {
num: 1
});
</script>

Expand Down
21 changes: 9 additions & 12 deletions paopao-web/src/components/post-attachment.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,26 +35,23 @@
</div>
</template>

<script setup>
<script setup lang="ts">
import { h, ref } from 'vue';
import { CloudDownloadOutline } from '@vicons/ionicons5';
import { precheckAttachment, getAttachment } from '@/api/user';

const props = defineProps({
attachments: {
type: Array,
default: () => [],
},
price: {
type: Number,
default: 0,
},
const props = withDefaults(defineProps<{
attachments: Item.AttachmentProps[],
price: number,
}>(), {
attachments: () => [],
price: 0
});
const showDownloadModal = ref(false);
const downloadTip = ref('');
const downloadTip = ref<any>('');
const attachmentID = ref(0);

const download = (attachment) => {
const download = (attachment: Item.AttachmentProps) => {
showDownloadModal.value = true;
attachmentID.value = attachment.id;

Expand Down
Loading

0 comments on commit aee6edc

Please sign in to comment.