From e998da37cbdc4f628ba042e0c36e28339f22958d Mon Sep 17 00:00:00 2001 From: R524809 Date: Mon, 25 May 2026 16:26:20 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=B8=80=E4=BA=9Bbug=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- miniprogram/base/pageMixin.ts | 12 +--- miniprogram/config/config.ts | 4 +- .../letterTracing/letterTracing.ts | 63 +++++++++++++++++++ .../letterTracing/letterTracing.wxml | 3 +- miniprogram/pages/favorites/favorites.ts | 40 +++++------- miniprogram/pages/favorites/favorites.wxml | 5 +- miniprogram/utils/downloadLogs.ts | 4 ++ miniprogram/utils/favorites.ts | 1 + 8 files changed, 90 insertions(+), 42 deletions(-) diff --git a/miniprogram/base/pageMixin.ts b/miniprogram/base/pageMixin.ts index a7b1785..45742d0 100644 --- a/miniprogram/base/pageMixin.ts +++ b/miniprogram/base/pageMixin.ts @@ -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: { diff --git a/miniprogram/config/config.ts b/miniprogram/config/config.ts index f98406a..06c111b 100644 --- a/miniprogram/config/config.ts +++ b/miniprogram/config/config.ts @@ -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', }; diff --git a/miniprogram/englishPages/letterTracing/letterTracing.ts b/miniprogram/englishPages/letterTracing/letterTracing.ts index ec4ace1..d2c6179 100644 --- a/miniprogram/englishPages/letterTracing/letterTracing.ts +++ b/miniprogram/englishPages/letterTracing/letterTracing.ts @@ -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 = {}; + + 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 & WechatMiniprogram.IAnyObject, + () => this.drawCanvas(), + ); + return; + } + + this.drawCanvas(); + }, + async onPreviewFavorite() { const next = !this.data.isPreviewFavorite; this.setData({ isPreviewFavorite: next }); diff --git a/miniprogram/englishPages/letterTracing/letterTracing.wxml b/miniprogram/englishPages/letterTracing/letterTracing.wxml index 3cb34f6..8026e89 100644 --- a/miniprogram/englishPages/letterTracing/letterTracing.wxml +++ b/miniprogram/englishPages/letterTracing/letterTracing.wxml @@ -4,10 +4,11 @@ diff --git a/miniprogram/pages/favorites/favorites.ts b/miniprogram/pages/favorites/favorites.ts index ccbef69..4ef2292 100644 --- a/miniprogram/pages/favorites/favorites.ts +++ b/miniprogram/pages/favorites/favorites.ts @@ -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', - }); - }, }); diff --git a/miniprogram/pages/favorites/favorites.wxml b/miniprogram/pages/favorites/favorites.wxml index d5854cd..bf345fe 100644 --- a/miniprogram/pages/favorites/favorites.wxml +++ b/miniprogram/pages/favorites/favorites.wxml @@ -199,10 +199,7 @@ > - +