Showing
11 changed files
with
45 additions
and
12 deletions
| ... | ... | @@ -11,6 +11,7 @@ import { ComponentConfigFieldEnum } from '../../../enum'; |
| 11 | 11 | |
| 12 | 12 | export const option: PublicPresetOptions = { |
| 13 | 13 | [ComponentConfigFieldEnum.SHOW_DEVICE_NAME]: false, |
| 14 | + [ComponentConfigFieldEnum.FONT_SIZE]: 14, | |
| 14 | 15 | // [ComponentConfigFieldEnum.FONT_COLOR]: '#000', |
| 15 | 16 | }; |
| 16 | 17 | ... | ... |
| ... | ... | @@ -19,6 +19,12 @@ |
| 19 | 19 | component: 'Checkbox', |
| 20 | 20 | defaultValue: option.showDeviceName, |
| 21 | 21 | }, |
| 22 | + { | |
| 23 | + field: ComponentConfigFieldEnum.FONT_SIZE, | |
| 24 | + label: '字体大小', | |
| 25 | + component: 'InputNumber', | |
| 26 | + defaultValue: 14, | |
| 27 | + }, | |
| 22 | 28 | ], |
| 23 | 29 | showActionButtonGroup: false, |
| 24 | 30 | labelWidth: 120, | ... | ... |
| ... | ... | @@ -19,20 +19,24 @@ |
| 19 | 19 | const currentValue = ref(false); |
| 20 | 20 | |
| 21 | 21 | const getDesign = computed(() => { |
| 22 | - // console.log(props.config, 'config'); | |
| 23 | - const { option } = props.config; | |
| 22 | + const { option, persetOption } = props.config; | |
| 23 | + console.log(props.config, 'props.config'); | |
| 24 | 24 | const { |
| 25 | 25 | attribute, |
| 26 | 26 | attributeRename, |
| 27 | 27 | attributeName, |
| 28 | + componentInfo, | |
| 28 | 29 | commandType, |
| 29 | 30 | extensionDesc, |
| 30 | 31 | codeType, |
| 31 | 32 | deviceCode, |
| 32 | 33 | customCommand, |
| 33 | 34 | } = option; |
| 35 | + const { fontSize: persetFontSize } = persetOption || {}; | |
| 36 | + const { fontSize } = componentInfo || {}; | |
| 34 | 37 | return { |
| 35 | 38 | attribute: attributeRename || attributeName || attribute, |
| 39 | + fontSize: fontSize || persetFontSize, | |
| 36 | 40 | extensionDesc: extensionDesc ? JSON.parse(extensionDesc) : {}, |
| 37 | 41 | commandType, |
| 38 | 42 | codeType, |
| ... | ... | @@ -81,7 +85,10 @@ |
| 81 | 85 | <span class="on">ON</span> |
| 82 | 86 | <span class="off">OFF</span> |
| 83 | 87 | </label> |
| 84 | - <div class="text-center mt-2 text-gray-700" :style="getScale"> | |
| 88 | + <div | |
| 89 | + class="text-center mt-2 text-gray-700" | |
| 90 | + :style="{ ...getScale, fontSize: getDesign.fontSize + 'px' }" | |
| 91 | + > | |
| 85 | 92 | {{ getDesign.attribute || '属性' }} |
| 86 | 93 | </div> |
| 87 | 94 | </Spin> | ... | ... |
| ... | ... | @@ -13,6 +13,7 @@ export const option: PublicPresetOptions = { |
| 13 | 13 | [ComponentConfigFieldEnum.ICON]: 'shuiwen', |
| 14 | 14 | [ComponentConfigFieldEnum.ICON_COLOR]: '#377DFF', |
| 15 | 15 | [ComponentConfigFieldEnum.SHOW_DEVICE_NAME]: false, |
| 16 | + [ComponentConfigFieldEnum.FONT_SIZE]: 14, | |
| 16 | 17 | }; |
| 17 | 18 | |
| 18 | 19 | export default class Config extends PublicConfigClass implements CreateComponentType { | ... | ... |
| ... | ... | @@ -32,6 +32,12 @@ |
| 32 | 32 | component: 'Checkbox', |
| 33 | 33 | defaultValue: option.showDeviceName, |
| 34 | 34 | }, |
| 35 | + { | |
| 36 | + field: ComponentConfigFieldEnum.FONT_SIZE, | |
| 37 | + label: '字体大小', | |
| 38 | + component: 'InputNumber', | |
| 39 | + defaultValue: option.fontSize, | |
| 40 | + }, | |
| 35 | 41 | ], |
| 36 | 42 | showActionButtonGroup: false, |
| 37 | 43 | labelWidth: 120, | ... | ... |
| ... | ... | @@ -31,14 +31,20 @@ |
| 31 | 31 | deviceCode, |
| 32 | 32 | customCommand, |
| 33 | 33 | } = option; |
| 34 | - const { icon: presetIcon, iconColor: presetIconColor } = persetOption || {}; | |
| 35 | - const { icon, iconColor } = componentInfo || {}; | |
| 34 | + console.log(props, 'option111'); | |
| 35 | + const { | |
| 36 | + icon: presetIcon, | |
| 37 | + iconColor: presetIconColor, | |
| 38 | + fontSize: persetFontSize, | |
| 39 | + } = persetOption || {}; | |
| 40 | + const { icon, iconColor, fontSize } = componentInfo || {}; | |
| 36 | 41 | |
| 37 | 42 | return { |
| 38 | 43 | icon: icon ?? presetIcon, |
| 39 | 44 | iconColor: iconColor || presetIconColor, |
| 40 | 45 | attribute: attributeRename || attributeName || attribute, |
| 41 | 46 | extensionDesc: extensionDesc ? JSON.parse(extensionDesc) : {}, |
| 47 | + fontSize: fontSize || persetFontSize, | |
| 42 | 48 | commandType, |
| 43 | 49 | codeType, |
| 44 | 50 | deviceCode, |
| ... | ... | @@ -84,7 +90,10 @@ |
| 84 | 90 | :style="{ color: getDesign.iconColor }" |
| 85 | 91 | :size="50" |
| 86 | 92 | /> |
| 87 | - <span class="mt-3 truncate text-gray-500 text-xs text-center"> | |
| 93 | + <span | |
| 94 | + class="mt-3 truncate text-gray-500 text-center" | |
| 95 | + :style="{ fontSize: getDesign.fontSize + 'px' }" | |
| 96 | + > | |
| 88 | 97 | {{ getDesign.attribute || '属性' }} |
| 89 | 98 | </span> |
| 90 | 99 | </div> | ... | ... |
| ... | ... | @@ -9,6 +9,7 @@ |
| 9 | 9 | import { useReceiveValue } from '../../../hook/useReceiveValue'; |
| 10 | 10 | import { useMultipleDataFetch } from '../../../hook/socket/useSocket'; |
| 11 | 11 | import { MultipleDataFetchUpdateFn } from '../../../hook/socket/useSocket.type'; |
| 12 | + import { useComponentScale } from '../../../hook/useComponentScale'; | |
| 12 | 13 | |
| 13 | 14 | const props = defineProps<{ |
| 14 | 15 | config: ComponentPropsConfigType<typeof option>; |
| ... | ... | @@ -84,6 +85,7 @@ |
| 84 | 85 | }; |
| 85 | 86 | |
| 86 | 87 | useMultipleDataFetch(props, updateFn); |
| 88 | + const { getRatio } = useComponentScale(props); | |
| 87 | 89 | </script> |
| 88 | 90 | |
| 89 | 91 | <template> |
| ... | ... | @@ -99,16 +101,16 @@ |
| 99 | 101 | <SvgIcon |
| 100 | 102 | :name="item.icon!" |
| 101 | 103 | prefix="iconfont" |
| 102 | - :size="40" | |
| 104 | + :size="getRatio ? 25 * getRatio : 25" | |
| 103 | 105 | :style="{ color: item.iconColor }" |
| 104 | 106 | /> |
| 105 | 107 | |
| 106 | - <div class="text-gray-500 text-lg truncate ml-6">{{ | |
| 108 | + <div class="text-gray-500 truncate ml-6">{{ | |
| 107 | 109 | item.deviceName + '-' + item.attributeName || '温度' |
| 108 | 110 | }}</div> |
| 109 | 111 | </div> |
| 110 | 112 | |
| 111 | - <h1 class="font-bold text-xl m-2 truncate" :style="{ color: item.fontColor }"> | |
| 113 | + <h1 class="font-bold m-2 truncate" :style="{ color: item.fontColor }"> | |
| 112 | 114 | <span> {{ item.value || 0 }}</span> |
| 113 | 115 | <span>{{ item.unit }} </span> |
| 114 | 116 | </h1> | ... | ... |
| ... | ... | @@ -354,7 +354,6 @@ export const useDataFetch = ( |
| 354 | 354 | props: { config: ComponentPropsConfigType }, |
| 355 | 355 | updateFn: DataFetchUpdateFn |
| 356 | 356 | ) => { |
| 357 | - console.log(props, 'props'); | |
| 358 | 357 | const getBindAttribute = computed(() => { |
| 359 | 358 | const { config } = props; |
| 360 | 359 | const { option } = config as ComponentPropsConfigType<Recordable, DataSource>; | ... | ... |