-
Notifications
You must be signed in to change notification settings - Fork 309
/
HelpDialog.vue
313 lines (291 loc) · 8.7 KB
/
HelpDialog.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
<template>
<QDialog
v-model="modelValueComputed"
maximized
transitionShow="jump-up"
transitionHide="jump-down"
class="help-dialog transparent-backdrop"
>
<QLayout container view="hHh Lpr lff">
<QPageContainer>
<QHeader class="q-pa-sm">
<QToolbar>
<QToolbarTitle class="text-display">
ヘルプ /
{{ selectedPage.parent ? selectedPage.parent + " / " : ""
}}{{ selectedPage.name }}
</QToolbarTitle>
<QBtn
v-if="selectedPage.shouldShowOpenLogDirectoryButton"
unelevated
color="toolbar-button"
textColor="toolbar-button-display"
class="text-no-wrap text-bold q-mr-sm"
@click="openLogDirectory"
>
ログフォルダを開く
</QBtn>
<!-- close button -->
<QBtn
round
flat
icon="close"
color="display"
aria-label="ヘルプを閉じる"
@click="modelValueComputed = false"
/>
</QToolbar>
</QHeader>
<BaseNavigationView>
<template #sidebar>
<template v-for="(page, pageIndex) of pagedata" :key="pageIndex">
<BaseListItem
v-if="page.type === 'item'"
:selected="selectedPageIndex === pageIndex"
@click="selectedPageIndex = pageIndex"
>
{{ page.name }}
</BaseListItem>
<div v-else-if="page.type === 'separator'" class="list-label">
{{ page.name }}
</div>
</template>
</template>
<QTabPanels v-model="selectedPageIndex">
<QTabPanel
v-for="(page, pageIndex) of pagedata"
:key="pageIndex"
:name="pageIndex"
class="q-pa-none"
>
<Component
:is="page.component"
v-if="page.type === 'item'"
v-bind="page.props"
/>
</QTabPanel>
</QTabPanels>
</BaseNavigationView>
</QPageContainer>
</QLayout>
</QDialog>
</template>
<script setup lang="ts">
import { computed, ref } from "vue";
import type { Component } from "vue";
import MarkdownView from "./HelpMarkdownViewSection.vue";
import OssLicense from "./HelpOssLicenseSection.vue";
import UpdateInfo from "./HelpUpdateInfoSection.vue";
import LibraryPolicy from "./HelpLibraryPolicySection.vue";
import BaseListItem from "@/components/Base/BaseListItem.vue";
import BaseNavigationView from "@/components/Base/BaseNavigationView.vue";
import { UpdateInfo as UpdateInfoObject, UrlString } from "@/type/preload";
import { useStore } from "@/store";
import { useFetchNewUpdateInfos } from "@/composables/useFetchNewUpdateInfos";
import { createLogger } from "@/domain/frontend/log";
type PageItem = {
type: "item";
name: string;
parent?: string;
component: Component;
props?: Record<string, unknown>;
shouldShowOpenLogDirectoryButton?: boolean;
};
type PageSeparator = {
type: "separator";
name: string;
};
type PageData = PageItem | PageSeparator;
const props = defineProps<{
modelValue: boolean;
}>();
const emit = defineEmits<{
(e: "update:modelValue", val: boolean): void;
}>();
const modelValueComputed = computed({
get: () => props.modelValue,
set: (val) => emit("update:modelValue", val),
});
// エディタのアップデート確認
const store = useStore();
const { warn } = createLogger("HelpDialog");
const updateInfos = ref<UpdateInfoObject[]>();
void store.actions.GET_UPDATE_INFOS().then((obj) => (updateInfos.value = obj));
if (!import.meta.env.VITE_LATEST_UPDATE_INFOS_URL) {
throw new Error(
"環境変数VITE_LATEST_UPDATE_INFOS_URLが設定されていません。.envに記載してください。",
);
}
const newUpdateResult = useFetchNewUpdateInfos(
() => window.backend.getAppInfos().then((obj) => obj.version), // アプリのバージョン
UrlString(import.meta.env.VITE_LATEST_UPDATE_INFOS_URL),
);
// エディタのOSSライセンス取得
const licenses = ref<Record<string, string>[]>();
void store.actions.GET_OSS_LICENSES().then((obj) => (licenses.value = obj));
const policy = ref<string>();
void store.actions.GET_POLICY_TEXT().then((obj) => (policy.value = obj));
const howToUse = ref<string>();
void store.actions.GET_HOW_TO_USE_TEXT().then((obj) => (howToUse.value = obj));
const ossCommunityInfos = ref<string>();
void store.actions
.GET_OSS_COMMUNITY_INFOS()
.then((obj) => (ossCommunityInfos.value = obj));
const qAndA = ref<string>();
void store.actions.GET_Q_AND_A_TEXT().then((obj) => (qAndA.value = obj));
const contact = ref<string>();
void store.actions.GET_CONTACT_TEXT().then((obj) => (contact.value = obj));
const pagedata = computed(() => {
const data: PageData[] = [
{
type: "item",
name: "ソフトウェアの利用規約",
component: MarkdownView,
props: {
markdown: policy.value,
},
},
{
type: "item",
name: "音声ライブラリの利用規約",
component: LibraryPolicy,
},
{
type: "item",
name: "使い方",
component: MarkdownView,
props: {
markdown: howToUse.value,
},
},
{
type: "item",
name: "開発コミュニティ",
component: MarkdownView,
props: {
markdown: ossCommunityInfos.value,
},
},
{
type: "item",
name: "ライセンス情報",
component: OssLicense,
props: {
licenses: licenses.value,
},
},
{
type: "item",
name: "アップデート情報",
component: UpdateInfo,
props: {
downloadLink: import.meta.env.VITE_OFFICIAL_WEBSITE_URL,
updateInfos: updateInfos.value,
...(newUpdateResult.value.status == "updateAvailable"
? {
isUpdateAvailable: true,
latestVersion: newUpdateResult.value.latestVersion,
}
: {
isUpdateAvailable: false,
latestVersion: undefined,
}),
},
},
{
type: "item",
name: "よくあるご質問",
component: MarkdownView,
props: {
markdown: qAndA.value,
},
},
{
type: "item",
name: "お問い合わせ",
component: MarkdownView,
props: {
markdown: contact.value,
},
shouldShowOpenLogDirectoryButton: true,
},
];
// エンジンが一つだけの場合は従来の表示のみ
if (store.state.engineIds.length > 1) {
for (const id of store.getters.GET_SORTED_ENGINE_INFOS.map((m) => m.uuid)) {
const manifest = store.state.engineManifests[id];
if (!manifest) {
warn(`manifest not found: ${id}`);
continue;
}
data.push(
{
type: "separator",
name: manifest.name,
},
{
type: "item",
name: "利用規約",
parent: manifest.name,
component: MarkdownView,
props: {
markdown: manifest.termsOfService,
},
},
{
type: "item",
name: "ライセンス情報",
parent: manifest.name,
component: OssLicense,
props: {
licenses: manifest.dependencyLicenses,
},
},
{
type: "item",
name: "アップデート情報",
parent: manifest.name,
component: UpdateInfo,
props: {
updateInfos: manifest.updateInfos,
// TODO: エンジン側で最新バージョンチェックAPIが出来たら実装する。
// https://github.com/VOICEVOX/voicevox_engine/issues/476
isUpdateAvailable: false,
},
},
);
}
}
return data;
});
const selectedPageIndex = ref(0);
const selectedPage = computed(() => {
if (pagedata.value[selectedPageIndex.value].type == "item") {
return pagedata.value[selectedPageIndex.value] as PageItem;
} else {
throw new Error("selectedPageにはPageItem型の値を指定してください。");
}
});
const openLogDirectory = () => window.backend.openLogDirectory();
</script>
<style scoped lang="scss">
@use "@/styles/v2/colors" as colors;
@use "@/styles/v2/variables" as vars;
.list-label {
padding: vars.$padding-2;
padding-bottom: vars.$padding-1;
color: colors.$display-sub;
}
.help-dialog .q-layout-container :deep(.absolute-full) {
right: 0 !important;
.scroll {
left: unset !important;
right: unset !important;
width: unset !important;
max-height: unset;
}
}
.q-tab-panels {
display: contents;
}
</style>