Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
B
bill-manager-ui
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
赵啸非
bill-manager-ui
Commits
3eeb7834
Commit
3eeb7834
authored
Dec 02, 2024
by
“yiyousong”
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
perf: 优化
parent
29cd91b8
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
52 additions
and
42 deletions
+52
-42
admin_2/src/router/index.js
admin_2/src/router/index.js
+52
-42
No files found.
admin_2/src/router/index.js
View file @
3eeb7834
import
Vue
from
"
vue
"
;
import
Vue
from
'
vue
'
;
import
VueRouter
from
"
vue-router
"
;
import
VueRouter
from
'
vue-router
'
;
import
Layouts
from
"
@/layouts/Layouts.vue
"
;
import
Layouts
from
'
@/layouts/Layouts.vue
'
;
import
store
from
"
@/store
"
;
import
store
from
'
@/store
'
;
import
{
generateRoutes
}
from
"
@/utils
"
;
import
{
generateRoutes
}
from
'
@/utils
'
;
// import local from "@/utils/local";
// import local from "@/utils/local";
// 解决重复点击同一个路由报错
// 解决重复点击同一个路由报错
const
originalPush
=
VueRouter
.
prototype
.
push
;
const
originalPush
=
VueRouter
.
prototype
.
push
;
...
@@ -13,10 +13,10 @@ Vue.use(VueRouter);
...
@@ -13,10 +13,10 @@ Vue.use(VueRouter);
const
routes
=
[
const
routes
=
[
{
{
path
:
"
/
"
,
path
:
'
/
'
,
name
:
"
/
"
,
name
:
'
/
'
,
component
:
Layouts
,
component
:
Layouts
,
redirect
:
"
/sso
"
,
redirect
:
'
/sso
'
,
children
:
[
children
:
[
// {
// {
// path: "/home",
// path: "/home",
...
@@ -59,35 +59,35 @@ const routes = [
...
@@ -59,35 +59,35 @@ const routes = [
// },
// },
// 数据搜索引擎
// 数据搜索引擎
{
{
path
:
"
/enginesearch
"
,
path
:
'
/enginesearch
'
,
component
:
()
=>
import
(
"
@/pages/engineSearch/EngineSearch
"
),
component
:
()
=>
import
(
'
@/pages/engineSearch/EngineSearch
'
),
hidden
:
true
,
hidden
:
true
,
redirect
:
"
/enginesearch/queueupdata
"
,
redirect
:
'
/enginesearch/queueupdata
'
,
children
:
[
children
:
[
{
{
path
:
"
/enginesearch/queueupdata
"
,
path
:
'
/enginesearch/queueupdata
'
,
hideChildrenInMenu
:
true
,
hideChildrenInMenu
:
true
,
hidden
:
true
,
hidden
:
true
,
component
:
()
=>
import
(
"
@/pages/engineSearch/QueueUpData
"
),
component
:
()
=>
import
(
'
@/pages/engineSearch/QueueUpData
'
),
meta
:
{
meta
:
{
title
:
"
排队数据
"
,
title
:
'
排队数据
'
,
activeMenu
:
"
/engine
"
,
activeMenu
:
'
/engine
'
,
parentPath
:
"
/enginesearch
"
,
parentPath
:
'
/enginesearch
'
}
,
}
},
},
{
{
path
:
"
/enginesearch/evaluatedata
"
,
path
:
'
/enginesearch/evaluatedata
'
,
hideChildrenInMenu
:
true
,
hideChildrenInMenu
:
true
,
hidden
:
true
,
hidden
:
true
,
component
:
()
=>
import
(
"
@/pages/engineSearch/EvaluateData
"
),
component
:
()
=>
import
(
'
@/pages/engineSearch/EvaluateData
'
),
meta
:
{
meta
:
{
title
:
"
评价数据
"
,
title
:
'
评价数据
'
,
activeMenu
:
"
/engine
"
,
activeMenu
:
'
/engine
'
,
parentPath
:
"
/enginesearch
"
,
parentPath
:
'
/enginesearch
'
}
,
}
}
,
}
]
,
]
}
,
}
// {
// {
// path: "/market",
// path: "/market",
...
@@ -216,38 +216,48 @@ const routes = [
...
@@ -216,38 +216,48 @@ const routes = [
// },
// },
// ],
// ],
// },
// },
]
,
]
},
},
{
{
path
:
"
/sso
"
,
path
:
'
/sso
'
,
name
:
"
跳转页
"
,
name
:
'
跳转页
'
,
hidden
:
true
,
hidden
:
true
,
component
:
()
=>
import
(
"
@/pages/sso/Sso
"
),
component
:
()
=>
import
(
'
@/pages/sso/Sso
'
)
},
},
{
{
path
:
"
/login
"
,
path
:
'
/login
'
,
name
:
"
登录页
"
,
name
:
'
登录页
'
,
hidden
:
true
,
hidden
:
true
,
component
:
()
=>
import
(
"
@/pages/login/Login
"
),
component
:
()
=>
import
(
'
@/pages/login/Login
'
)
},
},
{
{
path
:
"
*
"
,
path
:
'
*
'
,
component
:
()
=>
import
(
"
@/pages/404/404.vue
"
),
component
:
()
=>
import
(
'
@/pages/404/404.vue
'
),
hidden
:
true
,
hidden
:
true
}
,
}
];
];
const
router
=
new
VueRouter
({
const
router
=
new
VueRouter
({
routes
,
routes
,
scrollBehavior
(
to
,
from
,
savedPosition
)
{
// savedPosition 会在你使用浏览器前进或后退按钮时候生效
// savedPosition: 会记录滚动条的坐标,点击"后退/前进" 时的记录值(x:?,y:?)
if
(
savedPosition
)
{
return
savedPosition
;
}
else
{
// 期望滚动的位置
return
{
x
:
0
,
y
:
0
,
behavior
:
'
smooth
'
};
}
}
});
});
// 前置路由卫士
// 前置路由卫士
router
.
beforeEach
((
to
,
from
,
next
)
=>
{
router
.
beforeEach
((
to
,
from
,
next
)
=>
{
let
islogin
=
store
.
getters
[
"
user/token
"
];
let
islogin
=
store
.
getters
[
'
user/token
'
];
if
(
islogin
)
{
if
(
islogin
)
{
next
();
next
();
}
else
{
}
else
{
if
(
to
.
path
===
"
/sso
"
||
to
.
path
===
"
/login
"
)
{
if
(
to
.
path
===
'
/sso
'
||
to
.
path
===
'
/login
'
)
{
next
();
next
();
}
else
{
}
else
{
location
.
href
=
process
.
env
.
VUE_APP_API_portal_URL
;
location
.
href
=
process
.
env
.
VUE_APP_API_portal_URL
;
...
@@ -269,13 +279,13 @@ function menusFilter(arr) {
...
@@ -269,13 +279,13 @@ function menusFilter(arr) {
}
}
// 动态菜单
// 动态菜单
export
function
calcMenu
()
{
export
function
calcMenu
()
{
let
menusList
=
store
.
getters
[
"
user/menusList
"
];
let
menusList
=
store
.
getters
[
'
user/menusList
'
];
let
dynamicRouter
=
generateRoutes
(
menusList
);
let
dynamicRouter
=
generateRoutes
(
menusList
);
dynamicRouter
.
forEach
((
v
)
=>
{
dynamicRouter
.
forEach
((
v
)
=>
{
router
.
addRoute
(
"
/
"
,
v
);
router
.
addRoute
(
'
/
'
,
v
);
});
});
let
menus
=
menusFilter
(
dynamicRouter
);
let
menus
=
menusFilter
(
dynamicRouter
);
store
.
commit
(
"
user/SET_menus
"
,
menus
);
store
.
commit
(
'
user/SET_menus
'
,
menus
);
}
}
calcMenu
();
calcMenu
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment