feat: location catalog api

This commit is contained in:
Hufe921
2023-05-09 21:00:07 +08:00
parent 7ad4ba3a26
commit 535562e396
2 changed files with 25 additions and 0 deletions
+6
View File
@@ -87,6 +87,7 @@ export class Command {
private static removeControl: CommandAdapt['removeControl']
private static setLocale: CommandAdapt['setLocale']
private static getCatalog: CommandAdapt['getCatalog']
private static locationCatalog: CommandAdapt['locationCatalog']
constructor(adapt: CommandAdapt) {
Command.mode = adapt.mode.bind(adapt)
@@ -166,6 +167,7 @@ export class Command {
Command.removeControl = adapt.removeControl.bind(adapt)
Command.setLocale = adapt.setLocale.bind(adapt)
Command.getCatalog = adapt.getCatalog.bind(adapt)
Command.locationCatalog = adapt.locationCatalog.bind(adapt)
}
// 全局命令
@@ -483,4 +485,8 @@ export class Command {
return Command.getCatalog()
}
public executeLocationCatalog(titleId: string) {
return Command.locationCatalog(titleId)
}
}
+19
View File
@@ -1660,4 +1660,23 @@ export class CommandAdapt {
return this.workerManager.getCatalog()
}
public locationCatalog(titleId: string) {
const elementList = this.draw.getMainElementList()
let newIndex = -1
for (let e = 0; e < elementList.length; e++) {
const element = elementList[e]
if (element.titleId === titleId && elementList[e + 1]?.titleId !== titleId) {
newIndex = e
break
}
}
if (!~newIndex) return
this.range.setRange(newIndex, newIndex)
this.draw.render({
curIndex: newIndex,
isCompute: false,
isSubmitHistory: false
})
}
}