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
- node_modules
- package.json
- assets/
afterSign: .erb/scripts/notarize.js
mac:
target:

@ -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) {

@ -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);
},
},
],
},
];

@ -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'
);
}
}

Loading…
Cancel
Save