1
1
<template >
2
2
<ErrorBoundary >
3
3
<!-- TODO: メニューバーをEditorHomeから移動する -->
4
- <RouterView v-slot = " { Component } " >
5
- <KeepAlive >
6
- < Component
7
- :is = " Component "
8
- :is-engines-ready = " isEnginesReady "
9
- :is-project-file-loaded = " isProjectFileLoaded "
10
- />
11
- </ KeepAlive >
12
- </RouterView >
4
+ <KeepAlive >
5
+ <Component
6
+ :is = " openedEditor == 'talk' ? TalkEditor : SingEditor "
7
+ v-if = " openedEditor != undefined "
8
+ :key = " openedEditor "
9
+ :is-engines-ready = " isEnginesReady "
10
+ :is-project-file-loaded = " isProjectFileLoaded "
11
+ / >
12
+ </KeepAlive >
13
13
<AllDialog :is-engines-ready =" isEnginesReady" />
14
14
</ErrorBoundary >
15
15
</template >
16
16
17
17
<script setup lang="ts">
18
18
import { watch , onMounted , ref , computed , toRaw } from " vue" ;
19
19
import { useGtm } from " @gtm-support/vue-gtm" ;
20
- import { useRoute } from " vue-router" ;
20
+ import TalkEditor from " @/components/Talk/TalkEditor.vue" ;
21
+ import SingEditor from " @/components/Sing/SingEditor.vue" ;
21
22
import { EngineId } from " @/type/preload" ;
22
23
import ErrorBoundary from " @/components/ErrorBoundary.vue" ;
23
24
import { useStore } from " @/store" ;
24
25
import { useHotkeyManager } from " @/plugins/hotkeyPlugin" ;
25
26
import AllDialog from " @/components/Dialog/AllDialog.vue" ;
26
27
27
28
const store = useStore ();
28
- const route = useRoute ();
29
29
30
- // TODO: プロジェクトファイルの読み込みもEditorHomeから移動する
31
- const projectFilePath = computed (() => route .query [" projectFilePath" ]);
30
+ const openedEditor = computed (() => store .state .openedEditor );
31
+
32
+ /**
33
+ * 読み込むプロジェクトファイルのパス。
34
+ * undefinedのときは何も読み込むべきものがない。
35
+ */
36
+ const projectFilePath = ref <string | undefined >(undefined );
32
37
33
38
// Google Tag Manager
34
39
const gtm = useGtm ();
@@ -49,20 +54,13 @@ watch(
49
54
{ immediate: true }
50
55
);
51
56
52
- // エディタの切り替えを監視する
57
+ // エディタの切り替えを監視してショートカットキーの設定を変更する
53
58
watch (
54
- () => route .path ,
55
- async (unknownPath ) => {
56
- let path: " talk" | " song" ;
57
- if ([" /talk" , " /song" ].includes (unknownPath )) {
58
- path = unknownPath .slice (1 ) as " talk" | " song" ;
59
- } else {
60
- // 不明なパスの場合はトークエディタにする
61
- path = " talk" ;
62
- window .backend .logWarn (` unknown path: ${unknownPath } ` );
59
+ () => store .state .openedEditor ,
60
+ async (openedEditor ) => {
61
+ if (openedEditor != undefined ) {
62
+ hotkeyManager .onEditorChange (openedEditor );
63
63
}
64
-
65
- hotkeyManager .onEditorChange (path );
66
64
}
67
65
);
68
66
@@ -71,10 +69,22 @@ const { hotkeyManager } = useHotkeyManager();
71
69
const isEnginesReady = ref (false );
72
70
const isProjectFileLoaded = ref <boolean | " waiting" >(" waiting" );
73
71
onMounted (async () => {
72
+ const queryString = window .location .search ;
73
+ const urlParams = new URLSearchParams (queryString );
74
+
74
75
await store .dispatch (" INIT_VUEX" );
75
76
76
- const hotkeySettings = store .state .hotkeySettings ;
77
+ // プロジェクトファイルのパスを取得
78
+ const _projectFilePath = urlParams .get (" projectFilePath" );
79
+ if (_projectFilePath != undefined && _projectFilePath !== " " ) {
80
+ projectFilePath .value = _projectFilePath ;
81
+ }
82
+
83
+ // どちらのエディタを開くか設定
84
+ await store .dispatch (" SET_OPENED_EDITOR" , { editor: " talk" });
77
85
86
+ // ショートカットキーの設定を登録
87
+ const hotkeySettings = store .state .hotkeySettings ;
78
88
hotkeyManager .load (structuredClone (toRaw (hotkeySettings )));
79
89
80
90
// エンジンの初期化開始
@@ -83,7 +93,7 @@ onMounted(async () => {
83
93
await store .dispatch (" GET_ENGINE_INFOS" );
84
94
85
95
// URLパラメータに従ってマルチエンジンをオフにする
86
- const isMultiEngineOffMode = route . query [ " isMultiEngineOffMode" ] === " true" ;
96
+ const isMultiEngineOffMode = urlParams . get ( " isMultiEngineOffMode" ) === " true" ;
87
97
store .dispatch (" SET_IS_MULTI_ENGINE_OFF_MODE" , isMultiEngineOffMode );
88
98
89
99
// マルチエンジンオフモードのときはデフォルトエンジンだけにする
0 commit comments