Skip to content

Commit

Permalink
refactor(ui): 对新架构下, 制作新的按键音 时, 按下配置 以及 抬起配置 中的 选择声音框所依赖的 options, 对象…
Browse files Browse the repository at this point in the history
…中字段, 进行重构。 将key字段改名为type字段。

commit #39、commit #36
  • Loading branch information
LuSrackhall committed Nov 13, 2024
1 parent b4e407d commit a3d435b
Showing 1 changed file with 26 additions and 26 deletions.
52 changes: 26 additions & 26 deletions frontend/src/pages/KeytonePkgPageChildren/Create_keytone_pkg.vue
Original file line number Diff line number Diff line change
Expand Up @@ -829,15 +829,15 @@
v-model="selectedSoundsForDown"
:options="downSoundList"
:option-label="(item: any) => {
if (item.key === 'audio_files') {
return (options.find((option) => item.key === option.value)?.label ) + '  §   ' + (item?.value?.name + item?.value?.type);
if (item.type === 'audio_files') {
return (options.find((option) => item.type === option.value)?.label ) + '  §   ' + (item?.value?.name + item?.value?.type);
}
if (item.key === 'sounds') {
if (item.type === 'sounds') {
// 此处的item可以是any , 但其soundList的源类型, 必须是指定准确, 否则此处会发生意外报错, 且无法定位
if (item.value.soundValue?.name !== '' && item.value.soundValue?.name !== undefined) {
return item.value.soundValue.name;
return (options.find((option) => item.type === option.value)?.label ) + '      §   ' + (item.value.soundValue.name)
} else {
return (options.find((option) => item.key === option.value)?.label ) + '      §   ' + (
return (options.find((option) => item.type === option.value)?.label ) + '      §   ' + (
soundFileList.find(
(soundFile:any) =>
soundFile.sha256 === item.value.soundValue?.source_file_for_sound?.sha256 &&
Expand All @@ -852,8 +852,8 @@
);
}
}
if (item.key === 'key_sounds') {
return (options.find((option) => item.key === option.value)?.label ) + '  §   ' + (item.value.keySoundValue?.name);
if (item.type === 'key_sounds') {
return (options.find((option) => item.type === option.value)?.label ) + '  §   ' + (item.value.keySoundValue?.name);
}
}"
label="选择声音 (多选)"
Expand Down Expand Up @@ -983,15 +983,15 @@
v-model="selectedSoundsForUp"
:options="upSoundList"
:option-label="(item: any) => {
if (item.key === 'audio_files') {
return (options.find((option) => item.key === option.value)?.label ) + '  §   ' + (item?.value?.name + item?.value?.type);
if (item.type === 'audio_files') {
return (options.find((option) => item.type === option.value)?.label ) + '  §   ' + (item?.value?.name + item?.value?.type);
}
if (item.key === 'sounds') {
if (item.type === 'sounds') {
// 此处的item可以是any , 但其soundList的源类型, 必须是指定准确, 否则此处会发生意外报错, 且无法定位
if (item.value.soundValue?.name !== '' && item.value.soundValue?.name !== undefined) {
return item.value.soundValue.name;
return (options.find((option) => item.type === option.value)?.label ) + '      §   '+ (item.value.soundValue.name)
} else {
return (options.find((option) => item.key === option.value)?.label ) + '      §   ' + (
return (options.find((option) => item.type === option.value)?.label ) + '      §   ' + (
soundFileList.find(
(soundFile:any) =>
soundFile.sha256 === item.value.soundValue?.source_file_for_sound?.sha256 &&
Expand All @@ -1006,8 +1006,8 @@
);
}
}
if (item.key === 'key_sounds') {
return (options.find((option) => item.key === option.value)?.label ) + '  §   ' + (item.value.keySoundValue?.name);
if (item.type === 'key_sounds') {
return (options.find((option) => item.type === option.value)?.label ) + '  §   ' + (item.value.keySoundValue?.name);
}
}"
label="选择声音 (多选)"
Expand Down Expand Up @@ -1696,17 +1696,17 @@ const downSoundList = computed(() => {
const List: Array<any> = [];
if (downTypeGroup.value.includes('audio_files')) {
soundFileList.value.forEach((item) => {
List.push({ key: 'audio_files', value: item });
List.push({ type: 'audio_files', value: item });
});
}
if (downTypeGroup.value.includes('sounds')) {
soundList.value.forEach((item) => {
List.push({ key: 'sounds', value: item });
List.push({ type: 'sounds', value: item });
});
}
if (downTypeGroup.value.includes('key_sounds')) {
keySoundList.value.forEach((item) => {
List.push({ key: 'key_sounds', value: item });
List.push({ type: 'key_sounds', value: item });
});
}
console.log('List=', List);
Expand All @@ -1727,17 +1727,17 @@ const upSoundList = computed(() => {
const List: Array<any> = [];
if (upTypeGroup.value.includes('audio_files')) {
soundFileList.value.forEach((item) => {
List.push({ key: 'audio_files', value: item });
List.push({ type: 'audio_files', value: item });
});
}
if (upTypeGroup.value.includes('sounds')) {
soundList.value.forEach((item) => {
List.push({ key: 'sounds', value: item });
List.push({ type: 'sounds', value: item });
});
}
if (upTypeGroup.value.includes('key_sounds')) {
keySoundList.value.forEach((item) => {
List.push({ key: 'key_sounds', value: item });
List.push({ type: 'key_sounds', value: item });
});
}
return List;
Expand Down Expand Up @@ -1806,33 +1806,33 @@ function saveKeySoundConfig(
down: {
mode: params.down.mode,
value: params.down.value.map((item) => {
if (item.key === 'audio_files') {
if (item.type === 'audio_files') {
return {
type: 'audio_files',
value: { sha256: item.value.sha256, name_id: item.value.name_id, type: item.value.type },
};
}
if (item.key === 'sounds') {
if (item.type === 'sounds') {
return { type: 'sounds', value: item.value.soundKey };
}
if (item.key === 'key_sounds') {
if (item.type === 'key_sounds') {
return { type: 'key_sounds', value: item.value.keySoundKey };
}
}),
},
up: {
mode: params.up.mode,
value: params.up.value.map((item) => {
if (item.key === 'audio_files') {
if (item.type === 'audio_files') {
return {
type: 'audio_files',
value: { sha256: item.value.sha256, name_id: item.value.name_id, type: item.value.type },
};
}
if (item.key === 'sounds') {
if (item.type === 'sounds') {
return { type: 'sounds', value: item.value.soundKey };
}
if (item.key === 'key_sounds') {
if (item.type === 'key_sounds') {
return { type: 'key_sounds', value: item.value.keySoundKey };
}
}),
Expand Down

0 comments on commit a3d435b

Please sign in to comment.