u
This commit is contained in:
1 parent
3e172a1d53
commit
401a6719f6
12 files changed
+487
-277
No files matched your search
@@ -83,58 +83,82 @@ function switchTab(tab, index) {
|
||||
moveScroll(index);
|
||||
}
|
||||
|
||||
const HOME_PATH = "/";
|
||||
|
||||
// 关闭标签
|
||||
async function closeTab(tab) {
|
||||
if (tab.fullPath === HOME_PATH) return; // ❗首页不能关
|
||||
|
||||
const activePath = await tabStore.closeTab(tab.fullPath);
|
||||
|
||||
if (activePath && route.fullPath !== activePath) {
|
||||
router.push(activePath);
|
||||
} else if (!activePath) {
|
||||
router.push("/");
|
||||
router.push(HOME_PATH);
|
||||
}
|
||||
}
|
||||
|
||||
// 关闭左侧
|
||||
function closeLeft(data) {
|
||||
const currentIndex = tabStore.tabs.findIndex(
|
||||
(item) => item.fullPath === data.fullPath,
|
||||
);
|
||||
if (currentIndex === -1) return;
|
||||
|
||||
// 关闭左侧所有标签
|
||||
tabStore.tabs.slice(0, currentIndex).forEach((item) => {
|
||||
const index = tabStore.tabs.findIndex((t) => t.fullPath === item.fullPath);
|
||||
if (index !== -1) tabStore.tabs.splice(index, 1);
|
||||
if (item.fullPath === route.fullPath) {
|
||||
router.push(data.fullPath);
|
||||
}
|
||||
});
|
||||
tabStore.tabs
|
||||
.slice(0, currentIndex)
|
||||
.filter((item) => item.fullPath !== HOME_PATH) // ❗过滤首页
|
||||
.forEach((item) => {
|
||||
const index = tabStore.tabs.findIndex(
|
||||
(t) => t.fullPath === item.fullPath,
|
||||
);
|
||||
if (index !== -1) tabStore.tabs.splice(index, 1);
|
||||
|
||||
if (item.fullPath === route.fullPath) {
|
||||
router.push(data.fullPath);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 关闭右侧
|
||||
function closeRight(data) {
|
||||
const currentIndex = tabStore.tabs.findIndex(
|
||||
(item) => item.fullPath === data.fullPath,
|
||||
);
|
||||
if (currentIndex === -1) return;
|
||||
|
||||
tabStore.tabs.slice(currentIndex + 1).forEach((item) => {
|
||||
const index = tabStore.tabs.findIndex((t) => t.fullPath === item.fullPath);
|
||||
if (index !== -1) tabStore.tabs.splice(index, 1);
|
||||
if (item.fullPath === route.fullPath) {
|
||||
router.push(data.fullPath);
|
||||
}
|
||||
});
|
||||
tabStore.tabs
|
||||
.slice(currentIndex + 1)
|
||||
.filter((item) => item.fullPath !== HOME_PATH) // ❗过滤首页
|
||||
.forEach((item) => {
|
||||
const index = tabStore.tabs.findIndex(
|
||||
(t) => t.fullPath === item.fullPath,
|
||||
);
|
||||
if (index !== -1) tabStore.tabs.splice(index, 1);
|
||||
|
||||
if (item.fullPath === route.fullPath) {
|
||||
router.push(data.fullPath);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 关闭其他
|
||||
function closeOther(tab) {
|
||||
tabStore.tabs = tabStore.tabs.filter((t) => t.fullPath === tab.fullPath);
|
||||
tabStore.tabs = tabStore.tabs.filter(
|
||||
(t) => t.fullPath === tab.fullPath || t.fullPath === HOME_PATH, // ❗保留首页
|
||||
);
|
||||
|
||||
router.push(tab.fullPath);
|
||||
}
|
||||
|
||||
// 关闭全部
|
||||
function closeAll() {
|
||||
tabStore.tabs = [];
|
||||
router.push("/");
|
||||
}
|
||||
tabStore.tabs = tabStore.tabs.filter(
|
||||
(t) => t.fullPath === HOME_PATH, // ❗只保留首页
|
||||
);
|
||||
|
||||
router.push(HOME_PATH);
|
||||
}
|
||||
function toHome() {
|
||||
router.push("/");
|
||||
}
|
||||
|
||||
@@ -63,13 +63,22 @@ function logout() {
|
||||
</div>
|
||||
<template #dropdown>
|
||||
<el-dropdown-menu>
|
||||
<el-dropdown-item @click="router.push('/user-center')"
|
||||
>个人中心</el-dropdown-item
|
||||
>
|
||||
<el-dropdown-item @click="router.push('/user-center')">
|
||||
<el-icon class="el-icon--left">
|
||||
<G3Icon icon="lucide:user-round-pen" />
|
||||
</el-icon>
|
||||
个人中心
|
||||
</el-dropdown-item>
|
||||
<el-dropdown-item @click="showUpdatePassword = !showUpdatePassword">
|
||||
<el-icon class="el-icon--left">
|
||||
<G3Icon icon="lucide:lock-keyhole-open" />
|
||||
</el-icon>
|
||||
修改密码
|
||||
</el-dropdown-item>
|
||||
<el-dropdown-item divided @click="logout">
|
||||
<el-icon class="el-icon--left">
|
||||
<G3Icon icon="lucide:arrow-right-from-line" />
|
||||
</el-icon>
|
||||
退出登录
|
||||
</el-dropdown-item>
|
||||
</el-dropdown-menu>
|
||||
|
||||
Reference in new issue
Block a user