feat: add multi-source breed encyclopedia and two-hour refresh sessions
ci-cd / verify (push) Successful in 1m59s
ci-cd / deploy (push) Skipped

This commit is contained in:
2026-10-05 13:38:24 +08:00
parent 607d709100
commit 9d7cf720a5
73 changed files with 25771 additions and 264 deletions
+50
View File
@@ -0,0 +1,50 @@
const { loadBreeds, groupBreeds } = require("../../utils/breeds");
Page({
data: {
groups: [],
query: "",
loading: true,
error: "",
total: 0,
initial: "",
},
onLoad() {
this.load();
},
async load() {
if (this.pending) return;
this.pending = true;
this.setData({ loading: true, error: "" });
try {
this.rows = await loadBreeds();
this.filter();
} catch (error) {
this.setData({ error: error.message });
} finally {
this.pending = false;
this.setData({ loading: false });
}
},
filter() {
let groups = groupBreeds(this.rows || [], this.data.query);
if (this.data.initial)
groups = groups.filter((g) => g.letter === this.data.initial);
this.setData({
groups,
total: groups.reduce((n, g) => n + g.items.length, 0),
});
},
search(e) {
this.setData({ query: e.detail.value, initial: "" });
this.filter();
},
letter(e) {
this.setData({ initial: e.currentTarget.dataset.letter });
this.filter();
},
open(e) {
wx.navigateTo({
url: "/pages/breed-detail/breed-detail?id=" + e.currentTarget.dataset.id,
});
},
});