fix(安全): 修复HTML导出中的XSS漏洞并清理调试日志
Some checks failed
CI / Lint & TypeCheck (push) Has been cancelled
CI / Unit Tests (push) Has been cancelled
CI / Build Frontend (push) Has been cancelled
CI / Rust Check (push) Has been cancelled
CI / Security Scan (push) Has been cancelled
CI / E2E Tests (push) Has been cancelled
Some checks failed
CI / Lint & TypeCheck (push) Has been cancelled
CI / Unit Tests (push) Has been cancelled
CI / Build Frontend (push) Has been cancelled
CI / Rust Check (push) Has been cancelled
CI / Security Scan (push) Has been cancelled
CI / E2E Tests (push) Has been cancelled
refactor(日志): 替换console.log为tracing日志系统 style(代码): 移除未使用的代码和依赖项 feat(测试): 添加端到端测试文档和CI工作流 docs(变更日志): 更新CHANGELOG.md记录0.1.0版本变更 perf(构建): 更新依赖版本并优化CI流程
This commit is contained in:
@@ -27,6 +27,9 @@ import {
|
||||
type HealthStatus,
|
||||
} from '../lib/health-check';
|
||||
import { useConfigStore } from './configStore';
|
||||
import { createLogger } from '../lib/logger';
|
||||
|
||||
const log = createLogger('ConnectionStore');
|
||||
|
||||
// === Mode Selection ===
|
||||
// IMPORTANT: Check isTauriRuntime() at RUNTIME (inside functions), not at module load time.
|
||||
@@ -57,7 +60,7 @@ function loadCustomModels(): CustomModel[] {
|
||||
return JSON.parse(stored);
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('[connectionStore] Failed to parse models:', err);
|
||||
log.error('Failed to parse models:', err);
|
||||
}
|
||||
return [];
|
||||
}
|
||||
@@ -88,7 +91,7 @@ export function getDefaultModelConfig(): { provider: string; model: string; apiK
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
console.warn('[connectionStore] Failed to read chatStore:', err);
|
||||
log.warn('Failed to read chatStore:', err);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -213,10 +216,10 @@ export const useConnectionStore = create<ConnectionStore>((set, get) => {
|
||||
// === Internal Kernel Mode (Tauri) ===
|
||||
// Check at RUNTIME, not at module load time, to ensure __TAURI_INTERNALS__ is available
|
||||
const useInternalKernel = isTauriRuntime();
|
||||
console.log('[ConnectionStore] isTauriRuntime():', useInternalKernel);
|
||||
log.debug('isTauriRuntime():', useInternalKernel);
|
||||
|
||||
if (useInternalKernel) {
|
||||
console.log('[ConnectionStore] Using internal ZCLAW Kernel (no external process needed)');
|
||||
log.debug('Using internal ZCLAW Kernel (no external process needed)');
|
||||
const kernelClient = getKernelClient();
|
||||
|
||||
// Get model config from custom models settings
|
||||
@@ -230,7 +233,7 @@ export const useConnectionStore = create<ConnectionStore>((set, get) => {
|
||||
throw new Error(`模型 ${modelConfig.model} 未配置 API Key,请在"模型与 API"设置页面配置`);
|
||||
}
|
||||
|
||||
console.log('[ConnectionStore] Model config:', {
|
||||
log.debug('Model config:', {
|
||||
provider: modelConfig.provider,
|
||||
model: modelConfig.model,
|
||||
hasApiKey: !!modelConfig.apiKey,
|
||||
@@ -269,9 +272,9 @@ export const useConnectionStore = create<ConnectionStore>((set, get) => {
|
||||
await kernelClient.connect();
|
||||
|
||||
// Set version
|
||||
set({ gatewayVersion: '0.2.0-internal' });
|
||||
set({ gatewayVersion: '0.1.0-internal' });
|
||||
|
||||
console.log('[ConnectionStore] Connected to internal ZCLAW Kernel');
|
||||
log.debug('Connected to internal ZCLAW Kernel');
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -312,7 +315,7 @@ export const useConnectionStore = create<ConnectionStore>((set, get) => {
|
||||
|
||||
// Resolve effective token
|
||||
const effectiveToken = token || useConfigStore.getState().quickConfig?.gatewayToken || getStoredGatewayToken();
|
||||
console.log('[ConnectionStore] Connecting with token:', effectiveToken ? '[REDACTED]' : '(empty)');
|
||||
log.debug('Connecting with token:', effectiveToken ? '[REDACTED]' : '(empty)');
|
||||
|
||||
const candidateUrls = await resolveCandidates();
|
||||
let lastError: unknown = null;
|
||||
@@ -351,7 +354,7 @@ export const useConnectionStore = create<ConnectionStore>((set, get) => {
|
||||
set({ gatewayVersion: health?.version });
|
||||
} catch { /* health may not return version */ }
|
||||
|
||||
console.log('[ConnectionStore] Connected to:', connectedUrl);
|
||||
log.debug('Connected to:', connectedUrl);
|
||||
} catch (err: unknown) {
|
||||
const errorMessage = err instanceof Error ? err.message : String(err);
|
||||
set({ error: errorMessage });
|
||||
|
||||
Reference in New Issue
Block a user