diff --git a/electron/services/dbPathService.ts b/electron/services/dbPathService.ts index 6a72257..592c9f9 100644 --- a/electron/services/dbPathService.ts +++ b/electron/services/dbPathService.ts @@ -218,34 +218,22 @@ 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 { - 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 (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 }) } } + if (wxids.length === 0) { const rootName = basename(rootPath) if (rootName.includes('_') && rootName.toLowerCase() !== 'all_users') { @@ -294,25 +282,6 @@ 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) => {