diff --git a/electron/main.ts b/electron/main.ts index 62e5574..bbe351b 100644 --- a/electron/main.ts +++ b/electron/main.ts @@ -17,6 +17,7 @@ import { annualReportService } from './services/annualReportService' import { exportService, ExportOptions, ExportProgress } from './services/exportService' import { KeyService } from './services/keyService' import { KeyServiceMac } from './services/keyServiceMac' +import { KeyServiceLinux} from "./services/keyServiceLinux" import { voiceTranscribeService } from './services/voiceTranscribeService' import { videoService } from './services/videoService' import { snsService, isVideoUrl } from './services/snsService' @@ -95,7 +96,7 @@ let keyService: any if (process.platform === 'darwin') { keyService = new KeyServiceMac() } else if (process.platform === 'linux') { - const { KeyServiceLinux } = require('./services/keyServiceLinux') + // const { KeyServiceLinux } = require('./services/keyServiceLinux') keyService = new KeyServiceLinux() } else { keyService = new KeyService() @@ -280,12 +281,18 @@ const requestMainWindowCloseConfirmation = (win: BrowserWindow): void => { function createWindow(options: { autoShow?: boolean } = {}) { // 获取图标路径 - 打包后在 resources 目录 const { autoShow = true } = options + let iconName = 'icon.ico'; + if (process.platform === 'linux') { + iconName = 'icon.png'; + } else if (process.platform === 'darwin') { + iconName = 'icon.icns'; + } + const isDev = !!process.env.VITE_DEV_SERVER_URL + const iconPath = isDev - ? join(__dirname, '../public/icon.ico') - : (process.platform === 'darwin' - ? join(process.resourcesPath, 'icon.icns') - : join(process.resourcesPath, 'icon.ico')) + ? join(__dirname, `../public/${iconName}`) + : join(process.resourcesPath, iconName); const win = new BrowserWindow({ width: 1400, @@ -2533,12 +2540,20 @@ app.whenReady().then(async () => { updateSplashProgress(30, '正在加载界面...') mainWindow = createWindow({ autoShow: false }) - // 初始化系统托盘图标(与其他窗口 icon 路径逻辑保持一致) - const resolvedTrayIcon = process.platform === 'win32' - ? join(__dirname, '../public/icon.ico') - : (process.platform === 'darwin' - ? join(process.resourcesPath, 'icon.icns') - : join(process.resourcesPath, 'icon.ico')) + let iconName = 'icon.ico'; + if (process.platform === 'linux') { + iconName = 'icon.png'; + } else if (process.platform === 'darwin') { + iconName = 'icon.icns'; + } + + const isDev = !!process.env.VITE_DEV_SERVER_URL + + const resolvedTrayIcon = isDev + ? join(__dirname, `../public/${iconName}`) + : join(process.resourcesPath, iconName); + + try { tray = new Tray(resolvedTrayIcon) tray.setToolTip('WeFlow') diff --git a/electron/services/wcdbCore.ts b/electron/services/wcdbCore.ts index b946a67..a54a460 100644 --- a/electron/services/wcdbCore.ts +++ b/electron/services/wcdbCore.ts @@ -551,6 +551,7 @@ export class WcdbCore { const dllDir = dirname(dllPath) const isMac = process.platform === 'darwin' + const isLinux = process.platform === 'linux' // 预加载依赖库 if (isMac) { @@ -564,6 +565,8 @@ export class WcdbCore { this.writeLog(`预加载 libWCDB.dylib 失败: ${String(e)}`) } } + } else if (isLinux) { + // 如果有libWCDB.so的话, 没有就算了 } else { const wcdbCorePath = join(dllDir, 'WCDB.dll') if (existsSync(wcdbCorePath)) { diff --git a/package.json b/package.json index 21b618e..7ab669a 100644 --- a/package.json +++ b/package.json @@ -89,6 +89,18 @@ ], "icon": "public/icon.ico" }, + "linux": { + "icon": "public/icon.png", + "target": [ + "AppImage", + "pacman", + "deb", + "tar.gz" + ], + "category": "Utility", + "executableName": "weflow", + "synopsis": "WeFlow for Linux" + }, "nsis": { "oneClick": false, "differentialPackage": false, @@ -155,4 +167,4 @@ ], "icon": "resources/icon.icns" } -} \ No newline at end of file +} diff --git a/public/icon.png b/public/icon.png new file mode 100644 index 0000000..7372ec7 Binary files /dev/null and b/public/icon.png differ