fix: 重新登录后页签清空只保留固定页签
This commit is contained in:
parent
46f8d918db
commit
5ec2d573b7
|
|
@ -255,12 +255,23 @@ export const useTabsStore = defineStore('tabs', () => {
|
||||||
setStorage('activeTab', activeTab.value)
|
setStorage('activeTab', activeTab.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 清空页签
|
// 清空页签(重新登录时调用,保留固定页签)
|
||||||
const clearTabs = () => {
|
const clearTabs = () => {
|
||||||
tabs.value = []
|
// 只保留固定页签
|
||||||
activeTab.value = ''
|
const fixedTabItems = tabs.value.filter(item => isFixedTab(item.path))
|
||||||
removeStorage('tabs')
|
// 如果没有固定页签,至少添加首页
|
||||||
removeStorage('activeTab')
|
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({
|
mqttClient.onTopicMessages({
|
||||||
[topic]: (_topic: string, msg: string): void => {
|
[topic]: (_topic: string, msg: string): void => {
|
||||||
console.log(_topic, msg)
|
// console.log(_topic, msg)
|
||||||
|
|
||||||
let [type, data] = msg.split('|')
|
let [type, data] = msg.split('|')
|
||||||
switch (type) {
|
switch (type) {
|
||||||
|
|
@ -96,9 +96,7 @@ export const useTransactionStore = defineStore('transaction', () => {
|
||||||
orderStore.handlePositionOrderList(data)
|
orderStore.handlePositionOrderList(data)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
case 'SUBSCRIBE_AMOUNT_FLOATING_BACK': {
|
case 'SUBSCRIBE_AMOUNT_FLOATING_BACK': {
|
||||||
// 做市商浮动盈亏回调:更新 marketFloatProfitMap
|
|
||||||
console.log('做市商浮动盈亏数据:', data);
|
|
||||||
handleMarketFloatProfit(data)
|
handleMarketFloatProfit(data)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
@ -130,8 +128,7 @@ export const useTransactionStore = defineStore('transaction', () => {
|
||||||
marketFloatProfitMap.value.set(account_id, float_profit_loss)
|
marketFloatProfitMap.value.set(account_id, float_profit_loss)
|
||||||
// 触发响应式更新(创建新的 Map 实例)
|
// 触发响应式更新(创建新的 Map 实例)
|
||||||
marketFloatProfitMap.value = new Map(marketFloatProfitMap.value)
|
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 { formatMenuToElMenu, type ElMenuItem } from '@/utils/menuFormat'
|
||||||
import { handleRouter, setRouter } from '@/router/handleRouter.ts'
|
import { handleRouter, setRouter } from '@/router/handleRouter.ts'
|
||||||
import { useTransactionStore } from './transaction'
|
import { useTransactionStore } from './transaction'
|
||||||
|
import { useTabsStore } from './tabs'
|
||||||
|
|
||||||
// 定义用户 Store
|
// 定义用户 Store
|
||||||
export const useUserStore = defineStore('user', () => {
|
export const useUserStore = defineStore('user', () => {
|
||||||
|
|
@ -81,6 +82,10 @@ export const useUserStore = defineStore('user', () => {
|
||||||
// 断开 MQTT 连接
|
// 断开 MQTT 连接
|
||||||
const transactionStore = useTransactionStore()
|
const transactionStore = useTransactionStore()
|
||||||
transactionStore.disconnect()
|
transactionStore.disconnect()
|
||||||
|
|
||||||
|
// 清空页签数据(重新登录后只保留固定页签)
|
||||||
|
const tabsStore = useTabsStore()
|
||||||
|
tabsStore.clearTabs()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue