mirror of
https://github.com/remvze/moodist.git
synced 2025-12-18 09:24:14 +00:00
fix: 修复音乐删除功能401认证错误
- 将原生fetch替换为ApiClient,确保JWT Authorization头正确发送 - 修复删除音乐、重命名音乐、保存音乐功能的认证问题 - 移除不必要的用户名密码字段,依赖JWT认证 - 解决因缺少Authorization头导致的401未授权错误 Issues Fixed: - 音乐删除失败返回401错误 - 音乐操作API调用缺少认证头
This commit is contained in:
parent
010fb9674b
commit
a464745a9f
1 changed files with 7 additions and 31 deletions
|
|
@ -130,17 +130,9 @@ export function SelectedSoundsDisplay() {
|
|||
if (!isAuthenticated || !user) return;
|
||||
|
||||
try {
|
||||
const response = await fetch('/api/auth/music/rename', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify({
|
||||
musicId,
|
||||
name: newName,
|
||||
username: user.username,
|
||||
password: sessionPassword || '',
|
||||
}),
|
||||
const response = await ApiClient.post('/api/auth/music/rename', {
|
||||
musicId,
|
||||
name: newName
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
|
|
@ -172,16 +164,8 @@ export function SelectedSoundsDisplay() {
|
|||
if (!confirm('确定要删除这首音乐吗?')) return;
|
||||
|
||||
try {
|
||||
const response = await fetch('/api/auth/music/delete', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify({
|
||||
musicId,
|
||||
username: user.username,
|
||||
password: sessionPassword || '',
|
||||
}),
|
||||
const response = await ApiClient.post('/api/auth/music/delete', {
|
||||
musicId
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
|
|
@ -296,19 +280,11 @@ export function SelectedSoundsDisplay() {
|
|||
volume,
|
||||
speed,
|
||||
rate,
|
||||
random_effects,
|
||||
username: user?.username,
|
||||
password: sessionPassword || '' // 使用会话密码,如果为空则让后端处理
|
||||
random_effects
|
||||
};
|
||||
|
||||
// 调用保存API
|
||||
const response = await fetch('/api/auth/music/save', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify(musicData),
|
||||
});
|
||||
const response = await ApiClient.post('/api/auth/music/save', musicData);
|
||||
|
||||
if (response.ok) {
|
||||
const result = await response.json();
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue