Skip to content

Commit

Permalink
refactor(about_window): enable sandbox on the about window
Browse files Browse the repository at this point in the history
  • Loading branch information
hal-shu-sato committed Oct 30, 2023
1 parent efc45eb commit 3774420
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 18 deletions.
1 change: 0 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,6 @@ async function launch() {
icon: icon,
webPreferences: {
preload: ABOUT_WINDOW_PRELOAD_WEBPACK_ENTRY,
sandbox: false,
},
});
aboutWindow.once('close', () => {
Expand Down
28 changes: 11 additions & 17 deletions src/renderer/about/about_preload.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import log from 'electron-log';
import 'source-map-support/register';
import { app, openDialog } from '../../lib/ipcWrapper';
import replaceText from '../../lib/replaceText';
// import log from 'electron-log';
// import 'source-map-support/register';
import { contextBridge } from 'electron';
import { app } from '../../lib/ipcWrapper';

log.catchErrors({
/* log.catchErrors({
onError: async () => {
await openDialog(
'エラー',
Expand All @@ -13,16 +13,10 @@ log.catchErrors({
'error',
);
},
});
}); */

window.addEventListener('click', () => {
window.close();
});

window.addEventListener('DOMContentLoaded', async () => {
const appVersion = await app.getVersion();
replaceText('app-version', appVersion);
for (const dependency of ['chrome', 'node', 'electron']) {
replaceText(`${dependency}-version`, process.versions[dependency]);
}
});
contextBridge.exposeInMainWorld(
'appVersion',
async () => await app.getVersion(),
);
contextBridge.exposeInMainWorld('versions', process.versions);
15 changes: 15 additions & 0 deletions src/renderer/about/about_renderer.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
import '../../../node_modules/bootstrap/dist/css/bootstrap.min.css';
import '../main.css';
import './about.css';
import replaceText from '../../lib/replaceText';

declare const appVersion: () => Promise<string>;
declare const versions: { [key: string]: string };

window.addEventListener('click', () => {
window.close();
});

window.addEventListener('DOMContentLoaded', async () => {
replaceText('app-version', await appVersion());
for (const dependency of ['chrome', 'node', 'electron']) {
replaceText(`${dependency}-version`, versions[dependency]);
}
});

0 comments on commit 3774420

Please sign in to comment.