明树Git Lab

Commit 38c3b1f8 authored by zhanghan's avatar zhanghan

解决一个路由的bug

parent 99ce2cfd
......@@ -38,23 +38,24 @@
<!-- 主内容Main -->
<el-main class="city-main">
<!-- 路由标签页 -->
<div class="tabs-view">
<el-tabs
v-model="activePath"
type="card"
closable
@tab-click="handleTabClick"
@tab-remove="handleTabRemove"
>
<el-tab-pane
v-for="view in visitedViews"
:key="view.path"
:label="view.title"
:name="view.path"
/>
</el-tabs>
</div>
<template v-if="route?.path && isExcludeRoute(route.path)">
<div class="tabs-view" v-if="visitedViews && visitedViews.length > 0">
<el-tabs
v-model="activePath"
type="card"
closable
@tab-click="handleTabClick"
@tab-remove="handleTabRemove"
>
<el-tab-pane
v-for="view in visitedViews"
:key="view.path"
:label="view.title"
:name="view.path"
/>
</el-tabs>
</div>
</template>
<!-- 路由视图 -->
<div class="view-content">
<router-view />
......@@ -74,6 +75,12 @@ import axios from "axios"; // watch中使用proxy会有warning
const userStore = useUserStore();
const proxyRef = ref(null);
const { proxy } = getCurrentInstance();
const excludeTabs = ["/homePage"];
// 2. 判断是否包含目标路由的核心方法
const isExcludeRoute = (path) => {
return !excludeTabs.includes(path);
};
// 在 setup 中设置
const instance = getCurrentInstance();
......@@ -91,19 +98,17 @@ const route = useRoute();
// ========== 路由标签页相关 ==========
const visitedViews = ref([]); // 已访问的路由列表
const activePath = ref(""); // 当前激活的路由路径
// 添加路由到已访问列表
const addView = (view) => {
// 检查路由是否已存在
const index = visitedViews.value.findIndex((v) => v.path === view.path);
if (index === -1) {
console.log(view, "viewview");
// 不存在则添加,优先使用 title,其次 meta.title,最后 name
visitedViews.value.push({
path: view.path,
title: view.title || view.meta?.title || view.name || "未命名",
});
console.log(visitedViews, "visitedViewsvisitedViews");
}
// 设置当前激活的路由
activePath.value = view.path;
......
......@@ -12,7 +12,7 @@ const routes = [
name: "gzbPage",
title: "数据大屏",
component: () => import("@/views/homePage/index.vue"),
meta: { nopermission: true, title: "数据大屏" },
meta: { nopermission: true, title: "数据大屏", hideTabs: false },
},
{
path: "/",
......
......@@ -197,6 +197,9 @@ const handleLogin = async () => {
}
.login-btn {
&:hover {
background-color: #40a9ff;
}
width: 100%;
height: 36px;
border-radius: 4px;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment