| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- import Vue from 'vue'
- import Router from 'vue-router'
- import Layout from '@/pages/layout'
- import Map from '@/pages/map'
- import List from '@/pages/list'
- import Home from '@/pages/home'
- import Search from '@/pages/search'
- import External from '@/pages/External'
- Vue.use(Router)
- // let isLocal = process.env.isLocal
- let isLocal = Vue.$isLocal
- let routes = [
- {
- path: '/',
- name: 'mainLayout',
- component: Layout,
- children: [
- {
- path: '/',
- name: 'home',
- component: Home
- },
- {
- path: '/list/:title/:type',
- name: 'list',
- component: List,
- children: [
- {name: 'item', path: ':show'}
- ]
- }
- ]
- },
- {
- path: '/search',
- name: 'search',
- component: Search
- },
- {
- path: '/external/:url/:id',
- name: 'external',
- component: External
- }
- ]
- isLocal || routes[0].children.push(
- {
- path: '/map/:title',
- name: 'map',
- component: Map,
- children: [
- {name: 'info', path: ':show'}
- ]
- }
- )
- const router = new Router({
- routes,
- scrollBehavior (to, from, savedPosition) {
- if (to.hash === '') {
- return { x: 0, y: 0 }
- } else {
- return false
- }
- }
- })
- global.paths = []
- router.beforeEach((to, from, next) => {
- global.paths.push(from)
- next()
- })
- global.setExternalUrl = (url) => {
- router.push({name: 'external', params: {url: url}})
- }
- export default router
|