index.vue 1.9 KB
<script lang="ts" setup>
  import { useDataFetch } from '/@/views/visual/packages/hook/useSocket';
  import { ComponentPropsConfigType, DataFetchUpdateFn } from '/@/views/visual/packages/index.type';

  import { option } from './config';
  import { SvgIcon } from '/@/components/Icon';
  import { computed } from 'vue';
  import { DeviceName } from '/@/views/visual/commonComponents/DeviceName';

  const props = defineProps<{
    config: ComponentPropsConfigType<typeof option>;
  }>();

  const getDesign = computed(() => {
    const { persetOption = {}, option } = props.config;

    const {
      iconColor: persetIconColor,
      unit: perseUnit,
      icon: persetIcon,
      fontColor: persetFontColor,
    } = persetOption;

    const { componentInfo, attribute, attributeRename } = option;

    const { icon, iconColor, fontColor, unit } = componentInfo || {};
    return {
      iconColor: iconColor || persetIconColor,
      unit: unit ?? perseUnit,
      icon: icon || persetIcon,
      fontColor: fontColor || persetFontColor,
      attribute: attributeRename || attribute,
    };
  });

  // const svgList = ref<any>([
  //   {
  //     value: 26.2,
  //     name: 'wendu',
  //     icon: 'zongfushe',
  //     unit: 'kw',
  //     iconColor: '#367BFF',
  //     fontColor: '#357CFB',
  //   },
  //   {
  //     value: 53.7,
  //     name: 'shidu',
  //     icon: 'guangzhaoqiangdu',
  //     unit: '℃',
  //     iconColor: '#FFA000',
  //     fontColor: '#FFA000',
  //   },
  // ]);

  const updateFn: DataFetchUpdateFn = () => {};

  useDataFetch(props, updateFn);
</script>

<template>
  <main class="w-full h-full flex flex-col justify-evenly items-center">
    <DeviceName :config="config" />
    <div class="flex justify-center items-center">
      <SvgIcon
        :name="getDesign.icon!"
        prefix="iconfont"
        :size="60"
        :style="{ color: getDesign.iconColor }"
      />
    </div>
  </main>
</template>