feat: 完成全部接口替换为新后端接口

This commit is contained in:
R524809
2026-10-19 13:19:07 +08:00
parent 8de06ce66b
commit 997042789d
40 changed files with 1946 additions and 785 deletions
@@ -1,3 +1,4 @@
import { managementRequest } from '../../services/admin-api';
import { MOCK_SEED_COUNTS } from './mockLikes';
import {
MATH_WORKSHEET_DEFINITIONS,
@@ -21,17 +22,6 @@ type CloudFunctionResult<T> = {
results?: Array<{ id: string | null; ok: boolean; error?: string }>;
};
async function callCloudFunction<T>(
name: string,
data?: Record<string, unknown>,
): Promise<CloudFunctionResult<T>> {
const response = (await wx.cloud.callFunction({
name,
data: data || {},
})) as { result?: CloudFunctionResult<T> };
return response.result || {};
}
function inferGradeFromAge(ageMin: number, ageMax: number): number {
const centerAge = Math.round((ageMin + ageMax) / 2);
const ageGradeMap: Record<number, number> = {
@@ -224,7 +214,7 @@ Page({
const startedAt = Date.now();
try {
const patchRes = await callCloudFunction('worksheetsBatchPatch', {
const patchRes = await managementRequest('worksheets.batch', {
patches,
dryRun: false,
});
@@ -262,7 +252,7 @@ Page({
const startedAt = Date.now();
try {
const rebuildRes = await callCloudFunction('pageContentBuild', {
const rebuildRes = await managementRequest('site.rebuild', {
page: 'all',
});
const elapsed = Math.round((Date.now() - startedAt) / 1000);
@@ -358,7 +348,7 @@ Page({
}),
);
const patchRes = await callCloudFunction('worksheetsBatchPatch', {
const patchRes = await managementRequest('worksheets.batch', {
patches,
dryRun: false,
});
@@ -415,8 +405,8 @@ Page({
const startedAt = Date.now();
try {
const queryRes = await callCloudFunction<Array<{ _id: string }>>(
'worksheetsQuery',
const queryRes = await managementRequest<Array<{ _id: string }>>(
'worksheets.list',
{},
);
@@ -438,7 +428,7 @@ Page({
return;
}
const patchRes = await callCloudFunction('worksheetsBatchPatch', {
const patchRes = await managementRequest('worksheets.batch', {
patches,
dryRun: false,
});