mirror of
https://github.com/truewhile/MeBox.git
synced 2026-09-29 19:36:36 +08:00
1e291df647
Store pinned library IDs on the user record and expose GET/PUT /me/pinned-libraries endpoints. The web client now loads and saves pins through the API, migrates legacy localStorage data once, and applies pinned ordering on both the libraries and home pages. Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: truewhile <truewhile@users.noreply.github.com>
24 lines
765 B
TypeScript
24 lines
765 B
TypeScript
import { api } from './client'
|
|
import type { User } from '../types'
|
|
|
|
export const profileAPI = {
|
|
update: (patch: {
|
|
username?: string
|
|
nickname?: string
|
|
email?: string
|
|
avatar_url?: string
|
|
hide_adult?: boolean
|
|
password?: string
|
|
}) =>
|
|
api.patch<User>('/me', patch).then((r) => r.data),
|
|
|
|
getPinnedLibraries: () =>
|
|
api.get<{ library_ids: string[] }>('/me/pinned-libraries').then((r) => r.data.library_ids ?? []),
|
|
|
|
setPinnedLibraries: (libraryIds: string[]) =>
|
|
api.put<{ library_ids: string[] }>('/me/pinned-libraries', { library_ids: libraryIds }).then((r) => r.data.library_ids ?? []),
|
|
|
|
adminUpdateRole: (id: string, role: 'admin' | 'user') =>
|
|
api.patch<User>(`/admin/users/${id}/role`, { role }).then((r) => r.data),
|
|
}
|