123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228 |
- /**
- * 全站路由配置
- *
- * 建议:
- * 1. 代码中路由统一使用name属性跳转(不使用path属性)
- */
- import Vue from 'vue'
- import Router from 'vue-router'
- Vue.use(Router)
- // 开发环境不使用懒加载, 因为懒加载页面太多的话会造成webpack热更新太慢, 所以只有生产环境使用懒加载
- const _import = require('./import-' + process.env.NODE_ENV)
- // 全局路由(无需嵌套上左右整体布局)
- const globalRoutes = [
- { path: '/404', component: _import('common/404'), name: '404', meta: { title: '404未找到' } }
- ]
- // 参猫
- export const toolsRoutes = [
- {
- path: '/tools-analyze',
- component: _import('modules/tools/tools-analyze'),
- name: 'toolsAnalyze',
- meta: { title: '任意竞品透析' }
- },
- {
- path: '/tools-credit',
- component: _import('modules/tools/tools-credit'),
- name: 'toolsCredit',
- meta: { title: '淘宝极速验号' }
- },
- {
- path: '/tools-online',
- component: _import('modules/tools/tools-online'),
- name: 'toolsOnline',
- meta: { title: '在线指数还原' }
- },
- {
- path: '/tools-ordersearch',
- component: _import('modules/tools/tools-ordersearch'),
- name: 'toolsOrdersearch',
- meta: { title: '淘客订单查询' }
- },
- {
- path: '/tools-starkeysearch',
- component: _import('modules/tools/tools-starkeysearch'),
- name: 'toolsStarkeysearch',
- meta: { title: '淘宝下拉框选词' }
- },
- {
- path: '/tools-pricetrend',
- component: _import('modules/tools/tools-pricetrend'),
- name: 'toolsPricetrend',
- meta: { title: '价格走势' }
- },
- {
- path: '/tools-shopinfo',
- component: _import('modules/tools/tools-shopinfo'),
- name: 'toolsShopinfo',
- meta: { title: '店铺信息查询' }
- },
- {
- path: '/tools-feedback',
- component: _import('modules/tools/tools-feedback'),
- name: 'toolsFeedback',
- meta: { title: '商品评论查询' }
- },
- {
- path: '/tools-productinfo',
- component: _import('modules/tools/tools-productinfo'),
- name: 'toolsProductinfo',
- meta: { title: '商品信息查询' }
- },
- {
- path: '/tools-productaskinfo',
- component: _import('modules/tools/tools-productaskinfo'),
- name: 'toolsProductaskinfo',
- meta: { title: '商品问大家' }
- },
- {
- path: '/tools-promote',
- component: _import('modules/tools/tools-promote'),
- name: 'toolsPromote',
- meta: { title: '淘宝卡首屏' }
- }
- ]
- // 个人中心
- const mineRoutes = [
- {
- path: '/mine',
- component: _import('modules/mine/index'),
- children: [
- {
- path: '',
- component: _import('modules/mine/user'),
- name: 'mine',
- meta: {
- title: '个人中心',
- isTab: true
- }
- },
- {
- path: '/order-check-order',
- component: _import('modules/mine/order/order-check-order'),
- name: 'orderCheckOrder',
- meta: {
- title: '订单查询',
- isTab: true
- }
- },
- {
- path: '/order-check-package',
- component: _import('modules/mine/order/order-check-package'),
- name: 'orderCheckPackage',
- meta: {
- title: '包裹查询',
- isTab: true
- }
- },
- {
- path: '/pay-check',
- component: _import('modules/mine/pay/pay-check'),
- name: 'payCheck',
- meta: {
- title: '充值',
- isTab: true,
- isUseCache: false,
- keepAlive: true
- }
- },
- {
- path: '/pay-wallet',
- component: _import('modules/mine/pay/pay-wallet'),
- name: 'payWallet',
- meta: {
- title: '我的钱包',
- isTab: true,
- isUseCache: false,
- keepAlive: true
- }
- }
- ]
- }
- ]
- // 礼品商城
- const mallRoutes = [
- {
- path: '/mall',
- component: _import('modules/mall/index'),
- name: 'mall',
- meta: {
- title: '礼品商城',
- isUseCache: false
- }
- },
- {
- path: '/mall/goods-detail/:goodsId',
- component: _import('modules/mall/goods-detail'),
- name: 'goodsDetail',
- meta: {
- title: '商品详情',
- isUseCache: false
- }
- },
- {
- path: '/mall/goods-order/:goodsId',
- component: _import('modules/mall/goods-order'),
- name: 'goodsDetail',
- meta: {
- title: '确认订单',
- isUseCache: false
- }
- }
- ]
- // 主入口路由(需嵌套上左右整体布局)
- const mainRoutes = {
- path: '/',
- component: _import('main'),
- name: 'main',
- redirect: { name: 'home' },
- meta: { title: '主入口整体布局' },
- children: [
- // 通过meta对象设置路由展示方式
- // 1. isTab: 是否通过tab展示内容, true: 是, false: 否
- // 2. iframeUrl: 是否通过iframe嵌套展示内容, '以http[s]://开头': 是, '': 否
- // 提示: 如需要通过iframe嵌套展示内容, 但不通过tab打开, 请自行创建组件使用iframe处理!
- { path: '/login', component: _import('modules/account/login'), name: 'login', meta: { title: '登录' } },
- { path: '/register', component: _import('modules/account/register'), name: 'register', meta: { title: '注册' } },
- { path: '/home', component: _import('common/home'), name: 'home', meta: { title: '首页', isTab: true } },
- ...toolsRoutes,
- ...mineRoutes,
- ...mallRoutes
- ]
- }
- const router = new Router({
- mode: 'history',
- scrollBehavior (to, from, savedPosition) {
- if (to.hash) {
- return {
- selector: to.hash
- }
- }
- // keep-alive 返回缓存页面后记录浏览位置
- if (savedPosition && to.meta.keepAlive) {
- return savedPosition
- }
- // 异步滚动操作
- return new Promise((resolve) => {
- setTimeout(() => {
- resolve({ x: 0, y: 1 })
- }, 0)
- })
- },
- isAddDynamicMenuRoutes: false, // 是否已经添加动态(菜单)路由
- routes: globalRoutes.concat(mainRoutes)
- })
- router.beforeEach((to, from, next) => {
- next()
- })
- export default router
|