更新:1.课程详情增加骨架屏;2.图书首页和图书详情增加骨架屏;

This commit is contained in:
2025-12-11 16:13:40 +08:00
parent b3d9b0c100
commit b8dd0584aa
27 changed files with 897 additions and 649 deletions

View File

@@ -1,6 +1,5 @@
// api/modules/book.ts
import { createRequestClient } from '../request'
import { SERVICE_MAP } from '../config'
import { mainClient, skeletonClient } from '@/api/clients'
import type { IApiResponse } from '../types'
import type {
IBook,
@@ -13,8 +12,6 @@ import type {
} from '@/types/book'
import type { IGoods } from '@/types/order'
const client = createRequestClient({ baseURL: SERVICE_MAP.MAIN })
/**
* 书籍相关API
*/
@@ -25,7 +22,7 @@ export const bookApi = {
* @param limit 每页数量
*/
getMyBooks(current: number, limit: number) {
return client.request<IApiResponse<{ page: IPageData<IBook> }>>({
return mainClient.request<IApiResponse<{ page: IPageData<IBook> }>>({
url: 'bookAbroad/home/getMyBooks',
method: 'POST',
data: { current, limit }
@@ -37,7 +34,7 @@ export const bookApi = {
* @param bookId 书籍ID
*/
getBookInfo(bookId: number) {
return client.request<IApiResponse<{ bookInfo: IBookDetail }>>({
return skeletonClient.request<IApiResponse<{ bookInfo: IBookDetail }>>({
url: 'bookAbroad/home/getBookInfo',
method: 'POST',
data: { bookId }
@@ -49,7 +46,7 @@ export const bookApi = {
* @param bookId 书籍ID
*/
getBookReadCount(bookId: number) {
return client.request<IApiResponse<{
return skeletonClient.request<IApiResponse<{
readCount: number
listenCount: number
buyCount: number
@@ -65,7 +62,7 @@ export const bookApi = {
* @param bookId 书籍ID
*/
getRecommendBook(bookId: number) {
return client.request<IApiResponse<{ bookList: IBook[] }>>({
return skeletonClient.request<IApiResponse<{ bookList: IBook[] }>>({
url: 'bookAbroad/home/getRecommendBook',
method: 'POST',
data: { bookId }
@@ -79,7 +76,7 @@ export const bookApi = {
* @param limit 每页数量
*/
getBookComments(bookId: number, current: number, limit: number) {
return client.request<IApiResponse<{
return mainClient.request<IApiResponse<{
commentsTree: IComment[]
commentsCount: number
}>>({
@@ -96,7 +93,7 @@ export const bookApi = {
* @param pid 父评论ID默认为0表示顶级评论
*/
insertComment(bookId: number, content: string, pid: number = 0) {
return client.request<IApiResponse>({
return mainClient.request<IApiResponse>({
url: 'bookAbroad/insertBookAbroadComment',
method: 'POST',
data: { bookId, content, pid }
@@ -108,7 +105,7 @@ export const bookApi = {
* @param commentId 评论ID
*/
likeComment(commentId: number) {
return client.request<IApiResponse>({
return mainClient.request<IApiResponse>({
url: 'bookAbroad/insertBookAbroadCommentLike',
method: 'POST',
data: { commentId }
@@ -120,7 +117,7 @@ export const bookApi = {
* @param commentId 评论ID
*/
unlikeComment(commentId: number) {
return client.request<IApiResponse>({
return mainClient.request<IApiResponse>({
url: 'bookAbroad/delBookAbroadCommentLike',
method: 'POST',
data: { commentId }
@@ -132,7 +129,7 @@ export const bookApi = {
* @param commentId 评论ID
*/
deleteComment(commentId: number) {
return client.request<IApiResponse>({
return mainClient.request<IApiResponse>({
url: 'bookAbroad/delBookAbroadComment',
method: 'POST',
data: { commentId }
@@ -144,7 +141,7 @@ export const bookApi = {
* @param bookId 书籍ID
*/
getBookChapter(data: { bookId: number; language: string }) {
return client.request<IApiResponse<{ chapterList: IChapter[] }>>({
return mainClient.request<IApiResponse<{ chapterList: IChapter[] }>>({
url: 'bookAbroad/home/getBookChapter',
method: 'POST',
data
@@ -156,7 +153,7 @@ export const bookApi = {
* @param chapterId 章节ID
*/
getChapterContent(chapterId: number) {
return client.request<IApiResponse<{ contentPage: IChapterContent[] }>>({
return mainClient.request<IApiResponse<{ contentPage: IChapterContent[] }>>({
url: 'bookAbroad/home/getBookChapterContent',
method: 'POST',
data: { chapterId }
@@ -168,7 +165,7 @@ export const bookApi = {
* @param bookId 书籍ID
*/
getReadProgress(bookId: number) {
return client.request<IApiResponse<{ bookReadRate: IReadProgress | null }>>({
return mainClient.request<IApiResponse<{ bookReadRate: IReadProgress | null }>>({
url: 'bookAbroad/home/getBookReadRate',
method: 'POST',
data: { bookId }
@@ -182,7 +179,7 @@ export const bookApi = {
* @param contentId 内容ID
*/
saveReadProgress(bookId: number, chapterId: number, contentId: number) {
return client.request<IApiResponse>({
return mainClient.request<IApiResponse>({
url: 'bookAbroad/home/insertBookReadRate',
method: 'POST',
data: { bookId, chapterId, contentId }
@@ -196,7 +193,7 @@ export const bookApi = {
* @param contentId 内容ID
*/
getBookLanguages(bookId: number) {
return client.request<IApiResponse>({
return mainClient.request<IApiResponse>({
url: 'bookAbroad/home/getBookLanguage',
method: 'POST',
data: { bookId }
@@ -208,7 +205,7 @@ export const bookApi = {
* @param chapterId 章节ID
*/
getChapterContentListen(chapterId: number) {
return client.request<IApiResponse<{ bookChapterContents: any[] }>>({
return mainClient.request<IApiResponse<{ bookChapterContents: any[] }>>({
url: 'bookAbroad/home/getBookChapterContentListen',
method: 'POST',
data: { chapterId }
@@ -220,7 +217,7 @@ export const bookApi = {
* @param bookId 书籍ID
*/
getBookGoods(bookId: number) {
return client.request<IApiResponse<{ goodsList: IGoods[] }>>({
return mainClient.request<IApiResponse<{ goodsList: IGoods[] }>>({
url: 'bookAbroad/home/getProductListForBook',
method: 'POST',
data: { bookId }