Skip to content

Commit 123413c

Browse files
authored
registerFileProtocolの離脱 (#1441)
1 parent da73bcd commit 123413c

File tree

4 files changed

+28
-38
lines changed

4 files changed

+28
-38
lines changed

package-lock.json

Lines changed: 15 additions & 29 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@
9393
"@vue/test-utils": "2.3.0",
9494
"cross-env": "7.0.3",
9595
"cross-var": "1.1.0",
96-
"electron": "23.3.10",
96+
"electron": "25.3.2",
9797
"electron-builder": "24.0.0-alpha.12",
9898
"electron-devtools-installer": "3.2.0",
9999
"eslint": "8.24.0",

src/background.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
Menu,
1212
shell,
1313
nativeTheme,
14+
net,
1415
} from "electron";
1516
import installExtension, { VUEJS_DEVTOOLS } from "electron-devtools-installer";
1617
import Store, { Schema } from "electron-store";
@@ -128,17 +129,10 @@ if (isDevelopment) {
128129
__static = __dirname;
129130
}
130131

131-
// ソフトウェア起動時はプロトコルを app にする
132132
protocol.registerSchemesAsPrivileged([
133133
{ scheme: "app", privileges: { secure: true, standard: true, stream: true } },
134134
]);
135-
if (process.env.VITE_DEV_SERVER_URL == undefined) {
136-
// FIXME: registerFileProtocolが非推奨になったので対策を考える
137-
protocol.registerFileProtocol("app", (request, callback) => {
138-
const filePath = new URL(request.url).pathname;
139-
callback(path.join(__dirname, filePath));
140-
});
141-
}
135+
142136
const firstUrl = process.env.VITE_DEV_SERVER_URL ?? "app://./index.html";
143137

144138
// 設定ファイル
@@ -495,6 +489,14 @@ async function createWindow() {
495489
}
496490
}
497491

492+
// ソフトウェア起動時はプロトコルを app にする
493+
if (process.env.VITE_DEV_SERVER_URL == undefined) {
494+
protocol.handle("app", (request) => {
495+
const filePath = new URL(request.url).pathname;
496+
return net.fetch(`file://${filePath}`);
497+
});
498+
}
499+
498500
await loadUrl({ projectFilePath });
499501

500502
if (isDevelopment && !isTest) win.webContents.openDevTools();

src/background/engineManager.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -495,6 +495,8 @@ export class EngineManager {
495495

496496
if (engineProcess === undefined)
497497
throw Error("engineProcess === undefined");
498+
if (engineProcess.pid === undefined)
499+
throw Error("engineProcess.pid === undefined");
498500

499501
engineProcess.once("close", restartEngineOnProcessClosedCallback);
500502

0 commit comments

Comments
 (0)