Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
sheng du
CountingDreams
Commits
360dbb0b
Commit
360dbb0b
authored
1 year ago
by
sheng du
Browse files
Options
Download
Email Patches
Plain Diff
未登录判断
parent
00fc4c57
master
No related merge requests found
Pipeline
#804
failed with stages
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
14 deletions
+23
-14
src/components/App/BreadCrumb/index.vue
src/components/App/BreadCrumb/index.vue
+10
-10
src/components/App/SideBar/index.vue
src/components/App/SideBar/index.vue
+2
-2
src/router/index.js
src/router/index.js
+11
-2
No files found.
src/components/App/BreadCrumb/index.vue
View file @
360dbb0b
...
...
@@ -30,11 +30,11 @@ export default {
computed
:
{
paths
()
{
const
matched
=
this
.
$route
.
matched
.
filter
(
(
item
)
=>
item
.
meta
&&
item
.
meta
.
title
(
item
)
=>
item
?
.
meta
&&
item
?
.
meta
.
title
);
this
.
changeRouter
(
matched
);
// console.log(matched.filter((item) => item.meta && item.meta.title));
return
matched
.
filter
((
item
)
=>
(
item
.
meta
?
item
.
meta
.
title
:
""
));
return
matched
.
filter
((
item
)
=>
(
item
?
.
meta
?
item
?
.
meta
.
title
:
""
));
},
pageName
()
{
return
this
.
$route
.
matched
[
this
.
$route
.
matched
.
length
-
1
]?.
meta
?.
title
;
...
...
@@ -53,16 +53,16 @@ export default {
if
(
matched
.
length
>
1
)
{
matched
=
[
matched
[
matched
.
length
-
1
]];
}
if
(
matched
[
0
].
meta
.
disTab
)
{
if
(
matched
[
0
]
?
.
meta
.
disTab
)
{
return
;
}
//从左侧导航打开页面时添加在头部导航,没有则只定位
let
paths
=
this
.
pathList
.
map
((
item
)
=>
item
.
path
);
if
(
paths
.
includes
(
matched
[
0
].
path
))
{
this
.
activeName
=
matched
[
0
].
path
;
let
paths
=
this
.
pathList
.
map
((
item
)
=>
item
?
.
path
);
if
(
paths
.
includes
(
matched
[
0
]
?
.
path
))
{
this
.
activeName
=
matched
[
0
]
?
.
path
;
}
else
{
this
.
pathList
=
[...
this
.
pathList
,
...
matched
];
this
.
activeName
=
matched
[
0
].
path
;
this
.
activeName
=
matched
[
0
]
?
.
path
;
}
// this.pathList = [...this.pathList, ...matched];
// console.log(this.pathList);
...
...
@@ -75,17 +75,17 @@ export default {
return
;
}
//删除缓存页面
let
findItem
=
this
.
pathList
.
find
((
item
)
=>
item
.
path
==
targetName
);
let
findItem
=
this
.
pathList
.
find
((
item
)
=>
item
?
.
path
==
targetName
);
// console.log(findItem);
this
.
$store
.
dispatch
(
"
app/removeCacheRoutes
"
,
findItem
.
name
);
if
(
findItem
.
parent
)
{
this
.
$store
.
dispatch
(
"
app/removeCacheRoutes
"
,
findItem
.
parent
.
name
);
}
//从列表去掉
this
.
pathList
=
this
.
pathList
.
filter
((
item
)
=>
item
.
path
!=
targetName
);
this
.
pathList
=
this
.
pathList
.
filter
((
item
)
=>
item
?
.
path
!=
targetName
);
if
(
this
.
$route
.
path
==
targetName
)
{
//关闭当前页面跳转到最后一个页面
this
.
$router
.
replace
(
this
.
pathList
[
this
.
pathList
.
length
-
1
].
path
);
this
.
$router
.
replace
(
this
.
pathList
[
this
.
pathList
.
length
-
1
]
?
.
path
);
// this.activeName = matched[0].path;
}
}
...
...
This diff is collapsed.
Click to expand it.
src/components/App/SideBar/index.vue
View file @
360dbb0b
...
...
@@ -27,7 +27,7 @@ export default {
console
.
log
(
allMenu
);
// let findFatherItem = allMenu;
return
allMenu
;
return
allMenu
||
[]
;
// let findFatherItem = allMenu.find(
// (item) => item.name == this.mainMenuName
// );
...
...
@@ -70,7 +70,7 @@ export default {
res
=
res
.
filter
(
(
item
)
=>
!
item
.
meta
.
hidden
&&
this
.
userAuth
.
includes
(
item
.
name
)
);
return
res
.
length
?
res
:
null
;
return
res
?
.
length
?
res
:
null
;
},
routeTo
(
indexs
)
{
let
path
=
""
;
...
...
This diff is collapsed.
Click to expand it.
src/router/index.js
View file @
360dbb0b
...
...
@@ -76,6 +76,7 @@ const routes = [
},
{
path
:
"
/login
"
,
name
:
'
login
'
,
component
:
()
=>
import
(
/* webpackChunkName: "accout" */
"
@/views/login.vue
"
),
// redirect: "/index"
...
...
@@ -97,11 +98,19 @@ const router = new VueRouter({
});
router
.
beforeEach
((
to
,
from
,
next
)
=>
{
// console.log(to, from);
let
userAuth
=
store
.
state
.
user
.
userAuth
;
console
.
log
(
to
,
userAuth
);
if
(
to
.
meta
.
keepAlive
)
{
store
.
dispatch
(
"
app/addCacheRoutes
"
,
to
.
name
);
}
next
();
if
(
(
userAuth
&&
userAuth
.
includes
(
to
.
matched
[
0
]?.
name
))
||
[
"
login
"
].
includes
(
to
.
matched
[
0
]?.
name
)
)
{
next
();
}
else
{
router
.
replace
(
"
/login
"
);
}
});
router
.
addRoutes
(
asyncRoutes
);
...
...
This diff is collapsed.
Click to expand it.
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