From 7c42ad70d0c1079737357687ab717b527937be3d Mon Sep 17 00:00:00 2001 From: zerob13 Date: Sun, 29 Jun 2025 11:41:37 +0800 Subject: [PATCH 1/2] feat: add support for aihubmix appcode --- .../presenter/llmProviderPresenter/index.ts | 4 + .../providers/aihubmixProvider.ts | 81 +++++++++++++++++++ .../providers/openAICompatibleProvider.ts | 2 +- 3 files changed, 86 insertions(+), 1 deletion(-) create mode 100644 src/main/presenter/llmProviderPresenter/providers/aihubmixProvider.ts diff --git a/src/main/presenter/llmProviderPresenter/index.ts b/src/main/presenter/llmProviderPresenter/index.ts index 04b463103..6a450982b 100644 --- a/src/main/presenter/llmProviderPresenter/index.ts +++ b/src/main/presenter/llmProviderPresenter/index.ts @@ -34,6 +34,7 @@ import { LMStudioProvider } from './providers/lmstudioProvider' import { OpenAIResponsesProvider } from './providers/openAIResponsesProvider' import { OpenRouterProvider } from './providers/openRouterProvider' import { MinimaxProvider } from './providers/minimaxProvider' +import { AihubmixProvider } from './providers/aihubmixProvider' // 流的状态 interface StreamState { isGenerating: boolean @@ -111,6 +112,9 @@ export class LLMProviderPresenter implements ILlmProviderPresenter { if (provider.id === 'deepseek') { return new DeepseekProvider(provider, this.configPresenter) } + if (provider.id === 'aihubmix') { + return new AihubmixProvider(provider, this.configPresenter) + } switch (provider.apiType) { case 'minimax': return new OpenAIProvider(provider, this.configPresenter) diff --git a/src/main/presenter/llmProviderPresenter/providers/aihubmixProvider.ts b/src/main/presenter/llmProviderPresenter/providers/aihubmixProvider.ts new file mode 100644 index 000000000..f5e9c58b0 --- /dev/null +++ b/src/main/presenter/llmProviderPresenter/providers/aihubmixProvider.ts @@ -0,0 +1,81 @@ +import { LLM_PROVIDER, LLMResponse, ChatMessage } from '@shared/presenter' +import { OpenAICompatibleProvider } from './openAICompatibleProvider' +import { ConfigPresenter } from '../../configPresenter' +import { proxyConfig } from '@/presenter/proxyConfig' +import { ProxyAgent } from 'undici' +import OpenAI from 'openai' + +export class AihubmixProvider extends OpenAICompatibleProvider { + constructor(provider: LLM_PROVIDER, configPresenter: ConfigPresenter) { + super(provider, configPresenter) + } + + protected createOpenAIClient(): void { + // Get proxy configuration + const proxyUrl = proxyConfig.getProxyUrl() + const fetchOptions: { dispatcher?: ProxyAgent } = {} + + if (proxyUrl) { + console.log(`[Aihubmix Provider] Using proxy: ${proxyUrl}`) + const proxyAgent = new ProxyAgent(proxyUrl) + fetchOptions.dispatcher = proxyAgent + } + + this.openai = new OpenAI({ + apiKey: this.provider.apiKey, + baseURL: this.provider.baseUrl, + defaultHeaders: { + ...this.defaultHeaders, + "APP-Code": "SMUE7630", + }, + fetchOptions + }) + } + + async completions( + messages: ChatMessage[], + modelId: string, + temperature?: number, + maxTokens?: number + ): Promise { + return this.openAICompletion(messages, modelId, temperature, maxTokens) + } + + async summaries( + text: string, + modelId: string, + temperature?: number, + maxTokens?: number + ): Promise { + return this.openAICompletion( + [ + { + role: 'user', + content: `You need to summarize the user's conversation into a title of no more than 10 words, with the title language matching the user's primary language, without using punctuation or other special symbols:\n${text}` + } + ], + modelId, + temperature, + maxTokens + ) + } + + async generateText( + prompt: string, + modelId: string, + temperature?: number, + maxTokens?: number + ): Promise { + return this.openAICompletion( + [ + { + role: 'user', + content: prompt + } + ], + modelId, + temperature, + maxTokens + ) + } +} diff --git a/src/main/presenter/llmProviderPresenter/providers/openAICompatibleProvider.ts b/src/main/presenter/llmProviderPresenter/providers/openAICompatibleProvider.ts index 091f55913..0db2514a7 100644 --- a/src/main/presenter/llmProviderPresenter/providers/openAICompatibleProvider.ts +++ b/src/main/presenter/llmProviderPresenter/providers/openAICompatibleProvider.ts @@ -63,7 +63,7 @@ export class OpenAICompatibleProvider extends BaseLLMProvider { this.init() } - private createOpenAIClient(): void { + protected createOpenAIClient(): void { // Get proxy configuration const proxyUrl = proxyConfig.getProxyUrl() const fetchOptions: { dispatcher?: ProxyAgent } = {} From 46b52acb0214ea390bea0fd514b1d855d30cece1 Mon Sep 17 00:00:00 2001 From: zerob13 Date: Sun, 29 Jun 2025 11:52:40 +0800 Subject: [PATCH 2/2] feat: add provider and lint --- src/main/index.ts | 2 +- .../configPresenter/providerModelSettings.ts | 26 +++ .../FloatingButtonWindow.ts | 150 +++++++++--------- .../floatingButtonPresenter/index.ts | 78 ++++----- .../floatingButtonPresenter/types.ts | 40 ++--- .../providers/aihubmixProvider.ts | 18 +-- src/main/presenter/mcpPresenter/mcpClient.ts | 1 - src/preload/floating-preload.ts | 26 +-- src/preload/index.d.ts | 4 +- src/preload/index.ts | 2 +- src/renderer/floating/FloatingButton.vue | 18 ++- src/renderer/floating/index.html | 7 +- src/renderer/index.html | 4 +- src/renderer/shell/index.html | 4 +- src/renderer/src/components/ChatInput.vue | 25 ++- src/renderer/src/components/NewThread.vue | 2 +- .../components/settings/DisplaySettings.vue | 4 +- src/renderer/src/stores/floatingButton.ts | 16 +- 18 files changed, 229 insertions(+), 198 deletions(-) diff --git a/src/main/index.ts b/src/main/index.ts index 9a40a2c93..b1eecdefc 100644 --- a/src/main/index.ts +++ b/src/main/index.ts @@ -268,7 +268,7 @@ app.whenReady().then(async () => { app.on('window-all-closed', () => { // 检查是否还有非悬浮按钮的窗口 const mainWindows = presenter.windowPresenter.getAllWindows() - + if (mainWindows.length === 0) { // 只有悬浮按钮窗口时,在非 macOS 平台退出应用 if (process.platform !== 'darwin') { diff --git a/src/main/presenter/configPresenter/providerModelSettings.ts b/src/main/presenter/configPresenter/providerModelSettings.ts index 190d78db7..6a5a3fef1 100644 --- a/src/main/presenter/configPresenter/providerModelSettings.ts +++ b/src/main/presenter/configPresenter/providerModelSettings.ts @@ -982,7 +982,33 @@ export const providerModelSettings: Record { if (this.window) { - return; + return } try { - const position = this.calculatePosition(); - + const position = this.calculatePosition() + // 根据环境选择正确的预加载脚本路径 - const isDev = process.env.NODE_ENV === 'development'; - const preloadPath = isDev + const isDev = process.env.NODE_ENV === 'development' + const preloadPath = isDev ? path.join(process.cwd(), 'out/preload/floating.mjs') - : path.join(__dirname, '../../preload/floating.mjs'); - + : path.join(__dirname, '../../preload/floating.mjs') + this.window = new BrowserWindow({ width: this.config.size.width, height: this.config.size.height, @@ -61,27 +61,27 @@ export class FloatingButtonWindow { devTools: true, // 开发模式下启用开发者工具 sandbox: false // 禁用沙盒模式,确保预加载脚本能正常工作 } - }); + }) // 设置窗口透明度 - this.window.setOpacity(this.config.opacity); + this.window.setOpacity(this.config.opacity) // 加载悬浮按钮页面 if (isDev) { - await this.window.loadURL('http://localhost:5173/floating/'); + await this.window.loadURL('http://localhost:5173/floating/') // 开发模式下可选择性打开开发者工具(暂时禁用,避免影响拖拽) - this.window.webContents.openDevTools({ mode: 'detach' }); + this.window.webContents.openDevTools({ mode: 'detach' }) } else { - await this.window.loadFile(path.join(__dirname, '../../../renderer/floating/index.html')); + await this.window.loadFile(path.join(__dirname, '../../../renderer/floating/index.html')) } // 监听窗口事件 - this.setupWindowEvents(); + this.setupWindowEvents() - logger.info('FloatingButtonWindow created successfully'); + logger.info('FloatingButtonWindow created successfully') } catch (error) { - logger.error('Failed to create FloatingButtonWindow:', error); - throw error; + logger.error('Failed to create FloatingButtonWindow:', error) + throw error } } @@ -90,12 +90,12 @@ export class FloatingButtonWindow { */ public show(): void { if (!this.window) { - return; + return } - this.window.show(); - this.state.isVisible = true; - logger.debug('FloatingButtonWindow shown'); + this.window.show() + this.state.isVisible = true + logger.debug('FloatingButtonWindow shown') } /** @@ -103,12 +103,12 @@ export class FloatingButtonWindow { */ public hide(): void { if (!this.window) { - return; + return } - this.window.hide(); - this.state.isVisible = false; - logger.debug('FloatingButtonWindow hidden'); + this.window.hide() + this.state.isVisible = false + logger.debug('FloatingButtonWindow hidden') } /** @@ -116,10 +116,10 @@ export class FloatingButtonWindow { */ public destroy(): void { if (this.window) { - this.window.destroy(); - this.window = null; - this.state.isVisible = false; - logger.debug('FloatingButtonWindow destroyed'); + this.window.destroy() + this.window = null + this.state.isVisible = false + logger.debug('FloatingButtonWindow destroyed') } } @@ -127,29 +127,29 @@ export class FloatingButtonWindow { * 更新配置 */ public updateConfig(config: Partial): void { - this.config = { ...this.config, ...config }; - + this.config = { ...this.config, ...config } + if (this.window) { // 更新窗口属性 if (config.size) { - this.window.setSize(this.config.size.width, this.config.size.height); - this.state.bounds.width = this.config.size.width; - this.state.bounds.height = this.config.size.height; + this.window.setSize(this.config.size.width, this.config.size.height) + this.state.bounds.width = this.config.size.width + this.state.bounds.height = this.config.size.height } if (config.position || config.offset) { - const position = this.calculatePosition(); - this.window.setPosition(position.x, position.y); - this.state.bounds.x = position.x; - this.state.bounds.y = position.y; + const position = this.calculatePosition() + this.window.setPosition(position.x, position.y) + this.state.bounds.x = position.x + this.state.bounds.y = position.y } if (config.opacity !== undefined) { - this.window.setOpacity(this.config.opacity); + this.window.setOpacity(this.config.opacity) } if (config.alwaysOnTop !== undefined) { - this.window.setAlwaysOnTop(this.config.alwaysOnTop); + this.window.setAlwaysOnTop(this.config.alwaysOnTop) } } } @@ -158,46 +158,46 @@ export class FloatingButtonWindow { * 获取当前状态 */ public getState(): FloatingButtonState { - return { ...this.state }; + return { ...this.state } } /** * 检查窗口是否存在 */ public exists(): boolean { - return this.window !== null && !this.window.isDestroyed(); + return this.window !== null && !this.window.isDestroyed() } /** * 计算悬浮按钮位置 */ private calculatePosition(): { x: number; y: number } { - const primaryDisplay = screen.getPrimaryDisplay(); - const { workAreaSize } = primaryDisplay; - - let x: number, y: number; + const primaryDisplay = screen.getPrimaryDisplay() + const { workAreaSize } = primaryDisplay + + let x: number, y: number switch (this.config.position) { case 'top-left': - x = this.config.offset.x; - y = this.config.offset.y; - break; + x = this.config.offset.x + y = this.config.offset.y + break case 'top-right': - x = workAreaSize.width - this.config.size.width - this.config.offset.x; - y = this.config.offset.y; - break; + x = workAreaSize.width - this.config.size.width - this.config.offset.x + y = this.config.offset.y + break case 'bottom-left': - x = this.config.offset.x; - y = workAreaSize.height - this.config.size.height - this.config.offset.y; - break; + x = this.config.offset.x + y = workAreaSize.height - this.config.size.height - this.config.offset.y + break case 'bottom-right': default: - x = workAreaSize.width - this.config.size.width - this.config.offset.x; - y = workAreaSize.height - this.config.size.height - this.config.offset.y; - break; + x = workAreaSize.width - this.config.size.width - this.config.offset.x + y = workAreaSize.height - this.config.size.height - this.config.offset.y + break } - return { x, y }; + return { x, y } } /** @@ -205,23 +205,23 @@ export class FloatingButtonWindow { */ private setupWindowEvents(): void { if (!this.window) { - return; + return } // 窗口关闭事件 this.window.on('closed', () => { - this.window = null; - this.state.isVisible = false; - }); + this.window = null + this.state.isVisible = false + }) // 窗口移动事件 this.window.on('moved', () => { if (this.window) { - const bounds = this.window.getBounds(); - this.state.bounds.x = bounds.x; - this.state.bounds.y = bounds.y; + const bounds = this.window.getBounds() + this.state.bounds.x = bounds.x + this.state.bounds.y = bounds.y } - }); + }) // 注意:悬浮按钮点击事件的 IPC 处理器在主进程的 index.ts 中设置 } diff --git a/src/main/presenter/floatingButtonPresenter/index.ts b/src/main/presenter/floatingButtonPresenter/index.ts index 58af64b11..a7b2833dd 100644 --- a/src/main/presenter/floatingButtonPresenter/index.ts +++ b/src/main/presenter/floatingButtonPresenter/index.ts @@ -1,20 +1,20 @@ -import { FloatingButtonWindow } from './FloatingButtonWindow'; -import { FloatingButtonConfig, FloatingButtonState, DEFAULT_FLOATING_BUTTON_CONFIG } from './types'; -import { ConfigPresenter } from '../configPresenter'; -import { ipcMain } from 'electron'; -import { FLOATING_BUTTON_EVENTS } from '@/events'; -import { handleShowHiddenWindow } from '@/utils'; +import { FloatingButtonWindow } from './FloatingButtonWindow' +import { FloatingButtonConfig, FloatingButtonState, DEFAULT_FLOATING_BUTTON_CONFIG } from './types' +import { ConfigPresenter } from '../configPresenter' +import { ipcMain } from 'electron' +import { FLOATING_BUTTON_EVENTS } from '@/events' +import { handleShowHiddenWindow } from '@/utils' export class FloatingButtonPresenter { - private floatingWindow: FloatingButtonWindow | null = null; - private config: FloatingButtonConfig; + private floatingWindow: FloatingButtonWindow | null = null + private config: FloatingButtonConfig private configPresenter: ConfigPresenter constructor(configPresenter: ConfigPresenter) { this.configPresenter = configPresenter this.config = { - ...DEFAULT_FLOATING_BUTTON_CONFIG, - }; + ...DEFAULT_FLOATING_BUTTON_CONFIG + } } /** @@ -25,19 +25,19 @@ export class FloatingButtonPresenter { try { this.config = { ...this.config, - ...config || {}, + ...config, enabled: floatingButtonEnabled - }; + } if (!this.config.enabled) { - console.log('FloatingButton is disabled, skipping window creation'); - return; + console.log('FloatingButton is disabled, skipping window creation') + return } - await this.createFloatingWindow(); + await this.createFloatingWindow() } catch (error) { - console.error('Failed to initialize FloatingButtonPresenter:', error); - throw error; + console.error('Failed to initialize FloatingButtonPresenter:', error) + throw error } } @@ -45,12 +45,12 @@ export class FloatingButtonPresenter { * 销毁悬浮按钮功能 */ public destroy(): void { - this.config.enabled = false; + this.config.enabled = false - ipcMain.removeAllListeners(FLOATING_BUTTON_EVENTS.CLICKED); + ipcMain.removeAllListeners(FLOATING_BUTTON_EVENTS.CLICKED) if (this.floatingWindow) { - this.floatingWindow.destroy(); - this.floatingWindow = null; + this.floatingWindow.destroy() + this.floatingWindow = null } } @@ -58,18 +58,23 @@ export class FloatingButtonPresenter { * 启用悬浮按钮 */ public async enable(): Promise { - console.log('FloatingButtonPresenter.enable called, current enabled:', this.config.enabled, 'has window:', !!this.floatingWindow) - - this.config.enabled = true; + console.log( + 'FloatingButtonPresenter.enable called, current enabled:', + this.config.enabled, + 'has window:', + !!this.floatingWindow + ) + + this.config.enabled = true if (this.floatingWindow) { console.log('FloatingButton window already exists, showing it') - this.floatingWindow.show(); - return; // 已经存在窗口,只需显示 + this.floatingWindow.show() + return // 已经存在窗口,只需显示 } console.log('Creating new floating button window') - await this.createFloatingWindow(); + await this.createFloatingWindow() } /** @@ -77,9 +82,9 @@ export class FloatingButtonPresenter { */ public async setEnabled(enabled: boolean): Promise { if (enabled) { - await this.enable(); + await this.enable() } else { - this.destroy(); + this.destroy() } } @@ -87,36 +92,35 @@ export class FloatingButtonPresenter { * 获取当前配置 */ public getConfig(): FloatingButtonConfig { - return { ...this.config }; + return { ...this.config } } /** * 获取当前状态 */ public getState(): FloatingButtonState | null { - return this.floatingWindow?.getState() || null; + return this.floatingWindow?.getState() || null } /** * 创建悬浮窗口 */ private async createFloatingWindow(): Promise { - ipcMain.removeAllListeners(FLOATING_BUTTON_EVENTS.CLICKED); + ipcMain.removeAllListeners(FLOATING_BUTTON_EVENTS.CLICKED) ipcMain.on(FLOATING_BUTTON_EVENTS.CLICKED, () => { try { // 触发内置事件处理器 handleShowHiddenWindow(true) - } catch { - } + } catch {} }) if (!this.floatingWindow) { - this.floatingWindow = new FloatingButtonWindow(this.config); - await this.floatingWindow.create(); + this.floatingWindow = new FloatingButtonWindow(this.config) + await this.floatingWindow.create() } // 悬浮按钮创建后立即显示 - this.floatingWindow.show(); + this.floatingWindow.show() } } diff --git a/src/main/presenter/floatingButtonPresenter/types.ts b/src/main/presenter/floatingButtonPresenter/types.ts index 2662716e0..d6698b52a 100644 --- a/src/main/presenter/floatingButtonPresenter/types.ts +++ b/src/main/presenter/floatingButtonPresenter/types.ts @@ -1,43 +1,43 @@ export interface FloatingButtonConfig { /** 是否启用悬浮按钮 */ - enabled: boolean; + enabled: boolean /** 悬浮按钮位置 */ - position: 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right'; + position: 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right' /** 距离边缘的偏移量 */ offset: { - x: number; - y: number; - }; + x: number + y: number + } /** 悬浮按钮大小 */ size: { - width: number; - height: number; - }; + width: number + height: number + } /** 是否置顶显示 */ - alwaysOnTop: boolean; + alwaysOnTop: boolean /** 透明度 (0-1) */ - opacity: number; + opacity: number } export interface FloatingButtonState { /** 是否正在显示 */ - isVisible: boolean; + isVisible: boolean /** 当前位置 */ bounds: { - x: number; - y: number; - width: number; - height: number; - }; + x: number + y: number + width: number + height: number + } } export interface FloatingButtonEvents { /** 悬浮按钮被点击 */ - 'floating-button-clicked': void; + 'floating-button-clicked': void /** 悬浮按钮显示状态改变 */ - 'floating-button-visibility-changed': { visible: boolean }; + 'floating-button-visibility-changed': { visible: boolean } /** 悬浮按钮位置改变 */ - 'floating-button-position-changed': { x: number; y: number }; + 'floating-button-position-changed': { x: number; y: number } } export const DEFAULT_FLOATING_BUTTON_CONFIG: FloatingButtonConfig = { @@ -53,4 +53,4 @@ export const DEFAULT_FLOATING_BUTTON_CONFIG: FloatingButtonConfig = { }, alwaysOnTop: true, opacity: 0.8 -}; +} diff --git a/src/main/presenter/llmProviderPresenter/providers/aihubmixProvider.ts b/src/main/presenter/llmProviderPresenter/providers/aihubmixProvider.ts index f5e9c58b0..769501e7e 100644 --- a/src/main/presenter/llmProviderPresenter/providers/aihubmixProvider.ts +++ b/src/main/presenter/llmProviderPresenter/providers/aihubmixProvider.ts @@ -21,15 +21,15 @@ export class AihubmixProvider extends OpenAICompatibleProvider { fetchOptions.dispatcher = proxyAgent } - this.openai = new OpenAI({ - apiKey: this.provider.apiKey, - baseURL: this.provider.baseUrl, - defaultHeaders: { - ...this.defaultHeaders, - "APP-Code": "SMUE7630", - }, - fetchOptions - }) + this.openai = new OpenAI({ + apiKey: this.provider.apiKey, + baseURL: this.provider.baseUrl, + defaultHeaders: { + ...this.defaultHeaders, + 'APP-Code': 'SMUE7630' + }, + fetchOptions + }) } async completions( diff --git a/src/main/presenter/mcpPresenter/mcpClient.ts b/src/main/presenter/mcpPresenter/mcpClient.ts index 9efac374c..9255ef247 100644 --- a/src/main/presenter/mcpPresenter/mcpClient.ts +++ b/src/main/presenter/mcpPresenter/mcpClient.ts @@ -535,7 +535,6 @@ export class McpClient { env, stderr: 'pipe' }) - ;(this.transport as StdioClientTransport).stderr?.on('data', (data) => { console.info('mcp StdioClientTransport error', this.serverName, data.toString()) }) diff --git a/src/preload/floating-preload.ts b/src/preload/floating-preload.ts index 2866dfd2c..4639912b8 100644 --- a/src/preload/floating-preload.ts +++ b/src/preload/floating-preload.ts @@ -1,46 +1,46 @@ -import { contextBridge, ipcRenderer } from 'electron'; +import { contextBridge, ipcRenderer } from 'electron' // 直接定义事件常量,避免路径解析问题 const FLOATING_BUTTON_EVENTS = { CLICKED: 'floating-button:clicked' -} as const; +} as const // 定义悬浮按钮的 API const floatingButtonAPI = { // 通知主进程悬浮按钮被点击 onClick: () => { try { - ipcRenderer.send(FLOATING_BUTTON_EVENTS.CLICKED); + ipcRenderer.send(FLOATING_BUTTON_EVENTS.CLICKED) } catch (error) { - console.error('FloatingPreload: Error sending IPC message:', error); + console.error('FloatingPreload: Error sending IPC message:', error) } }, // 监听来自主进程的事件 onConfigUpdate: (callback: (config: any) => void) => { ipcRenderer.on('floating-button-config-update', (_event, config) => { - callback(config); - }); + callback(config) + }) }, // 移除事件监听器 removeAllListeners: () => { - console.log('FloatingPreload: Removing all listeners'); - ipcRenderer.removeAllListeners('floating-button-config-update'); + console.log('FloatingPreload: Removing all listeners') + ipcRenderer.removeAllListeners('floating-button-config-update') } -}; +} // 尝试不同的方式暴露API if (process.contextIsolated) { try { - contextBridge.exposeInMainWorld('floatingButtonAPI', floatingButtonAPI); + contextBridge.exposeInMainWorld('floatingButtonAPI', floatingButtonAPI) } catch (error) { - console.error('=== FloatingPreload: Error exposing API via contextBridge ===:', error); + console.error('=== FloatingPreload: Error exposing API via contextBridge ===:', error) } } else { try { - (window as any).floatingButtonAPI = floatingButtonAPI; + ;(window as any).floatingButtonAPI = floatingButtonAPI } catch (error) { - console.error('=== FloatingPreload: Error attaching API to window ===:', error); + console.error('=== FloatingPreload: Error attaching API to window ===:', error) } } diff --git a/src/preload/index.d.ts b/src/preload/index.d.ts index fbba44e45..aec8a71d2 100644 --- a/src/preload/index.d.ts +++ b/src/preload/index.d.ts @@ -9,7 +9,7 @@ declare global { getPathForFile(file: File): string getWindowId(): number | null getWebContentsId(): number - }, - floatingButtonAPI: typeof floatingButtonAPI; + } + floatingButtonAPI: typeof floatingButtonAPI } } diff --git a/src/preload/index.ts b/src/preload/index.ts index a98c11fcf..e4c85f122 100644 --- a/src/preload/index.ts +++ b/src/preload/index.ts @@ -50,7 +50,7 @@ if (process.contextIsolated) { window.addEventListener('DOMContentLoaded', () => { cachedWebContentsId = ipcRenderer.sendSync('get-web-contents-id') cachedWindowId = ipcRenderer.sendSync('get-window-id') - console.log('cachedWebContentsId', cachedWebContentsId,cachedWindowId) + console.log('cachedWebContentsId', cachedWebContentsId, cachedWindowId) webFrame.setVisualZoomLevelLimits(1, 1) // 禁用 trackpad 缩放 webFrame.setZoomFactor(1) }) diff --git a/src/renderer/floating/FloatingButton.vue b/src/renderer/floating/FloatingButton.vue index 1be12da7c..d06c027a4 100644 --- a/src/renderer/floating/FloatingButton.vue +++ b/src/renderer/floating/FloatingButton.vue @@ -1,14 +1,20 @@ @@ -65,7 +71,7 @@ const handleConfigUpdate = (config: any) => { onMounted(() => { if (window.floatingButtonAPI) { - window.floatingButtonAPI.onConfigUpdate(handleConfigUpdate); + window.floatingButtonAPI.onConfigUpdate(handleConfigUpdate) } }) diff --git a/src/renderer/floating/index.html b/src/renderer/floating/index.html index 949331582..0df14ab22 100644 --- a/src/renderer/floating/index.html +++ b/src/renderer/floating/index.html @@ -1,10 +1,10 @@ - + - + Floating Button