From f3bde7e1116787ac34da4a2974374b4915e5bd54 Mon Sep 17 00:00:00 2001
From: YANGDL <114714267@qq.com>
Date: 星期二, 05 一月 2021 16:56:17 +0800
Subject: [PATCH] 优化逻辑
---
src/router/map.js | 18 ++++++++++++++++++
src/router/routes.js | 13 ++++---------
src/main.js | 1 +
src/router/index.js | 18 +++++++++++++++++-
4 files changed, 40 insertions(+), 10 deletions(-)
diff --git a/src/main.js b/src/main.js
index 4de11ed..e609408 100644
--- a/src/main.js
+++ b/src/main.js
@@ -11,6 +11,7 @@
Vue.config.productionTip = false
Vue.use(ElementUI, { size: 'small' })
+Vue.prototype.$cancels = []
// 娉ㄥ唽鎸囦护
// registerDirectives(Vue)
diff --git a/src/router/index.js b/src/router/index.js
index 7477bf9..99f1696 100644
--- a/src/router/index.js
+++ b/src/router/index.js
@@ -11,5 +11,21 @@
mode: routeMode || 'hash',
routes: routes
})
-
+router.beforeEach((to, from, next) => {
+ Vue.prototype.$cancels.forEach((cancel) => {
+ cancel()
+ })
+ Vue.prototype.$cancels = []
+ // 涓嶉渶瑕佺櫥褰曡璇佺殑璺敱
+ if (Object.hasOwnProperty.call(to.meta, 'noLoginIdentify') && to.meta.noLoginIdentify) {
+ next()
+ return
+ }
+ next()
+})
+router.beforeResolve((to, from, next) => {
+ next()
+})
+router.afterEach((to, from) => {
+})
export default router
diff --git a/src/router/map.js b/src/router/map.js
new file mode 100644
index 0000000..7847ce1
--- /dev/null
+++ b/src/router/map.js
@@ -0,0 +1,18 @@
+/**
+ * meta鍙厤缃殑鍙傛暟:
+ * meta: {
+ * title: { String } 鏄剧ず鍦ㄤ晶杈规爮銆侀潰鍖呭睉鍜屾爣绛炬爮鐨勬枃瀛�
+ * hideBread: (false) 璁句负true鍚庢绾ц矾鐢卞皢涓嶄細鍑虹幇鍦ㄩ潰鍖呭睉涓�
+ * hideMenu: (false) 璁句负true鍚庡湪宸︿晶鑿滃崟涓嶄細鏄剧ず璇ラ〉闈㈤�夐」
+ * notCache: (false) 璁句负true鍚庨〉闈㈠湪鍒囨崲鏍囩鍚庝笉浼氱紦瀛橈紝濡傛灉闇�瑕佺紦瀛橈紝鏃犻渶璁剧疆杩欎釜瀛楁锛岃�屼笖闇�瑕佽缃〉闈㈢粍浠秐ame灞炴�у拰璺敱閰嶇疆鐨刵ame涓�鑷�
+ * access: (null) 鍙闂椤甸潰鐨勬潈闄愭暟缁勶紝褰撳墠璺敱璁剧疆鐨勬潈闄愪細褰卞搷瀛愯矾鐢�
+ * }
+ */
+const MapTemplate = (r) => require.ensure([], () => r(require('../views/MapTemplate')), 'frame')
+// const MapHomeMapTalks = r => require.ensure([], () => r(require('../views/map/MapHome-maptalks')), 'web')
+const routes = [
+ { path: '/mapTemplate', name: 'MapTemplate', meta: { statusBgc: 0 }, component: MapTemplate }
+]
+
+// 鎵�鏈変笂闈㈠畾涔夌殑璺敱閮借鍐欏湪涓嬮潰鐨剅outes閲�
+export const mapRoutes = routes
diff --git a/src/router/routes.js b/src/router/routes.js
index a27e957..2bdac51 100644
--- a/src/router/routes.js
+++ b/src/router/routes.js
@@ -8,24 +8,18 @@
* access: (null) 鍙闂椤甸潰鐨勬潈闄愭暟缁勶紝褰撳墠璺敱璁剧疆鐨勬潈闄愪細褰卞搷瀛愯矾鐢�
* }
*/
+import { mapRoutes } from '@router/map'
// 榛樿璺宠浆璺敱
import PipeLineIndex from '../views/baseInfoMgr/pipeline/PipeLineIndex'
import MapTemplate from '../views/MapTemplate'
// 搴旂敤涓氬姟鐩稿叧璺敱锛屾寕杞絤enu涓婄殑page
-export const routes = [{
+const mainRoutes = [{
path: '/',
name: 'Main',
component: MapTemplate,
- redirect: '/home',
+ redirect: '/mapTemplate',
children: [{
- path: 'home',
- name: 'Home',
- meta: {
- title: '棣栭〉'
- },
- component: MapTemplate
- }, {
path: 'baseInfoMgr/pipeLine',
name: 'baseInfoMgr',
component: PipeLineIndex,
@@ -34,3 +28,4 @@
}
}]
}]
+export const routes = [...mainRoutes, ...mapRoutes]
--
Gitblit v1.8.0