diff --git a/client/desktop/src/main/lib/capturer-source-picker.html b/client/desktop/assets/capturer-source-picker.html similarity index 100% rename from client/desktop/src/main/lib/capturer-source-picker.html rename to client/desktop/assets/capturer-source-picker.html diff --git a/client/desktop/electron-builder.yml b/client/desktop/electron-builder.yml index 7e6bb371..6101aea7 100644 --- a/client/desktop/electron-builder.yml +++ b/client/desktop/electron-builder.yml @@ -6,6 +6,7 @@ files: - dist - node_modules - package.json + - assets/ afterSign: .erb/scripts/notarize.js mac: target: diff --git a/client/desktop/src/main/main.ts b/client/desktop/src/main/main.ts index c26fd68d..008f8453 100644 --- a/client/desktop/src/main/main.ts +++ b/client/desktop/src/main/main.ts @@ -20,15 +20,13 @@ import { import { autoUpdater } from 'electron-updater'; import log from 'electron-log'; import MenuBuilder from './menu'; -import { resolveHtmlPath } from './util'; +import { getCapturerSourcePickerUrl, resolveHtmlPath } from './util'; import windowStateKeeper from 'electron-window-state'; import is from 'electron-is'; import { initScreenshots } from './screenshots'; import { generateInjectedScript } from './inject'; import { handleTailchatMessage } from './inject/message-handler'; import { initWebviewManager } from './lib/webview-manager'; -// @ts-ignore -import capturerSourcePickerHtmlUrl from './lib/capturer-source-picker.html'; log.info('Start...'); @@ -308,9 +306,9 @@ const createCapturerSourcePicker = async ( }); // 加载欢迎窗口的HTML文件 - capturerSourcePickerWindow.webContents.loadFile( - path.resolve(__dirname, capturerSourcePickerHtmlUrl) - ); + const htmlPath = getCapturerSourcePickerUrl(); + log.info('htmlPath', htmlPath); + capturerSourcePickerWindow.webContents.loadFile(htmlPath); capturerSourcePickerWindow.webContents.on('did-finish-load', () => { if (capturerSourcePickerWindow) { diff --git a/client/desktop/src/main/menu.ts b/client/desktop/src/main/menu.ts index d3ddb5de..83552d2e 100644 --- a/client/desktop/src/main/menu.ts +++ b/client/desktop/src/main/menu.ts @@ -5,6 +5,7 @@ import { BrowserWindow, MenuItemConstructorOptions, } from 'electron'; +import log from 'electron-log'; interface DarwinMenuItemConstructorOptions extends MenuItemConstructorOptions { selector?: string; @@ -243,6 +244,12 @@ export default class MenuBuilder { shell.openExternal('https://github.com/msgbyte/tailchat/issues'); }, }, + { + label: 'Logs', + click() { + shell.showItemInFolder(log.transports.file.getFile().path); + }, + }, ], }, ]; diff --git a/client/desktop/src/main/util.ts b/client/desktop/src/main/util.ts index ddea9da5..2c773499 100644 --- a/client/desktop/src/main/util.ts +++ b/client/desktop/src/main/util.ts @@ -16,3 +16,14 @@ export function resolveHtmlPath(htmlFileName: string) { export function getDefaultLoggerPath(): string { return log.transports.file.getFile().path; } + +export function getCapturerSourcePickerUrl() { + if (process.env.NODE_ENV === 'development') { + return path.resolve(__dirname, '../../assets/capturer-source-picker.html'); + } else { + return path.resolve( + __dirname, + '../../../assets/capturer-source-picker.html' + ); + } +}