fix: 修复桌面集成失效 + 清理死代码
- main.ts: window.__metonaBridge → window.metonaDesktop(与 preload.ts 对齐) - 删除 DesktopBridge 接口和 __metonaBridge 类型(从未使用) - 删除 extractDocument(定义了但无调用) - 删除 logIPC(导出了但零引用) - 删除 getMessagesContainer(导出了但无调用) - SAFE_DATA_TYPES 去掉多余的 export - vite.config.ts 移除未使用的 server 配置
This commit is contained in:
@@ -373,10 +373,6 @@ export function appendSystemMessage(text: string, tempClass?: string): void {
|
||||
scrollToBottom();
|
||||
}
|
||||
|
||||
export function getMessagesContainer(): HTMLElement {
|
||||
return messagesContainerEl;
|
||||
}
|
||||
|
||||
export function clearMessages(): void {
|
||||
messagesContainerEl.innerHTML = '';
|
||||
currentPlaceholder = null;
|
||||
|
||||
@@ -43,7 +43,7 @@ function initHelpModal(): void {
|
||||
}
|
||||
|
||||
function setupDesktopIntegration(): void {
|
||||
const bridge = window.__metonaBridge;
|
||||
const bridge = window.metonaDesktop;
|
||||
if (!bridge || !bridge.isDesktop) {
|
||||
logDebug('非桌面环境,跳过桌面集成');
|
||||
return;
|
||||
|
||||
@@ -58,10 +58,6 @@ function splitSentences(text: string): string[] {
|
||||
return parts.filter(p => p.trim()).map(p => p.trim() + ' ');
|
||||
}
|
||||
|
||||
export function extractDocument(content: string, filename: string): { text: string; filename: string } {
|
||||
return { text: content, filename };
|
||||
}
|
||||
|
||||
export function createChunkMetadata(chunk: string, index: number, docId: string, filename: string) {
|
||||
return {
|
||||
id: `${docId}_chunk_${index}`,
|
||||
|
||||
@@ -183,5 +183,4 @@ export function logSession(action: string, detail?: string): void { addLog('info
|
||||
export function logMemory(action: string, detail?: string): void { addLog('debug', `记忆: ${action}`, detail); }
|
||||
export function logRAG(action: string, detail?: string): void { addLog('info', `RAG: ${action}`, detail); }
|
||||
export function logSetting(key: string, value: string): void { addLog('debug', `设置: ${key}`, value); }
|
||||
export function logIPC(action: string, detail?: string): void { addLog('debug', `IPC: ${action}`, detail); }
|
||||
export function logInit(msg: string): void { addLog('info', `初始化: ${msg}`); }
|
||||
|
||||
Vendored
-20
@@ -234,25 +234,6 @@ export interface SaveFileOptions {
|
||||
filters?: Array<{ name: string; extensions: string[] }>;
|
||||
}
|
||||
|
||||
// ── 桌面 Bridge 接口 ──
|
||||
|
||||
export interface DesktopBridge {
|
||||
isDesktop: boolean;
|
||||
getInfo: () => Promise<{ platform: string; version: string; arch?: string; electronVersion?: string; userDataPath?: string }>;
|
||||
openFile: (filters?: Array<{ name: string; extensions: string[] }>) => Promise<string[] | null>;
|
||||
saveFile: (options?: SaveFileOptions) => Promise<string | null>;
|
||||
readFile: (filePath: string) => Promise<{ success: boolean; content?: string; name?: string; error?: string }>;
|
||||
writeFile: (filePath: string, content: string) => Promise<{ success: boolean; error?: string }>;
|
||||
notify: (title: string, body: string) => void;
|
||||
minimize: () => void;
|
||||
maximize: () => void;
|
||||
close: () => void;
|
||||
openExternal: (url: string) => void;
|
||||
onMenuAction: (callback: (action: string) => void) => void;
|
||||
onTrayAction: (callback: (action: string) => void) => void;
|
||||
off: (channel: string) => void;
|
||||
}
|
||||
|
||||
// ── State Keys ──
|
||||
|
||||
export type StateKey =
|
||||
@@ -333,7 +314,6 @@ export type AgentState = 'idle' | 'sending' | 'accumulating' | 'executing' | 'co
|
||||
declare global {
|
||||
interface Window {
|
||||
metonaDesktop?: MetonaDesktopAPI;
|
||||
__metonaBridge?: DesktopBridge;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
*/
|
||||
|
||||
export const SAFE_URI_SCHEMES = new Set(['http:', 'https:', 'mailto:', 'tel:', 'ftp:', 'ftps:', 'xmpp:']);
|
||||
export const SAFE_DATA_TYPES = new Set(['image/png', 'image/jpeg', 'image/gif', 'image/webp', 'image/svg+xml']);
|
||||
const SAFE_DATA_TYPES = new Set(['image/png', 'image/jpeg', 'image/gif', 'image/webp', 'image/svg+xml']);
|
||||
|
||||
const ALLOWED_TAGS = new Set([
|
||||
'a', 'abbr', 'b', 'blockquote', 'br', 'code', 'del', 'details', 'div',
|
||||
|
||||
@@ -14,7 +14,4 @@ export default defineConfig({
|
||||
css: {
|
||||
preprocessorOptions: {},
|
||||
},
|
||||
server: {
|
||||
port: 5173,
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user