mirror of
https://github.com/remvze/moodist.git
synced 2025-12-18 17:34:17 +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;
|
if (!isAuthenticated || !user) return;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await fetch('/api/auth/music/rename', {
|
const response = await ApiClient.post('/api/auth/music/rename', {
|
||||||
method: 'POST',
|
musicId,
|
||||||
headers: {
|
name: newName
|
||||||
'Content-Type': 'application/json',
|
|
||||||
},
|
|
||||||
body: JSON.stringify({
|
|
||||||
musicId,
|
|
||||||
name: newName,
|
|
||||||
username: user.username,
|
|
||||||
password: sessionPassword || '',
|
|
||||||
}),
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
|
|
@ -172,16 +164,8 @@ export function SelectedSoundsDisplay() {
|
||||||
if (!confirm('确定要删除这首音乐吗?')) return;
|
if (!confirm('确定要删除这首音乐吗?')) return;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await fetch('/api/auth/music/delete', {
|
const response = await ApiClient.post('/api/auth/music/delete', {
|
||||||
method: 'POST',
|
musicId
|
||||||
headers: {
|
|
||||||
'Content-Type': 'application/json',
|
|
||||||
},
|
|
||||||
body: JSON.stringify({
|
|
||||||
musicId,
|
|
||||||
username: user.username,
|
|
||||||
password: sessionPassword || '',
|
|
||||||
}),
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
|
|
@ -296,19 +280,11 @@ export function SelectedSoundsDisplay() {
|
||||||
volume,
|
volume,
|
||||||
speed,
|
speed,
|
||||||
rate,
|
rate,
|
||||||
random_effects,
|
random_effects
|
||||||
username: user?.username,
|
|
||||||
password: sessionPassword || '' // 使用会话密码,如果为空则让后端处理
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// 调用保存API
|
// 调用保存API
|
||||||
const response = await fetch('/api/auth/music/save', {
|
const response = await ApiClient.post('/api/auth/music/save', musicData);
|
||||||
method: 'POST',
|
|
||||||
headers: {
|
|
||||||
'Content-Type': 'application/json',
|
|
||||||
},
|
|
||||||
body: JSON.stringify(musicData),
|
|
||||||
});
|
|
||||||
|
|
||||||
if (response.ok) {
|
if (response.ok) {
|
||||||
const result = await response.json();
|
const result = await response.json();
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue