fix: 组件在文档编写中发现的问题

This commit is contained in:
AncTe committed 2026-11-26 20:00:59 +08:00
1 parent 72599d465b
commit afb1ff30aa
4 files changed
+27 -15

No files matched your search

@@ -50,7 +50,7 @@ export const Icon = defineComponent<IIconProps>(props => {
});
/** 当不播放图块动画时,静态使用的贴图 */
const staticImage = computed<ITexture | null>(() => {
if (!animate.value || !data.value) return null;
if (animate.value || !data.value) return null;
const frame = props.frame ?? data.value.defaultFrame;
const o = data.value.offset * frame;
const tex = data.value.texture;
@@ -73,8 +73,10 @@ export const ListSelector = defineComponent<
}
});
/** 当前选中项的信息 */
const current = computed(
() => list.value[list.value.length - now.value - 1]
const current = computed(() =>
props.reverse
? list.value[list.value.length - now.value - 1]
: list.value[now.value]
);
/** 每行的行高 */
const lh = computed(() => props.interval ?? 24);
@@ -137,7 +139,7 @@ export const ListSelector = defineComponent<
/** 切换至指定选择项 */
const changeTo = (index: number, time: number = 500) => {
const res = clamp(index, 0, list.value.length - 1);
const reversed = list.value.length - res - 1;
const reversed = props.reverse ? list.value.length - res - 1 : res;
now.value = res;
selList.value = reversed;
const y = reversed * lh.value;
@@ -164,9 +166,11 @@ export const ListSelector = defineComponent<
padEnd={height.value / 2 - lh.value / 2}
>
{list.value.map(([, title], i, a) => {
const reversed = a.length - i - 1;
const nowFloor = a.length - now.value - 1;
const highlight = nowFloor === i || selList.value === i;
const reversed = props.reverse ? a.length - i - 1 : i;
const nowItem = props.reverse
? a.length - now.value - 1
: now.value;
const highlight = nowItem === i || selList.value === i;
const color = highlight ? '#fff' : '#aaa';
const fill = highlight ? '#fff' : '#000';
const y = (i - 0.5) * lh.value + height.value / 2;
@@ -175,7 +179,7 @@ export const ListSelector = defineComponent<
nocache
loc={[0, y, width.value, lh.value]}
onEnter={() => enterList(i)}
onLeave={() => enterList(nowFloor)}
onLeave={() => enterList(nowItem)}
onClick={() => changeTo(reversed)}
>
<text
@@ -192,7 +196,7 @@ export const ListSelector = defineComponent<
lineWidth={1}
circle={[lx.value + pad.value, lh.value / 2, 3]}
strokeStyle={color}
fillStyle={nowFloor === i ? fill : '#000'}
fillStyle={nowItem === i ? fill : '#000'}
/>
</container>
);
@@ -315,6 +315,7 @@ const textboxOptions = {
'titleStroke',
'titlePadding',
'materials',
'typer',
'icon',
'loc',
'x',
@@ -330,6 +331,13 @@ export const Textbox = defineComponent<
TextboxEmits,
keyof TextboxEmits
>((props, { expose, emit }) => {
const defaultMaterials = inject<ITextureManager | null>(
'@default/materials',
null
);
/** 使用的贴图管理器 */
const materials = computed(() => props.materials ?? defaultMaterials);
/** 是否包含标题 */
const hasTitle = computed(() => !isNil(props.title));
/** 标题内边距 */
@@ -358,7 +366,7 @@ export const Textbox = defineComponent<
/** 图标信息 */
const iconData = computed(() => {
const icon = props.icon;
const material = props.materials;
const material = materials.value;
if (isNil(icon) || !material) return null;
const data = material.tile(icon);
return data;
@@ -428,7 +436,7 @@ export const Textbox = defineComponent<
color={props.backColor}
border={props.strokeColor}
circle={[0]}
materials={props.materials}
materials={materials.value ?? void 0}
loc={[0, 0, tw.value, th.value]}
/>
<text
@@ -447,7 +455,7 @@ export const Textbox = defineComponent<
color={props.backColor}
border={props.strokeColor}
circle={[0]}
materials={props.materials}
materials={materials.value ?? void 0}
loc={[0, contentY.value, width.value, backHeight.value]}
/>
@@ -455,7 +463,7 @@ export const Textbox = defineComponent<
hidden={!!iconData.value}
icon={props.icon}
loc={iconLoc.value}
materials={props.materials}
materials={materials.value ?? void 0}
animate
/>
<g-rect
@@ -277,7 +277,7 @@ export interface ThumbnailProps extends DefaultProps {
maps?: IMapState;
/** 缩略图填充样式,默认为黑色 */
padStyle?: CanvasStyle;
/** 地图渲染器,注意如果你不知道地图渲染的细节,一定永远传入 `expandMapRenderer`! */
/** 地图渲染器,默认会使用主对象上的辅助地图渲染器,如果不知道传什么就不要传 */
renderer?: IMapRenderer;
/**
* 要展示的地图区域的**格子坐标**,可以写小数以显示半个格子,超出地图范围的会被忽略,
@@ -431,7 +431,7 @@ export const Thumbnail = defineComponent<ThumbnailProps>(props => {
floorId={props.floorId}
size={size.value}
damage={props.damage}
zIndex={10}
zIndex={0}
/>
))}
<g-rect