Skip to content

Commit

Permalink
在导出操作前将所有歌词数据四舍五入以确保执行正确
Browse files Browse the repository at this point in the history
  • Loading branch information
Steve-xmh committed Feb 22, 2024
1 parent 9339c6c commit 8db8b3d
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/store/lyric.ts
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,19 @@ export const useEditingLyric = defineStore("editing-lyric", {
this.record();
}
},
roundTimeStamps() {
for (const line of this.lyrics) {
line.startTime = Math.round(line.startTime);
line.endTime = Math.round(line.endTime);
for (const word of line.words) {
word.startTime = Math.round(word.startTime);
word.endTime = Math.round(word.endTime);
if (word.emptyBeat !== undefined) word.emptyBeat = Math.round(word.emptyBeat);
}
}
},
toTTML() {
this.roundTimeStamps();
const transformed: LyricLine[] = [];

for (let i = 0; i < this.lyrics.length; i++) {
Expand All @@ -363,26 +375,32 @@ export const useEditingLyric = defineStore("editing-lyric", {
});
},
toLRC() {
this.roundTimeStamps();
const lines = toRaw(this.lyrics);
return stringifyLrc(lines);
},
toESLRC() {
this.roundTimeStamps();
const lines = toRaw(this.lyrics);
return stringifyEslrc(lines);
},
toYRC() {
this.roundTimeStamps();
const lines = toRaw(this.lyrics);
return stringifyYrc(lines);
},
toQRC() {
this.roundTimeStamps();
const lines = toRaw(this.lyrics);
return stringifyQrc(lines);
},
toLYS() {
this.roundTimeStamps();
const lines = toRaw(this.lyrics);
return stringifyLys(lines);
},
toASS() {
this.roundTimeStamps();
const lines = toRaw(this.lyrics);
return stringifyAss(lines);
},
Expand Down

0 comments on commit 8db8b3d

Please sign in to comment.