fix(playground): 画布尺寸切换无效

由于element-plus2.6后radio-button label属性改成value

fix #586
This commit is contained in:
roymondchen 2024-04-08 14:25:33 +08:00
parent f35fca0eeb
commit 3af247febb
2 changed files with 16 additions and 29 deletions

View File

@ -1,8 +1,8 @@
<template> <template>
<TMagicRadioGroup size="small" v-model="viewerDevice" :class="viewerDevice" @change="deviceSelect"> <TMagicRadioGroup size="small" v-model="viewerDevice" :class="viewerDevice" @change="deviceSelect">
<TMagicRadioButton label="phone">Phone</TMagicRadioButton> <TMagicRadioButton value="phone">Phone</TMagicRadioButton>
<TMagicRadioButton label="pad">Pad</TMagicRadioButton> <TMagicRadioButton value="pad">Pad</TMagicRadioButton>
<TMagicRadioButton label="pc">PC</TMagicRadioButton> <TMagicRadioButton value="pc">PC</TMagicRadioButton>
</TMagicRadioGroup> </TMagicRadioGroup>
</template> </template>
@ -34,22 +34,15 @@ const getDeviceHeight = (viewerDevice: DeviceType) => devH[viewerDevice];
const getDeviceWidth = (viewerDevice: DeviceType) => devW[viewerDevice]; const getDeviceWidth = (viewerDevice: DeviceType) => devW[viewerDevice];
withDefaults( const modelValue = defineModel<{
defineProps<{ width: number | string;
modelValue: { height: number | string;
width: number; }>('modelValue', {
height: number; default: () => ({
}; width: 375,
}>(), height: 817,
{ }),
modelValue: () => ({ });
width: 375,
height: 817,
}),
},
);
const emit = defineEmits(['update:modelValue']);
const stageContainerRect = computed(() => services?.uiService.get('stageContainerRect')); const stageContainerRect = computed(() => services?.uiService.get('stageContainerRect'));
@ -81,10 +74,10 @@ const viewerDevice = ref(DeviceType.Phone);
const deviceSelect = async (device: DeviceType) => { const deviceSelect = async (device: DeviceType) => {
const width = getDeviceWidth(device); const width = getDeviceWidth(device);
const height = getDeviceHeight(device); const height = getDeviceHeight(device);
emit('update:modelValue', { modelValue.value = {
width, width,
height, height,
}); };
await nextTick(); await nextTick();
calcFontsize(); calcFontsize();

View File

@ -24,19 +24,13 @@
</template> </template>
</m-editor> </m-editor>
<TMagicDialog <TMagicDialog v-model="previewVisible" destroy-on-close class="pre-viewer" title="预览" :width="stageRect?.width">
v-model="previewVisible"
destroy-on-close
class="pre-viewer"
title="预览"
:width="stageRect && stageRect.width"
>
<iframe <iframe
v-if="previewVisible" v-if="previewVisible"
ref="iframe" ref="iframe"
width="100%" width="100%"
style="border: none" style="border: none"
:height="stageRect && stageRect.height" :height="stageRect?.height"
:src="previewUrl" :src="previewUrl"
></iframe> ></iframe>
</TMagicDialog> </TMagicDialog>