mirror of
https://github.com/unanmed/HumanBreak.git
synced 2025-06-28 13:17:59 +08:00
feat: 记住最后存档位置 & fix: 存读档错位
This commit is contained in:
parent
c2cbc107a5
commit
dfd44e2083
@ -181,14 +181,14 @@ export const Save = defineComponent<SaveProps, SaveEmits, keyof SaveEmits>(
|
|||||||
*/
|
*/
|
||||||
const getPosIndex = (index: number) => {
|
const getPosIndex = (index: number) => {
|
||||||
if (index === -1) return 0;
|
if (index === -1) return 0;
|
||||||
return index % (grid.value.count - 1);
|
return (index % (grid.value.count - 1)) + 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取存档的总序号,从 0 开始,用于数据交互。
|
* 获取存档的总序号,从 0 开始,用于数据交互。
|
||||||
*/
|
*/
|
||||||
const getIndex = (posIndex: number, page: number) => {
|
const getIndex = (posIndex: number, page: number) => {
|
||||||
return page * grid.value.count + posIndex - 1;
|
return page * (grid.value.count - 1) + posIndex - 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
const updateDataList = async (page: number) => {
|
const updateDataList = async (page: number) => {
|
||||||
@ -217,11 +217,16 @@ export const Save = defineComponent<SaveProps, SaveEmits, keyof SaveEmits>(
|
|||||||
};
|
};
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
|
const startIndex = getPosIndex(core.saves.saveIndex);
|
||||||
|
selected.value = startIndex;
|
||||||
|
pageRef.value?.changePage(
|
||||||
|
Math.floor(core.saves.saveIndex / (grid.value.count - 1))
|
||||||
|
);
|
||||||
updateDataList(now.value);
|
updateDataList(now.value);
|
||||||
});
|
});
|
||||||
|
|
||||||
const emitSave = (index: number) => {
|
const emitSave = (index: number) => {
|
||||||
const posIndex = index === -1 ? 0 : getPosIndex(index);
|
const posIndex = getPosIndex(index);
|
||||||
if (inDelete.value) {
|
if (inDelete.value) {
|
||||||
emit('delete', index, exist(posIndex));
|
emit('delete', index, exist(posIndex));
|
||||||
deleteData(posIndex);
|
deleteData(posIndex);
|
||||||
@ -495,6 +500,7 @@ export async function saveSave(
|
|||||||
};
|
};
|
||||||
const index = await selectSave(controller, loc, validate, props);
|
const index = await selectSave(controller, loc, validate, props);
|
||||||
if (index === -2) return false;
|
if (index === -2) return false;
|
||||||
|
core.saves.saveIndex = index;
|
||||||
core.doSL(index + 1, 'save');
|
core.doSL(index + 1, 'save');
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user