Skip to content
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
3 changes: 2 additions & 1 deletion src/components/Dialog/Dialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,12 @@ export type WarningDialogOptions = {
isWarningColorButton?: boolean; // ボタンをWarning色にするか
cancel?: string;
};
export type QuestionDialogButtonColor = "display" | "primary" | "warning";
export type QuestionDialogOptions = {
type?: DialogType;
title: string;
message: string;
buttons: (string | { text: string; color: string })[];
buttons: (string | { text: string; color: QuestionDialogButtonColor })[];
cancel: number;
default?: number;
};
Expand Down
13 changes: 9 additions & 4 deletions src/components/Dialog/TextDialog/QuestionDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,19 @@
<script setup lang="ts">
import { QBtn, useDialogPluginComponent } from "quasar";
import { computed, onMounted, useTemplateRef } from "vue";
import { QuestionDialogButtonColor } from "../Dialog";
import { getIcon, getColor, DialogType } from "./common";
import BaseDialog from "@/components/Base/BaseDialog.vue";
import BaseButton from "@/components/Base/BaseButton.vue";
import { ExhaustiveError } from "@/type/utility";

const modelValue = defineModel<boolean>({ default: false });
const props = withDefaults(
defineProps<{
type: DialogType;
title: string;
message: string;
buttons: (string | { text: string; color: string })[];
buttons: (string | { text: string; color: QuestionDialogButtonColor })[];
persistent?: boolean | undefined;
default?: number | undefined;
}>(),
Expand All @@ -59,7 +61,10 @@ defineEmits({
const iconName = computed(() => getIcon(props.type));
const color = computed(() => getColor(props.type));
const buttonObjects = computed(() =>
props.buttons.map((button) =>
props.buttons.map<{
text: string;
color: QuestionDialogButtonColor;
}>((button) =>
typeof button === "string" ? { text: button, color: "display" } : button,
),
);
Expand All @@ -68,7 +73,7 @@ const { dialogRef, onDialogOK, onDialogHide } = useDialogPluginComponent();

const buttonsRef = useTemplateRef<QBtn[]>("buttons");

const toButtonVariant = (color: string) => {
const toButtonVariant = (color: QuestionDialogButtonColor) => {
switch (color) {
case "display":
return "default";
Expand All @@ -77,7 +82,7 @@ const toButtonVariant = (color: string) => {
case "warning":
return "danger";
default:
throw new Error("unknown color type: " + color);
throw new ExhaustiveError(color);
}
};

Expand Down
2 changes: 1 addition & 1 deletion src/store/project/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ export const projectStore = createPartialStore<ProjectStoreTypes>({
title: "プロジェクトファイルのバージョン警告",
message:
"このプロジェクトファイルは新しいバージョンのVOICEVOXで作成されたため、一部の機能が正しく動作しない可能性があります。読み込みを続行しますか?",
buttons: ["いいえ", { text: "はい", color: "danger" }],
buttons: ["いいえ", { text: "はい", color: "warning" }],
cancel: 0,
});
return result === 1;
Expand Down
Loading