refactor: change capturer source picker url getter to make sure its can work on dev and prod env

chore/devcontainer
moonrailgun 2 years ago
parent 3a6a729e1f
commit fedf1de8b9

@ -6,6 +6,7 @@ files:
- dist - dist
- node_modules - node_modules
- package.json - package.json
- assets/
afterSign: .erb/scripts/notarize.js afterSign: .erb/scripts/notarize.js
mac: mac:
target: target:

@ -20,15 +20,13 @@ import {
import { autoUpdater } from 'electron-updater'; import { autoUpdater } from 'electron-updater';
import log from 'electron-log'; import log from 'electron-log';
import MenuBuilder from './menu'; import MenuBuilder from './menu';
import { resolveHtmlPath } from './util'; import { getCapturerSourcePickerUrl, resolveHtmlPath } from './util';
import windowStateKeeper from 'electron-window-state'; import windowStateKeeper from 'electron-window-state';
import is from 'electron-is'; import is from 'electron-is';
import { initScreenshots } from './screenshots'; import { initScreenshots } from './screenshots';
import { generateInjectedScript } from './inject'; import { generateInjectedScript } from './inject';
import { handleTailchatMessage } from './inject/message-handler'; import { handleTailchatMessage } from './inject/message-handler';
import { initWebviewManager } from './lib/webview-manager'; import { initWebviewManager } from './lib/webview-manager';
// @ts-ignore
import capturerSourcePickerHtmlUrl from './lib/capturer-source-picker.html';
log.info('Start...'); log.info('Start...');
@ -308,9 +306,9 @@ const createCapturerSourcePicker = async (
}); });
// 加载欢迎窗口的HTML文件 // 加载欢迎窗口的HTML文件
capturerSourcePickerWindow.webContents.loadFile( const htmlPath = getCapturerSourcePickerUrl();
path.resolve(__dirname, capturerSourcePickerHtmlUrl) log.info('htmlPath', htmlPath);
); capturerSourcePickerWindow.webContents.loadFile(htmlPath);
capturerSourcePickerWindow.webContents.on('did-finish-load', () => { capturerSourcePickerWindow.webContents.on('did-finish-load', () => {
if (capturerSourcePickerWindow) { if (capturerSourcePickerWindow) {

@ -5,6 +5,7 @@ import {
BrowserWindow, BrowserWindow,
MenuItemConstructorOptions, MenuItemConstructorOptions,
} from 'electron'; } from 'electron';
import log from 'electron-log';
interface DarwinMenuItemConstructorOptions extends MenuItemConstructorOptions { interface DarwinMenuItemConstructorOptions extends MenuItemConstructorOptions {
selector?: string; selector?: string;
@ -243,6 +244,12 @@ export default class MenuBuilder {
shell.openExternal('https://github.com/msgbyte/tailchat/issues'); shell.openExternal('https://github.com/msgbyte/tailchat/issues');
}, },
}, },
{
label: 'Logs',
click() {
shell.showItemInFolder(log.transports.file.getFile().path);
},
},
], ],
}, },
]; ];

@ -16,3 +16,14 @@ export function resolveHtmlPath(htmlFileName: string) {
export function getDefaultLoggerPath(): string { export function getDefaultLoggerPath(): string {
return log.transports.file.getFile().path; 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'
);
}
}

Loading…
Cancel
Save