From ba60ef99eb162b01788fdb11735e789374421081 Mon Sep 17 00:00:00 2001 From: unanmed <1319491857@qq.com> Date: Thu, 17 Sep 2026 14:56:56 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20equipStore=20=E7=9A=84=20nextUid=20?= =?UTF-8?q?=E5=9C=A8=E7=A9=BA=E5=AD=98=E6=A1=A3=E4=B8=8B=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages-user/data-base/src/hero/equipStore.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/packages-user/data-base/src/hero/equipStore.ts b/packages-user/data-base/src/hero/equipStore.ts index 9a53a61..5a6d394 100644 --- a/packages-user/data-base/src/hero/equipStore.ts +++ b/packages-user/data-base/src/hero/equipStore.ts @@ -297,11 +297,15 @@ export class HeroEquipsStore implements IHeroEquipsStore { this.instanceMap.delete(uid); } } - const maxUid = maxBy(state.equipments, 'uid'); - if (!maxUid) { - logger.error(58); - return; + if (state.equipments.length === 0) { + this.nextUid = 0; + } else { + const maxUid = maxBy(state.equipments, 'uid'); + if (!maxUid) { + logger.error(58); + return; + } + this.nextUid = maxUid.uid + 1; } - this.nextUid = maxUid.uid + 1; } }