Skip to content

Commit 264fb7d

Browse files
committed
fix: 删除歌曲卡死
1 parent 78d5bfa commit 264fb7d

File tree

2 files changed

+15
-11
lines changed

2 files changed

+15
-11
lines changed

MaiChartManager/Front/src/components/MusicSelectedTopRightToolbar/DeleteMusicButton.tsx

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { defineComponent, ref } from "vue";
22
import api from "@/client/api";
3-
import { selectedADir, selectMusicId, updateMusicList } from "@/store/refs";
3+
import { globalCapture, selectedADir, selectMusicId, updateMusicList } from "@/store/refs";
44
import { NButton, useDialog } from "naive-ui";
55

66
export default defineComponent({
@@ -16,11 +16,15 @@ export default defineComponent({
1616
}
1717
deleteConfirm.value = false;
1818
deleteLoading.value = true;
19-
const res = await api.DeleteMusic(selectMusicId.value, selectedADir.value);
20-
if (res.error) {
21-
const error = res.error as any;
22-
dialog.warning({title: '删除失败', content: error.message || error});
23-
return;
19+
try {
20+
const res = await api.DeleteMusic(selectMusicId.value, selectedADir.value);
21+
if (res.error) {
22+
const error = res.error as any;
23+
dialog.warning({ title: '删除失败', content: error.message || error });
24+
return;
25+
}
26+
} catch (e) {
27+
globalCapture(e, "删除乐曲失败")
2428
}
2529
selectMusicId.value = 0;
2630
updateMusicList();

MaiChartManager/Models/MusicXmlWithABJacket.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -125,24 +125,24 @@ public void Delete()
125125
{
126126
if (HasJacket)
127127
{
128-
FileSystem.DeleteFile(JacketPath, UIOption.OnlyErrorDialogs, RecycleOption.SendToRecycleBin);
128+
FileSystem.DeleteFile(JacketPath);
129129
}
130130

131131
if (StaticSettings.AcbAwb.TryGetValue($"music{NonDxId:000000}.acb", out var acb))
132132
{
133-
FileSystem.DeleteFile(acb, UIOption.OnlyErrorDialogs, RecycleOption.SendToRecycleBin);
133+
FileSystem.DeleteFile(acb);
134134
}
135135

136136
if (StaticSettings.AcbAwb.TryGetValue($"music{NonDxId:000000}.awb", out var awb))
137137
{
138-
FileSystem.DeleteFile(awb, UIOption.OnlyErrorDialogs, RecycleOption.SendToRecycleBin);
138+
FileSystem.DeleteFile(awb);
139139
}
140140

141141
if (StaticSettings.MovieDataMap.TryGetValue(NonDxId, out var movieData))
142142
{
143-
FileSystem.DeleteFile(movieData, UIOption.OnlyErrorDialogs, RecycleOption.SendToRecycleBin);
143+
FileSystem.DeleteFile(movieData);
144144
}
145145

146-
FileSystem.DeleteDirectory(Path.GetDirectoryName(FilePath), UIOption.OnlyErrorDialogs, RecycleOption.SendToRecycleBin);
146+
FileSystem.DeleteDirectory(Path.GetDirectoryName(FilePath), DeleteDirectoryOption.DeleteAllContents);
147147
}
148148
}

0 commit comments

Comments
 (0)