feat: 一些bug修复

This commit is contained in:
R524809
2026-05-25 16:26:20 +08:00
parent 4d6b65e223
commit e998da37cb
8 changed files with 90 additions and 42 deletions
+1 -11
View File
@@ -1,9 +1,6 @@
import { PAPER_SIZE } from '../constants/colors';
import { downloadPrint, tryUnlockWithRewardedAd } from '../utils/downloadPrint';
import {
shouldShowShareGuide,
shouldUnlockWithAd,
} from '../utils/shareGuide';
import { shouldShowShareGuide, shouldUnlockWithAd } from '../utils/shareGuide';
import { BaseDrawService } from '../core/draw/baseDraw';
import tracker from '../utils/tracker';
import { defaultShareConfig } from '../config/config';
@@ -411,24 +408,19 @@ export function getPageCommonMethods(config: PageCommonMethodsConfig = {}) {
quality: 1,
});
console.log('sourcePath', sourcePath);
const processed = await debugPublishTools.processImage({
sourcePath,
settings: detail.settings,
});
console.log('processed', processed);
const cloudPath = buildWorksheetPreviewCloudPath(
publishMeta.category,
publishMeta.id,
);
console.log('cloudPath', cloudPath);
const uploadRes = await wx.cloud.uploadFile({
cloudPath,
filePath: processed.tempFilePath,
});
console.log('uploadRes', uploadRes);
const cloudCall = (await wx.cloud.callFunction({
name: 'worksheetsPublish',
@@ -439,13 +431,11 @@ export function getPageCommonMethods(config: PageCommonMethodsConfig = {}) {
})) as {
result?: { success?: boolean; message?: string };
};
console.log('cloudCall', cloudCall);
if (!cloudCall.result?.success) {
throw new Error(
cloudCall.result?.message || '云端写入失败',
);
}
console.log('success');
this.setData({
debugPublishVisible: false,
debugPublishMeta: {
+2 -2
View File
@@ -14,8 +14,8 @@ export const defaultPrintConfig: PrintConfig = {
};
export const defaultShareConfig = {
// title: '涂鸦丫 - 一张会“教知识”的涂色卡',
title: '涂鸦丫 - 快来生成宝宝的专属学习卡',
// title: '涂鸦丫·儿童打印练习纸,数学练字拼音一键打印',
title: '涂鸦丫·轻松早教练习纸,幼小衔接宝妈分享推荐',
path: '/pages/mathIndex/mathIndex',
imageUrl: 'https://cdn.joeyone.cn/doodle/share-img/index-share-v2.png',
};
@@ -52,6 +52,24 @@ function getDailyGroupIndex(letters?: string[]): number {
return idx >= 0 ? idx : 0;
}
function pickRandomIndexExcept(total: number, current: number): number {
if (total <= 1) return 0;
let next = Math.floor(Math.random() * total);
while (next === current) {
next = Math.floor(Math.random() * total);
}
return next;
}
function pickRandomLetterExcept(current: string): string {
if (LETTERS_UPPER.length <= 1) return LETTERS_UPPER[0] ?? 'A';
let next = LETTERS_UPPER[Math.floor(Math.random() * LETTERS_UPPER.length)];
while (next === current) {
next = LETTERS_UPPER[Math.floor(Math.random() * LETTERS_UPPER.length)];
}
return next;
}
const pageInfoLookup = getModeInfo;
type PageData = CanvasDataState & {
@@ -279,6 +297,51 @@ createPage(
this.drawCanvas();
},
/** 预览区刷新:按当前模式随机换字母 / 分组后重绘 */
onPreviewRefresh() {
const mode = this.data.traceMode;
const updates: Partial<PageData> = {};
switch (mode) {
case 'letter-tracing-single': {
const next = pickRandomLetterExcept(
this.data.selectedLetter,
);
updates.selectedLetter = next;
updates.selectedLetterPair = `${next}${next.toLowerCase()}`;
break;
}
case 'letter-tracing-case-pairing':
case 'letter-tracing-half':
updates.letterCaseLower = !this.data.letterCaseLower;
break;
case 'letter-tracing-three':
updates.selectedTripleGroupIdx = pickRandomIndexExcept(
TRIPLE_GROUPS.length,
this.data.selectedTripleGroupIdx,
);
break;
case 'letter-tracing-daily-checkin':
updates.selectedDailyGroupIdx = pickRandomIndexExcept(
DAILY_GROUPS.length,
this.data.selectedDailyGroupIdx,
);
break;
default:
break;
}
if (Object.keys(updates).length > 0) {
this.setData(
updates as Partial<PageData> & WechatMiniprogram.IAnyObject,
() => this.drawCanvas(),
);
return;
}
this.drawCanvas();
},
async onPreviewFavorite() {
const next = !this.data.isPreviewFavorite;
this.setData({ isPreviewFavorite: next });
@@ -4,10 +4,11 @@
<view class="lt-main">
<preview-card
id="previewCard"
showRefresh="{{false}}"
showRefresh="{{true}}"
showFavorite="{{true}}"
favorited="{{isPreviewFavorite}}"
bind:canvas-ready="onCanvasReady"
bind:refresh="onPreviewRefresh"
bind:favorite="onPreviewFavorite" />
<!-- 选择字母(默认字帖模式) -->
+16 -24
View File
@@ -41,17 +41,12 @@ type DownloadSection = {
items: DownloadRow[];
};
function buildWorksheetPath(worksheetId: string, category: string): string {
if (category === 'math') {
return `/mathPages/mathDraw/mathDraw?id=${worksheetId}`;
}
if (category === 'puzzle') {
return `/focusPages/focusDraw/focusDraw?id=${worksheetId}`;
}
if (category === 'english') {
return `/englishPages/letterTracing/letterTracing?id=${worksheetId}`;
}
return `/mathPages/mathDraw/mathDraw?id=${worksheetId}`;
/** 跳转路径仅以云库 worksheets.path 为准 */
function getWorksheetNavPath(
ws: FavoriteRecord['worksheet'] | DownloadLogRecord['worksheet'],
): string {
const path = ws?.path?.trim();
return path && path.startsWith('/') ? path : '';
}
function mapFavoriteToItem(record: FavoriteRecord): FavoriteItem {
@@ -68,7 +63,7 @@ function mapFavoriteToItem(record: FavoriteRecord): FavoriteItem {
return {
id: record._id,
worksheetId: record.worksheetId,
path: buildWorksheetPath(record.worksheetId, category),
path: getWorksheetNavPath(ws),
title,
metaLine,
stars: Math.min(difficulty, 3),
@@ -136,7 +131,7 @@ function groupDownloadsByDate(records: DownloadLogRecord[]): DownloadSection[] {
groups[key].items.push({
id: record._id,
worksheetId: record.worksheetId,
path: buildWorksheetPath(record.worksheetId, category),
path: getWorksheetNavPath(ws),
title: ws?.title || '未知题型',
metaLine,
stars: Math.min(difficulty, 3),
@@ -189,7 +184,10 @@ Page({
const tab = this.data.activeTab;
if (tab === 'favorites' && this.data.favoriteList.length === 0) {
this.loadFavorites();
} else if (tab === 'downloads' && this.data.downloadSections.length === 0) {
} else if (
tab === 'downloads' &&
this.data.downloadSections.length === 0
) {
this.loadDownloads();
}
},
@@ -238,8 +236,10 @@ Page({
onCardTap(e: WechatMiniprogram.TouchEvent) {
const path = e.currentTarget.dataset.path as string | undefined;
console.log('path:', path);
if (!path) return;
if (!path) {
wx.showToast({ title: '该练习已下架', icon: 'none' });
return;
}
wx.navigateTo({ url: path });
},
@@ -279,12 +279,4 @@ Page({
},
});
},
onDownloadMore(e: WechatMiniprogram.TouchEvent) {
const id = e.currentTarget.dataset.id as string | undefined;
wx.showToast({
title: id ? `更多操作:${id}` : '更多',
icon: 'none',
});
},
});
+1 -4
View File
@@ -199,10 +199,7 @@
>
</view>
</view>
<view
class="fav-dl-row__more"
data-id="{{row.id}}"
catchtap="onDownloadMore">
<view class="fav-dl-row__more">
<toy-icon
name="arrow-right"
size="36rpx"
+4
View File
@@ -11,6 +11,10 @@ export interface DownloadLogRecord {
subtitle: string;
category: string;
subcategory: string;
path: string;
ageMin?: number;
ageMax?: number;
difficulty?: number;
previewImg: string;
} | null;
}
+1
View File
@@ -11,6 +11,7 @@ export interface FavoriteRecord {
subtitle: string;
category: string;
subcategory: string;
path: string;
ageMin: number;
ageMax: number;
difficulty: number;