初始化

This commit is contained in:
李琦
2026-01-15 15:42:20 +08:00
parent f39e37e534
commit 944d642d38
5 changed files with 755 additions and 3 deletions

View File

@@ -891,3 +891,69 @@ export const fetchAboutProfile = async (): Promise<AboutProfile> => {
throw error
}
}
export const getAdminAboutProfiles = async (): Promise<AboutProfile[]> => {
try {
const response = await fetch(`${API_BASE}/admin/about`, {
headers: getAuthHeaders()
})
if (!response.ok) {
const errorData = await response.json()
throw new Error(errorData.error || '获取个人资料列表失败')
}
return await response.json()
} catch (error) {
console.error('Get admin about profiles error:', error)
throw error
}
}
export const createAboutProfile = async (profileData: Omit<AboutProfile, 'id' | 'createdAt' | 'updatedAt'>): Promise<void> => {
try {
const response = await fetch(`${API_BASE}/admin/about`, {
method: 'POST',
headers: getAuthHeaders(),
body: JSON.stringify(profileData)
})
if (!response.ok) {
const errorData = await response.json()
throw new Error(errorData.error || '创建个人资料失败')
}
} catch (error) {
console.error('Create about profile error:', error)
throw error
}
}
export const updateAboutProfile = async (id: number, profileData: Omit<AboutProfile, 'id' | 'createdAt' | 'updatedAt'>): Promise<void> => {
try {
const response = await fetch(`${API_BASE}/admin/about/${id}`, {
method: 'PUT',
headers: getAuthHeaders(),
body: JSON.stringify(profileData)
})
if (!response.ok) {
const errorData = await response.json()
throw new Error(errorData.error || '更新个人资料失败')
}
} catch (error) {
console.error('Update about profile error:', error)
throw error
}
}
export const deleteAboutProfile = async (id: number): Promise<void> => {
try {
const response = await fetch(`${API_BASE}/admin/about/${id}`, {
method: 'DELETE',
headers: getAuthHeaders()
})
if (!response.ok) {
const errorData = await response.json()
throw new Error(errorData.error || '删除个人资料失败')
}
} catch (error) {
console.error('Delete about profile error:', error)
throw error
}
}