Prechádzať zdrojové kódy

调整 src/router 中的路由

reghao 5 mesiacov pred
rodič
commit
840a788276

+ 0 - 291
src/router/admin.js

@@ -1,291 +0,0 @@
-// ********************************************************************************************************************
-// 后台管理主页
-const Admin = () => import('views/admin/Admin')
-
-// 站点配置
-const AdminStoreConfig = () => import('views/admin/site/AdminStoreConfig')
-const AdminNotifyConfig = () => import('views/admin/site/AdminNotifyConfig')
-const AdminCategory = () => import('views/admin/site/AdminCategory')
-const AdminRegistry = () => import('views/admin/site/AdminRegistry')
-
-// 后台管理
-const AdminCharge = () => import('views/admin/AdminCharge')
-const AdminUserList = () => import('views/admin/AdminUserList')
-const AdminVideoList = () => import('views/admin/AdminVideoList')
-const AdminAvatarList = () => import('views/admin/AdminAvatarList')
-
-// 后端系统
-const AdminGateway = () => import('views/admin/backend/AdminGateway')
-const AdminDubboService = () => import('views/admin/backend/AdminDubboService')
-const AdminSpringCloudService = () => import('views/admin/backend/AdminSpringCloudService')
-const AdminBackendLog = () => import('views/admin/backend/AdminBackendLog')
-const AdminAccessLog = () => import('views/admin/backend/AdminAccessLog')
-const AdminRuntimeLog = () => import('views/admin/backend/AdminRuntimeLog')
-
-// ********************************************************************************************************************
-// 用户后台主页
-const MyIndex = () => import('views/my/MyIndex')
-const MyProfile = () => import('views/my/MyProfile')
-const MyContact = () => import('views/my/MyContact')
-const MyRecord = () => import('views/my/MyRecord')
-const MyOAuth = () => import('views/my/MyOAuth')
-const MyRcmd = () => import('views/my/MyRcmd')
-const MyMessage = () => import('views/my/MyMessage')
-const MyVip = () => import('views/my/MyVip')
-const MyWallet = () => import('views/my/MyWallet')
-
-// ********************************************************************************************************************
-// 稿件后台主页
-const PostIndex = () => import('views/post/PostIndex')
-const History = () => import('views/post/History')
-const AlbumPost = () => import('views/post/AlbumPost')
-// 稿件后台管理
-const VideoPost = () => import('views/post/VideoPost')
-const VideoPostEdit = () => import('views/post/VideoPostEdit')
-const ImagePost = () => import('views/post/ImagePost')
-const ImagePostEdit = () => import('views/post/ImagePostEdit')
-const ArticlePost = () => import('views/post/ArticlePost')
-const ArticlePostEdit = () => import('views/post/ArticlePostEdit')
-
-export default {
-  path: '/background',
-  name: 'Admin',
-  component: Admin,
-  meta: { needAuth: true },
-  children: [
-    {
-      path: '',
-      name: 'Admin',
-      component: MyProfile,
-      meta: { needAuth: true }
-    },
-    {
-      path: '/background/account',
-      name: 'Account',
-      component: MyIndex,
-      meta: { needAuth: true },
-      children: [
-        {
-          path: '/background/account/profile',
-          name: 'MyProfile',
-          component: MyProfile,
-          meta: { needAuth: true }
-        },
-        {
-          path: '/background/account/record',
-          name: 'MyRecord',
-          component: MyRecord,
-          meta: { needAuth: true }
-        },
-        {
-          path: '/background/account/oauth',
-          name: 'OAuth',
-          component: MyOAuth,
-          meta: { needAuth: true }
-        }
-      ]
-    },
-    {
-      path: '/background/my',
-      name: 'My',
-      component: MyIndex,
-      meta: { needAuth: true },
-      children: [
-        {
-          path: '/background/my/album',
-          name: 'AlbumPost',
-          component: AlbumPost,
-          meta: { needAuth: true }
-        },
-        {
-          path: '/background/my/history',
-          name: 'History',
-          component: History,
-          meta: { needAuth: true }
-        },
-        {
-          path: '/background/my/vip',
-          name: 'MyVip',
-          component: MyVip,
-          meta: { needAuth: true }
-        },
-        {
-          path: '/background/my/wallet',
-          name: 'MyWallet',
-          component: MyWallet,
-          meta: { needAuth: true }
-        },
-        {
-          path: '/background/my/message',
-          name: 'MyMessage',
-          component: MyMessage,
-          meta: { needAuth: true }
-        },
-        {
-          path: '/background/my/rcmd',
-          name: 'Rcmd',
-          component: MyRcmd,
-          meta: { needAuth: true }
-        },
-        {
-          path: '/background/my/contact',
-          name: 'MyContact',
-          component: MyContact,
-          meta: { needAuth: true }
-        }
-      ]
-    },
-    {
-      path: '/background/post',
-      name: 'Post',
-      component: PostIndex,
-      meta: { needAuth: true },
-      children: [
-        {
-          path: '/background/post/video',
-          name: 'VideoPost',
-          component: VideoPost,
-          meta: { needAuth: true }
-        },
-        {
-          path: '/background/post/video/edit/:videoId',
-          name: 'VideoPostEdit',
-          component: VideoPostEdit,
-          meta: { needAuth: true }
-        },
-        {
-          path: '/background/post/image',
-          name: 'ImagePost',
-          component: ImagePost,
-          meta: { needAuth: true }
-        },
-        {
-          path: '/background/post/image/edit/:albumId',
-          name: 'ImagePostEdit',
-          component: ImagePostEdit,
-          meta: { needAuth: true }
-        },
-        {
-          path: '/background/post/article',
-          name: 'ArticlePost',
-          component: ArticlePost,
-          meta: { needAuth: true }
-        },
-        {
-          path: '/background/post/article/edit/:articleId',
-          name: 'ArticlePostEdit',
-          component: ArticlePostEdit,
-          meta: { needAuth: true }
-        }
-      ]
-    },
-    {
-      path: '/background/site',
-      name: 'Post',
-      component: PostIndex,
-      meta: { needAuth: true },
-      children: [
-        {
-          path: '/background/site/store',
-          name: 'AdminStoreConfig',
-          component: AdminStoreConfig,
-          meta: { needAuth: true }
-        },
-        {
-          path: '/background/site/notify',
-          name: 'AdminNotifyConfig',
-          component: AdminNotifyConfig,
-          meta: { needAuth: true }
-        },
-        {
-          path: '/background/site/registry',
-          name: 'AdminRegistry',
-          component: AdminRegistry,
-          meta: { needAuth: true }
-        },
-        {
-          path: '/background/site/category',
-          name: 'AdminCategory',
-          component: AdminCategory,
-          meta: { needAuth: true }
-        }
-      ]
-    },
-    {
-      path: '/background/admin',
-      name: 'Post',
-      component: PostIndex,
-      meta: { needAuth: true },
-      children: [
-        {
-          path: '/background/admin/charge',
-          name: 'AdminCharge',
-          component: AdminCharge,
-          meta: { needAuth: true, role: ['admin'] }
-        },
-        {
-          path: '/background/admin/user',
-          name: 'AdminUserList',
-          component: AdminUserList,
-          meta: { needAuth: true, role: ['admin'] }
-        },
-        {
-          path: '/background/admin/video',
-          name: 'AdminVideoList',
-          component: AdminVideoList,
-          meta: { needAuth: true, role: ['admin'] }
-        },
-        {
-          path: '/background/admin/avatar',
-          name: 'AdminAvatarList',
-          component: AdminAvatarList,
-          meta: { needAuth: true, role: ['admin'] }
-        }
-      ]
-    },
-    {
-      path: '/background/backend',
-      name: 'Backend',
-      component: PostIndex,
-      meta: { needAuth: true },
-      children: [
-        {
-          path: '/background/backend/gateway',
-          name: 'Gateway',
-          component: AdminGateway,
-          meta: { needAuth: true }
-        },
-        {
-          path: '/background/backend/dubbo_service',
-          name: 'DubboService',
-          component: AdminDubboService,
-          meta: { needAuth: true }
-        },
-        {
-          path: '/background/backend/springcloud_service',
-          name: 'SpringCloudService',
-          component: AdminSpringCloudService,
-          meta: { needAuth: true }
-        },
-        {
-          path: '/background/backend/access_log',
-          name: 'AccessLog',
-          component: AdminAccessLog,
-          meta: { needAuth: true }
-        },
-        {
-          path: '/background/backend/runtime_log',
-          name: 'RuntimeLog',
-          component: AdminRuntimeLog,
-          meta: { needAuth: true }
-        },
-        {
-          path: '/background/backend/realtime_log',
-          name: 'Realtime',
-          component: AdminBackendLog,
-          meta: { needAuth: true }
-        }
-      ]
-    }
-  ]
-}

