@@ -43,7 +43,7 @@ function extractCookieUid(cookie: string): string {
export function getCloudConfigs ( ) : CloudConfig [ ] {
export function getCloudConfigs ( ) : CloudConfig [ ] {
const db = getDb ( ) ;
const db = getDb ( ) ;
const rows = db . prepare (
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,
checkin_status, last_checkin_at, checkin_message, consecutive_failures,
last_used_at, total_saves, created_at, updated_at, verification_status
last_used_at, total_saves, created_at, updated_at, verification_status
FROM cloud_configs ORDER BY id ASC `
FROM cloud_configs ORDER BY id ASC `
@@ -55,7 +55,7 @@ export function getCloudConfigs(): CloudConfig[] {
export function getAvailableClouds ( ) : CloudConfig [ ] {
export function getAvailableClouds ( ) : CloudConfig [ ] {
const db = getDb ( ) ;
const db = getDb ( ) ;
const rows = db . prepare (
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,
checkin_status, last_checkin_at, checkin_message, consecutive_failures,
last_used_at, total_saves, created_at, updated_at
last_used_at, total_saves, created_at, updated_at
FROM cloud_configs WHERE is_active = 1 ORDER BY id ASC `
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 {
export function getCloudConfigByType ( cloudType : string ) : CloudConfig | undefined {
const db = getDb ( ) ;
const db = getDb ( ) ;
const cfg = db . prepare (
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,
checkin_status, last_checkin_at, checkin_message, consecutive_failures,
last_used_at, total_saves, created_at, updated_at, verification_status
last_used_at, total_saves, created_at, updated_at, verification_status
FROM cloud_configs WHERE cloud_type = ? AND is_active = 1
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 {
export function getCloudConfigById ( id : number ) : CloudConfig | undefined {
const db = getDb ( ) ;
const db = getDb ( ) ;
const cfg = db . prepare (
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,
checkin_status, last_checkin_at, checkin_message, consecutive_failures,
last_used_at, total_saves, created_at, updated_at, verification_status
last_used_at, total_saves, created_at, updated_at, verification_status
FROM cloud_configs WHERE id = ? `
FROM cloud_configs WHERE id = ? `
@@ -94,7 +94,7 @@ export function getCloudConfigById(id: number): CloudConfig | undefined {
export function getActiveCloudConfigs ( ) : CloudConfig [ ] {
export function getActiveCloudConfigs ( ) : CloudConfig [ ] {
const db = getDb ( ) ;
const db = getDb ( ) ;
const rows = db . prepare (
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,
checkin_status, last_checkin_at, checkin_message, consecutive_failures,
last_used_at, total_saves, created_at, updated_at
last_used_at, total_saves, created_at, updated_at
FROM cloud_configs WHERE is_active = 1
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 ;
const savedId = data . id || ( db . prepare ( 'SELECT last_insert_rowid() as id' ) . get ( ) as any ) . id ;
return db . prepare (
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,
checkin_status, last_checkin_at, checkin_message, consecutive_failures,
last_used_at, total_saves, created_at, updated_at
last_used_at, total_saves, created_at, updated_at
FROM cloud_configs WHERE id = ? `
FROM cloud_configs WHERE id = ? `
@@ -246,6 +246,7 @@ export async function testCloudConnection(id: number): Promise<{
if ( valid ) {
if ( valid ) {
nickname = config . nickname || ( await fetchQuarkNickname ( cookie ) ) || '夸克网盘' ;
nickname = config . nickname || ( await fetchQuarkNickname ( cookie ) ) || '夸克网盘' ;
const storage = await driver . getStorageInfoQuick ( ) ;
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 || '' ) ;
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 无效或已过期,或网络暂时异常' } ;
return { success : false , message : '连接失败: Cookie 无效或已过期,或网络暂时异常' } ;
}
}
const cookieUid = extractCookieUid ( cookie ) ;
db . prepare (
db . prepare (
` UPDATE cloud_configs SET nickname = ?, storage_total = ?, storage_used = ?, is_active = 1, verification_status = 'valid', updated_at = ? WHERE 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 , localTimestamp ( ) , id ) ;
) . run ( nickname , storageTotal , storageUsed , cookieUid , localTimestamp ( ) , id ) ;
return {
return {
success : true ,
success : true ,