|
|
@@ -11652,10 +11652,19 @@ export struct LocalMusic {
|
|
|
}
|
|
|
|
|
|
private copySelectedLyricLines(): void {
|
|
|
- if (ArrayUtil.isEmpty(this.lyricSelectedIndexes)) {
|
|
|
- ToastUtil.showToast('请先选择歌词');
|
|
|
+ const selectedLines = this.getSelectedLyricLines();
|
|
|
+ if (ArrayUtil.isEmpty(selectedLines)) {
|
|
|
+ ToastUtil.showToast('暂无可复制歌词');
|
|
|
return;
|
|
|
}
|
|
|
+ Utility.copyText(selectedLines.join('\n'));
|
|
|
+ ToastUtil.showToast(`已复制${selectedLines.length}行歌词`);
|
|
|
+ }
|
|
|
+
|
|
|
+ private getSelectedLyricLines(): string[] {
|
|
|
+ if (ArrayUtil.isEmpty(this.lyricSelectedIndexes)) {
|
|
|
+ return [];
|
|
|
+ }
|
|
|
const selectedIndexes = [...this.lyricSelectedIndexes].sort((a: number, b: number) => a - b);
|
|
|
const selectedLines: string[] = [];
|
|
|
for (let i = 0; i < selectedIndexes.length; i++) {
|
|
|
@@ -11664,12 +11673,17 @@ export struct LocalMusic {
|
|
|
selectedLines.push(this.lyricCopyLines[index]);
|
|
|
}
|
|
|
}
|
|
|
+ return selectedLines;
|
|
|
+ }
|
|
|
+
|
|
|
+ private shareSelectedLyricLines(): void {
|
|
|
+ const selectedLines = this.getSelectedLyricLines();
|
|
|
if (ArrayUtil.isEmpty(selectedLines)) {
|
|
|
- ToastUtil.showToast('暂无可复制歌词');
|
|
|
+ ToastUtil.showToast('暂无可分享歌词');
|
|
|
return;
|
|
|
}
|
|
|
- Utility.copyText(selectedLines.join('\n'));
|
|
|
- ToastUtil.showToast(`已复制${selectedLines.length}行歌词`);
|
|
|
+ const shareTitle = `${this.currentSong?.name ?? '歌词'}歌词`;
|
|
|
+ Utility.doShareText(selectedLines.join('\n'), this.context, shareTitle, '分享歌词');
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -12084,6 +12098,9 @@ export struct LocalMusic {
|
|
|
},
|
|
|
onCopySelectedLines: () => {
|
|
|
this.copySelectedLyricLines();
|
|
|
+ },
|
|
|
+ onShareSelectedLines: () => {
|
|
|
+ this.shareSelectedLyricLines();
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
@@ -13670,6 +13687,7 @@ export struct LocalMusic {
|
|
|
|
|
|
Row() {
|
|
|
this.pushLyricButton($r('app.media.cut_current'), 0, '本地歌词')
|
|
|
+ this.pushLyricButton($r('app.media.share2'), 2, '分享歌词')
|
|
|
this.pushLyricButton($r('app.media.white_search'), 1, '获取歌词')
|
|
|
// this.pushLyricButton($r('app.media.white_search'), 1, '繁体转简体')
|
|
|
}
|
|
|
@@ -13981,13 +13999,17 @@ export struct LocalMusic {
|
|
|
this.initLyric(lyricPath, true);
|
|
|
}
|
|
|
break;
|
|
|
+ case 2:
|
|
|
+ this.isLyricSetting = false
|
|
|
+ this.openLyricCopySheet()
|
|
|
+ break;
|
|
|
}
|
|
|
})
|
|
|
.padding(5)
|
|
|
- .width(110)
|
|
|
+ .layoutWeight(1)
|
|
|
.backgroundColor(Color.Transparent)
|
|
|
.height(40)
|
|
|
- .margin({ left: 6, right: 6 })
|
|
|
+ .margin({ left: 4, right: 4 })
|
|
|
.border({
|
|
|
color: '#FFFFFF',
|
|
|
radius: 20,
|