feat: 汉字页输入和选择体验优化

This commit is contained in:
R524809
2026-05-25 14:18:28 +08:00
parent 2e8a03de57
commit 4379358a41
3 changed files with 48 additions and 98 deletions
@@ -45,9 +45,23 @@ Component({
},
observers: {
cardList(newVal: CardList) {
if (!Array.isArray(newVal)) return;
// 练字贴等页面只传 selectedWords、cardList 恒为 [],勿用空列表覆盖已选字
if (newVal.length === 0) {
const fromProp = this.properties.selectedWords as string[];
if (Array.isArray(fromProp) && fromProp.length > 0) return;
}
const selectedWords = newVal.map((item) => item.word);
this.setData({ selectedWords });
},
/** 仅在弹窗打开时从父组件同步一次,避免监听 selectedWords 与 setData 形成死循环 */
show(show: boolean) {
if (!show) return;
const incoming = this.properties.selectedWords as string[];
this.setData({
selectedWords: Array.isArray(incoming) ? [...incoming] : [],
});
},
},
/**
* 组件的方法列表