config.ts 1.27 KB
import { formatToDateTime } from '/@/utils/dateUtil';

export interface TextComponentLayout {
  id: string;
  base?: boolean;
  showUpdate?: boolean;
  showIcon?: boolean;
  showUnit?: boolean;
}

export interface TextComponentValue {
  name: string;
  value: number;
  icon?: string;
  unit?: string;
  updateTime?: string;
  fontColor?: string;
  iconColor?: string;
}

type TextComponentDefault = TextComponentLayout & { value: TextComponentValue };

export const textComponentConfig: TextComponentDefault[] = [
  { id: 'text-component-1', base: true, value: { value: 123, name: '温度' } },
  { id: 'text-component-2', base: false, value: { value: 123, name: '温度' } },
  {
    id: 'text-component-3',
    base: false,
    showUpdate: true,
    value: {
      value: 123,
      name: '温度',
      updateTime: formatToDateTime(new Date(), 'YYYY-MM-DD HH:mm:ss'),
    },
  },
  {
    id: 'text-component-4',
    base: false,
    showIcon: true,
    showUpdate: true,
    showUnit: true,
    value: {
      value: 123,
      name: '温度',
      updateTime: formatToDateTime(new Date(), 'YYYY-MM-DD HH:mm:ss'),
      unit: '℃',
    },
  },
  {
    id: 'text-component-5',
    base: false,
    showIcon: true,
    showUnit: true,
    value: { value: 123, name: '温度', unit: '℃' },
  },
];