Skip to content

Commit

Permalink
VOICEVOX#2524 の変更提案プルリクエスト (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
Hiroshiba authored Feb 15, 2025
1 parent 5b9ed1f commit 7ed9924
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 15 deletions.
10 changes: 3 additions & 7 deletions src/backend/electron/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ function checkMultiEngineEnabled(): boolean {
return enabled;
}

/** コマンドライン引数を取得する */
function getArgv(): string[] {
// 製品版でmacOS以外の場合、引数はargv[1]以降をそのまま
if (isProduction) {
Expand All @@ -262,7 +263,7 @@ function getArgv(): string[] {
return [];
}

let initialFilePath: string | undefined = getArgv()[0];
let initialFilePath: string | undefined = getArgv()[0]; // TODO: カプセル化する

const menuTemplateForMac: Electron.MenuItemConstructorOptions[] = [
{
Expand Down Expand Up @@ -373,12 +374,7 @@ registerIpcMainHandle<IpcMainHandle>({
},

GET_INITIAL_PROJECT_FILE_PATH: async () => {
if (
initialFilePath &&
fs.existsSync(initialFilePath) &&
fs.statSync(initialFilePath).isFile() &&
initialFilePath.endsWith(".vvproj")
) {
if (initialFilePath && initialFilePath.endsWith(".vvproj")) {
return initialFilePath;
}
},
Expand Down
4 changes: 2 additions & 2 deletions src/components/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,8 @@ onMounted(async () => {
});
// プロジェクトファイルが指定されていればロード
const projectFilePath = await window.backend.getInitialProjectFilePath();
if (typeof projectFilePath === "string" && projectFilePath !== "") {
const projectFilePath = await store.actions.GET_INITIAL_PROJECT_FILE_PATH();
if (projectFilePath != undefined) {
isProjectFileLoaded.value = await store.actions.LOAD_PROJECT_FILE({
type: "path",
filePath: projectFilePath,
Expand Down
6 changes: 6 additions & 0 deletions src/store/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,12 @@ export const projectStore = createPartialStore<ProjectStoreTypes>({
}),
},

GET_INITIAL_PROJECT_FILE_PATH: {
action: async () => {
return await window.backend.getInitialProjectFilePath();
},
},

IS_EDITED: {
getter(state, getters) {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
Expand Down
4 changes: 4 additions & 0 deletions src/store/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1859,6 +1859,10 @@ export type ProjectStoreTypes = {
}): "saved" | "discarded" | "canceled";
};

GET_INITIAL_PROJECT_FILE_PATH: {
action(): Promise<string | undefined>;
};

IS_EDITED: {
getter: boolean;
};
Expand Down
9 changes: 3 additions & 6 deletions vite.config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,9 @@ export default defineConfig((options) => {
// ここのprocess.argvは以下のような形で渡ってくる:
// ["node", ".../vite.js", (...vite用の引数...), "--", その他引数...]
const args: string[] = [".", "--no-sandbox"];
const doubleSeparatorIndex = process.argv.indexOf("--");
if (doubleSeparatorIndex !== -1) {
args.push(
"--",
...process.argv.slice(doubleSeparatorIndex + 1),
);
const doubleDashIndex = process.argv.indexOf("--");
if (doubleDashIndex !== -1) {
args.push("--", ...process.argv.slice(doubleDashIndex + 1));
}
void startup(args);
}
Expand Down

0 comments on commit 7ed9924

Please sign in to comment.