fix: 重新登录后页签清空只保留固定页签
This commit is contained in:
parent
46f8d918db
commit
5ec2d573b7
|
|
@ -255,12 +255,23 @@ export const useTabsStore = defineStore('tabs', () => {
|
|||
setStorage('activeTab', activeTab.value)
|
||||
}
|
||||
|
||||
// 清空页签
|
||||
// 清空页签(重新登录时调用,保留固定页签)
|
||||
const clearTabs = () => {
|
||||
tabs.value = []
|
||||
activeTab.value = ''
|
||||
removeStorage('tabs')
|
||||
removeStorage('activeTab')
|
||||
// 只保留固定页签
|
||||
const fixedTabItems = tabs.value.filter(item => isFixedTab(item.path))
|
||||
// 如果没有固定页签,至少添加首页
|
||||
if (fixedTabItems.length === 0) {
|
||||
tabs.value = [{
|
||||
title: '首页',
|
||||
path: '/dashboard'
|
||||
}]
|
||||
activeTab.value = '/dashboard'
|
||||
} else {
|
||||
tabs.value = fixedTabItems
|
||||
const firstFixedTab = fixedTabItems[0]
|
||||
activeTab.value = firstFixedTab ? firstFixedTab.path : '/dashboard'
|
||||
}
|
||||
saveTabs()
|
||||
}
|
||||
|
||||
// 初始化默认首页标签
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ export const useTransactionStore = defineStore('transaction', () => {
|
|||
|
||||
mqttClient.onTopicMessages({
|
||||
[topic]: (_topic: string, msg: string): void => {
|
||||
console.log(_topic, msg)
|
||||
// console.log(_topic, msg)
|
||||
|
||||
let [type, data] = msg.split('|')
|
||||
switch (type) {
|
||||
|
|
@ -97,8 +97,6 @@ export const useTransactionStore = defineStore('transaction', () => {
|
|||
break
|
||||
}
|
||||
case 'SUBSCRIBE_AMOUNT_FLOATING_BACK': {
|
||||
// 做市商浮动盈亏回调:更新 marketFloatProfitMap
|
||||
console.log('做市商浮动盈亏数据:', data);
|
||||
handleMarketFloatProfit(data)
|
||||
break
|
||||
}
|
||||
|
|
@ -131,7 +129,6 @@ export const useTransactionStore = defineStore('transaction', () => {
|
|||
// 触发响应式更新(创建新的 Map 实例)
|
||||
marketFloatProfitMap.value = new Map(marketFloatProfitMap.value)
|
||||
|
||||
console.log(`做市商浮动盈亏更新: account=${account_id}, float=${float_profit_loss}`)
|
||||
}
|
||||
|
||||
// ------------------ 持仓列表 ------------------
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ import type { UserInfo, MenuItem, PermissionItem } from '@/stores/types/user'
|
|||
import { formatMenuToElMenu, type ElMenuItem } from '@/utils/menuFormat'
|
||||
import { handleRouter, setRouter } from '@/router/handleRouter.ts'
|
||||
import { useTransactionStore } from './transaction'
|
||||
import { useTabsStore } from './tabs'
|
||||
|
||||
// 定义用户 Store
|
||||
export const useUserStore = defineStore('user', () => {
|
||||
|
|
@ -81,6 +82,10 @@ export const useUserStore = defineStore('user', () => {
|
|||
// 断开 MQTT 连接
|
||||
const transactionStore = useTransactionStore()
|
||||
transactionStore.disconnect()
|
||||
|
||||
// 清空页签数据(重新登录后只保留固定页签)
|
||||
const tabsStore = useTabsStore()
|
||||
tabsStore.clearTabs()
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in New Issue