This commit is contained in:
2026-04-18 13:05:29 +08:00
parent 09d4c0c31b
commit 5032701c38
77 changed files with 8538 additions and 2413 deletions

View File

@@ -61,28 +61,6 @@ function requestRuntimeJson<T>(
);
}
function requestProfileJson<T>(
path: string,
init: RequestInit,
fallbackMessage: string,
options: RuntimeRequestOptions = {},
) {
const method = (init.method ?? 'GET').toUpperCase();
const retry =
options.retry ??
(method === 'GET' ? RUNTIME_READ_RETRY : RUNTIME_WRITE_RETRY);
return requestJson<T>(
`/api/profile${path}`,
{
...init,
signal: options.signal,
},
fallbackMessage,
{ retry },
);
}
export async function getSaveSnapshot(options: RuntimeRequestOptions = {}) {
const snapshot = await requestRuntimeJson<HydratedSavedGameSnapshot | null>(
'/save/snapshot',
@@ -315,8 +293,8 @@ export async function getCustomWorldGalleryDetail(
export async function listProfileBrowseHistory(
options: RuntimeRequestOptions = {},
) {
const response = await requestProfileJson<PlatformBrowseHistoryResponse>(
'/browse-history',
const response = await requestRuntimeJson<PlatformBrowseHistoryResponse>(
'/profile/browse-history',
{ method: 'GET' },
'读取浏览历史失败',
options,
@@ -329,8 +307,8 @@ export async function upsertProfileBrowseHistory(
entry: PlatformBrowseHistoryWriteEntry,
options: RuntimeRequestOptions = {},
) {
const response = await requestProfileJson<PlatformBrowseHistoryResponse>(
'/browse-history',
const response = await requestRuntimeJson<PlatformBrowseHistoryResponse>(
'/profile/browse-history',
{
method: 'POST',
headers: { 'Content-Type': 'application/json' },
@@ -347,8 +325,8 @@ export async function syncProfileBrowseHistory(
entries: PlatformBrowseHistoryWriteEntry[],
options: RuntimeRequestOptions = {},
) {
const response = await requestProfileJson<PlatformBrowseHistoryResponse>(
'/browse-history',
const response = await requestRuntimeJson<PlatformBrowseHistoryResponse>(
'/profile/browse-history',
{
method: 'POST',
headers: { 'Content-Type': 'application/json' },
@@ -366,8 +344,8 @@ export async function syncProfileBrowseHistory(
export async function clearProfileBrowseHistory(
options: RuntimeRequestOptions = {},
) {
const response = await requestProfileJson<PlatformBrowseHistoryResponse>(
'/browse-history',
const response = await requestRuntimeJson<PlatformBrowseHistoryResponse>(
'/profile/browse-history',
{ method: 'DELETE' },
'清空浏览历史失败',
options,