Skip to content

Commit

Permalink
feat: ウインドウの作成とナビゲーションを無効化する (VOICEVOX#2154)
Browse files Browse the repository at this point in the history
* feat: ウインドウの作成とナビゲーションを無効化する

* Update src/backend/electron/main.ts

---------

Co-authored-by: Hiroshiba <[email protected]>
  • Loading branch information
sabonerune and Hiroshiba authored Jul 3, 2024
1 parent 6ece7e6 commit d2f0cbe
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/backend/electron/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1018,11 +1018,19 @@ ipcMainHandle("READ_FILE", async (_, { filePath }) => {
app.on("web-contents-created", (e, contents) => {
// リンククリック時はブラウザを開く
contents.setWindowOpenHandler(({ url }) => {
if (url.match(/^http/)) {
const { protocol } = new URL(url);
if (protocol.match(/^https?:/)) {
shell.openExternal(url);
return { action: "deny" };
} else {
log.error(`許可されないリンクです。url: ${url}`);
}
return { action: "allow" };
return { action: "deny" };
});

// ナビゲーションを無効化
contents.on("will-navigate", (event) => {
log.error(`ナビゲーションは無効化されています。url: ${event.url}`);
event.preventDefault();
});
});

Expand Down

0 comments on commit d2f0cbe

Please sign in to comment.