2.4.7 优化过滤 新增重置任务
This commit is contained in:
@@ -109,10 +109,42 @@ onMounted(() => {
|
||||
buildViewMap(props.accountGroups)
|
||||
}
|
||||
|
||||
// 监听本地存储变化,当配置更新时重新加载
|
||||
window.addEventListener('storage', handleStorageChange)
|
||||
// 监听自定义配置更新事件
|
||||
window.addEventListener('config-updated', handleConfigUpdate)
|
||||
|
||||
// Listeners specific to browser view
|
||||
// ...
|
||||
})
|
||||
|
||||
onUnmounted(() => {
|
||||
// 清理监听器
|
||||
window.removeEventListener('storage', handleStorageChange)
|
||||
window.removeEventListener('config-updated', handleConfigUpdate)
|
||||
})
|
||||
|
||||
// 处理本地存储变化
|
||||
const handleStorageChange = (event) => {
|
||||
if (event.key === CONFIG_KEY) {
|
||||
loadConfig()
|
||||
// 强制重新构建 viewAccountMap,确保使用最新的账号信息
|
||||
if (props.accountGroups) {
|
||||
buildViewMap(props.accountGroups)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 处理配置更新事件
|
||||
const handleConfigUpdate = () => {
|
||||
console.log('[YoloBrowser] 收到配置更新事件,重新加载配置')
|
||||
loadConfig()
|
||||
// 强制重新构建 viewAccountMap,确保使用最新的账号信息
|
||||
if (props.accountGroups) {
|
||||
buildViewMap(props.accountGroups)
|
||||
}
|
||||
}
|
||||
|
||||
// Original loadConfig logic
|
||||
const loadConfig = () => {
|
||||
try {
|
||||
@@ -142,7 +174,7 @@ const buildViewMap = (groups) => {
|
||||
|
||||
watch(() => props.accountGroups, (newVal) => {
|
||||
if (newVal) buildViewMap(newVal)
|
||||
})
|
||||
}, { deep: true })
|
||||
|
||||
// Actions
|
||||
const handleTabSwitch = async (tab) => {
|
||||
@@ -166,6 +198,12 @@ const handleTabSwitch = async (tab) => {
|
||||
|
||||
const handleViewSwitch = async (viewId) => {
|
||||
selectedViewId.value = viewId
|
||||
// 重新加载配置,确保获取最新的账号信息
|
||||
loadConfig()
|
||||
// 强制重新构建 viewAccountMap,确保使用最新的账号信息
|
||||
if (props.accountGroups) {
|
||||
buildViewMap(props.accountGroups)
|
||||
}
|
||||
if (isElectron()) {
|
||||
await window.electronAPI.switchToView(viewId)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user