From ea03ff220314d0da86a815c1234bcd1a30082877 Mon Sep 17 00:00:00 2001 From: admin <362324317@qq.com> Date: Sun, 17 May 2026 15:49:43 +0800 Subject: [PATCH] =?UTF-8?q?v0.3.14:=20cookie=5Fuid/=E7=A9=BA=E9=97=B4?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20+=20checkin/cleanup=E7=BB=9F=E4=B8=80?= =?UTF-8?q?=E8=B5=B0getter=E8=A7=A3=E5=AF=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复: - testCloudConnection: 验证成功后更新cookie_uid和storageUsed - 5个getter SELECT添加cookie_uid列 - checkin.service: dailyCheckIn改用getCloudConfigById(自带解密) - cleanup.service: getActiveCleanupConfigs改用getActiveCloudConfigs(自带解密) - checkin/cleanup不再直接查DB绕开解密 --- VERSION | 2 +- source_clean/VERSION | 2 +- source_clean/src/cloud/checkin.service.ts | 4 +--- source_clean/src/cloud/cleanup.service.ts | 10 ++++------ source_clean/src/cloud/credential.service.ts | 18 ++++++++++-------- 5 files changed, 17 insertions(+), 19 deletions(-) diff --git a/VERSION b/VERSION index e473765..0b69c00 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.13 +0.3.14 diff --git a/source_clean/VERSION b/source_clean/VERSION index e473765..0b69c00 100644 --- a/source_clean/VERSION +++ b/source_clean/VERSION @@ -1 +1 @@ -0.3.13 +0.3.14 diff --git a/source_clean/src/cloud/checkin.service.ts b/source_clean/src/cloud/checkin.service.ts index 471a019..bcf187c 100644 --- a/source_clean/src/cloud/checkin.service.ts +++ b/source_clean/src/cloud/checkin.service.ts @@ -8,9 +8,7 @@ export async function dailyCheckIn(id: number): Promise<{ signedDays?: number; }> { const db = getDb(); - const config = db.prepare( - 'SELECT * FROM cloud_configs WHERE id = ?' - ).get(id) as CloudConfig | undefined; + const config = getCloudConfigById(id); if (!config || !config.cookie) { return { success: false, message: '未找到该网盘的有效配置' }; } diff --git a/source_clean/src/cloud/cleanup.service.ts b/source_clean/src/cloud/cleanup.service.ts index 1c836c0..d746ea4 100755 --- a/source_clean/src/cloud/cleanup.service.ts +++ b/source_clean/src/cloud/cleanup.service.ts @@ -2,6 +2,7 @@ import { getDb } from '../database/database'; import { getSystemConfig, updateSystemConfig } from '../admin/system-config.service'; import { formatLocalDate, formatLocalDateTime } from '../utils/time'; import { QuarkDriver } from './drivers/quark.driver'; +import { CloudConfig, getActiveCloudConfigs } from './credential.service'; import { BaiduDriver } from './drivers/baidu.driver'; // ═══════════════════════════════════════════════════════════════════════════ @@ -63,12 +64,9 @@ interface CleanupStats { } /** Get all active cloud configs (any type). Used by the orchestrator. */ -function getActiveCleanupConfigs(): Array<{ id: number; cloud_type: string; cookie: string; nickname?: string }> { - const db = getDb(); - return db.prepare( - `SELECT id, cloud_type, cookie, nickname FROM cloud_configs - WHERE is_active = 1 AND cookie IS NOT NULL AND cookie != ''` - ).all() as Array<{ id: number; cloud_type: string; cookie: string; nickname?: string }>; +function getActiveCleanupConfigs() { + const configs = getActiveCloudConfigs(); + return configs.filter((c): c is CloudConfig & { cookie: string } => !!c.cookie); } /** diff --git a/source_clean/src/cloud/credential.service.ts b/source_clean/src/cloud/credential.service.ts index d2662e2..339d2ce 100644 --- a/source_clean/src/cloud/credential.service.ts +++ b/source_clean/src/cloud/credential.service.ts @@ -43,7 +43,7 @@ function extractCookieUid(cookie: string): string { export function getCloudConfigs(): CloudConfig[] { const db = getDb(); const rows = db.prepare( - `SELECT id, cloud_type, cookie, nickname, is_active, storage_used, storage_total, + `SELECT id, cloud_type, cookie, nickname, is_active, cookie_uid, storage_used, storage_total, checkin_status, last_checkin_at, checkin_message, consecutive_failures, last_used_at, total_saves, created_at, updated_at, verification_status FROM cloud_configs ORDER BY id ASC` @@ -55,7 +55,7 @@ export function getCloudConfigs(): CloudConfig[] { export function getAvailableClouds(): CloudConfig[] { const db = getDb(); const rows = db.prepare( - `SELECT id, cloud_type, nickname, is_active, storage_used, storage_total, + `SELECT id, cloud_type, nickname, is_active, cookie_uid, storage_used, storage_total, checkin_status, last_checkin_at, checkin_message, consecutive_failures, last_used_at, total_saves, created_at, updated_at FROM cloud_configs WHERE is_active = 1 ORDER BY id ASC` @@ -68,7 +68,7 @@ export function getAvailableClouds(): CloudConfig[] { export function getCloudConfigByType(cloudType: string): CloudConfig | undefined { const db = getDb(); const cfg = db.prepare( - `SELECT id, cloud_type, cookie, nickname, is_active, storage_used, storage_total, + `SELECT id, cloud_type, cookie, nickname, is_active, cookie_uid, storage_used, storage_total, checkin_status, last_checkin_at, checkin_message, consecutive_failures, last_used_at, total_saves, created_at, updated_at, verification_status FROM cloud_configs WHERE cloud_type = ? AND is_active = 1 @@ -81,7 +81,7 @@ export function getCloudConfigByType(cloudType: string): CloudConfig | undefined export function getCloudConfigById(id: number): CloudConfig | undefined { const db = getDb(); const cfg = db.prepare( - `SELECT id, cloud_type, cookie, nickname, is_active, storage_used, storage_total, + `SELECT id, cloud_type, cookie, nickname, is_active, cookie_uid, storage_used, storage_total, checkin_status, last_checkin_at, checkin_message, consecutive_failures, last_used_at, total_saves, created_at, updated_at, verification_status FROM cloud_configs WHERE id = ?` @@ -94,7 +94,7 @@ export function getCloudConfigById(id: number): CloudConfig | undefined { export function getActiveCloudConfigs(): CloudConfig[] { const db = getDb(); const rows = db.prepare( - `SELECT id, cloud_type, cookie, nickname, is_active, storage_used, storage_total, + `SELECT id, cloud_type, cookie, nickname, is_active, cookie_uid, storage_used, storage_total, checkin_status, last_checkin_at, checkin_message, consecutive_failures, last_used_at, total_saves, created_at, updated_at FROM cloud_configs WHERE is_active = 1 @@ -162,7 +162,7 @@ export function saveCloudConfig(data: { const savedId = data.id || (db.prepare('SELECT last_insert_rowid() as id').get() as any).id; return db.prepare( - `SELECT id, cloud_type, cookie, nickname, is_active, storage_used, storage_total, + `SELECT id, cloud_type, cookie, nickname, is_active, cookie_uid, storage_used, storage_total, checkin_status, last_checkin_at, checkin_message, consecutive_failures, last_used_at, total_saves, created_at, updated_at FROM cloud_configs WHERE id = ?` @@ -246,6 +246,7 @@ export async function testCloudConnection(id: number): Promise<{ if (valid) { nickname = config.nickname || (await fetchQuarkNickname(cookie)) || '夸克网盘'; const storage = await driver.getStorageInfoQuick(); + storageUsed = (storage.used !== '-' && storage.used !== '0 B') ? storage.used : (config.storage_used || ''); storageTotal = (storage.total !== '-' && storage.total !== '0 B') ? storage.total : (config.storage_total || ''); } } @@ -258,9 +259,10 @@ export async function testCloudConnection(id: number): Promise<{ return { success: false, message: '连接失败:Cookie 无效或已过期,或网络暂时异常' }; } + const cookieUid = extractCookieUid(cookie); db.prepare( - `UPDATE cloud_configs SET nickname = ?, storage_total = ?, storage_used = ?, is_active = 1, verification_status = 'valid', updated_at = ? WHERE id = ?` - ).run(nickname, storageTotal, storageUsed, localTimestamp(), id); + `UPDATE cloud_configs SET nickname = ?, storage_total = ?, storage_used = ?, cookie_uid = ?, is_active = 1, verification_status = 'valid', updated_at = ? WHERE id = ?` + ).run(nickname, storageTotal, storageUsed, cookieUid, localTimestamp(), id); return { success: true,