当前,私域直播正处在风口时期,很多企业老板都开始尝试私域,但是却不知道从何下手。
2025年08月18日
下面是为 Pinia Store 增加关闭所有标签页、关闭其他标签页、关闭左侧标签页和关闭右侧标签页功能的完整实现:
const useTabStore = defineStore('tabs', {
state: () => ({
tabs: [], // 标签页数组
activeTab: '', // 当前激活的标签页
cachedViews: [] // 需要缓存的视图名称
}),
actions: {
// 添加标签页
addTab(route) {
// 检查标签页是否已存在
const exists = this.tabs.some(tab => tab.path === route.path);
if (!exists) {
this.tabs.push({
title: route.meta.title,
path: route.path,
name: route.name,
meta: route.meta
});
// 如果路由需要缓存,则添加到缓存列表
if (route.meta.keepAlive && !this.cachedViews.includes(route.name)) {
this.cachedViews.push(route.name);
}
}
// 设置当前激活的标签页
this.activeTab = route.path;
},
// 关闭标签页
closeTab(tab) {
// 从标签页列表中移除
this.tabs = this.tabs.filter(t => t.path !== tab.path);
// 如果关闭的是当前激活的标签页
if (this.activeTab === tab.path) {
// 激活最后一个标签页
const lastTab = this.tabs[this.tabs.length - 1];
if (lastTab) {
router.push(lastTab.path);
this.activeTab = lastTab.path;
} else {
// 如果没有标签页了,跳转到首页
router.push('/');
}
}
// 如果关闭的是需要缓存的标签页,从缓存中移除
if (tab.meta?.keepAlive) {
this.cachedViews = this.cachedViews.filter(name => name !== tab.name);
}
},
// 切换标签页
switchTab(tab) {
router.push(tab.path);
this.activeTab = tab.path;
},
// 关闭所有标签页
closeAllTabs() {
// 保留首页(如果存在)
const homeTab = this.tabs.find(tab => tab.path === '/');
// 清空标签页数组
this.tabs = [];
// 清空缓存
this.cachedViews = [];
// 如果首页存在,重新添加首页
if (homeTab) {
this.tabs.push(homeTab);
if (homeTab.meta.keepAlive) {
this.cachedViews.push(homeTab.name);
}
router.push('/');
this.activeTab = '/';
} else {
// 如果没有首页,跳转到首页
router.push('/');
this.addTab(router.currentRoute.value);
}
},
// 关闭其他标签页(保留当前页和首页)
closeOtherTabs() {
const currentTab = this.tabs.find(tab => tab.path === this.activeTab);
const homeTab = this.tabs.find(tab => tab.path === '/');
// 保留当前页和首页
const tabsToKeep = [];
if (homeTab) tabsToKeep.push(homeTab);
if (currentTab && currentTab.path !== '/') tabsToKeep.push(currentTab);
// 过滤掉不需要保留的标签页
const tabsToClose = this.tabs.filter(tab => !tabsToKeep.includes(tab));
// 更新标签页列表
this.tabs = tabsToKeep;
// 更新缓存列表
this.cachedViews = this.tabs
.filter(tab => tab.meta.keepAlive)
.map(tab => tab.name);
// 如果当前页被关闭了,跳转到首页
if (!currentTab || !tabsToKeep.includes(currentTab)) {
router.push('/');
this.activeTab = '/';
}
},
// 关闭左侧标签页
closeLeftTabs() {
const currentIndex = this.tabs.findIndex(tab => tab.path === this.activeTab);
if (currentIndex > 1) { // 左侧有标签页需要关闭
// 获取需要关闭的标签页
const tabsToClose = this.tabs.slice(0, currentIndex);
// 保留首页(如果首页在左侧)
const homeTab = this.tabs.find(tab => tab.path === '/');
if (homeTab && tabsToClose.includes(homeTab)) {
// 首页保留
this.tabs = [homeTab, ...this.tabs.slice(currentIndex)];
} else {
// 没有首页,直接保留右侧
this.tabs = this.tabs.slice(currentIndex);
}
// 更新缓存列表
this.cachedViews = this.tabs
.filter(tab => tab.meta.keepAlive)
.map(tab => tab.name);
}
},
// 关闭右侧标签页
closeRightTabs() {
const currentIndex = this.tabs.findIndex(tab => tab.path === this.activeTab);
if (currentIndex < this.tabs.length - 1) { // 右侧有标签页需要关闭
// 获取需要关闭的标签页
const tabsToClose = this.tabs.slice(currentIndex + 1);
// 保留首页(如果首页在右侧)
const homeTab = this.tabs.find(tab => tab.path === '/');
if (homeTab && tabsToClose.includes(homeTab)) {
// 首页保留
this.tabs = [...this.tabs.slice(0, currentIndex + 1), homeTab];
} else {
// 没有首页,直接保留左侧
this.tabs = this.tabs.slice(0, currentIndex + 1);
}
// 更新缓存列表
this.cachedViews = this.tabs
.filter(tab => tab.meta.keepAlive)
.map(tab => tab.name);
}
},
// 关闭除首页外的所有标签页
closeAllExceptHome() {
const homeTab = this.tabs.find(tab => tab.path === '/');
if (homeTab) {
// 只保留首页
this.tabs = [homeTab];
this.cachedViews = homeTab.meta.keepAlive ? [homeTab.name] : [];
if (this.activeTab !== '/') {
router.push('/');
this.activeTab = '/';
}
} else {
// 如果首页不存在,则跳转到首页并添加
router.push('/');
this.addTab(router.currentRoute.value);
}
}
}
});
2025年08月18日
在当今数字化业务场景中,企业上传至云端的文件种类繁多,从图片、视频、日志、备份,到各种静态资源,如何在阿里云OSS中实现有序分类管理,是使用过程中的高频问题之一。
作为阿里云OSS代理商,我们在实际服务客户时,常会被问到:“OSS能不能像本地文件夹一样给文件分类?”其实,虽然OSS是对象存储,不具备真正的文件系统目录结构,但通过合理设计“对象前缀”,完全可以实现灵活、可控的
2025年08月18日
你的错题本是否记满就落灰?花费时间整理却收效甚微?问题可能出在方法上!今天揭秘学霸圈盛行的“三色标记法”,让错题本真正成为你的提分利器。
核心法则:用红、蓝、绿三色笔精准标记,分类攻克。
2025年08月18日
产品多了,分类(Categories)和标签(Tags)是WordPress管理内容的好帮手。但用不好,反而害了你的独立站SEO和用户体验!
分类 vs 标签:
2025年08月18日
天眼查APP显示,近日,郑州畅想高科股份有限公司申请的“一种基于智能多标签分类的乘务员服饰识别方法及装置”专利公布。 摘要显示,本发明涉及一种基于智能多标签分类的乘务员服饰识别方法及装置,属于计算机视觉与人工智能技术领域。本发明考虑到服饰与身体部位的关联性,在利用乘务员图像对进行服饰识别时,将对乘务员图像中的关键骨骼点坐标对应的特征与乘务员图像特征进行融合得到融合特征,利用多标签分类模型对融合特征进行处理,以实现对乘务员服饰的识别。本发明在进行识别时,通过关键骨骼点坐标的补偿,提高了乘务员服饰识别精度。此外,本发明通过关键骨骼点坐标匹配的方式来触发后续识别,减少了不必要无效检测。
2025年08月18日
在数字化办公和生活的时代,截图和文件加密是我们经常会用到的功能。一个好用的截图工具,能让我们高效记录屏幕内容;一款可靠的文件夹加密工具,则能为我们的重要文件保驾护航。今天,就给大家深度剖析两款在各自领域表现出色的实用工具——xsnip截图v1.1.0.10和文件夹加密工具6.30 。
xsnip截图v1.1.0.10:小身材,大能量
酷似QQ截图,上手0难度
对于经常使用QQ截图的用户来说,xsnip截图简直是福音。它的操作界面和使用习惯与QQ截图极为相似 ,当你打开xsnip截图,那种熟悉感扑面而来,无需花费额外时间去学习新的操作技巧,就能迅速上手,大大提升了截图效率。
2025年08月18日
初创团队,最怕听到 “这个任务该谁做”—— 有人同时管产品、运营、客服,有人上午写文案下午改代码,任务像一团乱麻缠在一起。根据 2025 年初创团队效率报告,72% 的早期项目延误源于 “职责模糊”:不是没人做事,而是不知道该谁做事。