// 浏览器环境下的完整Wails运行时模拟 - 在导入Wails库之前执行 if (typeof window.runtime === 'undefined') { window.runtime = { // 日志相关方法 - 生产环境使用新的LogFrontend接口 LogPrint: (message) => { if (window.go && window.go.main && window.go.main.App && window.go.main.App.LogFrontend) { window.go.main.App.LogFrontend('info', message); } else { console.log(message); } }, LogTrace: (message) => { if (window.go && window.go.main && window.go.main.App && window.go.main.App.LogFrontend) { window.go.main.App.LogFrontend('debug', message); } else { console.trace(message); } }, LogDebug: (message) => { if (window.go && window.go.main && window.go.main.App && window.go.main.App.LogFrontend) { window.go.main.App.LogFrontend('debug', message); } else { console.debug(message); } }, LogInfo: (message) => { if (window.go && window.go.main && window.go.main.App && window.go.main.App.LogFrontend) { window.go.main.App.LogFrontend('info', message); } else { console.info(message); } }, LogWarning: (message) => { if (window.go && window.go.main && window.go.main.App && window.go.main.App.LogFrontend) { window.go.main.App.LogFrontend('warning', message); } else { console.warn(message); } }, LogError: (message) => { if (window.go && window.go.main && window.go.main.App && window.go.main.App.LogFrontend) { window.go.main.App.LogFrontend('error', message); } else { console.error(message); } }, LogFatal: (message) => { if (window.go && window.go.main && window.go.main.App && window.go.main.App.LogFrontend) { window.go.main.App.LogFrontend('error', 'FATAL: ' + message); } else { console.error('FATAL: ' + message); } }, // 事件相关方法 EventsOnMultiple: () => console.log('模拟: EventsOnMultiple'), EventsOn: () => console.log('模拟: EventsOn'), EventsOff: () => console.log('模拟: EventsOff'), EventsOnce: () => console.log('模拟: EventsOnce'), EventsEmit: () => console.log('模拟: EventsEmit'), // 窗口相关方法 WindowReload: () => console.log('模拟: WindowReload'), WindowReloadApp: () => console.log('模拟: WindowReloadApp'), WindowSetAlwaysOnTop: () => console.log('模拟: WindowSetAlwaysOnTop'), WindowSetSystemDefaultTheme: () => console.log('模拟: WindowSetSystemDefaultTheme'), WindowSetLightTheme: () => console.log('模拟: WindowSetLightTheme'), WindowSetDarkTheme: () => console.log('模拟: WindowSetDarkTheme'), WindowCenter: () => console.log('模拟: WindowCenter'), WindowSetTitle: () => console.log('模拟: WindowSetTitle'), WindowFullscreen: () => console.log('模拟: WindowFullscreen'), WindowUnfullscreen: () => console.log('模拟: WindowUnfullscreen'), WindowIsFullscreen: () => false, WindowGetSize: () => ({ width: 800, height: 600 }), WindowSetSize: () => console.log('模拟: WindowSetSize'), WindowSetMaxSize: () => console.log('模拟: WindowSetMaxSize'), WindowSetMinSize: () => console.log('模拟: WindowSetMinSize'), WindowSetPosition: () => console.log('模拟: WindowSetPosition'), WindowGetPosition: () => ({ x: 100, y: 100 }), WindowHide: () => console.log('模拟: WindowHide'), WindowShow: () => console.log('模拟: WindowShow'), WindowMaximise: () => console.log('模拟: WindowMaximise'), WindowToggleMaximise: () => console.log('模拟: WindowToggleMaximise'), WindowUnmaximise: () => console.log('模拟: WindowUnmaximise'), WindowIsMaximised: () => false, WindowMinimise: () => console.log('模拟: WindowMinimise'), WindowUnminimise: () => console.log('模拟: WindowUnminimise'), WindowSetBackgroundColour: () => console.log('模拟: WindowSetBackgroundColour'), WindowIsMinimised: () => false, WindowIsNormal: () => true, // 其他功能方法 ScreenGetAll: () => [{ id: 1, width: 1920, height: 1080 }], BrowserOpenURL: (url) => console.log(`模拟: 打开URL ${url}`), Environment: () => ({ os: 'browser' }), Quit: () => console.log('模拟: Quit'), Hide: () => console.log('模拟: Hide'), Show: () => console.log('模拟: Show'), ClipboardGetText: () => '', ClipboardSetText: (text) => console.log(`模拟: 设置剪贴板文本 ${text}`), OnFileDrop: () => console.log('模拟: OnFileDrop'), OnFileDropOff: () => console.log('模拟: OnFileDropOff'), CanResolveFilePaths: () => false, ResolveFilePaths: (files) => files }; } // 添加全局LogFrontend函数 window.LogFrontend = (level, message) => { if (typeof window.go !== 'undefined' && window.go.main && window.go.main.App && window.go.main.App.LogFrontend) { return window.go.main.App.LogFrontend(level, message); } else { console.log(`[前端-${level.toUpperCase()}] ${message}`); } }; // 修改Go函数模拟,添加LogFrontend方法 if (typeof window.go === 'undefined') { window.go = { main: { App: { // 模拟GetCallbackConfig函数 GetCallbackConfig: () => { console.log('模拟: 获取回调配置'); // 返回模拟数据,格式与后端一致 (bool, interface{}) return [true, { callbackUrl: '', callbackToken: '', httpPort: '10001', enableCallback: false, enableCloudAuth: false, fileUploadUrl: '' }]; }, // 模拟SaveCallbackConfig函数 SaveCallbackConfig: (jsonData) => { console.log('模拟: 保存回调配置', jsonData); // 返回模拟成功结果,格式与后端一致 (bool, string) return [true, '配置保存成功']; }, // 模拟SendWxWorkData函数 SendWxWorkData: (clientId, jsonData) => { console.log('模拟: 发送企微数据', clientId, jsonData); // 返回模拟成功结果 return [true, null, null]; }, // 模拟GetSystemMemoryUsage函数 GetSystemMemoryUsage: () => { console.log('模拟: 获取系统内存使用情况'); // 返回模拟内存使用数据 return [true, Math.floor(Math.random() * 40) + 10]; // 10-50%之间的随机值 }, // 模拟LogFrontend函数 LogFrontend: (level, message) => { console.log(`[前端-${level.toUpperCase()}] ${message}`); }, GetAutoReplyConfig: () => ({ enabled: false, listen: { enablePrivateChat: true, enableGroupChat: true, groupTriggerMode: 'mention_only', ignoreSelfMessage: true, deduplicateSeconds: 300 }, knowledge: { directory: 'config/knowledge', indexPath: 'config/knowledge/index.json', supportedExtensions: ['.md', '.txt', '.csv', '.xlsx', '.docx', '.pdf'], topK: 8, minScore: 0.40 }, retrieval: { retrievalMode: 'hybrid_rerank', embeddingIndexPath: 'config/knowledge/embedding_index.json', embeddingModel: 'text-embedding-v4', embeddingDimensions: 512, rerankModel: 'qwen3-rerank', recallTopK: 50, rerankTopK: 30, finalTopK: 8 }, ai: { provider: 'openai_compatible', baseUrl: '', apiKey: '', model: 'qwen-turbo', visionModel: 'qwen3-vl-plus', timeoutSeconds: 20, enableThinking: false, replyDetail: 'medium', temperature: 0, maxTokens: 700 }, handoff: { humanUserId: '', humanConversationId: '', messageTemplate: '', includeKnowledgeHits: true, sendHumanCardToCustomer: true, sendCustomerCardToHuman: true, cardTriggerMode: 'manual_keywords', manualTriggerKeywords: ['人工', '客服', '转人工', '人工客服', '真人', '真人客服'], cardKeywords: ['人工', '客服', '转人工', '人工客服', '真人', '真人客服'] }, identity: { unknownPolicy: 'customer', unknownHandoffPolicy: 'hold', refreshOnStart: true, refreshIntervalMinutes: 30, pageSize: 200, internalNoHandoffReply: '内部员工消息不触发转人工,如需协助请直接联系对应同事。', unknownNoHandoffReply: '正在核验联系人身份,暂不触发转人工。如需协助请直接联系对应同事。', internalUserIds: [], externalUserIds: [] }, replyPolicy: { unknownAnswerToken: 'NO_ANSWER', maxQuestionLength: 1000, cooldownSeconds: 3, sensitiveKeywords: [] } }), SaveAutoReplyConfig: (jsonData) => { console.log('模拟: 保存自动客服配置', jsonData); return [true, 'success']; }, SetAutoReplyEnabled: (enabled) => { console.log('模拟: 设置自动客服开关', enabled); return [true, 'success']; }, GetAutoReplyStatus: () => ({ success: true, data: { enabled: false, running: false, knowledgeFileCount: 0, knowledgeChunkCount: 0, retrievalMode: 'hybrid_rerank', embeddingChunkCount: 0, embeddingModel: 'text-embedding-v4', embeddingDimensions: 512, embeddingLastIndexedAt: 0, internalContactCount: 0, externalContactCount: 0, identityLastRefreshAt: 0, identityRefreshError: '', identityRefreshing: false, identityLastResponseType: '', identityLastResponseCount: 0, identityLastResponseAt: 0, identityLookupInFlight: 0, todayReceived: 0, todayReplied: 0, todayHandoff: 0, todayIgnored: 0, todayAIFailed: 0, lastKnowledgeDurationMs: 0, lastKeywordDurationMs: 0, lastVectorDurationMs: 0, lastRerankDurationMs: 0, lastAiDurationMs: 0, lastTotalDurationMs: 0, lastKeywordScore: 0, lastVectorScore: 0, lastRerankScore: 0, lastMessages: [] } }), RebuildKnowledgeIndex: () => ({ success: true, message: 'rebuilt' }), RefreshAutoReplyContacts: () => ({ success: true, message: 'contact refresh started' }), GetAutoReplyIdentityOptions: () => ({ success: true, data: { internal: [ { userId: 'engineer-a', name: '张工', source: 'mock', clientId: 1, lastSeenAt: 0 }, { userId: 'engineer-b', name: '李工', source: 'mock', clientId: 1, lastSeenAt: 0 } ], external: [] } }), GetAutoReplyGroupOptions: () => ({ success: true, data: [ { conversationId: 'R:demo-sales', name: '演示售后群', source: 'mock', clientId: 1, lastSeenAt: 0, memberCount: 12 } ] }), TestAIConnection: () => ({ success: true, data: { rawSummary: '连接正常', durationMs: 320 } }), TestHumanHandoff: () => ({ success: true, message: 'sent' }), GetIssues: () => [], SaveIssue: () => [true, 'saved'], DeleteIssue: () => [true, 'deleted'], GetAfterSalesDispatchConfig: () => ({ success: true, data: { engineers: [{ userId: 'engineer-a', name: '张工', description: '负责热成像镜头和图像模糊问题', remark: '镜头组', enabled: true }], rules: [{ id: 'demo-rule', name: '热成像问题', engineerUserId: 'engineer-a', engineerName: '张工', productKeywords: ['热成像'], issueKeywords: ['报错'], enabled: true }], notifyTemplate: '', notifyCooldownSeconds: 300, autoNotifyEnabled: false, autoNotifyMinConfidence: 0.75 } }), SaveAfterSalesDispatchConfig: () => [true, 'saved'], GetAfterSalesDispatchQueue: () => ({ success: true, data: { issues: [], summary: { pending: 0, unassigned: 0, assigned: 0, sent: 0, failed: 0, todayNew: 0, notSent: 0 }, config: { engineers: [{ userId: 'engineer-a', name: '张工', description: '负责热成像镜头和图像模糊问题', remark: '镜头组', enabled: true }], rules: [], notifyTemplate: '', notifyCooldownSeconds: 300, autoNotifyEnabled: false, autoNotifyMinConfidence: 0.75 } } }), AssignAfterSalesIssue: () => [true, 'assigned'], NotifyAfterSalesEngineer: () => ({ success: true, message: 'sent' }), BatchNotifyAfterSalesEngineers: () => ({ success: true, message: '已成功推送 0/0 条' }), ResolveAfterSalesIssue: () => ({ success: true, message: '已处理并保存到知识库', data: null }), ListAfterSalesKnowledgeArchives: () => ({ success: true, message: 'ok', data: [] }), ListAfterSalesKnowledgeCases: () => ({ success: true, message: 'ok', data: [] }), UpdateAfterSalesKnowledgeCase: () => ({ success: true, message: '知识案例已更新', data: null }), RevealAfterSalesKnowledgeCase: () => [true, 'opened'], GetPendingAfterSalesArchiveSummary: () => ({ success: true, message: 'ok', data: { pendingCount: 0, totalCount: 0, archiveCount: 0 } }), ArchivePendingAfterSalesIssues: () => ({ success: true, message: '暂无需要保存的问题', data: null }), RevealAfterSalesKnowledgeArchive: () => [true, 'opened'], ImportAfterSalesHistory: () => [true, '已同步 2 条历史消息,分析 2 段,新增 1 条售后问题'], PrepareWeComHistoryCopy: () => [true, '已发送复制命令'], SyncCurrentWeComChatHistory: () => [true, '已同步 2 条历史消息,分析 2 段,新增 1 条售后问题'], GetAfterSalesImageData: () => '', ExportIssuesToExcel: () => [true, 'C:\\tmp\\售后问题库.xlsx'], GetKingdeeMonitorConfig: () => ({ success: true, message: 'ok', data: { enabled: false, baseUrl: '', acctId: '', username: '', password: '', lcid: 2052, pollIntervalSeconds: 60, formId: 'SAL_SaleOrder', billNoFieldKey: 'FBillNo', orderIdFieldKey: 'FID', customerFieldKey: 'FCustId.FNumber', statusFieldKey: '', completedValue: '排产已完成', modifyTimeFieldKey: 'FModifyDate', notifyTemplate: '您好,您的订单 {{billNo}} 已完成排产,后续我们会继续跟进生产进度。', customerMappings: {} } }), SaveKingdeeMonitorConfig: () => [true, 'saved'], GetKingdeeMonitorStatus: () => ({ success: true, message: 'ok', data: { running: false, status: 'stopped', lastPollAt: 0, lastCursorTime: '', lastError: '', totalPolled: 0, totalNotified: 0, totalUnmapped: 0, notifiedOrders: {}, recentNotices: [], recentErrors: [] } }), TestKingdeeMonitorConnection: () => ({ success: true, message: '金蝶连接正常' }), RunKingdeeMonitorOnce: () => ({ success: true, message: '扫描完成', data: { polled: 0, matched: 0, notified: 0, skipped: 0, unmapped: 0, failed: 0 } }), TriggerManualCollect: () => [true, '售后问题收集已开始'], SetAutoCollectTask: () => [true, 'saved'], GetAfterSalesIssueStatus: () => ({ success: true, data: { autoCollectEnabled: false, lastCollectAt: 0, collecting: false, lastCollectedAt: 0, lastAddedCount: 0, lastError: '', messageBufferCount: 0 } }) } } }; } import { createApp } from 'vue' import App from './App.vue' import { LogInfo } from '../wailsjs/runtime/runtime.js' // 导入Element Plus import ElementPlus from 'element-plus' import 'element-plus/dist/index.css' // 创建Vue应用实例 const app = createApp(App) // 使用Element Plus app.use(ElementPlus) // 挂载应用到DOM app.mount('#app') if (window.go && window.go.main && window.go.main.App && window.go.main.App.LogFrontend) { window.go.main.App.LogFrontend('info', 'Vue 3 application successfully mounted'); } else { console.log('Vue 3 application successfully mounted'); }