+ 37 - 0
src/router/background_account.js

@@ -0,0 +1,37 @@
+// ********************************************************************************************************************
+// 后台管理主页
+const Background = () => import('views/admin/Background')
+
+// ********************************************************************************************************************
+// 用户后台主页
+const MyProfile = () => import('views/my/MyProfile')
+const MyRecord = () => import('views/my/MyRecord')
+const MyOAuth = () => import('views/my/MyOAuth')
+
+export default {
+  path: '/background/account',
+  redirect: '/background/account/profile',
+  name: 'Account',
+  component: Background,
+  meta: { needAuth: true },
+  children: [
+    {
+      path: '/background/account/profile',
+      name: 'MyProfile',
+      component: MyProfile,
+      meta: { title: '个人资料', needAuth: true }
+    },
+    {
+      path: '/background/account/record',
+      name: 'MyRecord',
+      component: MyRecord,
+      meta: { title: '登入历史', needAuth: true }
+    },
+    {
+      path: '/background/account/oauth',
+      name: 'OAuth',
+      component: MyOAuth,
+      meta: { title: 'OAuth认证', needAuth: true }
+    }
+  ]
+}

+ 43 - 0
src/router/background_admin.js

@@ -0,0 +1,43 @@
+// ********************************************************************************************************************
+// 后台管理主页
+const Background = () => import('views/admin/Background')
+
+// 后台管理
+const AdminCharge = () => import('views/admin/AdminCharge')
+const AdminUserList = () => import('views/admin/AdminUserList')
+const AdminVideoList = () => import('views/admin/AdminVideoList')
+const AdminAvatarList = () => import('views/admin/AdminAvatarList')
+
+export default {
+  path: '/background/admin',
+  redirect: '/background/account',
+  name: 'Admin',
+  component: Background,
+  meta: { needAuth: true },
+  children: [
+    {
+      path: '/background/admin/charge',
+      name: 'AdminCharge',
+      component: AdminCharge,
+      meta: { needAuth: true }
+    },
+    {
+      path: '/background/admin/user',
+      name: 'AdminUserList',
+      component: AdminUserList,
+      meta: { needAuth: true }
+    },
+    {
+      path: '/background/admin/video',
+      name: 'AdminVideoList',
+      component: AdminVideoList,
+      meta: { needAuth: true }
+    },
+    {
+      path: '/background/admin/avatar',
+      name: 'AdminAvatarList',
+      component: AdminAvatarList,
+      meta: { needAuth: true }
+    }
+  ]
+}

