mirror of
https://github.com/motajs/template.git
synced 2026-11-14 15:34:30 +08:00
fix: equipStore 的 nextUid 在空存档下报错
This commit is contained in:
1 parent
b6d1976fc7
commit
ba60ef99eb
1 file changed
+9
-5
@@ -297,11 +297,15 @@ export class HeroEquipsStore<THero> implements IHeroEquipsStore<THero> {
|
||||
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;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user