Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ダイアログをコンポーネント化 #1

Merged
merged 2 commits into from
Oct 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions voicevox_src/src/components/UpdateNotificationDialog.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<template>
<q-dialog v-model="modelValueComputed">
<q-card>
<q-card-section class="text-h6">
新しいアップデートがあります!
</q-card-section>
<q-card-section>
<!-- href の前にコロンつけないとダメ -->
<q-btn
color="primary"
:href="downloadLink"
tag="a"
target="_blank"
label="ダウンロードページへ"
@click="toDialogClosedState"
/>
<q-btn label="後で" @click="toDialogClosedState" />
</q-card-section>
</q-card>
</q-dialog>
</template>

<script setup lang="ts">
import { computed } from "vue";

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 toDialogClosedState = () => {
modelValueComputed.value = false;
};

const downloadLink = "https://voicevox.hiroshiba.jp/";
</script>

43 changes: 16 additions & 27 deletions voicevox_src/src/views/EditorHome.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@
<q-page-container>
<q-page class="main-row-panes">
<progress-dialog />
<!-- アップデート可能ダイアログ -->
<!-- なぜかパスカルケースとケバブケースが対応しているみたい -->
<update-notification-dialog
v-if="isUpdateAvailable"
v-model="isUpdateNotificationDialogOpenComputed"
/>

<!-- TODO: 複数エンジン対応 -->
<!-- TODO: allEngineStateが "ERROR" のときエラーになったエンジンを探してトーストで案内 -->
Expand Down Expand Up @@ -44,23 +50,6 @@
>
<q-btn v-else outline @click="openQa">Q&Aを見る</q-btn>
</template>
<!-- ダイアログ テスト -->
<q-dialog v-model="showModal" v-if="props.isUpdateAvailable">
<q-card>
<q-card-section class="text-h6">
新しいアップデートがあります!
</q-card-section>
<q-card-section>
<q-btn color="primary"
to="https://voicevox.hiroshiba.jp"
tag="a"
target="_blank"
label="アップデートする"
@click="closeModal" />
<q-btn label="後で通知する" @click="closeModal" />
</q-card-section>
</q-card>
</q-dialog>
</div>
</div>
<q-splitter
Expand Down Expand Up @@ -232,15 +221,11 @@ import {
} from "@/type/preload";
import { isOnCommandOrCtrlKeyDown } from "@/store/utility";
import { parseCombo, setHotkeyFunctions } from "@/store/setting";
import { UpdateInfo } from "@/type/preload";
import UpdateNotificationDialog from "@/components/UpdateNotificationDialog.vue";

const props =
defineProps<{
projectFilePath: string;
latestVersion: string;
downloadLink: string;
updateInfos: UpdateInfo[];
isUpdateAvailable: boolean;
}>();

const store = useStore();
Expand Down Expand Up @@ -867,11 +852,15 @@ const showAddAudioItemButton = computed(() => {
return store.state.showAddAudioItemButton;
});

const showModal = ref(true);

function closeModal() {
showModal.value = false;
}
// アップデート可能ダイアログ
const isUpdateAvailable = ref<boolean>(true);
const isUpdateNotificationDialogOpenComputed = ref<boolean>(true);
/* 他のis.*OpenComputedと同じように以下のようにしたい. type.tsとui.tsに追記する必要がある.
= computed({
get: () => store.state.isUpdateNotificationDialogOpen,
set: (val) => store.dispatch("SET_DIALOG_OPEN", { isUpdateNotificationDialogOpen: val }),
});
*/
</script>

<style scoped lang="scss">
Expand Down