+ 57 - 0
src/router/background_backend.js

@@ -0,0 +1,57 @@
+// ********************************************************************************************************************
+// 后台管理主页
+const Background = () => import('views/admin/Background')
+
+// 后端系统
+const AdminGateway = () => import('views/admin/backend/AdminGateway')
+const AdminDubboService = () => import('views/admin/backend/AdminDubboService')
+const AdminSpringCloudService = () => import('views/admin/backend/AdminSpringCloudService')
+const AdminBackendLog = () => import('views/admin/backend/AdminBackendLog')
+const AdminAccessLog = () => import('views/admin/backend/AdminAccessLog')
+const AdminRuntimeLog = () => import('views/admin/backend/AdminRuntimeLog')
+
+export default {
+  path: '/background/backend',
+  redirect: '/background/account',
+  name: 'Backend',
+  component: Background,
+  meta: { needAuth: true },
+  children: [
+    {
+      path: '/background/backend/gateway',
+      name: 'Gateway',
+      component: AdminGateway,
+      meta: { needAuth: true }
+    },
+    {
+      path: '/background/backend/dubbo_service',
+      name: 'DubboService',
+      component: AdminDubboService,
+      meta: { needAuth: true }
+    },
+    {
+      path: '/background/backend/springcloud_service',
+      name: 'SpringCloudService',
+      component: AdminSpringCloudService,
+      meta: { needAuth: true }
+    },
+    {
+      path: '/background/backend/access_log',
+      name: 'AccessLog',
+      component: AdminAccessLog,
+      meta: { needAuth: true }
+    },
+    {
+      path: '/background/backend/runtime_log',
+      name: 'RuntimeLog',
+      component: AdminRuntimeLog,
+      meta: { needAuth: true }
+    },
+    {
+      path: '/background/backend/realtime_log',
+      name: 'Realtime',
+      component: AdminBackendLog,
+      meta: { needAuth: true }
+    }
+  ]
+}

