Skip to content

Commit

Permalink
一部の処理をコンポーザブルへ移動
Browse files Browse the repository at this point in the history
  • Loading branch information
jdkfx committed Nov 30, 2024
1 parent 5f916c6 commit bd5eb97
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
13 changes: 1 addition & 12 deletions src/components/Dialog/DictionaryEditWordDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -286,16 +286,6 @@ const wordPriorityLabels = {
10: "最高",
};
// accent phraseにあるaccentと実際に登録するアクセントには差が生まれる
// アクセントが自動追加される「ガ」に指定されている場合、
// 実際に登録するaccentの値は0となるので、そうなるように処理する
const computeRegisteredAccent = () => {
if (!accentPhrase.value) throw new Error();
let accent = accentPhrase.value.accent;
accent = accent === accentPhrase.value.moras.length ? 0 : accent;
return accent;
};
const saveWord = async () => {
if (!accentPhrase.value) throw new Error(`accentPhrase === undefined`);
const accent = computeRegisteredAccent();
Expand Down Expand Up @@ -344,7 +334,6 @@ const resetWord = async (id: string) => {
actionName: "リセット",
});
if (result === "OK") {
// props.selectedId = id; // idを指定している理由が不明のためコメントアウト
surface.value = userDict.value[id].surface;
void setYomi(userDict.value[id].yomi, true);
wordPriority.value = userDict.value[id].priority;
Expand All @@ -359,6 +348,7 @@ const {
isWordChanged,
setYomi,
createUILockAction,
computeRegisteredAccent,

Check failure on line 351 in src/components/Dialog/DictionaryEditWordDialog.vue

View workflow job for this annotation

GitHub Actions / build_preview_pages

Property 'computeRegisteredAccent' does not exist on type '{ wordPriority: Ref<number, number>; userDict: Ref<Record<string, UserDictWord>, Record<string, UserDictWord>>; voiceComputed: ComputedRef<...>; ... 8 more ...; toWordEditingState: () => void; }'.

Check failure on line 351 in src/components/Dialog/DictionaryEditWordDialog.vue

View workflow job for this annotation

GitHub Actions / lint

Property 'computeRegisteredAccent' does not exist on type '{ wordPriority: Ref<number, number>; userDict: Ref<Record<string, UserDictWord>, Record<string, UserDictWord>>; voiceComputed: ComputedRef<...>; ... 8 more ...; toWordEditingState: () => void; }'.

Check failure on line 351 in src/components/Dialog/DictionaryEditWordDialog.vue

View workflow job for this annotation

GitHub Actions / build-test

Property 'computeRegisteredAccent' does not exist on type '{ wordPriority: Ref<number, number>; userDict: Ref<Record<string, UserDictWord>, Record<string, UserDictWord>>; voiceComputed: ComputedRef<...>; ... 8 more ...; toWordEditingState: () => void; }'.
loadingDictProcess,
discardOrNotDialog,
cancel,
Expand All @@ -369,7 +359,6 @@ const {
selectIdRef,
surface,
uiLocked,
computeRegisteredAccent,
yomi,

Check failure on line 362 in src/components/Dialog/DictionaryEditWordDialog.vue

View workflow job for this annotation

GitHub Actions / build_preview_pages

Argument of type 'Ref<string, string>' is not assignable to parameter of type 'Ref<"loading" | "synchronizing" | null, "loading" | "synchronizing" | null>'.

Check failure on line 362 in src/components/Dialog/DictionaryEditWordDialog.vue

View workflow job for this annotation

GitHub Actions / lint

Argument of type 'Ref<string, string>' is not assignable to parameter of type 'Ref<"loading" | "synchronizing" | null, "loading" | "synchronizing" | null>'.

Check failure on line 362 in src/components/Dialog/DictionaryEditWordDialog.vue

View workflow job for this annotation

GitHub Actions / build-test

Argument of type 'Ref<string, string>' is not assignable to parameter of type 'Ref<"loading" | "synchronizing" | null, "loading" | "synchronizing" | null>'.
accentPhrase,
surfaceInput,
Expand Down
11 changes: 10 additions & 1 deletion src/composables/useDictionaryDialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ export function useDictionaryDialog(
surface: Ref<string>,
uiLocked: Ref<boolean>,
loadingDictState: Ref<null | "loading" | "synchronizing">,
computeRegisteredAccent: () => number,
yomi?: Ref<string>,
accentPhrase?: Ref<AccentPhrase | undefined>,
surfaceInput?: Ref<QInput | undefined>,
Expand Down Expand Up @@ -101,6 +100,16 @@ export function useDictionaryDialog(
return { engineId, speakerId, styleId };
});

// accent phraseにあるaccentと実際に登録するアクセントには差が生まれる
// アクセントが自動追加される「ガ」に指定されている場合、
// 実際に登録するaccentの値は0となるので、そうなるように処理する
const computeRegisteredAccent = () => {
if (!accentPhraseRef.value) throw new Error();
let accent = accentPhraseRef.value.accent;
accent = accent === accentPhraseRef.value.moras.length ? 0 : accent;
return accent;
};

const loadingDictProcess = async () => {
if (store.state.engineIds.length === 0)
throw new Error(`assert engineId.length > 0`);
Expand Down

0 comments on commit bd5eb97

Please sign in to comment.