├── php-api/ # 改造后的PHP接口层 ├── java-ad-service/ # 若依框架微服务(广告+VIP+分账) ├── uniapp-reader/ # UniApp前端项目 │ ├── pages/ # 各端页面 │ └──
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. import Vue from 'vue'
  2. import Router from 'vue-router'
  3. import store from '@/store'
  4. Vue.use(Router)
  5. const routes = [
  6. {
  7. path: '/',
  8. redirect: '/pages/novel/list'
  9. },
  10. {
  11. path: '/pages/novel/list',
  12. name: 'NovelList',
  13. component: () => import('@/pages/novel/list'),
  14. meta: { title: '小说列表' }
  15. },
  16. {
  17. // 修复:添加动态路由参数
  18. path: '/pages/novel/detail/:id?',
  19. name: 'NovelDetail',
  20. component: () => import('@/pages/novel/detail.vue'),
  21. meta: { title: '小说详情' },
  22. props: true // 启用 props 接收参数
  23. },
  24. {
  25. path: '/pages/novel/reader/:id?',
  26. name: 'NovelReader',
  27. component: () => import('@/pages/novel/reader.vue'),
  28. meta: { title: '阅读器' },
  29. props: true
  30. },
  31. {
  32. path: '/pages/author/apply',
  33. name: 'AuthorApply',
  34. component: () => import('@/pages/author/apply'),
  35. meta: { title: '作者申请', requiresAuth: true }
  36. },
  37. {
  38. path: '/pages/login/index',
  39. name: 'Login',
  40. component: () => import('@/pages/login/index'),
  41. meta: { title: '登录' }
  42. },
  43. {
  44. path: '/pages/register/index',
  45. name: 'Register',
  46. component: () => import('@/pages/register/index'),
  47. meta: { title: '注册' }
  48. },
  49. // 添加更多路由...
  50. {
  51. path: '*',
  52. redirect: '/pages/novel/list'
  53. }
  54. ]
  55. const router = new Router({
  56. mode: 'hash',
  57. routes
  58. })
  59. // 添加简单的路由守卫
  60. router.beforeEach((to, from, next) => {
  61. console.log('🚀 路由跳转:', from.path, '->', to.path)
  62. console.log('📋 目标路由参数:', to.params)
  63. console.log('🔍 目标路由查询:', to.query)
  64. console.log('📍 完整路由对象:', to)
  65. // 设置页面标题
  66. if (to.meta.title) {
  67. document.title = to.meta.title
  68. }
  69. // 检查是否需要登录
  70. if (to.meta.requiresAuth) {
  71. if (!store.getters.token) {
  72. next('/pages/login/index')
  73. return
  74. }
  75. }
  76. next()
  77. })
  78. router.afterEach((to, from) => {
  79. console.log('✅ 路由跳转完成:', to.path)
  80. })
  81. // 确保路由初始化
  82. router.onReady(() => {
  83. console.log('Router is ready');
  84. })
  85. export default router