mirror of
https://github.com/motajs/template.git
synced 2026-12-06 23:24:30 +08:00
feat: 缩略图默认使用主对象上的 maps 地图状态对象
This commit is contained in:
1 parent
a024c5e40e
commit
5ea0c149e7
2 files changed
+12
-5
No files matched your search
@@ -76,6 +76,9 @@ export const ThumbnailCell = defineComponent<
|
||||
'@default/expandMapRenderer',
|
||||
null
|
||||
);
|
||||
const defaultMaps = inject<IMapState | null>('@default/maps', null);
|
||||
/** 使用的地图状态对象 */
|
||||
const maps = computed(() => props.maps ?? defaultMaps);
|
||||
/** 使用的地图渲染器 */
|
||||
const mapRenderer = computed(() => props.renderer ?? defaultRenderer);
|
||||
|
||||
@@ -85,8 +88,8 @@ export const ThumbnailCell = defineComponent<
|
||||
const size = computed(() => props.size ?? 1);
|
||||
/** 当前地图 */
|
||||
const map = computed(() => {
|
||||
if (isNil(props.floorId) || !props.maps) return null;
|
||||
return props.maps.getMap(props.floorId);
|
||||
if (isNil(props.floorId) || !maps.value) return null;
|
||||
return maps.value.getMap(props.floorId);
|
||||
});
|
||||
/** 分块坐标 */
|
||||
const origin = computed<[number, number]>(() => {
|
||||
@@ -318,8 +321,11 @@ export const Thumbnail = defineComponent<ThumbnailProps>(props => {
|
||||
'@default/expandMapRenderer',
|
||||
null
|
||||
);
|
||||
const defaultMaps = inject<IMapState | null>('@default/maps', null);
|
||||
/** 使用的地图渲染器 */
|
||||
const mapRenderer = computed(() => props.renderer ?? defaultRenderer);
|
||||
/** 使用的地图状态对象 */
|
||||
const maps = computed(() => props.maps ?? defaultMaps);
|
||||
/** 空白区域填充样式 */
|
||||
const padStyle = computed(() => props.padStyle ?? 'black');
|
||||
/** 渲染尺寸比例 */
|
||||
@@ -329,8 +335,8 @@ export const Thumbnail = defineComponent<ThumbnailProps>(props => {
|
||||
|
||||
/** 当前地图 */
|
||||
const map = computed(() => {
|
||||
if (isNil(props.floorId) || !props.maps) return null;
|
||||
return props.maps.getMap(props.floorId);
|
||||
if (isNil(props.floorId) || !maps.value) return null;
|
||||
return maps.value.getMap(props.floorId);
|
||||
});
|
||||
|
||||
/** 渲染区域,考虑了区域是否超出了地图范围 */
|
||||
@@ -427,7 +433,7 @@ export const Thumbnail = defineComponent<ThumbnailProps>(props => {
|
||||
loc={chunk.loc}
|
||||
origin={chunk.origin}
|
||||
renderer={mapRenderer.value ?? void 0}
|
||||
maps={props.maps}
|
||||
maps={maps.value ?? void 0}
|
||||
floorId={props.floorId}
|
||||
size={size.value}
|
||||
damage={props.damage}
|
||||
|
||||
@@ -127,6 +127,7 @@ export class ClientCore extends CoreState implements IClientCore {
|
||||
'@default/expandMapRenderer',
|
||||
this.expandMapRenderer
|
||||
);
|
||||
this.vueApp.provide('@default/maps', this.maps);
|
||||
|
||||
this.mainTextboxManager = new TextboxManager(this.materials);
|
||||
|
||||
|
||||
Reference in new issue
Block a user