From 3b8232a9d926c54969da702160f1568ef63f91ad Mon Sep 17 00:00:00 2001 From: unanmed <1319491857@qq.com> Date: Fri, 29 Sep 2023 18:06:52 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=A0=B9=E6=8D=AE=E5=94=AF=E4=B8=80?= =?UTF-8?q?=E6=A0=87=E8=AF=86=E7=AC=A6=E8=8E=B7=E5=8F=96ui?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/core/main/custom/ui.ts | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/core/main/custom/ui.ts b/src/core/main/custom/ui.ts index 0f0099f..1fc25e5 100644 --- a/src/core/main/custom/ui.ts +++ b/src/core/main/custom/ui.ts @@ -18,7 +18,7 @@ export class Focus extends EventEmitter> { stack: T[]; focused: T | null = null; - /** ui是否平等,在平等时,关闭ui不再会将其之后的ui全部删除,而是保留 */ + /** 聚焦目标是否平等,在平等时,关闭聚焦目标不再会将其之后的目标全部删除,而是保留 */ readonly equal: boolean; constructor(react: boolean = false, equal: boolean = false) { @@ -83,7 +83,7 @@ export class Focus extends EventEmitter> { } /** - * 从一个位置开始删除显示列表,如果ui平等,则只会删除一个,否则会将其之后的所有ui全部删除 + * 从一个位置开始删除显示列表,如果平等,则只会删除一个,否则会将其之后的所有的目标全部删除 * @param item 从哪开始删除,包括此项 */ splice(item: T) { @@ -249,8 +249,16 @@ export class UiController extends Focus { * @param num 要聚焦于的ui的唯一标识符 */ focusByNum(num: number) { - const ui = this.stack.find(v => v.num === num); + const ui = this.getByNum(num); if (!ui) return; this.focus(ui); } + + /** + * 根据唯一标识符获取对应的ui + * @param num ui的唯一标识符 + */ + getByNum(num: number) { + return this.stack.find(v => v.num === num); + } }