├── php-api/ # 改造后的PHP接口层 ├── java-ad-service/ # 若依框架微服务(广告+VIP+分账) ├── uniapp-reader/ # UniApp前端项目 │ ├── pages/ # 各端页面 │ └──
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

list.vue 24KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877
  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. const novelId = novel.id || novel.novelId || novel.bookId;
  229. if (!novelId) {
  230. console.error('无法获取小说ID:', novel);
  231. uni.showToast({
  232. title: '小说ID不存在',
  233. icon: 'none'
  234. });
  235. return;
  236. }
  237. console.log('跳转到阅读页面,小说ID:', novelId);
  238. // 使用若依框架的标准导航方式
  239. this.$router.push({
  240. path: '/pages/novel/reader',
  241. query: {
  242. novelId: novelId,
  243. chapterId: 1
  244. }
  245. });
  246. } catch (error) {
  247. console.error('openNovel方法执行异常:', error);
  248. uni.showToast({
  249. title: '发生未知错误',
  250. icon: 'none'
  251. });
  252. }
  253. },
  254. // 添加安全导航方法
  255. safeNavigateTo(url) {
  256. try {
  257. // 方法1: 直接使用 uni.navigateTo
  258. if (typeof uni.navigateTo === 'function') {
  259. uni.navigateTo({
  260. url: url,
  261. success: (res) => {
  262. console.log('navigateTo跳转成功', res);
  263. },
  264. fail: (err) => {
  265. console.error('navigateTo跳转失败', err);
  266. // 方法2: 使用重定向作为备选
  267. this.fallbackRedirect(url);
  268. }
  269. });
  270. } else {
  271. // 方法3: 使用备用导航
  272. this.fallbackRedirect(url);
  273. }
  274. } catch (error) {
  275. console.error('safeNavigateTo方法异常:', error);
  276. this.fallbackRedirect(url);
  277. }
  278. },
  279. // 备用重定向方法
  280. fallbackRedirect(url) {
  281. try {
  282. if (typeof uni.redirectTo === 'function') {
  283. uni.redirectTo({
  284. url: url,
  285. success: (res) => {
  286. console.log('redirectTo跳转成功', res);
  287. },
  288. fail: (err) => {
  289. console.error('redirectTo也失败', err);
  290. // 方法4: 使用Vue Router
  291. this.useVueRouter(url);
  292. }
  293. });
  294. } else {
  295. this.useVueRouter(url);
  296. }
  297. } catch (error) {
  298. console.error('fallbackRedirect方法异常:', error);
  299. this.useVueRouter(url);
  300. }
  301. },
  302. // 使用Vue Router进行导航
  303. useVueRouter(url) {
  304. try {
  305. // 解析URL
  306. const path = url.split('?')[0];
  307. const queryString = url.split('?')[1] || '';
  308. const params = new URLSearchParams(queryString);
  309. const query = {};
  310. for (const [key, value] of params.entries()) {
  311. query[key] = value;
  312. }
  313. if (this.$router && typeof this.$router.push === 'function') {
  314. this.$router.push({
  315. path: path,
  316. query: query
  317. });
  318. } else {
  319. // 最终降级方案
  320. window.location.href = url;
  321. }
  322. } catch (error) {
  323. console.error('useVueRouter方法异常:', error);
  324. // 最终降级方案
  325. window.location.href = url;
  326. }
  327. },
  328. // 备用导航方法
  329. fallbackNavigate(novelId) {
  330. try {
  331. console.log('尝试备用导航方法,小说ID:', novelId);
  332. // 方法1: 使用window.location (仅H5环境)
  333. if (typeof window !== 'undefined' && window.location) {
  334. window.location.href = `/pages/novel/reader?novelId=${novelId}`;
  335. return;
  336. }
  337. // 方法2: 使用Vue Router (如果可用)
  338. if (this.$router && typeof this.$router.push === 'function') {
  339. this.$router.push({
  340. path: '/pages/novel/reader',
  341. query: { novelId }
  342. });
  343. return;
  344. }
  345. // 方法3: 显示错误提示
  346. uni.showToast({
  347. title: '无法跳转,请检查页面配置',
  348. icon: 'none'
  349. });
  350. } catch (error) {
  351. console.error('备用导航方法也失败:', error);
  352. }
  353. },
  354. // 修复响应解析方法
  355. parseResponse(res) {
  356. console.log('原始响应对象:', res);
  357. // 处理不同的响应格式
  358. let responseData = {};
  359. // 如果res有arg属性,使用arg作为响应数据
  360. if (res && res.arg) {
  361. responseData = res.arg;
  362. console.log('使用res.arg作为响应数据:', responseData);
  363. }
  364. // 如果res有data属性,使用data作为响应数据
  365. else if (res && res.data) {
  366. responseData = res.data;
  367. console.log('使用res.data作为响应数据:', responseData);
  368. }
  369. // 如果res本身就是响应数据
  370. else {
  371. responseData = res;
  372. console.log('使用res本身作为响应数据:', responseData);
  373. }
  374. return responseData;
  375. },
  376. // 修复分类加载逻辑
  377. async loadCategories() {
  378. try {
  379. const res = await this.$http.get('/category/tree', {
  380. header: { isToken: false },
  381. timeout: 10000
  382. });
  383. console.log('分类API完整响应:', res);
  384. // 使用统一的响应解析方法
  385. const responseData = this.parseResponse(res);
  386. console.log('处理后的分类响应数据:', responseData);
  387. // 修复: 检查不同的响应格式
  388. let categoriesData = [];
  389. if (responseData.code === 200 && Array.isArray(responseData.data)) {
  390. categoriesData = responseData.data;
  391. } else if (Array.isArray(responseData)) {
  392. categoriesData = responseData;
  393. } else if (responseData.code === 200 && Array.isArray(responseData.rows)) {
  394. categoriesData = responseData.rows;
  395. }
  396. if (categoriesData.length > 0) {
  397. let subCategories = [];
  398. categoriesData.forEach(parent => {
  399. if (parent && parent.children && Array.isArray(parent.children)) {
  400. // 确保每个子分类都有必要的字段
  401. const validChildren = parent.children.filter(child =>
  402. child && child.id && (child.title || child.name)
  403. ).map(child => ({
  404. id: child.id,
  405. name: child.title || child.name // 使用title或name作为分类名称
  406. }));
  407. subCategories = [...subCategories, ...validChildren];
  408. }
  409. });
  410. // 添加"全部"分类
  411. this.categories = [
  412. { id: 0, name: '全部' },
  413. ...subCategories
  414. ];
  415. console.log('处理后的分类:', this.categories);
  416. } else {
  417. console.warn('分类数据结构异常,使用默认分类', responseData);
  418. this.categories = [{ id: 0, name: '全部' }];
  419. }
  420. } catch (e) {
  421. console.error('加载分类失败', e);
  422. this.categories = [{ id: 0, name: '全部' }];
  423. }
  424. },
  425. // 修复热门小说加载逻辑
  426. async loadHotNovels() {
  427. try {
  428. const res = await this.$http.get('/novel/hot', {
  429. header: { isToken: false },
  430. timeout: 10000
  431. });
  432. console.log('热门小说API完整响应:', res);
  433. // 使用统一的响应解析方法
  434. const responseData = this.parseResponse(res);
  435. console.log('处理后的热门小说响应:', responseData);
  436. // 处理API返回的数据格式
  437. if (responseData.code === 200) {
  438. if (Array.isArray(responseData.rows)) {
  439. this.hotNovels = responseData.rows;
  440. } else if (Array.isArray(responseData.data)) {
  441. this.hotNovels = responseData.data;
  442. } else {
  443. console.warn('热门小说数据格式异常', responseData);
  444. this.hotNovels = this.mockHotNovels;
  445. }
  446. } else {
  447. console.warn('热门小说API返回异常状态码', responseData);
  448. this.hotNovels = this.mockHotNovels;
  449. }
  450. // 只在真实数据不可用时使用模拟数据
  451. if (!this.hotNovels || this.hotNovels.length === 0) {
  452. console.warn('使用模拟热门小说数据');
  453. this.hotNovels = this.mockHotNovels;
  454. }
  455. } catch (e) {
  456. console.error('加载热门小说失败', e);
  457. this.hotNovels = this.mockHotNovels;
  458. }
  459. },
  460. // 修复小说列表加载逻辑
  461. async loadNovels(reset = false) {
  462. if (reset) {
  463. this.page = 1;
  464. this.hasMore = true;
  465. this.novels = [];
  466. }
  467. if (!this.hasMore) return;
  468. this.loading = true;
  469. this.error = null;
  470. // 提前声明变量,使其在整个函数中可用
  471. let newNovels = [];
  472. let total = 0;
  473. try {
  474. const res = await this.$http.get('/novel/list', {
  475. params: {
  476. page: this.page,
  477. pageSize: this.pageSize,
  478. categoryId: this.activeCategory
  479. },
  480. header: { isToken: false },
  481. timeout: 15000
  482. });
  483. console.log('小说列表API完整响应:', res);
  484. // 使用统一的响应解析方法
  485. const responseData = this.parseResponse(res);
  486. console.log('处理后的小说列表响应:', responseData);
  487. // 处理API返回的数据格式
  488. if (responseData.code === 200) {
  489. if (Array.isArray(responseData.rows)) {
  490. newNovels = responseData.rows;
  491. total = responseData.total || 0;
  492. } else if (Array.isArray(responseData.data)) {
  493. newNovels = responseData.data;
  494. total = responseData.total || newNovels.length;
  495. }
  496. } else if (responseData.code === 500) {
  497. // 处理服务器错误
  498. console.error('服务器内部错误:', responseData.msg);
  499. throw new Error('服务器内部错误,请稍后重试');
  500. }
  501. if (newNovels.length > 0) {
  502. this.novels = [...this.novels, ...newNovels];
  503. this.hasMore = this.novels.length < total;
  504. this.page++;
  505. // 修复: 确保图片URL正确
  506. this.novels.forEach(novel => {
  507. if (novel.coverImg) {
  508. novel.coverImg = this.getCoverUrl(novel.coverImg);
  509. }
  510. });
  511. // 确保每个novel对象都有有效的id
  512. this.novels.forEach((novel, index) => {
  513. if (!novel.id) {
  514. console.warn(`小说 ${index} 缺少ID,使用索引作为临时ID`);
  515. novel.id = index + 1; // 使用索引作为临时ID
  516. }
  517. });
  518. } else if (this.page === 1) {
  519. console.warn('小说列表为空,使用模拟数据');
  520. this.novels = this.mockNovels; // 使用模拟数据
  521. }
  522. } catch (e) {
  523. console.error('加载小说失败', e);
  524. if (e.errMsg && e.errMsg.includes('timeout')) {
  525. this.error = '网络请求超时,请检查网络连接';
  526. } else if (e.message && e.message.includes('服务器内部错误')) {
  527. this.error = '服务器暂时不可用,请稍后重试';
  528. } else {
  529. this.error = '加载失败,请重试';
  530. }
  531. this.novels = this.mockNovels; // 回退到模拟数据
  532. } finally {
  533. this.loading = false;
  534. }
  535. },
  536. // 暂时禁用广告加载,避免404错误
  537. async loadAds() {
  538. try {
  539. console.log('广告功能暂未开放');
  540. this.topAds = [];
  541. this.bottomAds = [];
  542. // 以下是原有的广告加载代码,暂时注释掉
  543. /*
  544. // 使用Promise.all并行请求
  545. const [topRes, bottomRes] = await Promise.all([
  546. this.$http.get('/ad/position?code=TOP_BANNER', {
  547. header: { isToken: false }
  548. }),
  549. this.$http.get('/ad/position?code=BOTTOM_BANNER', {
  550. header: { isToken: false }
  551. })
  552. ]);
  553. // 处理广告响应
  554. this.topAds = this.parseAdResponse(topRes);
  555. this.bottomAds = this.parseAdResponse(bottomRes);
  556. */
  557. } catch (e) {
  558. console.error('加载广告失败', e);
  559. this.topAds = [];
  560. this.bottomAds = [];
  561. }
  562. },
  563. // 广告响应解析方法 - 简化逻辑
  564. parseAdResponse(response) {
  565. if (!response || !response.data) return [];
  566. const responseData = response.data;
  567. // 统一处理可能的响应格式
  568. if (responseData.code === 200 && Array.isArray(responseData.data)) {
  569. return responseData.data;
  570. } else if (Array.isArray(responseData)) {
  571. return responseData;
  572. } else if (responseData.code === 200 && Array.isArray(responseData.rows)) {
  573. return responseData.rows;
  574. }
  575. return [];
  576. },
  577. // 修复封面URL处理
  578. getCoverUrl(cover) {
  579. if (!cover) return '/static/default-cover.jpg';
  580. // 如果已经是完整URL,直接返回
  581. if (cover.startsWith('http')) return cover;
  582. // 如果是相对路径,添加基础URL
  583. if (cover.startsWith('/')) {
  584. return `${process.env.VUE_APP_BASE_URL || ''}${cover}`;
  585. }
  586. // 其他情况,直接返回
  587. return cover;
  588. },
  589. // 添加图片错误处理
  590. handleImageError(event) {
  591. console.log('图片加载失败:', event);
  592. event.target.src = '/static/default-cover.jpg';
  593. },
  594. // 其他方法...
  595. changeCategory(categoryId) {
  596. this.activeCategory = categoryId;
  597. const category = this.categories.find(c => c.id === categoryId);
  598. this.currentCategoryName = category ? category.name : '全部';
  599. this.loadNovels(true); // 重置并加载新分类
  600. },
  601. applyAuthor() {
  602. if (!this.$store.getters.token) {
  603. uni.showToast({ title: '请先登录', icon: 'none' });
  604. uni.navigateTo({ url: '/pages/login' });
  605. return;
  606. }
  607. uni.navigateTo({ url: '/pages/author/apply' });
  608. },
  609. goMore() {
  610. uni.navigateTo({
  611. url: '/pages/novel/more'
  612. });
  613. },
  614. // 确保重新加载按钮绑定到正确的方法
  615. reloadData() {
  616. this.initData();
  617. },
  618. // 添加上拉加载事件
  619. onReachBottom() {
  620. this.loadNovels();
  621. }
  622. }
  623. }
  624. </script>
  625. <style scoped>
  626. /* 添加加载状态样式 */
  627. .loading-container {
  628. display: flex;
  629. flex-direction: column;
  630. align-items: center;
  631. justify-content: center;
  632. padding: 100rpx 0;
  633. }
  634. .loading-icon {
  635. animation: rotate 1s linear infinite;
  636. margin-bottom: 20rpx;
  637. }
  638. @keyframes rotate {
  639. from { transform: rotate(0deg); }
  640. to { transform: rotate(360deg); }
  641. }
  642. /* 添加空状态样式 */
  643. .empty-container, .error-container {
  644. display: flex;
  645. flex-direction: column;
  646. align-items: center;
  647. justify-content: center;
  648. padding: 100rpx 0;
  649. text-align: center;
  650. }
  651. .empty-img {
  652. width: 200rpx;
  653. height: 200rpx;
  654. opacity: 0.6;
  655. margin-bottom: 40rpx;
  656. }
  657. .empty-text, .error-text {
  658. font-size: 32rpx;
  659. color: var(--text-color);
  660. margin-bottom: 40rpx;
  661. }
  662. .error-text {
  663. color: var(--error-color);
  664. }
  665. .btn-refresh {
  666. background-color: var(--primary-color);
  667. color: white;
  668. width: 60%;
  669. border-radius: 50rpx;
  670. }
  671. /* 确保网格布局正确 */
  672. .novel-grid {
  673. display: grid;
  674. grid-template-columns: repeat(3, 1fr);
  675. gap: 20rpx;
  676. padding: 20rpx;
  677. }
  678. .novel-item {
  679. background-color: white;
  680. border-radius: 12rpx;
  681. overflow: hidden;
  682. box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.1);
  683. }
  684. /* 确保封面有默认背景和固定比例 */
  685. .novel-cover, .hot-cover {
  686. width: 100%;
  687. height: 300rpx;
  688. background-color: #f5f5f5;
  689. object-fit: cover;
  690. }
  691. .novel-title {
  692. display: block;
  693. font-size: 28rpx;
  694. padding: 10rpx 15rpx;
  695. white-space: nowrap;
  696. overflow: hidden;
  697. text-overflow: ellipsis;
  698. }
  699. .novel-author {
  700. display: block;
  701. font-size: 24rpx;
  702. color: #888;
  703. padding: 0 15rpx 15rpx;
  704. }
  705. /* 热门列表样式 */
  706. .hot-list {
  707. display: flex;
  708. padding: 20rpx;
  709. overflow-x: auto;
  710. white-space: nowrap;
  711. }
  712. .hot-item {
  713. display: inline-block;
  714. width: 200rpx;
  715. margin-right: 30rpx;
  716. }
  717. .hot-cover {
  718. width: 200rpx;
  719. height: 280rpx;
  720. border-radius: 8rpx;
  721. }
  722. .hot-title {
  723. display: block;
  724. margin-top: 10rpx;
  725. font-size: 26rpx;
  726. white-space: nowrap;
  727. overflow: hidden;
  728. text-overflow: ellipsis;
  729. }
  730. /* 分类导航样式 */
  731. .category-nav {
  732. white-space: nowrap;
  733. padding: 20rpx 0;
  734. background-color: #fff;
  735. border-bottom: 1rpx solid #eee;
  736. }
  737. .category-item {
  738. display: inline-block;
  739. padding: 10rpx 30rpx;
  740. margin: 0 10rpx;
  741. border-radius: 30rpx;
  742. font-size: 28rpx;
  743. }
  744. .category-item.active {
  745. background-color: var(--primary-color);
  746. color: white;
  747. }
  748. /* 章节标题样式 */
  749. .section {
  750. margin-top: 30rpx;
  751. }
  752. .section-header {
  753. display: flex;
  754. justify-content: space-between;
  755. align-items: center;
  756. padding: 0 20rpx 20rpx;
  757. }
  758. .section-title {
  759. font-size: 32rpx;
  760. font-weight: bold;
  761. }
  762. .section-more {
  763. font-size: 26rpx;
  764. color: var(--text-secondary-color);
  765. }
  766. /* 成为作家按钮样式 */
  767. .become-author {
  768. margin: 40rpx 20rpx;
  769. padding: 20rpx;
  770. text-align: center;
  771. background-color: var(--primary-color);
  772. color: white;
  773. border-radius: 10rpx;
  774. font-size: 30rpx;
  775. }
  776. </style>