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
-6
View File
@@ -1,6 +0,0 @@
/**
* 桥接文件 - 保持向后兼容
* 实际实现已迁移到 platform/cloud-adapter.ts
*/
import { callCloud } from '../platform/cloud-adapter';
export default callCloud;
+25 -34
View File
@@ -1,3 +1,5 @@
import { uploadAsset } from '../services/member-api';
import { apiRequest } from '../services/api-request';
import { PAPER_SIZE } from '../constants/colors';
import { downloadPrint, tryUnlockWithRewardedAd } from '../utils/downloadPrint';
import { shouldShowShareGuide, shouldUnlockWithAd } from '../utils/shareGuide';
@@ -5,7 +7,6 @@ import { BaseDrawService } from '../core/draw/baseDraw';
import tracker from '../utils/tracker';
import { defaultShareConfig } from '../config/config';
import {
buildWorksheetPreviewCloudPath,
isDebugPublishEnabled,
type DebugPublishConfirmDetail,
type DebugPublishMeta,
@@ -117,8 +118,7 @@ export function buildPageSharePath(page?: SharePathPage): string {
const normalized = route.startsWith('/') ? route : `/${route}`;
const data = page?.data || {};
const functionId = (data.functionId || data.worksheetId) as
| string
| undefined;
string | undefined;
const currentMode = data.currentMode as string | undefined;
if (!functionId) {
@@ -126,9 +126,7 @@ export function buildPageSharePath(page?: SharePathPage): string {
}
const modeQuery =
currentMode && currentMode !== functionId
? `&mode=${currentMode}`
: '';
currentMode && currentMode !== functionId ? `&mode=${currentMode}` : '';
return `${normalized}?id=${functionId}${modeQuery}`;
}
@@ -509,34 +507,28 @@ export function getPageCommonMethods(config: PageCommonMethodsConfig = {}) {
settings: detail.settings,
});
const cloudPath = buildWorksheetPreviewCloudPath(
publishMeta.category,
publishMeta.id,
const asset = await uploadAsset(
processed.tempFilePath,
'preview',
);
const uploadRes = await wx.cloud.uploadFile({
cloudPath,
filePath: processed.tempFilePath,
});
const cloudCall = (await wx.cloud.callFunction({
name: 'worksheetsPublish',
const {
category,
previewImg: _oldPreview,
...metadata
} = publishMeta;
await apiRequest('/admin/worksheets/publish', {
method: 'POST',
data: {
...publishMeta,
previewImg: uploadRes.fileID,
...metadata,
categoryId: category,
previewAssetId: asset.id,
},
})) as {
result?: { success?: boolean; message?: string };
};
if (!cloudCall.result?.success) {
throw new Error(
cloudCall.result?.message || '云端写入失败',
);
}
});
this.setData({
debugPublishVisible: false,
debugPublishMeta: {
...publishMeta,
previewImg: uploadRes.fileID,
previewImg: asset.url,
},
});
@@ -566,8 +558,7 @@ export function getPageCommonMethods(config: PageCommonMethodsConfig = {}) {
initPageInfo(
this: PageCanvasInstance,
functionIdOrOptions:
| string
| { title: string; desc?: string; functionId: string },
string | { title: string; desc?: string; functionId: string },
defaultTitle?: string,
) {
let functionId: string;
@@ -605,7 +596,9 @@ export function getPageCommonMethods(config: PageCommonMethodsConfig = {}) {
tracker.reportPreviewView(this.route || '', {
worksheet_id: functionId,
worksheet_title: title,
...(this.data.currentMode ? { mode: this.data.currentMode } : {}),
...(this.data.currentMode
? { mode: this.data.currentMode }
: {}),
});
},
};
@@ -670,8 +663,7 @@ export function applyPageMixin(
try {
const result = await originalDrawCanvas.apply(this, args);
const startedAt = (this as any)[generationStartKey] as
| number
| undefined;
number | undefined;
if (startedAt) {
delete (this as any)[generationStartKey];
const worksheetId =
@@ -693,8 +685,7 @@ export function applyPageMixin(
return result;
} catch (error) {
const startedAt = (this as any)[generationStartKey] as
| number
| undefined;
number | undefined;
if (startedAt) {
delete (this as any)[generationStartKey];
tracker.reportGenerateResult(this.route || '', false, {