+ 68 - 0
src/router/background_my.js

@@ -0,0 +1,68 @@
+// ********************************************************************************************************************
+// 后台管理主页
+const Background = () => import('views/admin/Background')
+
+// ********************************************************************************************************************
+// 用户后台主页
+const MyContact = () => import('views/my/MyContact')
+const MyRcmd = () => import('views/my/MyRcmd')
+const MyMessage = () => import('views/my/MyMessage')
+const MyVip = () => import('views/my/MyVip')
+const MyWallet = () => import('views/my/MyWallet')
+
+// ********************************************************************************************************************
+// 稿件后台主页
+const History = () => import('views/post/History')
+const AlbumPost = () => import('views/post/AlbumPost')
+
+export default {
+  path: '/background/my',
+  redirect: '/background/account',
+  name: 'My',
+  component: Background,
+  meta: { needAuth: true },
+  children: [
+    {
+      path: '/background/my/album',
+      name: 'AlbumPost',
+      component: AlbumPost,
+      meta: { title: '播放列表', needAuth: true }
+    },
+    {
+      path: '/background/my/history',
+      name: 'History',
+      component: History,
+      meta: { title: '历史记录', needAuth: true }
+    },
+    {
+      path: '/background/my/vip',
+      name: 'MyVip',
+      component: MyVip,
+      meta: { title: '我的会员', needAuth: true }
+    },
+    {
+      path: '/background/my/wallet',
+      name: 'MyWallet',
+      component: MyWallet,
+      meta: { title: '我的钱包', needAuth: true }
+    },
+    {
+      path: '/background/my/message',
+      name: 'MyMessage',
+      component: MyMessage,
+      meta: { title: '我的消息', needAuth: true }
+    },
+    {
+      path: '/background/my/rcmd',
+      name: 'Rcmd',
+      component: MyRcmd,
+      meta: { title: '推荐设置', needAuth: true }
+    },
+    {
+      path: '/background/my/contact',
+      name: 'MyContact',
+      component: MyContact,
+      meta: { title: '联系人', needAuth: true }
+    }
+  ]
+}

+ 55 - 0
src/router/background_post.js

@@ -0,0 +1,55 @@
+const Background = () => import('views/admin/Background')
+// ********************************************************************************************************************
+// 稿件后台管理
+const VideoPost = () => import('views/post/VideoPost')
+const VideoPostEdit = () => import('views/post/VideoPostEdit')
+const ImagePost = () => import('views/post/ImagePost')
+const ImagePostEdit = () => import('views/post/ImagePostEdit')
+const ArticlePost = () => import('views/post/ArticlePost')
+const ArticlePostEdit = () => import('views/post/ArticlePostEdit')
+
+export default {
+  path: '/background/post',
+  redirect: '/background/account',
+  name: 'Post',
+  component: Background,
+  meta: { needAuth: true },
+  children: [
+    {
+      path: '/background/post/video',
+      name: 'VideoPost',
+      component: VideoPost,
+      meta: { title: '视频稿件', needAuth: true }
+    },
+    {
+      path: '/background/post/video/edit/:videoId',
+      name: 'VideoPostEdit',
+      component: VideoPostEdit,
+      meta: { needAuth: true }
+    },
+    {
+      path: '/background/post/image',
+      name: 'ImagePost',
+      component: ImagePost,
+      meta: { title: '相册稿件', needAuth: true }
+    },
+    {
+      path: '/background/post/image/edit/:albumId',
+      name: 'ImagePostEdit',
+      component: ImagePostEdit,
+      meta: { needAuth: true }
+    },
+    {
+      path: '/background/post/article',
+      name: 'ArticlePost',
+      component: ArticlePost,
+      meta: { title: '文章稿件', needAuth: true }
+    },
+    {
+      path: '/background/post/article/edit/:articleId',
+      name: 'ArticlePostEdit',
+      component: ArticlePostEdit,
+      meta: { needAuth: true }
+    }
+  ]
+}

