Skip to content

Commit 9a16c16

Browse files
authored
Merge pull request #826 from imsyy/dev-fix
feat(上下文菜单): 新增复制歌曲名称和音乐标签编辑选项 在设置菜单中增加两个新的上下文菜单选项:复制歌曲名称和音乐标签编辑。同时调整了菜单项的分隔符显示逻辑,并将"从歌单中删除"选项移动到更合适的位置。
2 parents 33b1066 + 0533a45 commit 9a16c16

4 files changed

Lines changed: 16 additions & 8 deletions

File tree

src/components/Modal/Setting/ContextMenuManager.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ const items: Item[] = [
4848
{ label: "歌曲百科", key: "wiki" },
4949
{ label: "搜索", key: "search" },
5050
{ label: "下载", key: "download" },
51+
{ label: "复制歌曲名称", key: "copyName" },
52+
{ label: "音乐标签编辑", key: "musicTagEditor" },
5153
];
5254
5355
const updateSetting = (key: ContextMenuOptionKey, val: boolean) => {

src/composables/useSongMenu.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,7 @@ export const useSongMenu = () => {
230230
{
231231
key: "code-name",
232232
label: `复制${type === "song" ? "歌曲" : type === "streaming" ? "流媒体" : "节目"}名称`,
233+
show: settingStore.contextMenuOptions.copyName,
233234
props: {
234235
onClick: () => copyData(song.name),
235236
},
@@ -257,12 +258,12 @@ export const useSongMenu = () => {
257258
{
258259
key: "line-2",
259260
type: "divider",
260-
show: isLocal,
261+
show: settingStore.contextMenuOptions.musicTagEditor && isLocal,
261262
},
262263
{
263264
key: "meta-edit",
264265
label: "音乐标签编辑",
265-
show: isLocal,
266+
show: settingStore.contextMenuOptions.musicTagEditor && isLocal,
266267
props: {
267268
onClick: () => {
268269
if (song.path) openSongInfoEditor(song);

src/core/resource/DownloadManager.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -551,19 +551,20 @@ class DownloadManager {
551551
}
552552
}
553553

554-
// 如果进行了合并,或者原本就是 YRC/TTML,我们重新生成标准 TTML
555-
// 这样可以确保翻译被正确嵌入
556-
if (merged || ttmlLyric || yrcLyric) {
554+
// 如果进行了合并,或者原本就是 YRC (需要转换),我们重新生成标准 TTML
555+
// 注意:如果是 TTML 且未合并,不要重新生成,以免丢失原始内容
556+
if ((merged || yrcLyric) && lines.length > 0) {
557557
content = lyricLinesToTTML(lines);
558+
console.log("[Download] Generated new TTML content from lines.");
558559
}
559560
}
560561

561562
// 繁体转换
562563
content = await this._convertToTraditionalIfNeeded(content);
563564

564565
// 如果进行了合并或转换,统一保存为 ttml (因为我们生成的是 standard TTML)
565-
// 除非原本就是 yrc 且没合并
566-
const ext = (ttmlLyric || merged) ? "ttml" : "yrc";
566+
// 只要解析出了 lines (说明是 YRC 转换或进行了合并),或者是原生 TTML,都保存为 ttml
567+
const ext = (ttmlLyric || lines.length > 0) ? "ttml" : "yrc";
567568
const fileName = `${safeFileName}.${ext}`;
568569
const encoding = settingStore.downloadLyricEncoding || "utf-8";
569570

@@ -572,7 +573,7 @@ class DownloadManager {
572573
content = content.replace(/encoding=["']utf-8["']/i, `encoding="${encoding}"`);
573574
}
574575

575-
console.log(`[Download] Saving extra lyric file: ${fileName}`);
576+
console.log(`[Download] Saving extra lyric file: ${fileName}, content len: ${content.length}`);
576577
// 调用保存文件内容接口
577578
const saveRes = await window.electron.ipcRenderer.invoke("save-file-content", {
578579
path: targetPath,

src/stores/setting.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,8 @@ export interface SettingState {
404404
wiki: boolean;
405405
search: boolean;
406406
download: boolean;
407+
copyName: boolean;
408+
musicTagEditor: boolean;
407409
};
408410
/** 启用搜索关键词获取 */
409411
enableSearchKeyword: boolean;
@@ -683,6 +685,8 @@ export const useSettingStore = defineStore("setting", {
683685
wiki: true,
684686
search: true,
685687
download: true,
688+
copyName: true,
689+
musicTagEditor: true,
686690
},
687691
enableSearchKeyword: true,
688692
clearSearchOnBlur: false,

0 commit comments

Comments
 (0)