├── php-api/ # 改造后的PHP接口层 ├── java-ad-service/ # 若依框架微服务(广告+VIP+分账) ├── uniapp-reader/ # UniApp前端项目 │ ├── pages/ # 各端页面 │ └──
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

list.vue 24KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880
  1. <template>
  2. <view class="novel-list-page">
  3. <!-- 加载状态 -->
  4. <view v-if="loading" class="loading-container">
  5. <uni-icons type="spinner-cycle" size="36" color="var(--primary-color)" class="loading-icon" />
  6. <text>加载中...</text>
  7. </view>
  8. <!-- 内容区域 -->
  9. <template v-else>
  10. <!-- 顶部广告 -->
  11. <ad-banner v-if="topAds.length" :ads="topAds" />
  12. <!-- 顶部分类导航 -->
  13. <scroll-view scroll-x class="category-nav">
  14. <view
  15. v-for="category in categories"
  16. :key="category.id"
  17. class="category-item"
  18. :class="{ active: activeCategory === category.id }"
  19. @click="changeCategory(category.id)"
  20. >
  21. {{ category.name }}
  22. </view>
  23. </scroll-view>
  24. <!-- 空状态 -->
  25. <view v-if="showEmptyState" class="empty-container">
  26. <image src="/static/empty-book.png" class="empty-img" />
  27. <text class="empty-text">暂无小说数据</text>
  28. <button class="btn-refresh" @click="reloadData">重新加载</button>
  29. </view>
  30. <!-- 错误状态 -->
  31. <view v-if="error && !showNovels" class="error-container">
  32. <uni-icons type="info" size="48" color="var(--error-color)" />
  33. <text class="error-text">{{ error }}</text>
  34. <button class="btn-refresh" @click="loadNovels">重新加载</button>
  35. </view>
  36. <!-- 热门推荐 -->
  37. <view v-if="showHotNovels" class="section">
  38. <view class="section-header">
  39. <text class="section-title">热门推荐</text>
  40. <text class="section-more" @click="goMore">更多 ></text>
  41. </view>
  42. <scroll-view scroll-x class="hot-list">
  43. <view
  44. v-for="novel in displayedHotNovels"
  45. :key="novel.id"
  46. class="hot-item"
  47. @click="openNovel(novel)"
  48. >
  49. <image
  50. :src="getCoverUrl(novel.coverImg)"
  51. class="hot-cover"
  52. @error="handleImageError"
  53. />
  54. <text class="hot-title">{{ novel.title }}</text>
  55. </view>
  56. </scroll-view>
  57. </view>
  58. <!-- 小说列表 -->
  59. <view v-if="showNovels" class="section">
  60. <view class="section-header">
  61. <text class="section-title">小说列表</text>
  62. </view>
  63. <view class="novel-grid">
  64. <view
  65. v-for="novel in displayedNovels"
  66. :key="novel.id"
  67. class="novel-item"
  68. @click="openNovel(novel)"
  69. >
  70. <image
  71. :src="getCoverUrl(novel.coverImg)"
  72. class="novel-cover"
  73. @error="handleImageError"
  74. />
  75. <text class="novel-title">{{ novel.title }}</text>
  76. <text class="novel-author">{{ novel.author || '未知作者' }}</text>
  77. </view>
  78. </view>
  79. </view>
  80. <!-- 成为签约作家按钮 -->
  81. <view class="become-author" @click="applyAuthor">
  82. <text>成为签约作家,发布你的作品</text>
  83. </view>
  84. <!-- 底部广告 -->
  85. <ad-banner v-if="bottomAds.length" :ads="bottomAds" />
  86. </template>
  87. </view>
  88. </template>
  89. <script>
  90. import AdBanner from '@/components/AdBanner';
  91. export default {
  92. components: { AdBanner },
  93. data() {
  94. return {
  95. topAds: [],
  96. bottomAds: [],
  97. categories: [],
  98. activeCategory: 0,
  99. hotNovels: [],
  100. novels: [],
  101. loading: true,
  102. error: null,
  103. currentCategoryName: '全部',
  104. // 临时解决方案 - 模拟数据
  105. mockHotNovels: [
  106. { id: 1, title: '总裁的替身前妻', coverImg: '/static/demo-cover1.jpg', author: '言情作家' },
  107. { id: 2, title: '神医毒妃', coverImg: '/static/demo-cover2.jpg', author: '古风大神' },
  108. { id: 3, title: '穿越之王妃逆袭', coverImg: '/static/demo-cover3.jpg', author: '穿越达人' }
  109. ],
  110. mockNovels: [
  111. { id: 4, title: '都市最强赘婿', author: '网络作家', coverImg: '/static/demo-cover4.jpg' },
  112. { id: 5, title: '修仙归来', author: '仙侠迷', coverImg: '/static/demo-cover5.jpg' },
  113. { id: 6, title: '校园纯爱物语', author: '青春校园', coverImg: '/static/demo-cover6.jpg' }
  114. ],
  115. // 添加分页参数
  116. page: 1,
  117. pageSize: 10,
  118. total: 0,
  119. hasMore: true
  120. }
  121. },
  122. computed: {
  123. // 添加计算属性控制显示逻辑
  124. showEmptyState() {
  125. return this.novels.length === 0 && !this.error && !this.loading;
  126. },
  127. showHotNovels() {
  128. return this.hotNovels.length > 0 && !this.error;
  129. },
  130. showNovels() {
  131. return this.novels.length > 0 && !this.error;
  132. },
  133. displayedHotNovels() {
  134. return this.hotNovels.length > 0 ? this.hotNovels : this.mockHotNovels;
  135. },
  136. displayedNovels() {
  137. return this.novels.length > 0 ? this.novels : this.mockNovels;
  138. }
  139. },
  140. mounted() {
  141. this.initData();
  142. },
  143. methods: {
  144. async initData() {
  145. try {
  146. // 改为顺序加载,便于调试
  147. await this.loadCategories();
  148. await this.loadHotNovels();
  149. await this.loadNovels();
  150. } catch (e) {
  151. console.error('初始化失败', e);
  152. this.error = '初始化失败,请检查网络连接';
  153. } finally {
  154. this.loading = false;
  155. }
  156. },
  157. // 在 list.vue 的 methods 中修改 openNovel 方法
  158. // 在 list.vue 的 methods 中添加
  159. simpleNavigate(url) {
  160. try {
  161. // 方法1: 直接使用最基础的导航方式
  162. if (typeof uni !== 'undefined' && uni.navigateTo) {
  163. // 创建一个新的URL对象,确保格式正确
  164. const cleanUrl = url.split('?')[0];
  165. const params = new URLSearchParams(url.split('?')[1] || '');
  166. uni.navigateTo({
  167. url: `${cleanUrl}?${params.toString()}`,
  168. fail: (err) => {
  169. console.error('基础navigateTo失败:', err);
  170. // 方法2: 使用页面重定向
  171. this.simpleRedirect(url);
  172. }
  173. });
  174. } else {
  175. this.simpleRedirect(url);
  176. }
  177. } catch (error) {
  178. console.error('simpleNavigate异常:', error);
  179. this.simpleRedirect(url);
  180. }
  181. },
  182. simpleRedirect(url) {
  183. try {
  184. if (typeof uni !== 'undefined' && uni.redirectTo) {
  185. uni.redirectTo({
  186. url: url,
  187. fail: (err) => {
  188. console.error('redirectTo失败:', err);
  189. // 方法3: 使用Vue Router
  190. this.useVueRouterFallback(url);
  191. }
  192. });
  193. } else {
  194. this.useVueRouterFallback(url);
  195. }
  196. } catch (error) {
  197. console.error('simpleRedirect异常:', error);
  198. this.useVueRouterFallback(url);
  199. }
  200. },
  201. useVueRouterFallback(url) {
  202. try {
  203. // 解析URL路径和参数
  204. const [path, queryString] = url.split('?');
  205. const params = new URLSearchParams(queryString || '');
  206. const query = {};
  207. for (const [key, value] of params.entries()) {
  208. query[key] = value;
  209. }
  210. // 使用Vue Router
  211. if (this.$router && typeof this.$router.push === 'function') {
  212. this.$router.push({ path, query });
  213. } else {
  214. // 最终方案: 使用原生跳转
  215. window.location.href = url;
  216. }
  217. } catch (error) {
  218. console.error('useVueRouterFallback异常:', error);
  219. // 最终降级方案
  220. window.location.href = url;
  221. }
  222. },
  223. // 在 list.vue 中修改 openNovel 方法
  224. // 在 list.vue 中修改 openNovel 方法
  225. openNovel(novel) {
  226. try {
  227. console.log('📖 准备打开小说:', novel);
  228. // 确保获取到正确的小说ID
  229. const novelId = novel.id || novel.novelId;
  230. if (!novelId) {
  231. console.error('❌ 无法获取小说ID:', novel);
  232. uni.showToast({
  233. title: '小说ID不存在',
  234. icon: 'none'
  235. });
  236. return;
  237. }
  238. console.log('🎯 跳转到详情页,小说ID:', novelId);
  239. // 使用动态路由参数
  240. this.$router.push({
  241. name: 'NovelDetail',
  242. params: {
  243. id: novelId
  244. }
  245. });
  246. } catch (error) {
  247. console.error('💥 openNovel方法执行异常:', error);
  248. // 备选方案:使用查询参数
  249. const novelId = novel.id || novel.novelId;
  250. this.$router.push({
  251. path: '/pages/novel/detail',
  252. query: { novelId }
  253. });
  254. }
  255. },
  256. // 添加安全导航方法
  257. safeNavigateTo(url) {
  258. try {
  259. // 方法1: 直接使用 uni.navigateTo
  260. if (typeof uni.navigateTo === 'function') {
  261. uni.navigateTo({
  262. url: url,
  263. success: (res) => {
  264. console.log('navigateTo跳转成功', res);
  265. },
  266. fail: (err) => {
  267. console.error('navigateTo跳转失败', err);
  268. // 方法2: 使用重定向作为备选
  269. this.fallbackRedirect(url);
  270. }
  271. });
  272. } else {
  273. // 方法3: 使用备用导航
  274. this.fallbackRedirect(url);
  275. }
  276. } catch (error) {
  277. console.error('safeNavigateTo方法异常:', error);
  278. this.fallbackRedirect(url);
  279. }
  280. },
  281. // 备用重定向方法
  282. fallbackRedirect(url) {
  283. try {
  284. if (typeof uni.redirectTo === 'function') {
  285. uni.redirectTo({
  286. url: url,
  287. success: (res) => {
  288. console.log('redirectTo跳转成功', res);
  289. },
  290. fail: (err) => {
  291. console.error('redirectTo也失败', err);
  292. // 方法4: 使用Vue Router
  293. this.useVueRouter(url);
  294. }
  295. });
  296. } else {
  297. this.useVueRouter(url);
  298. }
  299. } catch (error) {
  300. console.error('fallbackRedirect方法异常:', error);
  301. this.useVueRouter(url);
  302. }
  303. },
  304. // 使用Vue Router进行导航
  305. useVueRouter(url) {
  306. try {
  307. // 解析URL
  308. const path = url.split('?')[0];
  309. const queryString = url.split('?')[1] || '';
  310. const params = new URLSearchParams(queryString);
  311. const query = {};
  312. for (const [key, value] of params.entries()) {
  313. query[key] = value;
  314. }
  315. if (this.$router && typeof this.$router.push === 'function') {
  316. this.$router.push({
  317. path: path,
  318. query: query
  319. });
  320. } else {
  321. // 最终降级方案
  322. window.location.href = url;
  323. }
  324. } catch (error) {
  325. console.error('useVueRouter方法异常:', error);
  326. // 最终降级方案
  327. window.location.href = url;
  328. }
  329. },
  330. // 备用导航方法
  331. fallbackNavigate(novelId) {
  332. try {
  333. console.log('尝试备用导航方法,小说ID:', novelId);
  334. // 方法1: 使用window.location (仅H5环境)
  335. if (typeof window !== 'undefined' && window.location) {
  336. window.location.href = `/pages/novel/reader?novelId=${novelId}`;
  337. return;
  338. }
  339. // 方法2: 使用Vue Router (如果可用)
  340. if (this.$router && typeof this.$router.push === 'function') {
  341. this.$router.push({
  342. path: '/pages/novel/reader',
  343. query: { novelId }
  344. });
  345. return;
  346. }
  347. // 方法3: 显示错误提示
  348. uni.showToast({
  349. title: '无法跳转,请检查页面配置',
  350. icon: 'none'
  351. });
  352. } catch (error) {
  353. console.error('备用导航方法也失败:', error);
  354. }
  355. },
  356. // 修复响应解析方法
  357. parseResponse(res) {
  358. console.log('原始响应对象:', res);
  359. // 处理不同的响应格式
  360. let responseData = {};
  361. // 如果res有arg属性,使用arg作为响应数据
  362. if (res && res.arg) {
  363. responseData = res.arg;
  364. console.log('使用res.arg作为响应数据:', responseData);
  365. }
  366. // 如果res有data属性,使用data作为响应数据
  367. else if (res && res.data) {
  368. responseData = res.data;
  369. console.log('使用res.data作为响应数据:', responseData);
  370. }
  371. // 如果res本身就是响应数据
  372. else {
  373. responseData = res;
  374. console.log('使用res本身作为响应数据:', responseData);
  375. }
  376. return responseData;
  377. },
  378. // 修复分类加载逻辑
  379. async loadCategories() {
  380. try {
  381. const res = await this.$http.get('/category/tree', {
  382. header: { isToken: false },
  383. timeout: 10000
  384. });
  385. console.log('分类API完整响应:', res);
  386. // 使用统一的响应解析方法
  387. const responseData = this.parseResponse(res);
  388. console.log('处理后的分类响应数据:', responseData);
  389. // 修复: 检查不同的响应格式
  390. let categoriesData = [];
  391. if (responseData.code === 200 && Array.isArray(responseData.data)) {
  392. categoriesData = responseData.data;
  393. } else if (Array.isArray(responseData)) {
  394. categoriesData = responseData;
  395. } else if (responseData.code === 200 && Array.isArray(responseData.rows)) {
  396. categoriesData = responseData.rows;
  397. }
  398. if (categoriesData.length > 0) {
  399. let subCategories = [];
  400. categoriesData.forEach(parent => {
  401. if (parent && parent.children && Array.isArray(parent.children)) {
  402. // 确保每个子分类都有必要的字段
  403. const validChildren = parent.children.filter(child =>
  404. child && child.id && (child.title || child.name)
  405. ).map(child => ({
  406. id: child.id,
  407. name: child.title || child.name // 使用title或name作为分类名称
  408. }));
  409. subCategories = [...subCategories, ...validChildren];
  410. }
  411. });
  412. // 添加"全部"分类
  413. this.categories = [
  414. { id: 0, name: '全部' },
  415. ...subCategories
  416. ];
  417. console.log('处理后的分类:', this.categories);
  418. } else {
  419. console.warn('分类数据结构异常,使用默认分类', responseData);
  420. this.categories = [{ id: 0, name: '全部' }];
  421. }
  422. } catch (e) {
  423. console.error('加载分类失败', e);
  424. this.categories = [{ id: 0, name: '全部' }];
  425. }
  426. },
  427. // 修复热门小说加载逻辑
  428. async loadHotNovels() {
  429. try {
  430. const res = await this.$http.get('/novel/hot', {
  431. header: { isToken: false },
  432. timeout: 10000
  433. });
  434. console.log('热门小说API完整响应:', res);
  435. // 使用统一的响应解析方法
  436. const responseData = this.parseResponse(res);
  437. console.log('处理后的热门小说响应:', responseData);
  438. // 处理API返回的数据格式
  439. if (responseData.code === 200) {
  440. if (Array.isArray(responseData.rows)) {
  441. this.hotNovels = responseData.rows;
  442. } else if (Array.isArray(responseData.data)) {
  443. this.hotNovels = responseData.data;
  444. } else {
  445. console.warn('热门小说数据格式异常', responseData);
  446. this.hotNovels = this.mockHotNovels;
  447. }
  448. } else {
  449. console.warn('热门小说API返回异常状态码', responseData);
  450. this.hotNovels = this.mockHotNovels;
  451. }
  452. // 只在真实数据不可用时使用模拟数据
  453. if (!this.hotNovels || this.hotNovels.length === 0) {
  454. console.warn('使用模拟热门小说数据');
  455. this.hotNovels = this.mockHotNovels;
  456. }
  457. } catch (e) {
  458. console.error('加载热门小说失败', e);
  459. this.hotNovels = this.mockHotNovels;
  460. }
  461. },
  462. // 修复小说列表加载逻辑
  463. async loadNovels(reset = false) {
  464. if (reset) {
  465. this.page = 1;
  466. this.hasMore = true;
  467. this.novels = [];
  468. }
  469. if (!this.hasMore) return;
  470. this.loading = true;
  471. this.error = null;
  472. // 提前声明变量,使其在整个函数中可用
  473. let newNovels = [];
  474. let total = 0;
  475. try {
  476. const res = await this.$http.get('/novel/list', {
  477. params: {
  478. page: this.page,
  479. pageSize: this.pageSize,
  480. categoryId: this.activeCategory
  481. },
  482. header: { isToken: false },
  483. timeout: 15000
  484. });
  485. console.log('小说列表API完整响应:', res);
  486. // 使用统一的响应解析方法
  487. const responseData = this.parseResponse(res);
  488. console.log('处理后的小说列表响应:', responseData);
  489. // 处理API返回的数据格式
  490. if (responseData.code === 200) {
  491. if (Array.isArray(responseData.rows)) {
  492. newNovels = responseData.rows;
  493. total = responseData.total || 0;
  494. } else if (Array.isArray(responseData.data)) {
  495. newNovels = responseData.data;
  496. total = responseData.total || newNovels.length;
  497. }
  498. } else if (responseData.code === 500) {
  499. // 处理服务器错误
  500. console.error('服务器内部错误:', responseData.msg);
  501. throw new Error('服务器内部错误,请稍后重试');
  502. }
  503. if (newNovels.length > 0) {
  504. this.novels = [...this.novels, ...newNovels];
  505. this.hasMore = this.novels.length < total;
  506. this.page++;
  507. // 修复: 确保图片URL正确
  508. this.novels.forEach(novel => {
  509. if (novel.coverImg) {
  510. novel.coverImg = this.getCoverUrl(novel.coverImg);
  511. }
  512. });
  513. // 确保每个novel对象都有有效的id
  514. this.novels.forEach((novel, index) => {
  515. if (!novel.id) {
  516. console.warn(`小说 ${index} 缺少ID,使用索引作为临时ID`);
  517. novel.id = index + 1; // 使用索引作为临时ID
  518. }
  519. });
  520. } else if (this.page === 1) {
  521. console.warn('小说列表为空,使用模拟数据');
  522. this.novels = this.mockNovels; // 使用模拟数据
  523. }
  524. } catch (e) {
  525. console.error('加载小说失败', e);
  526. if (e.errMsg && e.errMsg.includes('timeout')) {
  527. this.error = '网络请求超时,请检查网络连接';
  528. } else if (e.message && e.message.includes('服务器内部错误')) {
  529. this.error = '服务器暂时不可用,请稍后重试';
  530. } else {
  531. this.error = '加载失败,请重试';
  532. }
  533. this.novels = this.mockNovels; // 回退到模拟数据
  534. } finally {
  535. this.loading = false;
  536. }
  537. },
  538. // 暂时禁用广告加载,避免404错误
  539. async loadAds() {
  540. try {
  541. console.log('广告功能暂未开放');
  542. this.topAds = [];
  543. this.bottomAds = [];
  544. // 以下是原有的广告加载代码,暂时注释掉
  545. /*
  546. // 使用Promise.all并行请求
  547. const [topRes, bottomRes] = await Promise.all([
  548. this.$http.get('/ad/position?code=TOP_BANNER', {
  549. header: { isToken: false }
  550. }),
  551. this.$http.get('/ad/position?code=BOTTOM_BANNER', {
  552. header: { isToken: false }
  553. })
  554. ]);
  555. // 处理广告响应
  556. this.topAds = this.parseAdResponse(topRes);
  557. this.bottomAds = this.parseAdResponse(bottomRes);
  558. */
  559. } catch (e) {
  560. console.error('加载广告失败', e);
  561. this.topAds = [];
  562. this.bottomAds = [];
  563. }
  564. },
  565. // 广告响应解析方法 - 简化逻辑
  566. parseAdResponse(response) {
  567. if (!response || !response.data) return [];
  568. const responseData = response.data;
  569. // 统一处理可能的响应格式
  570. if (responseData.code === 200 && Array.isArray(responseData.data)) {
  571. return responseData.data;
  572. } else if (Array.isArray(responseData)) {
  573. return responseData;
  574. } else if (responseData.code === 200 && Array.isArray(responseData.rows)) {
  575. return responseData.rows;
  576. }
  577. return [];
  578. },
  579. // 修复封面URL处理
  580. getCoverUrl(cover) {
  581. if (!cover) return '/static/default-cover.jpg';
  582. // 如果已经是完整URL,直接返回
  583. if (cover.startsWith('http')) return cover;
  584. // 如果是相对路径,添加基础URL
  585. if (cover.startsWith('/')) {
  586. return `${process.env.VUE_APP_BASE_URL || ''}${cover}`;
  587. }
  588. // 其他情况,直接返回
  589. return cover;
  590. },
  591. // 添加图片错误处理
  592. handleImageError(event) {
  593. console.log('图片加载失败:', event);
  594. event.target.src = '/static/default-cover.jpg';
  595. },
  596. // 其他方法...
  597. changeCategory(categoryId) {
  598. this.activeCategory = categoryId;
  599. const category = this.categories.find(c => c.id === categoryId);
  600. this.currentCategoryName = category ? category.name : '全部';
  601. this.loadNovels(true); // 重置并加载新分类
  602. },
  603. applyAuthor() {
  604. if (!this.$store.getters.token) {
  605. uni.showToast({ title: '请先登录', icon: 'none' });
  606. uni.navigateTo({ url: '/pages/login/index' });
  607. return;
  608. }
  609. uni.navigateTo({ url: '/pages/author/apply' });
  610. },
  611. goMore() {
  612. uni.navigateTo({
  613. url: '/pages/novel/more'
  614. });
  615. },
  616. // 确保重新加载按钮绑定到正确的方法
  617. reloadData() {
  618. this.initData();
  619. },
  620. // 添加上拉加载事件
  621. onReachBottom() {
  622. this.loadNovels();
  623. }
  624. }
  625. }
  626. </script>
  627. <style scoped>
  628. /* 添加加载状态样式 */
  629. .loading-container {
  630. display: flex;
  631. flex-direction: column;
  632. align-items: center;
  633. justify-content: center;
  634. padding: 100rpx 0;
  635. }
  636. .loading-icon {
  637. animation: rotate 1s linear infinite;
  638. margin-bottom: 20rpx;
  639. }
  640. @keyframes rotate {
  641. from { transform: rotate(0deg); }
  642. to { transform: rotate(360deg); }
  643. }
  644. /* 添加空状态样式 */
  645. .empty-container, .error-container {
  646. display: flex;
  647. flex-direction: column;
  648. align-items: center;
  649. justify-content: center;
  650. padding: 100rpx 0;
  651. text-align: center;
  652. }
  653. .empty-img {
  654. width: 200rpx;
  655. height: 200rpx;
  656. opacity: 0.6;
  657. margin-bottom: 40rpx;
  658. }
  659. .empty-text, .error-text {
  660. font-size: 32rpx;
  661. color: var(--text-color);
  662. margin-bottom: 40rpx;
  663. }
  664. .error-text {
  665. color: var(--error-color);
  666. }
  667. .btn-refresh {
  668. background-color: var(--primary-color);
  669. color: white;
  670. width: 60%;
  671. border-radius: 50rpx;
  672. }
  673. /* 确保网格布局正确 */
  674. .novel-grid {
  675. display: grid;
  676. grid-template-columns: repeat(3, 1fr);
  677. gap: 20rpx;
  678. padding: 20rpx;
  679. }
  680. .novel-item {
  681. background-color: white;
  682. border-radius: 12rpx;
  683. overflow: hidden;
  684. box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.1);
  685. }
  686. /* 确保封面有默认背景和固定比例 */
  687. .novel-cover, .hot-cover {
  688. width: 100%;
  689. height: 300rpx;
  690. background-color: #f5f5f5;
  691. object-fit: cover;
  692. }
  693. .novel-title {
  694. display: block;
  695. font-size: 28rpx;
  696. padding: 10rpx 15rpx;
  697. white-space: nowrap;
  698. overflow: hidden;
  699. text-overflow: ellipsis;
  700. }
  701. .novel-author {
  702. display: block;
  703. font-size: 24rpx;
  704. color: #888;
  705. padding: 0 15rpx 15rpx;
  706. }
  707. /* 热门列表样式 */
  708. .hot-list {
  709. display: flex;
  710. padding: 20rpx;
  711. overflow-x: auto;
  712. white-space: nowrap;
  713. }
  714. .hot-item {
  715. display: inline-block;
  716. width: 200rpx;
  717. margin-right: 30rpx;
  718. }
  719. .hot-cover {
  720. width: 200rpx;
  721. height: 280rpx;
  722. border-radius: 8rpx;
  723. }
  724. .hot-title {
  725. display: block;
  726. margin-top: 10rpx;
  727. font-size: 26rpx;
  728. white-space: nowrap;
  729. overflow: hidden;
  730. text-overflow: ellipsis;
  731. }
  732. /* 分类导航样式 */
  733. .category-nav {
  734. white-space: nowrap;
  735. padding: 20rpx 0;
  736. background-color: #fff;
  737. border-bottom: 1rpx solid #eee;
  738. }
  739. .category-item {
  740. display: inline-block;
  741. padding: 10rpx 30rpx;
  742. margin: 0 10rpx;
  743. border-radius: 30rpx;
  744. font-size: 28rpx;
  745. }
  746. .category-item.active {
  747. background-color: var(--primary-color);
  748. color: white;
  749. }
  750. /* 章节标题样式 */
  751. .section {
  752. margin-top: 30rpx;
  753. }
  754. .section-header {
  755. display: flex;
  756. justify-content: space-between;
  757. align-items: center;
  758. padding: 0 20rpx 20rpx;
  759. }
  760. .section-title {
  761. font-size: 32rpx;
  762. font-weight: bold;
  763. }
  764. .section-more {
  765. font-size: 26rpx;
  766. color: var(--text-secondary-color);
  767. }
  768. /* 成为作家按钮样式 */
  769. .become-author {
  770. margin: 40rpx 20rpx;
  771. padding: 20rpx;
  772. text-align: center;
  773. background-color: var(--primary-color);
  774. color: white;
  775. border-radius: 10rpx;
  776. font-size: 30rpx;
  777. }
  778. </style>