+ 40 - 0
src/router/background_site.js

@@ -0,0 +1,40 @@
+const Background = () => import('views/admin/Background')
+// 站点配置
+const AdminStoreConfig = () => import('views/admin/site/AdminStoreConfig')
+const AdminNotifyConfig = () => import('views/admin/site/AdminNotifyConfig')
+const AdminCategory = () => import('views/admin/site/AdminCategory')
+const AdminRegistry = () => import('views/admin/site/AdminRegistry')
+
+export default {
+  path: '/background/site',
+  redirect: '/background/account',
+  name: 'Site',
+  component: Background,
+  meta: { needAuth: true, roles: ['admin'] },
+  children: [
+    {
+      path: '/background/site/store',
+      name: 'AdminStoreConfig',
+      component: AdminStoreConfig,
+      meta: { needAuth: true }
+    },
+    {
+      path: '/background/site/notify',
+      name: 'AdminNotifyConfig',
+      component: AdminNotifyConfig,
+      meta: { needAuth: true }
+    },
+    {
+      path: '/background/site/registry',
+      name: 'AdminRegistry',
+      component: AdminRegistry,
+      meta: { needAuth: true }
+    },
+    {
+      path: '/background/site/category',
+      name: 'AdminCategory',
+      component: AdminCategory,
+      meta: { needAuth: true }
+    }
+  ]
+}

+ 62 - 69
src/router/index.js

@@ -1,16 +1,15 @@
 import VueRouter from 'vue-router'
 import Vue from 'vue'
+
+import DiskRouter from './disk'
 import UserRouter from './user'
-import ExamRouter from './exam'
-import MallRouter from './mall'
-import MapRouter from './map'
-import ChartRouter from './chart'
-import GeoRouter from './geo'
 import SearchRouter from './search'
-import DiskRouter from './disk'
-import ChatRouter from './chat'
-import NewsRouter from './news'
-import AdminRouter from './admin'
+import BackgroundAccountRouter from './background_account'
+import BackgroundMyRouter from './background_my'
+import BackgroundPostRouter from './background_post'
+import BackgroundSiteRouter from './background_site'
+import BackgroundAdminRouter from './background_admin'
+import BackgroundBackendRouter from './background_backend'
 
 // 懒加载引入页面组件,es6语法
 // ********************************************************************************************************************
@@ -23,14 +22,13 @@ const ShareVideo = () => import('views/home/ShareVideo')
 const Home = () => import('views/home/Home')
 const TimelineIndex = () => import('views/home/Timeline')
 const VideoIndex = () => import('views/home/Video')
-const VideoList = () => import('views/home/VideoList')
 const VideoTag = () => import('views/home/VideoTag')
 const ShortVideoIndex = () => import('views/home/ShortVideo')
 const VideoPage = () => import('views/home/VideoPage')
 const AudioIndex = () => import('views/home/Audio')
 const AudioPage = () => import('views/home/AudioPage')
+const ArticlePage = () => import('views/news/ArticlePage')
 const ImagePage = () => import('views/home/ImagePage')
-const Chat = () => import('views/home/Chat')
 const PlaylistIndex = () => import('views/home/PlaylistIndex')
 const PlaylistView = () => import('views/home/PlaylistView')
 const Discover = () => import('views/home/Discover')
@@ -38,48 +36,16 @@ const Discover = () => import('views/home/Discover')
 // ********************************************************************************************************************
 // 使用安装路由插件
 Vue.use(VueRouter)
