web-学习
This commit is contained in:
@@ -11,6 +11,7 @@ import type { UserCollection, ResultDomain } from '@/types';
|
||||
* 用户收藏API服务
|
||||
*/
|
||||
export const userCollectionApi = {
|
||||
baseUrl: '/usercenter/collections',
|
||||
/**
|
||||
* 获取用户收藏列表
|
||||
* @param userID 用户ID
|
||||
@@ -18,7 +19,7 @@ export const userCollectionApi = {
|
||||
* @returns Promise<ResultDomain<UserCollection>>
|
||||
*/
|
||||
async getUserCollections(userID: string, collectionType?: number): Promise<ResultDomain<UserCollection>> {
|
||||
const response = await api.get<UserCollection>('/usercenter/collection/list', {
|
||||
const response = await api.get<UserCollection>(`${this.baseUrl}/list`, {
|
||||
userID,
|
||||
collectionType
|
||||
});
|
||||
@@ -31,7 +32,7 @@ export const userCollectionApi = {
|
||||
* @returns Promise<ResultDomain<UserCollection>>
|
||||
*/
|
||||
async addCollection(collection: UserCollection): Promise<ResultDomain<UserCollection>> {
|
||||
const response = await api.post<UserCollection>('/usercenter/collection/add', collection);
|
||||
const response = await api.post<UserCollection>(`${this.baseUrl}/collect`, collection);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
@@ -43,7 +44,7 @@ export const userCollectionApi = {
|
||||
* @returns Promise<ResultDomain<boolean>>
|
||||
*/
|
||||
async removeCollection(userID: string, collectionType: number, collectionID: string): Promise<ResultDomain<boolean>> {
|
||||
const response = await api.delete<boolean>('/usercenter/collection/remove', {
|
||||
const response = await api.delete<boolean>(`${this.baseUrl}/collect`, {
|
||||
userID,
|
||||
collectionType,
|
||||
collectionID
|
||||
@@ -58,9 +59,8 @@ export const userCollectionApi = {
|
||||
* @param collectionID 收藏对象ID
|
||||
* @returns Promise<ResultDomain<boolean>>
|
||||
*/
|
||||
async isCollected(userID: string, collectionType: number, collectionID: string): Promise<ResultDomain<boolean>> {
|
||||
const response = await api.get<boolean>('/usercenter/collection/check', {
|
||||
userID,
|
||||
async isCollected(collectionType: number, collectionID: string): Promise<ResultDomain<boolean>> {
|
||||
const response = await api.get<boolean>(`${this.baseUrl}/check`, {
|
||||
collectionType,
|
||||
collectionID
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user