Skip to content

Commit

Permalink
允许部分快捷键计入空拍次数
Browse files Browse the repository at this point in the history
细节修正
  • Loading branch information
Steve-xmh committed Feb 8, 2024
1 parent eddf16a commit 64eff1d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 19 deletions.
27 changes: 9 additions & 18 deletions src/components/LyricSyncEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -242,48 +242,39 @@ function onKeyPress(e: KeyboardEvent) {
case "KeyF": { // 记录当前时间为当前单词的起始时间
const curWord = getCurrentWord();
if (curWord) {
curWord.startTime = currentTimeMS.value;
const currentLine = getCurrentLine();
if (currentWord.wordIndex === 0 && currentLine) {
currentLine.startTime = currentTimeMS.value;
if ((curWord.emptyBeat ?? 0) > 0) {
currentWord.emptyBeat = 1;
}
curWord.startTime = currentTimeMS.value;
lyric.record();
}
collected = true;
break;
}
case "KeyG": { // 记录当前时间为当前单词的结束时间和下一个单词的起始时间,并移动到下一个单词
const curWord = getCurrentWord();
const currentLine = getCurrentLine();
const curWordIndex = currentWord.wordIndex;
if (moveRight()) {
let shouldRecord = false;
if (curWord) {
curWord.endTime = currentTimeMS.value;
if (currentLine && curWordIndex === currentLine.words.length - 1) {
currentLine.endTime = curWord.endTime;
}
shouldRecord = true;
}
const nextWord = getCurrentWord();
if (nextWord) {
nextWord.startTime = currentTimeMS.value;
const currentLine = getCurrentLine();
if (currentLine && currentWord.wordIndex === 0) {
currentLine.startTime = nextWord.startTime;
}
shouldRecord = true;
}
if (shouldRecord) lyric.record();
}
collected = true;
break;
}
case "KeyH": { // 记录当前时间为当前单词的结束时间,并移动到下一个单词(用于空出间奏时间)
const curWord = getCurrentWord();
const currentLine = getCurrentLine();
const curWordIndex = currentWord.wordIndex;
if (moveRight()) {
if (curWord) {
curWord.endTime = currentTimeMS.value;
if (currentLine && curWordIndex === currentLine.words.length - 1) {
currentLine.endTime = curWord.endTime;
}
lyric.record();
}
}
collected = true;
Expand Down
2 changes: 1 addition & 1 deletion src/utils/pinia-undo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class UndoStack<T> {
* @returns {Object} State of the store without omitted keys.
*/
function removeOmittedKeys(options: Options, store: Store): Store["$state"] {
const clone = JSON.parse(JSON.stringify(toRaw(store.$state)));
const clone = (window.structuredClone || structuredClone)(toRaw(store.$state));
if (options.undo?.omit) {
options.undo.omit.forEach((key) => {
// rome-ignore lint/performance/noDelete: <explanation>
Expand Down

0 comments on commit 64eff1d

Please sign in to comment.