fix: 存读档切页面失效

This commit is contained in:
unanmed 2025-06-25 12:11:05 +08:00
parent e3edac3d55
commit e0b3b2a68b

View File

@ -183,6 +183,8 @@ export const Save = defineComponent<SaveProps, SaveEmits, keyof SaveEmits>(
return [right, height.value - 13, void 0, void 0, 1, 1]; return [right, height.value - 13, void 0, void 0, 1, 1];
}); });
//#region 数据信息
/** /**
* 0 pageCap-1 * 0 pageCap-1
*/ */
@ -204,10 +206,9 @@ export const Save = defineComponent<SaveProps, SaveEmits, keyof SaveEmits>(
const index = getIndex(i, page); const index = getIndex(i, page);
promises.push(getSave(index + 1)); promises.push(getSave(index + 1));
} }
const before = now.value; const before = page;
const data = await Promise.all(promises); const data = await Promise.all(promises);
if (before !== now.value) return; if (now.value !== before) return;
data.forEach((v, i) => { data.forEach((v, i) => {
if (v) { if (v) {
saveData[i] = v; saveData[i] = v;
@ -217,6 +218,17 @@ export const Save = defineComponent<SaveProps, SaveEmits, keyof SaveEmits>(
}); });
}; };
onMounted(() => {
const startIndex = getPosIndex(core.saves.saveIndex);
selected.value = startIndex - 1;
pageRef.value?.changePage(
Math.floor(core.saves.saveIndex / (grid.value.count - 1))
);
updateDataList(now.value);
});
//#region 逻辑操作
const exist = (index: number) => { const exist = (index: number) => {
return saveData[index] !== null; return saveData[index] !== null;
}; };
@ -225,15 +237,6 @@ export const Save = defineComponent<SaveProps, SaveEmits, keyof SaveEmits>(
saveData[index] = null; saveData[index] = null;
}; };
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);
});
const emitSave = async (index: number) => { const emitSave = async (index: number) => {
const posIndex = getPosIndex(index); const posIndex = getPosIndex(index);
if (inDelete.value) { if (inDelete.value) {
@ -258,15 +261,6 @@ export const Save = defineComponent<SaveProps, SaveEmits, keyof SaveEmits>(
} }
}; };
const wheel = (ev: IWheelEvent) => {
const delta = Math.sign(ev.wheelY);
if (ev.ctrlKey) {
pageRef.value?.movePage(delta * 10);
} else {
pageRef.value?.movePage(delta);
}
};
const toggleDelete = () => { const toggleDelete = () => {
inDelete.value = !inDelete.value; inDelete.value = !inDelete.value;
}; };
@ -374,6 +368,16 @@ export const Save = defineComponent<SaveProps, SaveEmits, keyof SaveEmits>(
{ type: 'down-repeat' } { type: 'down-repeat' }
); );
//#region 事件监听
const wheel = (ev: IWheelEvent) => {
const delta = Math.sign(ev.wheelY);
if (ev.ctrlKey) {
pageRef.value?.movePage(delta * 10);
} else {
pageRef.value?.movePage(delta);
}
};
return () => ( return () => (
<container loc={props.loc}> <container loc={props.loc}>
<Page <Page
@ -393,6 +397,7 @@ export const Save = defineComponent<SaveProps, SaveEmits, keyof SaveEmits>(
const index = i === 0 ? 0 : rawIndex; const index = i === 0 ? 0 : rawIndex;
return ( return (
<SaveItem <SaveItem
key={index}
loc={v} loc={v}
index={index} index={index}
selected={selected.value === i} selected={selected.value === i}
@ -531,7 +536,6 @@ export async function saveSave(
props 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;
} }