chore: v0.1.6 UI优化 - 两列网格布局、暗色适配、系统配置浮窗保存、退出登录统一到侧边栏

This commit is contained in:
root
2026-05-15 23:08:33 +08:00
parent 4b437c34c6
commit 301bb63ef0
19 changed files with 2537 additions and 801 deletions

View File

@@ -322,31 +322,86 @@ export function cleanupOldSaveRecords(): void {
// ── Storage Refresh ───────────────────────────────────────────────
export async function refreshAllStorageInfo(): Promise<void> {
const configs = getActiveCloudConfigs().filter(c => c.cloud_type === 'quark' && c.cookie);
const configs = getActiveCloudConfigs().filter(c => c.cookie);
if (configs.length === 0) return;
const verifyCookies = getSystemConfig('cleanup_verify_enabled') === 'true';
for (const cfg of configs) {
try {
const { QuarkDriver } = require('./drivers/quark.driver');
const driver = new QuarkDriver({ cookie: decrypt(cfg.cookie!), nickname: cfg.nickname });
const storage = await driver.getStorageInfo(
decrypt(cfg.cookie!),
(fullUsed: string, total: string) => {
const db = getDb();
db.prepare(
`UPDATE cloud_configs SET storage_used = ?, storage_total = ? WHERE id = ?`
).run(fullUsed, total, cfg.id);
console.log(`[Storage] Background calibration done for quark#${cfg.id}: ${fullUsed} / ${total}`);
const db = getDb();
const decryptedCookie = decrypt(cfg.cookie!);
switch (cfg.cloud_type) {
case 'quark': {
const driver = new QuarkDriver({ cookie: decryptedCookie, nickname: cfg.nickname });
// Get storage info (includes background calibration callback)
const storage = await driver.getStorageInfo(
(fullUsed: string, total: string) => {
const dbInner = getDb();
dbInner.prepare(
`UPDATE cloud_configs SET storage_used = ?, storage_total = ? WHERE id = ?`
).run(fullUsed, total, cfg.id);
console.log(`[Storage] Background calibration done for quark#${cfg.id}: ${fullUsed} / ${total}`);
}
);
if (storage.totalBytes > 0 || storage.usedBytes > 0) {
db.prepare(
`UPDATE cloud_configs SET storage_used = ?, storage_total = ? WHERE id = ?`
).run(storage.used, storage.total, cfg.id);
console.log(`[Storage] Updated quark#${cfg.id}: ${storage.used} / ${storage.total}`);
}
// Cookie verification
if (verifyCookies) {
const valid = await driver.validate();
db.prepare(
`UPDATE cloud_configs SET verification_status = ?, updated_at = ? WHERE id = ?`
).run(valid ? 'valid' : 'invalid', localTimestamp(), cfg.id);
console.log(`[Storage] Verification for quark#${cfg.id}: ${valid ? 'valid' : 'invalid'}`);
}
break;
}
);
if (storage.totalBytes > 0 || storage.usedBytes > 0) {
const db = getDb();
db.prepare(
`UPDATE cloud_configs SET storage_used = ?, storage_total = ? WHERE id = ?`
).run(storage.used, storage.total, cfg.id);
case 'baidu': {
const driver = new BaiduDriver({ cookie: decryptedCookie, nickname: cfg.nickname });
// Get storage info
const storage = await driver.getStorageInfo();
if (storage.used !== '0 B' && storage.total !== '0 B') {
db.prepare(
`UPDATE cloud_configs SET storage_used = ?, storage_total = ? WHERE id = ?`
).run(storage.used, storage.total, cfg.id);
console.log(`[Storage] Updated baidu#${cfg.id}: ${storage.used} / ${storage.total}`);
}
// Cookie verification
if (verifyCookies) {
const valid = await driver.validate();
db.prepare(
`UPDATE cloud_configs SET verification_status = ?, updated_at = ? WHERE id = ?`
).run(valid ? 'valid' : 'invalid', localTimestamp(), cfg.id);
console.log(`[Storage] Verification for baidu#${cfg.id}: ${valid ? 'valid' : 'invalid'}`);
}
break;
}
default:
console.log(`[Storage] Skipping ${cfg.cloud_type}#${cfg.id} — unsupported cloud type for storage refresh`);
break;
}
} catch (err: any) {
console.error(`[Storage] Failed to refresh quark#${cfg.id}:`, err.message);
console.error(`[Storage] Failed to refresh ${cfg.cloud_type}#${cfg.id}:`, err.message);
// On error, mark as invalid if verification is enabled
if (verifyCookies) {
try {
const db = getDb();
db.prepare(
`UPDATE cloud_configs SET verification_status = 'invalid', updated_at = ? WHERE id = ?`
).run(localTimestamp(), cfg.id);
} catch {}
}
}
}
}