fix: cargo check --lib error
This commit is contained in:
@@ -173,7 +173,8 @@ export class ComfyUIV2Service {
|
||||
*/
|
||||
static async connect(config: ComfyUIV2Config): Promise<string> {
|
||||
try {
|
||||
return await invoke<string>('comfyui_v2_connect', { config });
|
||||
const result = await invoke<{connected: boolean, status: string, base_url: string}>('comfyui_v2_connect', { config });
|
||||
return result.connected ? '连接成功' : '连接失败';
|
||||
} catch (error) {
|
||||
console.error('Failed to connect to ComfyUI:', error);
|
||||
throw new Error(`连接 ComfyUI 失败: ${error}`);
|
||||
@@ -260,7 +261,29 @@ export class ComfyUIV2Service {
|
||||
*/
|
||||
static async updateConfig(config: Partial<ComfyUIV2Config>): Promise<string> {
|
||||
try {
|
||||
return await invoke<string>('comfyui_v2_update_config', { config });
|
||||
// 获取当前配置,然后合并新配置
|
||||
let currentConfig: ComfyUIV2Config;
|
||||
try {
|
||||
currentConfig = await this.getConfig();
|
||||
} catch {
|
||||
// 如果获取失败,使用默认配置
|
||||
currentConfig = {
|
||||
base_url: 'http://192.168.0.193:8188',
|
||||
timeout: 30000,
|
||||
retry_attempts: 3,
|
||||
enable_cache: true,
|
||||
max_concurrency: 4,
|
||||
websocket_url: 'ws://192.168.0.193:8188/ws',
|
||||
};
|
||||
}
|
||||
|
||||
// 合并配置
|
||||
const fullConfig: ComfyUIV2Config = {
|
||||
...currentConfig,
|
||||
...config,
|
||||
};
|
||||
|
||||
return await invoke<string>('comfyui_v2_update_config', { config: fullConfig });
|
||||
} catch (error) {
|
||||
console.error('Failed to update config:', error);
|
||||
throw new Error(`更新配置失败: ${error}`);
|
||||
|
||||
Reference in New Issue
Block a user