lazyLoadView使用字符串作为参数

master
toesbieya 6 years ago
parent 59094e384c
commit 428e1e10d9
  1. 4
      vue/src/router/authority/module/message.js
  2. 8
      vue/src/router/authority/module/purchase.js
  3. 8
      vue/src/router/authority/module/sell.js
  4. 2
      vue/src/router/authority/module/stock.js
  5. 12
      vue/src/router/authority/module/system.js
  6. 4
      vue/src/router/constant/module/app.js
  7. 26
      vue/src/router/constant/module/example.js
  8. 7
      vue/src/router/util.js

@ -10,13 +10,13 @@ const router = {
{
path: 'manage',
name: 'messageManagement',
component: lazyLoadView(import('@/view/message/manage/indexPage')),
component: lazyLoadView('message/manage/'),
meta: {title: '消息管理'}
},
{
path: 'user',
name: 'userMessage',
component: lazyLoadView(import('@/view/message/user/indexPage')),
component: lazyLoadView('message/user/'),
meta: {title: '个人消息', noAuth: true, noCache: true}
}
]

@ -10,13 +10,13 @@ const router = {
{
path: 'order',
name: 'purchaseOrder',
component: lazyLoadView(import('@/view/purchase/order/indexPage')),
component: lazyLoadView('purchase/order/'),
meta: {title: '采购订单'}
},
{
path: 'order/detail/:type(see|add|edit)/:id?',
props: true,
component: lazyLoadView(import('@/view/purchase/order/detailPage')),
component: lazyLoadView('purchase/order/detail'),
meta: {
dynamicTitle(to) {
const {type, id} = to.params
@ -37,13 +37,13 @@ const router = {
{
path: 'inbound',
name: 'purchaseInbound',
component: lazyLoadView(import('@/view/purchase/inbound/indexPage')),
component: lazyLoadView('purchase/inbound/'),
meta: {title: '采购入库'}
},
{
path: 'inbound/detail/:type(see|add|edit)/:id?',
props: true,
component: lazyLoadView(import('@/view/purchase/inbound/detailPage')),
component: lazyLoadView('purchase/inbound/detail'),
meta: {
dynamicTitle(to) {
const {type, id} = to.params

@ -10,13 +10,13 @@ const router = {
{
path: 'order',
name: 'sellOrder',
component: lazyLoadView(import('@/view/sell/order/indexPage')),
component: lazyLoadView('sell/order/'),
meta: {title: '销售订单'}
},
{
path: 'order/detail/:type(see|add|edit)/:id?',
props: true,
component: lazyLoadView(import('@/view/sell/order/detailPage')),
component: lazyLoadView('sell/order/detail'),
meta: {
dynamicTitle(to) {
const {type, id} = to.params
@ -37,13 +37,13 @@ const router = {
{
path: 'outbound',
name: 'sellOutbound',
component: lazyLoadView(import('@/view/sell/outbound/indexPage')),
component: lazyLoadView('sell/outbound/'),
meta: {title: '销售出库'}
},
{
path: 'outbound/detail/:type(see|add|edit)/:id?',
props: true,
component: lazyLoadView(import('@/view/sell/outbound/detailPage')),
component: lazyLoadView('sell/outbound/detail'),
meta: {
dynamicTitle(to) {
const {type, id} = to.params

@ -10,7 +10,7 @@ const router = {
{
path: 'current',
name: 'currentStock',
component: lazyLoadView(import('@/view/stock/current/indexPage')),
component: lazyLoadView('stock/current/'),
meta: {title: '当前库存'}
}
]

@ -10,37 +10,37 @@ const router = {
{
path: 'department',
name: 'departmentManagement',
component: lazyLoadView(import('@/view/system/department/indexPage')),
component: lazyLoadView('system/department/'),
meta: {title: '部门管理'}
},
{
path: 'role',
name: 'roleManagement',
component: lazyLoadView(import('@/view/system/role/indexPage')),
component: lazyLoadView('system/role/'),
meta: {title: '角色管理'}
},
{
path: 'user',
name: 'userManagement',
component: lazyLoadView(import('@/view/system/user/indexPage')),
component: lazyLoadView('system/user/'),
meta: {title: '用户管理'}
},
{
path: 'category',
name: 'categorySetting',
component: lazyLoadView(import('@/view/system/category/indexPage')),
component: lazyLoadView('system/category/'),
meta: {title: '商品分类'}
},
{
path: 'customer',
name: 'customerManagement',
component: lazyLoadView(import('@/view/system/customer/indexPage')),
component: lazyLoadView('system/customer/'),
meta: {title: '客户管理'}
},
{
path: 'supplier',
name: 'supplierManagement',
component: lazyLoadView(import('@/view/system/supplier/indexPage')),
component: lazyLoadView('system/supplier/'),
meta: {title: '供应商管理'}
}
]

@ -14,14 +14,14 @@ const router = [
children: [
{
path: 'index',
component: lazyLoadView(import('@/view/index/indexPage')),
component: lazyLoadView('index/'),
name: 'index',
meta: {title: '首页', affix: true, icon: 'home', sort: 0}
},
{
path: 'user',
name: 'userCenter',
component: lazyLoadView(import('@/view/userCenter/indexPage')),
component: lazyLoadView('userCenter/'),
meta: {title: '个人中心', noCache: true, icon: 'user', hidden: true},
}
]

@ -9,12 +9,12 @@ const router = {
children: [
{
path: 'stylePage',
component: lazyLoadView(import('@/view/example/stylePage')),
component: lazyLoadView('example/style'),
meta: {title: '样 式'}
},
{
path: 'icon',
component: lazyLoadView(import('@/view/example/icon/indexPage')),
component: lazyLoadView('example/icon/'),
meta: {title: '图 标'}
},
{
@ -28,12 +28,12 @@ const router = {
children: [
{
path: 'fluid',
component: lazyLoadView(import('@/view/example/cool/fluidPage')),
component: lazyLoadView('example/cool/fluid'),
meta: {title: '流体动画'}
},
{
path: 'l2d',
component: lazyLoadView(import('@/view/example/cool/l2dPage')),
component: lazyLoadView('example/cool/l2d'),
meta: {title: '看板娘'}
},
]
@ -45,44 +45,44 @@ const router = {
children: [
{
path: 'uploadExample',
component: lazyLoadView(import('@/view/example/component/uploadPage')),
component: lazyLoadView('example/component/upload'),
meta: {title: '上传文件'}
},
{
path: 'skeletonExample',
component: lazyLoadView(import('@/view/example/component/skeletonPage')),
component: lazyLoadView('example/component/skeleton'),
meta: {title: '骨架屏'}
},
{
path: 'rippleExample',
component: lazyLoadView(import('@/view/example/component/ripplePage')),
component: lazyLoadView('example/component/ripple'),
meta: {title: '波纹'}
},
{
path: 'signatureExample',
component: lazyLoadView(import('@/view/example/component/signaturePage')),
component: lazyLoadView('example/component/signature'),
meta: {title: '手写签名'}
},
{
path: 'regionSelectorExample',
component: lazyLoadView(import('@/view/example/component/regionSelectorPage')),
component: lazyLoadView('example/component/regionSelector'),
meta: {title: '行政区划选择'}
},
{
path: 'treeSelectExample',
component: lazyLoadView(import('@/view/example/component/treeSelectPage')),
component: lazyLoadView('example/component/treeSelect'),
meta: {title: '树选择'}
}
]
},
{
path: 'developingTest',
component: lazyLoadView(import('@/view/example/developingTest/indexPage')),
component: lazyLoadView('example/developingTest/'),
meta: {title: '开发测试'}
},
{
path: 'detailPage1',
component: lazyLoadView(import('@/view/example/detailPage')),
component: lazyLoadView('example/detail'),
meta: {
title: '详情页缓存1',
usePathKey: true,
@ -91,7 +91,7 @@ const router = {
},
{
path: 'detailPage2',
component: lazyLoadView(import('@/view/example/detailPage')),
component: lazyLoadView('example/detail'),
meta: {
title: '详情页缓存2',
usePathKey: true,

@ -45,8 +45,11 @@ export function metaExtend(routes, parentMeta) {
}
//路由页面懒加载
export function lazyLoadView(component) {
const AsyncHandler = () => ({component, loading: PageSkeleton})
export function lazyLoadView(path) {
if (path.endsWith('/')) path += 'index'
else path = path.replace('Page.vue', '')
const AsyncHandler = () => ({component: import(`@/view/${path}Page.vue`), loading: PageSkeleton})
return () => Promise.resolve({
functional: true,
render(h, {data, children}) {

Loading…
Cancel
Save