export default { // 获取首页推荐小说列表 async getHomeRecommend() { try { const res = await this.$http.get('/novel/home') return res.data } catch (error) { console.error('获取首页推荐失败', error) return [] } }, // 获取小说详情 async getNovelDetail(novelId) { try { const res = await this.$http.get(`/novel/detail/${novelId}`) return res.data } catch (error) { console.error('获取小说详情失败', error) return null } }, // 获取小说章节列表 async getChapters(novelId) { try { const res = await this.$http.get(`/novel/chapters/${novelId}`) return res.data } catch (error) { console.error('获取章节列表失败', error) return [] } }, // 获取章节内容 async getChapterContent(novelId, chapterId) { try { const res = await this.$http.get(`/novel/chapter/${novelId}/${chapterId}`) return res.data } catch (error) { console.error('获取章节内容失败', error) return null } }, // 添加到书架 async addToBookshelf(novelId) { try { const res = await this.$http.post('/bookshelf/add', { novelId }) return res.code === 0 } catch (error) { console.error('添加到书架失败', error) return false } } }