|
|
@@ -3245,7 +3245,7 @@ export struct LocalMusic {
|
|
|
Column() {
|
|
|
emptyView(this.themeColor)
|
|
|
}
|
|
|
- .padding({ right:10 })
|
|
|
+ .padding({ right:6 })
|
|
|
.onClick(()=>{
|
|
|
this.asyncCurrentPathOnlyFile()
|
|
|
})
|
|
|
@@ -10186,7 +10186,8 @@ export struct LocalMusic {
|
|
|
this.lyricTextWeight = PreferencesUtil.getNumberSync('lyricTextWeight', 400)
|
|
|
this.lyricController.setTextWeight(this.lyricTextWeight)
|
|
|
this.showSingleLyric = false
|
|
|
- this.timeOffset = 0
|
|
|
+ // 加载已保存的歌词时间偏移
|
|
|
+ this.loadLyricTimeOffset()
|
|
|
this.lyricController.setLyric(null)
|
|
|
this.lyricControllerSingle.setLyric(null)
|
|
|
let jiaMilyricPath = lyricPath.substring(0, lyricPath.lastIndexOf('.')) + '.lrcc'
|
|
|
@@ -12429,6 +12430,7 @@ export struct LocalMusic {
|
|
|
private handlePrecisionAdjust(step: number) {
|
|
|
if (step === 0) {
|
|
|
this.timeOffset = 0
|
|
|
+ this.saveLyricTimeOffset()
|
|
|
return
|
|
|
}
|
|
|
// 精度处理:保留1位小数
|
|
|
@@ -12440,6 +12442,8 @@ export struct LocalMusic {
|
|
|
}
|
|
|
// 状态更新
|
|
|
this.timeOffset = newOffset
|
|
|
+ // 保存歌词时间偏移
|
|
|
+ this.saveLyricTimeOffset()
|
|
|
|
|
|
}
|
|
|
|
|
|
@@ -12456,6 +12460,57 @@ export struct LocalMusic {
|
|
|
? '歌词时间已重置'
|
|
|
: `歌词已${this.timeOffset < 0 ? '延后' : '提前'} ${absValue.toFixed(1)} 秒`
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取当前歌曲的唯一标识key
|
|
|
+ * 使用歌曲的filePath作为唯一标识
|
|
|
+ */
|
|
|
+ private getLyricOffsetKey(): string {
|
|
|
+ if (this.currentSong && StrUtil.isNotEmpty(this.currentSong.filePath)) {
|
|
|
+ // 使用MD5对filePath进行加密,作为存储key
|
|
|
+ return 'lyric_offset_' + MD5.digestSync(this.currentSong.filePath)
|
|
|
+ }
|
|
|
+ return ''
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 保存当前歌曲的歌词时间偏移
|
|
|
+ */
|
|
|
+ private saveLyricTimeOffset(): void {
|
|
|
+ try {
|
|
|
+ const key = this.getLyricOffsetKey()
|
|
|
+ if (StrUtil.isEmpty(key)) {
|
|
|
+ console.warn('heanup saveLyricTimeOffset: key is empty')
|
|
|
+ return
|
|
|
+ }
|
|
|
+ PreferencesUtil.putSync(key, this.timeOffset)
|
|
|
+ console.info('heanup saveLyricTimeOffset: key=' + key + ', offset=' + this.timeOffset)
|
|
|
+ } catch (e) {
|
|
|
+ console.error('heanup saveLyricTimeOffset error: ' + JSON.stringify(e))
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 加载当前歌曲的歌词时间偏移
|
|
|
+ */
|
|
|
+ private loadLyricTimeOffset(): void {
|
|
|
+ try {
|
|
|
+ const key = this.getLyricOffsetKey()
|
|
|
+ if (StrUtil.isEmpty(key)) {
|
|
|
+ console.warn('heanup loadLyricTimeOffset: key is empty')
|
|
|
+ return
|
|
|
+ }
|
|
|
+ const savedOffset = PreferencesUtil.getNumberSync(key, 0)
|
|
|
+ if (savedOffset !== 0) {
|
|
|
+ this.timeOffset = savedOffset
|
|
|
+ console.info('heanup loadLyricTimeOffset: key=' + key + ', offset=' + savedOffset)
|
|
|
+ }else{
|
|
|
+ this.timeOffset = 0
|
|
|
+ }
|
|
|
+ } catch (e) {
|
|
|
+ console.error('heanup loadLyricTimeOffset error: ' + JSON.stringify(e))
|
|
|
+ }
|
|
|
+ }
|
|
|
// 导入 本地歌词 搜索歌词
|
|
|
@Builder
|
|
|
pushLyricButton(icon: Resource, step: number, label: string) {
|