feat: 一些bug修复
This commit is contained in:
@@ -1,9 +1,6 @@
|
|||||||
import { PAPER_SIZE } from '../constants/colors';
|
import { PAPER_SIZE } from '../constants/colors';
|
||||||
import { downloadPrint, tryUnlockWithRewardedAd } from '../utils/downloadPrint';
|
import { downloadPrint, tryUnlockWithRewardedAd } from '../utils/downloadPrint';
|
||||||
import {
|
import { shouldShowShareGuide, shouldUnlockWithAd } from '../utils/shareGuide';
|
||||||
shouldShowShareGuide,
|
|
||||||
shouldUnlockWithAd,
|
|
||||||
} from '../utils/shareGuide';
|
|
||||||
import { BaseDrawService } from '../core/draw/baseDraw';
|
import { BaseDrawService } from '../core/draw/baseDraw';
|
||||||
import tracker from '../utils/tracker';
|
import tracker from '../utils/tracker';
|
||||||
import { defaultShareConfig } from '../config/config';
|
import { defaultShareConfig } from '../config/config';
|
||||||
@@ -411,24 +408,19 @@ export function getPageCommonMethods(config: PageCommonMethodsConfig = {}) {
|
|||||||
quality: 1,
|
quality: 1,
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log('sourcePath', sourcePath);
|
|
||||||
|
|
||||||
const processed = await debugPublishTools.processImage({
|
const processed = await debugPublishTools.processImage({
|
||||||
sourcePath,
|
sourcePath,
|
||||||
settings: detail.settings,
|
settings: detail.settings,
|
||||||
});
|
});
|
||||||
console.log('processed', processed);
|
|
||||||
|
|
||||||
const cloudPath = buildWorksheetPreviewCloudPath(
|
const cloudPath = buildWorksheetPreviewCloudPath(
|
||||||
publishMeta.category,
|
publishMeta.category,
|
||||||
publishMeta.id,
|
publishMeta.id,
|
||||||
);
|
);
|
||||||
console.log('cloudPath', cloudPath);
|
|
||||||
const uploadRes = await wx.cloud.uploadFile({
|
const uploadRes = await wx.cloud.uploadFile({
|
||||||
cloudPath,
|
cloudPath,
|
||||||
filePath: processed.tempFilePath,
|
filePath: processed.tempFilePath,
|
||||||
});
|
});
|
||||||
console.log('uploadRes', uploadRes);
|
|
||||||
|
|
||||||
const cloudCall = (await wx.cloud.callFunction({
|
const cloudCall = (await wx.cloud.callFunction({
|
||||||
name: 'worksheetsPublish',
|
name: 'worksheetsPublish',
|
||||||
@@ -439,13 +431,11 @@ export function getPageCommonMethods(config: PageCommonMethodsConfig = {}) {
|
|||||||
})) as {
|
})) as {
|
||||||
result?: { success?: boolean; message?: string };
|
result?: { success?: boolean; message?: string };
|
||||||
};
|
};
|
||||||
console.log('cloudCall', cloudCall);
|
|
||||||
if (!cloudCall.result?.success) {
|
if (!cloudCall.result?.success) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
cloudCall.result?.message || '云端写入失败',
|
cloudCall.result?.message || '云端写入失败',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
console.log('success');
|
|
||||||
this.setData({
|
this.setData({
|
||||||
debugPublishVisible: false,
|
debugPublishVisible: false,
|
||||||
debugPublishMeta: {
|
debugPublishMeta: {
|
||||||
|
|||||||
@@ -14,8 +14,8 @@ export const defaultPrintConfig: PrintConfig = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const defaultShareConfig = {
|
export const defaultShareConfig = {
|
||||||
// title: '涂鸦丫 - 一张会“教知识”的涂色卡',
|
// title: '涂鸦丫·儿童打印练习纸,数学练字拼音一键打印',
|
||||||
title: '涂鸦丫 - 快来生成宝宝的专属学习卡',
|
title: '涂鸦丫·轻松早教练习纸,幼小衔接宝妈分享推荐',
|
||||||
path: '/pages/mathIndex/mathIndex',
|
path: '/pages/mathIndex/mathIndex',
|
||||||
imageUrl: 'https://cdn.joeyone.cn/doodle/share-img/index-share-v2.png',
|
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;
|
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;
|
const pageInfoLookup = getModeInfo;
|
||||||
|
|
||||||
type PageData = CanvasDataState & {
|
type PageData = CanvasDataState & {
|
||||||
@@ -279,6 +297,51 @@ createPage(
|
|||||||
this.drawCanvas();
|
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() {
|
async onPreviewFavorite() {
|
||||||
const next = !this.data.isPreviewFavorite;
|
const next = !this.data.isPreviewFavorite;
|
||||||
this.setData({ isPreviewFavorite: next });
|
this.setData({ isPreviewFavorite: next });
|
||||||
|
|||||||
@@ -4,10 +4,11 @@
|
|||||||
<view class="lt-main">
|
<view class="lt-main">
|
||||||
<preview-card
|
<preview-card
|
||||||
id="previewCard"
|
id="previewCard"
|
||||||
showRefresh="{{false}}"
|
showRefresh="{{true}}"
|
||||||
showFavorite="{{true}}"
|
showFavorite="{{true}}"
|
||||||
favorited="{{isPreviewFavorite}}"
|
favorited="{{isPreviewFavorite}}"
|
||||||
bind:canvas-ready="onCanvasReady"
|
bind:canvas-ready="onCanvasReady"
|
||||||
|
bind:refresh="onPreviewRefresh"
|
||||||
bind:favorite="onPreviewFavorite" />
|
bind:favorite="onPreviewFavorite" />
|
||||||
|
|
||||||
<!-- 选择字母(默认字帖模式) -->
|
<!-- 选择字母(默认字帖模式) -->
|
||||||
|
|||||||
@@ -41,17 +41,12 @@ type DownloadSection = {
|
|||||||
items: DownloadRow[];
|
items: DownloadRow[];
|
||||||
};
|
};
|
||||||
|
|
||||||
function buildWorksheetPath(worksheetId: string, category: string): string {
|
/** 跳转路径仅以云库 worksheets.path 为准 */
|
||||||
if (category === 'math') {
|
function getWorksheetNavPath(
|
||||||
return `/mathPages/mathDraw/mathDraw?id=${worksheetId}`;
|
ws: FavoriteRecord['worksheet'] | DownloadLogRecord['worksheet'],
|
||||||
}
|
): string {
|
||||||
if (category === 'puzzle') {
|
const path = ws?.path?.trim();
|
||||||
return `/focusPages/focusDraw/focusDraw?id=${worksheetId}`;
|
return path && path.startsWith('/') ? path : '';
|
||||||
}
|
|
||||||
if (category === 'english') {
|
|
||||||
return `/englishPages/letterTracing/letterTracing?id=${worksheetId}`;
|
|
||||||
}
|
|
||||||
return `/mathPages/mathDraw/mathDraw?id=${worksheetId}`;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function mapFavoriteToItem(record: FavoriteRecord): FavoriteItem {
|
function mapFavoriteToItem(record: FavoriteRecord): FavoriteItem {
|
||||||
@@ -68,7 +63,7 @@ function mapFavoriteToItem(record: FavoriteRecord): FavoriteItem {
|
|||||||
return {
|
return {
|
||||||
id: record._id,
|
id: record._id,
|
||||||
worksheetId: record.worksheetId,
|
worksheetId: record.worksheetId,
|
||||||
path: buildWorksheetPath(record.worksheetId, category),
|
path: getWorksheetNavPath(ws),
|
||||||
title,
|
title,
|
||||||
metaLine,
|
metaLine,
|
||||||
stars: Math.min(difficulty, 3),
|
stars: Math.min(difficulty, 3),
|
||||||
@@ -136,7 +131,7 @@ function groupDownloadsByDate(records: DownloadLogRecord[]): DownloadSection[] {
|
|||||||
groups[key].items.push({
|
groups[key].items.push({
|
||||||
id: record._id,
|
id: record._id,
|
||||||
worksheetId: record.worksheetId,
|
worksheetId: record.worksheetId,
|
||||||
path: buildWorksheetPath(record.worksheetId, category),
|
path: getWorksheetNavPath(ws),
|
||||||
title: ws?.title || '未知题型',
|
title: ws?.title || '未知题型',
|
||||||
metaLine,
|
metaLine,
|
||||||
stars: Math.min(difficulty, 3),
|
stars: Math.min(difficulty, 3),
|
||||||
@@ -189,7 +184,10 @@ Page({
|
|||||||
const tab = this.data.activeTab;
|
const tab = this.data.activeTab;
|
||||||
if (tab === 'favorites' && this.data.favoriteList.length === 0) {
|
if (tab === 'favorites' && this.data.favoriteList.length === 0) {
|
||||||
this.loadFavorites();
|
this.loadFavorites();
|
||||||
} else if (tab === 'downloads' && this.data.downloadSections.length === 0) {
|
} else if (
|
||||||
|
tab === 'downloads' &&
|
||||||
|
this.data.downloadSections.length === 0
|
||||||
|
) {
|
||||||
this.loadDownloads();
|
this.loadDownloads();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -238,8 +236,10 @@ Page({
|
|||||||
|
|
||||||
onCardTap(e: WechatMiniprogram.TouchEvent) {
|
onCardTap(e: WechatMiniprogram.TouchEvent) {
|
||||||
const path = e.currentTarget.dataset.path as string | undefined;
|
const path = e.currentTarget.dataset.path as string | undefined;
|
||||||
console.log('path:', path);
|
if (!path) {
|
||||||
if (!path) return;
|
wx.showToast({ title: '该练习已下架', icon: 'none' });
|
||||||
|
return;
|
||||||
|
}
|
||||||
wx.navigateTo({ url: path });
|
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',
|
|
||||||
});
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -199,10 +199,7 @@
|
|||||||
>
|
>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view
|
<view class="fav-dl-row__more">
|
||||||
class="fav-dl-row__more"
|
|
||||||
data-id="{{row.id}}"
|
|
||||||
catchtap="onDownloadMore">
|
|
||||||
<toy-icon
|
<toy-icon
|
||||||
name="arrow-right"
|
name="arrow-right"
|
||||||
size="36rpx"
|
size="36rpx"
|
||||||
|
|||||||
@@ -11,6 +11,10 @@ export interface DownloadLogRecord {
|
|||||||
subtitle: string;
|
subtitle: string;
|
||||||
category: string;
|
category: string;
|
||||||
subcategory: string;
|
subcategory: string;
|
||||||
|
path: string;
|
||||||
|
ageMin?: number;
|
||||||
|
ageMax?: number;
|
||||||
|
difficulty?: number;
|
||||||
previewImg: string;
|
previewImg: string;
|
||||||
} | null;
|
} | null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ export interface FavoriteRecord {
|
|||||||
subtitle: string;
|
subtitle: string;
|
||||||
category: string;
|
category: string;
|
||||||
subcategory: string;
|
subcategory: string;
|
||||||
|
path: string;
|
||||||
ageMin: number;
|
ageMin: number;
|
||||||
ageMax: number;
|
ageMax: number;
|
||||||
difficulty: number;
|
difficulty: number;
|
||||||
|
|||||||
Reference in New Issue
Block a user