Skip to content

Commit

Permalink
refactor: electron/main.tsのappDirPathと__staticをカプセル化 (#2567)
Browse files Browse the repository at this point in the history
  • Loading branch information
Hiroshiba authored Feb 26, 2025
1 parent da3e457 commit f19ef05
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions src/backend/electron/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,18 +113,23 @@ process.on("unhandledRejection", (reason) => {
log.error(reason);
});

let appDirPath: string;
let __static: string;
function initializeAppPaths() {
let appDirPath: string;
let __static: string;

if (isDevelopment) {
// __dirnameはdist_electronを指しているので、一つ上のディレクトリに移動する
appDirPath = path.resolve(__dirname, "..");
__static = path.join(appDirPath, "public");
} else {
appDirPath = path.dirname(app.getPath("exe"));
process.chdir(appDirPath);
__static = __dirname;
if (isDevelopment) {
// __dirnameはdist_electronを指しているので、一つ上のディレクトリに移動する
appDirPath = path.resolve(__dirname, "..");
__static = path.join(appDirPath, "public");
} else {
appDirPath = path.dirname(app.getPath("exe"));
process.chdir(appDirPath);
__static = __dirname;
}

return { appDirPath, __static };
}
const { appDirPath, __static } = initializeAppPaths();

protocol.registerSchemesAsPrivileged([
{ scheme: "app", privileges: { secure: true, standard: true, stream: true } },
Expand Down

0 comments on commit f19ef05

Please sign in to comment.