mirror of
https://github.com/unanmed/HumanBreak.git
synced 2025-06-28 05:07:59 +08:00
fix: 存档位置
This commit is contained in:
parent
5adeff1a11
commit
c2cbc107a5
@ -63,7 +63,7 @@ export const SaveItem = defineComponent<SaveItemProps>(props => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const name = computed(() => {
|
const name = computed(() => {
|
||||||
return props.index === -1 ? '自动存档' : `存档${props.index}`;
|
return props.index === 0 ? '自动存档' : `存档${props.index}`;
|
||||||
});
|
});
|
||||||
const statusText = computed(() => {
|
const statusText = computed(() => {
|
||||||
if (!props.data) return '';
|
if (!props.data) return '';
|
||||||
@ -192,10 +192,10 @@ export const Save = defineComponent<SaveProps, SaveEmits, keyof SaveEmits>(
|
|||||||
};
|
};
|
||||||
|
|
||||||
const updateDataList = async (page: number) => {
|
const updateDataList = async (page: number) => {
|
||||||
const promises: Promise<SaveData | null>[] = [];
|
const promises: Promise<SaveData | null>[] = [getSave(0)];
|
||||||
for (let i = 0; i < grid.value.count; i++) {
|
for (let i = 1; i < grid.value.count; i++) {
|
||||||
const index = getIndex(i, page);
|
const index = getIndex(i, page);
|
||||||
promises.push(getSave(index));
|
promises.push(getSave(index + 1));
|
||||||
}
|
}
|
||||||
const data = await Promise.all(promises);
|
const data = await Promise.all(promises);
|
||||||
|
|
||||||
@ -221,7 +221,7 @@ export const Save = defineComponent<SaveProps, SaveEmits, keyof SaveEmits>(
|
|||||||
});
|
});
|
||||||
|
|
||||||
const emitSave = (index: number) => {
|
const emitSave = (index: number) => {
|
||||||
const posIndex = getPosIndex(index);
|
const posIndex = index === -1 ? 0 : getPosIndex(index);
|
||||||
if (inDelete.value) {
|
if (inDelete.value) {
|
||||||
emit('delete', index, exist(posIndex));
|
emit('delete', index, exist(posIndex));
|
||||||
deleteData(posIndex);
|
deleteData(posIndex);
|
||||||
@ -260,7 +260,9 @@ export const Save = defineComponent<SaveProps, SaveEmits, keyof SaveEmits>(
|
|||||||
if (selected.value === 0) {
|
if (selected.value === 0) {
|
||||||
emitSave(-1);
|
emitSave(-1);
|
||||||
} else {
|
} else {
|
||||||
emitSave((grid.value.count - 1) * now.value + selected.value);
|
emitSave(
|
||||||
|
(grid.value.count - 1) * now.value + selected.value - 1
|
||||||
|
);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.realize('exit', exit)
|
.realize('exit', exit)
|
||||||
@ -360,7 +362,7 @@ export const Save = defineComponent<SaveProps, SaveEmits, keyof SaveEmits>(
|
|||||||
{grid.value.locs.map((v, i) => {
|
{grid.value.locs.map((v, i) => {
|
||||||
const count = grid.value.count;
|
const count = grid.value.count;
|
||||||
const rawIndex = (count - 1) * page + i;
|
const rawIndex = (count - 1) * page + i;
|
||||||
const index = i === 0 ? -1 : rawIndex;
|
const index = i === 0 ? 0 : rawIndex;
|
||||||
return (
|
return (
|
||||||
<SaveItem
|
<SaveItem
|
||||||
loc={v}
|
loc={v}
|
||||||
@ -368,7 +370,7 @@ export const Save = defineComponent<SaveProps, SaveEmits, keyof SaveEmits>(
|
|||||||
selected={selected.value === i}
|
selected={selected.value === i}
|
||||||
inDelete={inDelete.value}
|
inDelete={inDelete.value}
|
||||||
data={saveData[i]}
|
data={saveData[i]}
|
||||||
onClick={() => emitSave(index)}
|
onClick={() => emitSave(index - 1)}
|
||||||
onEnter={() => (selected.value = i)}
|
onEnter={() => (selected.value = i)}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
@ -508,7 +510,7 @@ export async function saveLoad(
|
|||||||
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;
|
||||||
if (index === -1) {
|
if (index === -1) {
|
||||||
core.doSL('autosave', 'load');
|
core.doSL('autoSave', 'load');
|
||||||
} else {
|
} else {
|
||||||
core.doSL(index + 1, 'load');
|
core.doSL(index + 1, 'load');
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@ export function getSave(index: number) {
|
|||||||
const content = {
|
const content = {
|
||||||
name: core.firstData.name,
|
name: core.firstData.name,
|
||||||
version: core.firstData.version,
|
version: core.firstData.version,
|
||||||
data: data instanceof Array ? data[0] : data
|
data: data instanceof Array ? data.at(-1)! : data
|
||||||
};
|
};
|
||||||
res(content);
|
res(content);
|
||||||
});
|
});
|
||||||
|
2
src/types/declaration/control.d.ts
vendored
2
src/types/declaration/control.d.ts
vendored
@ -636,7 +636,7 @@ interface Control {
|
|||||||
/**
|
/**
|
||||||
* 获得某个存档内容
|
* 获得某个存档内容
|
||||||
*/
|
*/
|
||||||
getSave(index: number, callback?: (data?: Save) => void): void;
|
getSave(index: number, callback?: (data?: Save | Save[]) => void): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获得某些存档内容
|
* 获得某些存档内容
|
||||||
|
Loading…
Reference in New Issue
Block a user