From 5f6b0e8960acb1acf134f47076f2619ed7ad7196 Mon Sep 17 00:00:00 2001 From: hicccc77 <98377878+hicccc77@users.noreply.github.com> Date: Sat, 28 Mar 2026 17:28:52 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=85=BC=E5=AE=B9=E5=BE=AE=E4=BF=A1?= =?UTF-8?q?=E6=96=B0=E7=9B=AE=E5=BD=95=E7=BB=93=E6=9E=84=E5=A4=9A=E4=B8=80?= =?UTF-8?q?=E5=B1=82=E5=B5=8C=E5=A5=97=E5=AF=BC=E8=87=B4=E8=B4=A6=E5=8F=B7?= =?UTF-8?q?=E7=9B=AE=E5=BD=95=E8=AF=86=E5=88=AB=E5=A4=B1=E8=B4=A5=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复 scanWxids 和 scanWxidCandidates 在 2.0b4.0.9/xwechat_files/wxid_xxx 结构下扫描不到账号目录的问题,增加往下多扫一层的兜底逻辑 Fixes #541 --- electron/services/dbPathService.ts | 55 +++++++++++++++++++++++------- 1 file changed, 43 insertions(+), 12 deletions(-) diff --git a/electron/services/dbPathService.ts b/electron/services/dbPathService.ts index 592c9f9..6a72257 100644 --- a/electron/services/dbPathService.ts +++ b/electron/services/dbPathService.ts @@ -218,22 +218,34 @@ export class DbPathService { scanWxidCandidates(rootPath: string): WxidInfo[] { const wxids: WxidInfo[] = [] + const scanOneLevelForCandidates = (scanPath: string) => { + if (!existsSync(scanPath)) return + const entries = readdirSync(scanPath) + for (const entry of entries) { + const entryPath = join(scanPath, entry) + let stat: ReturnType + try { stat = statSync(entryPath) } catch { continue } + if (!stat.isDirectory()) continue + const lower = entry.toLowerCase() + if (lower === 'all_users') continue + if (!entry.includes('_')) continue + wxids.push({ wxid: entry, modifiedTime: stat.mtimeMs }) + } + } + try { - if (existsSync(rootPath)) { - const entries = readdirSync(rootPath) - for (const entry of entries) { - const entryPath = join(rootPath, entry) - let stat: ReturnType - try { stat = statSync(entryPath) } catch { continue } - if (!stat.isDirectory()) continue - const lower = entry.toLowerCase() - if (lower === 'all_users') continue - if (!entry.includes('_')) continue - wxids.push({ wxid: entry, modifiedTime: stat.mtimeMs }) + scanOneLevelForCandidates(rootPath) + + // 兜底:往下再找一层(兼容 2.0b4.0.9/xwechat_files/wxid_xxx 结构) + if (wxids.length === 0 && existsSync(rootPath)) { + const subDirs = readdirSync(rootPath) + for (const sub of subDirs) { + const subPath = join(rootPath, sub) + try { if (!statSync(subPath).isDirectory()) continue } catch { continue } + scanOneLevelForCandidates(subPath) } } - if (wxids.length === 0) { const rootName = basename(rootPath) if (rootName.includes('_') && rootName.toLowerCase() !== 'all_users') { @@ -282,6 +294,25 @@ export class DbPathService { const modifiedTime = this.getAccountModifiedTime(fullPath) wxids.push({ wxid: account, modifiedTime }) } + + // 兜底:如果一层找不到,尝试往下再找一层子目录(兼容 2.0b4.0.9/xwechat_files/wxid_xxx 结构) + if (wxids.length === 0) { + try { + const subDirs = readdirSync(rootPath) + for (const sub of subDirs) { + const subPath = join(rootPath, sub) + try { + if (!statSync(subPath).isDirectory()) continue + } catch { continue } + const subAccounts = this.findAccountDirs(subPath) + for (const account of subAccounts) { + const fullPath = join(subPath, account) + const modifiedTime = this.getAccountModifiedTime(fullPath) + wxids.push({ wxid: account, modifiedTime }) + } + } + } catch { } + } } catch { } const sorted = wxids.sort((a, b) => {