fix:修复存档界面写法问题

This commit is contained in:
ShakeFlower 2025-06-17 16:27:38 +08:00
parent dff0a925e3
commit 5b24af71b1

View File

@ -16,6 +16,13 @@ export interface SaveProps extends UIComponentProps, DefaultProps {
loc: ElementLocator; loc: ElementLocator;
} }
interface SaveBtnProps {
loc: ElementLocator;
index: number;
emit: (index: number) => void;
isDelete: boolean;
}
export type SaveEmits = { export type SaveEmits = {
/** 点击存档时触发 */ /** 点击存档时触发 */
emit: (index: number) => void; emit: (index: number) => void;
@ -30,21 +37,20 @@ const saveProps = {
emits: ['delete', 'emit', 'exit'] emits: ['delete', 'emit', 'exit']
} satisfies SetupComponentOptions<SaveProps, SaveEmits, keyof SaveEmits>; } satisfies SetupComponentOptions<SaveProps, SaveEmits, keyof SaveEmits>;
function SaveBtn(props: { const saveBtnProps = {
loc: ElementLocator; props: ['loc', 'index', 'emit', 'isDelete']
index: number; } satisfies SetupComponentOptions<SaveBtnProps>;
emit: (index: number) => void;
isDelete: boolean; const SaveBtn = defineComponent<SaveBtnProps>(props => {
}) {
const w = props.loc[2]; const w = props.loc[2];
return ( return () => (
<container loc={props.loc}> <container loc={props.loc}>
<text <text
text={ text={
props.index === -1 ? '自动存档' : '存档' + (props.index + 1) props.index === -1 ? '自动存档' : '存档' + (props.index + 1)
} }
font={new Font('normal', 18)} font={new Font('normal', 18)}
loc={[w! / 2, 0, undefined, undefined, 0.5, 0]} loc={[w! / 2, 0, void 0, void 0, 0.5, 0]}
/> />
<g-rect <g-rect
loc={[0, 20, w, w]} loc={[0, 20, w, w]}
@ -55,14 +61,20 @@ function SaveBtn(props: {
onClick={() => props.emit(props.index)} onClick={() => props.emit(props.index)}
/> />
<text <text
text={'1000/10/10'} text={
fillStyle={'yellow'} core.status.hero.hp +
'/' +
core.status.hero.atk +
'/' +
core.status.hero.def
}
fillStyle="yellow"
font={new Font('normal', 18)} font={new Font('normal', 18)}
loc={[w! / 2, w! + 20, undefined, undefined, 0.5, 0]} loc={[w! / 2, w! + 20, void 0, void 0, 0.5, 0]}
/> />
</container> </container>
); );
} }, saveBtnProps);
export const Save = defineComponent<SaveProps, SaveEmits, keyof SaveEmits>( export const Save = defineComponent<SaveProps, SaveEmits, keyof SaveEmits>(
(props, { emit }) => { (props, { emit }) => {
@ -82,14 +94,15 @@ export const Save = defineComponent<SaveProps, SaveEmits, keyof SaveEmits>(
const pageRef = ref<PageExpose>(); const pageRef = ref<PageExpose>();
const pageCap = 5; const pageCap = 5;
let isDelete = ref(false); const isDelete = ref(false);
const emitSave = (index: number) => { const emitSave = (index: number) => {
if (index === -1) { if (index === -1) {
console.log('不能覆盖自动存档!'); core.drawTip('不能覆盖自动存档!');
return; return;
} }
emit('emit', index, isDelete.value); if (isDelete.value) emit('delete', index);
else emit('emit', index);
}; };
const wheel = (ev: IWheelEvent) => { const wheel = (ev: IWheelEvent) => {
@ -151,9 +164,9 @@ export const Save = defineComponent<SaveProps, SaveEmits, keyof SaveEmits>(
)} )}
</Page> </Page>
<text <text
text={'删除模式'} text="删除模式"
font={new Font('normal', 18)} font={new Font('normal', 18)}
loc={[30, 450, undefined, undefined, 0, 0]} loc={[30, 450, void 0, void 0, 0, 0]}
zIndex={1} zIndex={1}
fillStyle={isDelete.value ? 'red' : 'white'} fillStyle={isDelete.value ? 'red' : 'white'}
onClick={() => { onClick={() => {
@ -161,9 +174,9 @@ export const Save = defineComponent<SaveProps, SaveEmits, keyof SaveEmits>(
}} }}
/> />
<text <text
text={'返回游戏'} text="返回游戏"
font={new Font('normal', 18)} font={new Font('normal', 18)}
loc={[450, 450, undefined, undefined, 1, 0]} loc={[450, 450, void 0, void 0, 1, 0]}
zIndex={1} zIndex={1}
onClick={() => emit('exit')} onClick={() => emit('exit')}
/> />