明树Git Lab
Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
J
jt_front
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
jt_front
Commits
38c3b1f8
Commit
38c3b1f8
authored
Mar 17, 2026
by
zhanghan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
解决一个路由的bug
parent
99ce2cfd
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
21 deletions
+29
-21
MainLayout.vue
src/layouts/MainLayout.vue
+25
-20
routes.js
src/router/routes.js
+1
-1
index.vue
src/views/login/index.vue
+3
-0
No files found.
src/layouts/MainLayout.vue
View file @
38c3b1f8
...
@@ -38,23 +38,24 @@
...
@@ -38,23 +38,24 @@
<!-- 主内容Main -->
<!-- 主内容Main -->
<el-main
class=
"city-main"
>
<el-main
class=
"city-main"
>
<!-- 路由标签页 -->
<
template
v-if=
"route?.path && isExcludeRoute(route.path)"
>
<div
class=
"tabs-view"
>
<div
class=
"tabs-view"
v-if=
"visitedViews && visitedViews.length > 0"
>
<el-tabs
<el-tabs
v-model=
"activePath"
v-model=
"activePath"
type=
"card"
type=
"card"
closable
closable
@
tab-click=
"handleTabClick"
@
tab-click=
"handleTabClick"
@
tab-remove=
"handleTabRemove"
@
tab-remove=
"handleTabRemove"
>
>
<el-tab-pane
<el-tab-pane
v-for=
"view in visitedViews"
v-for=
"view in visitedViews"
:key=
"view.path"
:key=
"view.path"
:label=
"view.title"
:label=
"view.title"
:name=
"view.path"
:name=
"view.path"
/>
/>
</el-tabs>
</el-tabs>
</div>
</div>
</
template
>
<!-- 路由视图 -->
<!-- 路由视图 -->
<div
class=
"view-content"
>
<div
class=
"view-content"
>
<router-view
/>
<router-view
/>
...
@@ -74,6 +75,12 @@ import axios from "axios"; // watch中使用proxy会有warning
...
@@ -74,6 +75,12 @@ import axios from "axios"; // watch中使用proxy会有warning
const
userStore
=
useUserStore
();
const
userStore
=
useUserStore
();
const
proxyRef
=
ref
(
null
);
const
proxyRef
=
ref
(
null
);
const
{
proxy
}
=
getCurrentInstance
();
const
{
proxy
}
=
getCurrentInstance
();
const
excludeTabs
=
[
"/homePage"
];
// 2. 判断是否包含目标路由的核心方法
const
isExcludeRoute
=
(
path
)
=>
{
return
!
excludeTabs
.
includes
(
path
);
};
// 在 setup 中设置
// 在 setup 中设置
const
instance
=
getCurrentInstance
();
const
instance
=
getCurrentInstance
();
...
@@ -91,19 +98,17 @@ const route = useRoute();
...
@@ -91,19 +98,17 @@ const route = useRoute();
// ========== 路由标签页相关 ==========
// ========== 路由标签页相关 ==========
const
visitedViews
=
ref
([]);
// 已访问的路由列表
const
visitedViews
=
ref
([]);
// 已访问的路由列表
const
activePath
=
ref
(
""
);
// 当前激活的路由路径
const
activePath
=
ref
(
""
);
// 当前激活的路由路径
// 添加路由到已访问列表
// 添加路由到已访问列表
const
addView
=
(
view
)
=>
{
const
addView
=
(
view
)
=>
{
// 检查路由是否已存在
// 检查路由是否已存在
const
index
=
visitedViews
.
value
.
findIndex
((
v
)
=>
v
.
path
===
view
.
path
);
const
index
=
visitedViews
.
value
.
findIndex
((
v
)
=>
v
.
path
===
view
.
path
);
if
(
index
===
-
1
)
{
if
(
index
===
-
1
)
{
console
.
log
(
view
,
"viewview"
);
// 不存在则添加,优先使用 title,其次 meta.title,最后 name
// 不存在则添加,优先使用 title,其次 meta.title,最后 name
visitedViews
.
value
.
push
({
visitedViews
.
value
.
push
({
path
:
view
.
path
,
path
:
view
.
path
,
title
:
view
.
title
||
view
.
meta
?.
title
||
view
.
name
||
"未命名"
,
title
:
view
.
title
||
view
.
meta
?.
title
||
view
.
name
||
"未命名"
,
});
});
console
.
log
(
visitedViews
,
"visitedViewsvisitedViews"
);
}
}
// 设置当前激活的路由
// 设置当前激活的路由
activePath
.
value
=
view
.
path
;
activePath
.
value
=
view
.
path
;
...
...
src/router/routes.js
View file @
38c3b1f8
...
@@ -12,7 +12,7 @@ const routes = [
...
@@ -12,7 +12,7 @@ const routes = [
name
:
"gzbPage"
,
name
:
"gzbPage"
,
title
:
"数据大屏"
,
title
:
"数据大屏"
,
component
:
()
=>
import
(
"@/views/homePage/index.vue"
),
component
:
()
=>
import
(
"@/views/homePage/index.vue"
),
meta
:
{
nopermission
:
true
,
title
:
"数据大屏"
},
meta
:
{
nopermission
:
true
,
title
:
"数据大屏"
,
hideTabs
:
false
},
},
},
{
{
path
:
"/"
,
path
:
"/"
,
...
...
src/views/login/index.vue
View file @
38c3b1f8
...
@@ -197,6 +197,9 @@ const handleLogin = async () => {
...
@@ -197,6 +197,9 @@ const handleLogin = async () => {
}
}
.login-btn {
.login-btn {
&:hover {
background-color: #40a9ff;
}
width: 100%;
width: 100%;
height: 36px;
height: 36px;
border-radius: 4px;
border-radius: 4px;
...
...
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