Skip to content

Commit

Permalink
add AccentPhraseに個別idを設定
Browse files Browse the repository at this point in the history
AccentPhraseを継承したEditorAccentPhraseという型を作成し、EditorAudioQueryのプロパティとした。

AudioDetail.vueファイルの中でaccentPhrases変数の変更のタイミングで割り振るように
  • Loading branch information
P0ngCh4ng committed Feb 27, 2024
1 parent 8b959ab commit 7606c95
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/components/Talk/AudioDetail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
</ToolTip>
<AccentPhrase
v-for="(accentPhrase, accentPhraseIndex) in accentPhrases"
:key="accentPhraseIndex"
:key="accentPhrase.editorID"
ref="accentPhraseComponents"
:audio-key="activeAudioKey"
:accent-phrase="accentPhrase"
Expand Down Expand Up @@ -234,6 +234,9 @@ const setPlayAndStartPoint = (accentPhraseIndex: number) => {
};
watch(accentPhrases, async () => {
await store.dispatch("SET_ACCENT_PHRASES_EDITORID", {
audioKey: props.activeAudioKey,
});
activePoint.value = startPoint.value;
// 連続再生時に、最初に選択されていた場所に戻るためにscrollToActivePointを呼ぶ必要があるが、
// DOMの描画が少し遅いので、nextTickをはさむ
Expand Down
20 changes: 20 additions & 0 deletions src/store/audio.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1012,6 +1012,26 @@ export const audioStore = createPartialStore<AudioStoreTypes>({
query.accentPhrases.splice(accentPhraseIndex, 1, ...accentPhrases);
},
},
SET_ACCENT_PHRASES_EDITORID: {
mutation(
state,
{
audioKey,
}: {
audioKey: AudioKey;
}
) {
const accentPhrases = state.audioItems[audioKey].query?.accentPhrases;
if (accentPhrases)
accentPhrases.map((elem) => {
if (!elem.editorID)
elem.editorID = uuidv4();
});
},
action({ commit }, { audioKey }: { audioKey: AudioKey }) {
commit("SET_ACCENT_PHRASES_EDITORID", { audioKey });
},
},

SET_AUDIO_MORA_DATA: {
mutation(
Expand Down
16 changes: 14 additions & 2 deletions src/store/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,12 @@ import { OverlappingNoteInfos } from "@/sing/storeHelper";
/**
* エディタ用のAudioQuery
*/
export type EditorAudioQuery = Omit<AudioQuery, "outputSamplingRate"> & {
export type EditorAudioQuery = Omit<
AudioQuery,
"outputSamplingRate" | "accentPhrases"
> & {
outputSamplingRate: number | "engineDefault";
accentPhrases: Array<EditorAccentPhrase>;
};

export type AudioItem = {
Expand Down Expand Up @@ -125,6 +129,9 @@ export type StoreType<T, U extends "getter" | "mutation" | "action"> = {
: R
: never;
};
export interface EditorAccentPhrase extends AccentPhrase {
editorID?: string;
}

/*
* Audio Store Types
Expand Down Expand Up @@ -349,7 +356,12 @@ export type AudioStoreTypes = {
accentPhrases: AccentPhrase[];
};
};

SET_ACCENT_PHRASES_EDITORID: {
mutation: {
audioKey: AudioKey;
};
action(payload: { audioKey: AudioKey }): void;
};
SET_AUDIO_MORA_DATA: {
mutation: {
audioKey: AudioKey;
Expand Down

0 comments on commit 7606c95

Please sign in to comment.