123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186 |
- import Vue from 'vue'
- import Router from 'vue-router'
- Vue.use(Router)
- const pcRouter = new Router({
- routes: [
- {
- path: '/',
- alias: [
- '/user/:id',
- '/login',
- '/other/:id',
- '/me',
- '/editMe',
- '/editInfo/:type',
- '/groupSet/:id',
- '/invite/:inviteType',
- '/packetSend',
- '/packetGet/:id',
- '/search',
- '/discover'
- ],
- name: 'noChat',
- component: resolve => {
- require(['@/components/chatRoom/noChat.vue'], resolve)
- }
- },
- {
- path: '/group/:id',
- name: 'groupChat',
- component: resolve => {
- require(['@/components/chatRoom/chatRoom.vue'], resolve)
- }
- },
- {
- path: '/pm/:id',
- name: 'pmChat',
- component: resolve => {
- require(['@/components/chatRoom/chatRoom.vue'], resolve)
- }
- },
- {
- path: '/hotGroup',
- name: 'hotGroup',
- component: resolve => {
- require(['@/components/hotGroup/hotGroup.vue'], resolve)
- }
- },
- {
- path: '/relateGroup',
- name: 'relateGroup',
- component: resolve => {
- require(['@/components/relateGroup/relateGroup.vue'], resolve)
- }
- }
- ]
- })
- const h5Router = new Router({
- routes: [
- {
- name: 'chatList',
- path: '/',
- alias: '/user/:id',
- component: resolve => {
- require(['@/pages/h5/view/chatList.vue'], resolve)
- }
- },
- {
- path: '/login',
- name: 'login',
- component: resolve => {
- require(['@/pages/h5/view/login.vue'], resolve)
- }
- },
- {
- path: '/loginMee',
- name: 'loginMee',
- component: resolve => {
- require(['@/pages/h5/view/loginMee.vue'], resolve)
- }
- },
- {
- path: '/other/:id',
- name: 'aboutOther',
- component: resolve => {
- require(['@/pages/h5/view/aboutOther.vue'], resolve)
- }
- },
- {
- path: '/me',
- name: 'aboutMe',
- component: resolve => {
- require(['@/pages/h5/view/aboutMe.vue'], resolve)
- }
- },
- {
- path: '/editMe',
- name: 'editMe',
- component: resolve => {
- require(['@/pages/h5/view/editMe.vue'], resolve)
- }
- },
- {
- path: '/editInfo/:type/:id?',
- name: 'editInfo',
- component: resolve => {
- require(['@/pages/h5/view/editInfo.vue'], resolve)
- }
- },
- {
- path: '/group/:id',
- name: 'groupChat',
- component: resolve => {
- require(['@/pages/h5/view/chatRoom.vue'], resolve)
- }
- },
- {
- path: '/groupSet/:id',
- name: 'groupSet',
- component: resolve => {
- require(['@/pages/h5/view/chatSet.vue'], resolve)
- }
- },
- {
- path: '/pm/:id',
- name: 'pmChat',
- component: resolve => {
- require(['@/pages/h5/view/chatRoom.vue'], resolve)
- }
- },
- {
- path: '/invite/:inviteType/:id?',
- name: 'invite',
- component: resolve => {
- require(['@/pages/h5/view/invite.vue'], resolve)
- }
- },
- {
- path: '/search',
- name: 'search',
- component: resolve => {
- require(['@/pages/h5/view/search.vue'], resolve)
- }
- },
- {
- path: '/discover',
- name: 'discover',
- component: resolve => {
- require(['@/pages/h5/view/discover.vue'], resolve)
- }
- },
- {
- path: '/password',
- name: 'password',
- component: resolve => {
- require(['@/pages/h5/view/password.vue'], resolve)
- }
- },
- {
- path: '/relateGroup',
- name: 'relateGroup',
- component: resolve => {
- require(['@/components/relateGroup/relateGroup.vue'], resolve)
- }
- }
- ]
- })
- h5Router.beforeEach((to, from, next) => {
- if (to.path !== '/login' && to.path !== '/loginMee') {
- let userId = localStorage.getItem('user_id')
- let token = localStorage.getItem('token')
- if (userId && token) {
- next()
- } else {
- next('/login')
- }
- } else {
- next()
- }
- })
- export { h5Router, pcRouter }
|