提交
This commit is contained in:
1 parent
2df2ef0808
commit
683f14828f
388 files changed
+2738488
-81306
No files matched your search
@@ -7,12 +7,15 @@ import { collectPortalHomeSections, findHomeCardByPath } from '@/utils/router/po
|
||||
const PREOPEN_FLAG_KEY = 'portal-favorites-preopened-user'
|
||||
|
||||
/**
|
||||
* 冷登录:按收藏预开 Tab,当前仍停在首页。
|
||||
* 冷登录:按收藏预开 Tab。
|
||||
* 有有效收藏时激活第一个收藏页;否则落点首页。
|
||||
* 同用户刷新且已有业务 Tab 时跳过(依赖 worktab 本地持久化)。
|
||||
*
|
||||
* @returns 落点 path;未执行预开则返回 null
|
||||
*/
|
||||
/** @returns 是否执行了冷登录预开(调用方应落点首页) */
|
||||
export async function preopenFavoriteTabsIfNeeded(userId: string): Promise<boolean> {
|
||||
if (!userId) return false
|
||||
export async function preopenFavoriteTabsIfNeeded(userId: string): Promise<string | null> {
|
||||
const uid = String(userId || '').trim()
|
||||
if (!uid) return null
|
||||
|
||||
const home = HOME_PAGE_PATH || '/home'
|
||||
const worktab = useWorktabStore()
|
||||
@@ -21,12 +24,12 @@ export async function preopenFavoriteTabsIfNeeded(userId: string): Promise<boole
|
||||
)
|
||||
// 刷新恢复:已有业务 Tab 则不再按收藏重开
|
||||
if (hasBusinessTabs) {
|
||||
sessionStorage.setItem(PREOPEN_FLAG_KEY, userId)
|
||||
return false
|
||||
sessionStorage.setItem(PREOPEN_FLAG_KEY, uid)
|
||||
return null
|
||||
}
|
||||
// 同会话已预开过(仅首页等)则跳过
|
||||
if (sessionStorage.getItem(PREOPEN_FLAG_KEY) === userId) {
|
||||
return false
|
||||
if (sessionStorage.getItem(PREOPEN_FLAG_KEY) === uid) {
|
||||
return null
|
||||
}
|
||||
|
||||
const favStore = useMenuFavoriteStore()
|
||||
@@ -45,6 +48,7 @@ export async function preopenFavoriteTabsIfNeeded(userId: string): Promise<boole
|
||||
{ activate: true }
|
||||
)
|
||||
|
||||
let firstFavPath: string | null = null
|
||||
for (const item of [...favStore.items]) {
|
||||
const card = findHomeCardByPath(sections, item.path)
|
||||
if (!card) {
|
||||
@@ -59,6 +63,10 @@ export async function preopenFavoriteTabsIfNeeded(userId: string): Promise<boole
|
||||
if (!resolved.matched.length) {
|
||||
continue
|
||||
}
|
||||
const isFirst = firstFavPath == null
|
||||
if (isFirst) {
|
||||
firstFavPath = card.path
|
||||
}
|
||||
worktab.openTab(
|
||||
{
|
||||
path: card.path,
|
||||
@@ -67,12 +75,12 @@ export async function preopenFavoriteTabsIfNeeded(userId: string): Promise<boole
|
||||
fixedTab: false,
|
||||
keepAlive: true
|
||||
},
|
||||
{ activate: false }
|
||||
{ activate: isFirst }
|
||||
)
|
||||
}
|
||||
|
||||
sessionStorage.setItem(PREOPEN_FLAG_KEY, userId)
|
||||
return true
|
||||
sessionStorage.setItem(PREOPEN_FLAG_KEY, uid)
|
||||
return firstFavPath || home
|
||||
}
|
||||
|
||||
export function clearFavoritePreopenFlag(): void {
|
||||
|
||||
Reference in new issue
Block a user