feat: 一些bug修复
This commit is contained in:
@@ -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',
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user