mirror of
https://wget.la/https://github.com/Wxw-Gu/WechatExplorer
synced 2026-11-30 16:02:58 +08:00
fix: 修复退群监控列表错误, 界面左侧滚动条
This commit is contained in:
1 parent
4b83aaed61
commit
77a6912ade
7 files changed
+173
-12
No files matched your search
+24
-3
@@ -14,7 +14,8 @@ import {
|
||||
Menu,
|
||||
Tray,
|
||||
dialog,
|
||||
protocol
|
||||
protocol,
|
||||
screen
|
||||
} from 'electron'
|
||||
import { dirname, extname, join } from 'path'
|
||||
import { existsSync, promises as fsPromises } from 'fs'
|
||||
@@ -504,9 +505,29 @@ async function createLocalMediaResponse(request: Request, filePath: string): Pro
|
||||
|
||||
function createWindow(): void {
|
||||
// 创建浏览器窗口
|
||||
/*
|
||||
* 初始尺寸按当前屏幕工作区的 60% 计算,不再用固定 1400×800。
|
||||
* 两个夹逼都是必要的:
|
||||
* - 下限:小屏上 60% 会算出比原固定值更小的窗口(1920×1080 的工作区高度
|
||||
* 只有 ~985,60% 才 591 高),反而比改动前更糟;高度下限取 900,
|
||||
* 即「高度拉大一点」的诉求。
|
||||
* - 上限:不能超过工作区本身,否则初始尺寸会把标题栏顶出屏幕。
|
||||
*/
|
||||
const { workAreaSize } = screen.getPrimaryDisplay()
|
||||
const initialWidth = Math.min(
|
||||
Math.max(Math.round(workAreaSize.width * 0.6), 1400),
|
||||
workAreaSize.width
|
||||
)
|
||||
const initialHeight = Math.min(
|
||||
Math.max(Math.round(workAreaSize.height * 0.6), 900),
|
||||
workAreaSize.height
|
||||
)
|
||||
const mainWindow = new BrowserWindow({
|
||||
width: 1400,
|
||||
height: 800,
|
||||
width: initialWidth,
|
||||
height: initialHeight,
|
||||
minWidth: 960,
|
||||
minHeight: 640,
|
||||
center: true,
|
||||
show: false,
|
||||
autoHideMenuBar: true,
|
||||
icon: appIconPath,
|
||||
|
||||
@@ -112,8 +112,9 @@ class GroupExitMonitorService {
|
||||
getState(): GroupExitMonitorState {
|
||||
this.ensureLoaded()
|
||||
return {
|
||||
// this.events 恒为「新在前」,所以这里取到的就是**最新**的 MAX_EVENTS 条。
|
||||
events: this.events.slice(0, MAX_EVENTS),
|
||||
/** 永久保留的事件总数(`events` 只是最近一批)。 */
|
||||
/** 永久保留的事件总数(`events` 只是最新的一批)。 */
|
||||
totalEventCount: this.events.length,
|
||||
enabled: this.enabled,
|
||||
running: this.enabled && this.active && chat.isReady(),
|
||||
@@ -794,10 +795,16 @@ class GroupExitMonitorService {
|
||||
const legacy = normalizeEvents(stored.events)
|
||||
if (legacy.length && !fromDisk.length) {
|
||||
// 老版本把事件塞在状态文件里 —— 一次性迁移过去,避免这批历史丢失。
|
||||
this.rewriteEventsToDisk(legacy)
|
||||
this.events = legacy
|
||||
// 落盘按时间**升序**(旧 → 新),与之后 append 的方向一致,避免在
|
||||
// append-only 文件开头留下一段方向相反的旧历史(历史行序错乱的来源)。
|
||||
this.rewriteEventsToDisk(
|
||||
[...legacy].sort((left, right) => left.detectedAt - right.detectedAt)
|
||||
)
|
||||
this.events = sortEventsNewestFirst(legacy)
|
||||
} else {
|
||||
this.events = normalizeEvents(fromDisk)
|
||||
// 磁盘行序不保证时间有序(迁移段与追加段方向相反),读回后必须显式重建
|
||||
// 「新在前」这个内存不变量,否则列表顶部会恒为最旧的一批。
|
||||
this.events = sortEventsNewestFirst(normalizeEvents(fromDisk))
|
||||
}
|
||||
this.actionGateway.registerMemberEvents?.(this.events)
|
||||
this.lastReadAt = Number(stored.lastReadAt) || 0
|
||||
@@ -817,7 +824,7 @@ class GroupExitMonitorService {
|
||||
} catch {
|
||||
// 首次启动或状态文件损坏时从空记录开始 —— 但事件在独立文件里,
|
||||
// 不该被状态文件的问题连累,仍然读回来。
|
||||
this.events = normalizeEvents(this.readEventsFromDisk())
|
||||
this.events = sortEventsNewestFirst(normalizeEvents(this.readEventsFromDisk()))
|
||||
this.enabled = true
|
||||
this.lastReadAt = 0
|
||||
this.monitorSelectionConfigured = true
|
||||
@@ -1053,6 +1060,21 @@ function normalizeEvents(
|
||||
return normalized
|
||||
}
|
||||
|
||||
/**
|
||||
* 事件在内存里恒定保持「**新在前**」。
|
||||
*
|
||||
* 这个不变量有三个依赖方:`recordExit` 的 `[event, ...this.events]` 写入方向、
|
||||
* `listEvents()` 的 `.reverse()`(它假定内存是倒序,反转后得到升序)、
|
||||
* 以及 `getState()` 的 `slice(0, MAX_EVENTS)`(要求取到的是**最新**的一批)。
|
||||
*
|
||||
* 必须显式重建它:磁盘是 append-only,行序由「迁移写入的历史 + 之后追加的新事件」
|
||||
* 决定,两段方向相反,整体不保证时间有序。直接信任文件行序会让列表顶部恒为最旧的
|
||||
* 一批,并让 `slice(0, MAX_EVENTS)` 恰好把最新的事件截掉。
|
||||
*/
|
||||
function sortEventsNewestFirst(events: GroupExitMonitorEvent[]): GroupExitMonitorEvent[] {
|
||||
return [...events].sort((left, right) => right.detectedAt - left.detectedAt)
|
||||
}
|
||||
|
||||
function normalizeNotificationStatus(value: unknown): GroupExitNotificationStatus {
|
||||
const status = String(value || '').trim()
|
||||
return status === 'pending' || status === 'sent' || status === 'blocked' || status === 'failed'
|
||||
|
||||
Reference in new issue
Block a user