feat: 首页跳转到分类页指定分类优化

This commit is contained in:
R524809
2026-05-09 11:08:29 +08:00
parent c21ac9e935
commit debecd67c6
20 changed files with 1450 additions and 959 deletions
+8 -3
View File
@@ -1,4 +1,5 @@
import { CATEGORY_LIST_WITH_ALL } from '../../core/data/categories';
import { takePendingCategoryTabId } from '../../utils/index';
import { CATEGORY_DATA, type CategoryItem } from './category.data';
type CategoryTab = {
@@ -190,10 +191,10 @@ Page({
onShow() {
_categoryData = null;
this.setData({ displayItems: SKELETON_ITEMS, loading: true });
void this.loadWorksheets();
void this.loadWorksheets(takePendingCategoryTabId() ?? undefined);
},
async loadWorksheets() {
async loadWorksheets(overrideCategoryId?: string | null) {
try {
const res = await wx.cloud.callFunction({
name: 'worksheetsQuery',
@@ -207,7 +208,11 @@ Page({
_categoryData = CATEGORY_DATA;
}
const activeId = this.data.activeCategoryId || this._defaultCategoryId;
const activeId =
overrideCategoryId != null &&
String(overrideCategoryId).trim() !== ''
? String(overrideCategoryId).trim()
: this.data.activeCategoryId || this._defaultCategoryId;
const items = getItemsByCategory(activeId);
const filtered = filterByKeyword(items, this.data.searchKeyword);