-const routes = [
-  ExamRouter,
+export const constantRoutes = [
+  DiskRouter,
   UserRouter,
-  MallRouter,
-  MapRouter,
-  ChartRouter,
-  GeoRouter,
   SearchRouter,
-  DiskRouter,
-  ChatRouter,
-  NewsRouter,
-  AdminRouter,
-  {
-    path: '/login',
-    name: 'Login',
-    component: Login,
-    meta: { needAuth: false }
-  },
-  {
-    path: '/register',
-    name: 'Register',
-    component: Register,
-    meta: { needAuth: false }
-  },
-  {
-    path: '/forgot',
-    name: 'Forgot',
-    component: Forgot,
-    meta: { needAuth: false }
-  },
-  {
-    path: '/s/:shareId',
-    name: 'ShareVideo',
-    component: ShareVideo,
-    meta: { needAuth: false }
-  },
-  {
-    path: '*',
-    name: '404',
-    component: () => import('@/views/404.vue'),
-    meta: { needAuth: false }
-  },
+  BackgroundAccountRouter,
+  BackgroundMyRouter,
+  BackgroundPostRouter,
+  BackgroundSiteRouter,
+  BackgroundAdminRouter,
+  BackgroundBackendRouter,
   {
     path: '/',
     name: 'Index',
@@ -98,12 +64,6 @@ const routes = [
         component: TimelineIndex,
         meta: { needAuth: true }
       },
-      {
-        path: '/chat',
-        name: 'Chat',
-        component: Chat,
-        meta: { needAuth: false }
-      },
       {
         path: '/shortvideo',
         name: 'ShortVideoIndex',
@@ -116,12 +76,6 @@ const routes = [
         component: VideoIndex,
         meta: { needAuth: false }
       },
-      {
-        path: '/edit/videolist/:userId',
-        name: 'VideoList',
-        component: VideoList,
-        meta: { needAuth: false }
-      },
       {
         path: '/video/:id',
         name: 'VideoPage',
@@ -146,6 +100,12 @@ const routes = [
         component: AudioPage,
         meta: { needAuth: false }
       },
+      {
+        path: '/article/:articleId',
+        name: 'ArticlePage',
+        component: ArticlePage,
+        meta: { needAuth: false }
+      },
       {
         path: '/image/:albumId',
         name: 'ImagePage',
@@ -164,6 +124,12 @@ const routes = [
         component: PlaylistView,
         meta: { needAuth: false }
       },
+      {
+        path: '/s/:shareId',
+        name: 'ShareVideo',
+        component: ShareVideo,
+        meta: { needAuth: false }
+      },
       {
         path: '/discover',
         name: 'Discover',
@@ -171,17 +137,44 @@ const routes = [
         meta: { needAuth: false }
       }
     ]
+  },
+  {
+    path: '/background',
+    redirect: '/background/account',
+    name: 'Background',
+    meta: { needAuth: false }
+  },
+  {
+    path: '/login',
+    name: 'Login',
+    component: Login,
+    meta: { needAuth: false }
+  },
+  {
+    path: '/register',
+    name: 'Register',
+    component: Register,
+    meta: { needAuth: false }
+  },
+  {
+    path: '/forgot',
+    name: 'Forgot',
+    component: Forgot,
+    meta: { needAuth: false }
+  },
+  {
+    path: '*',
+    name: '404',
+    component: () => import('@/views/404.vue'),
+    meta: { needAuth: false }
   }
 ]
 
-// 创建路由对象
-const router = new VueRouter({
+// 创建路由对象并导出
+export default new VueRouter({
   mode: 'history',
-  routes,
+  routes: constantRoutes,
   scrollBehavior(to, from, savedPosition) {
     return { x: 0, y: 0 }
   }
 })
-
-// 导出router
-export default router

+ 2 - 2
src/router/user.js

@@ -46,13 +46,13 @@ export default {
     },
     {
       path: '/user/:id/following',
-      name: 'UserRelation',
+      name: 'UserFollowing',
       component: UserRelation,
       meta: { needAuth: false }
     },
     {
       path: '/user/:id/follower',
-      name: 'UserRelation',
+      name: 'UserFollower',
       component: UserRelation,
       meta: { needAuth: false }
     }