import { mergeParameters } from '../../base/utils'; import React from 'react'; import { iIOTWeatherJSON } from '.'; import { ComponentsType, iProperty, TagType } from "../../base/type"; import iGrapesJSConfig from "../../type"; import { IOTWeatherProps } from "./interface"; import IOTWeather from './IOTWeather'; const grapesJSConfig: iGrapesJSConfig = { type: [ComponentsType.WeatherType], id: TagType.IOTWeather, tag: TagType.IOTWeather, access: 'r', render: (jsonData, ...args) => { const props = mergeParameters(jsonData, ...args); const { weather } = props; const { location, temperature, humidity, pm25 } = weather; props.weather = { location: { flag: location, text: '定位失败' }, pm25: { flag: pm25, text: '500'}, temperature: { flag: temperature, text: '-25℃' }, humidity: { flag: humidity, text: '100%' }, }; return ; }, buildData: ( mock: boolean = false,property?: iProperty) => { const props: iIOTWeatherJSON = { weather: { location: true, temperature: true, humidity: true, pm25: true, }, }; return props; }, traits: () => { return [ { type: 'weather', name: 'weather', label: '添加配置', }, ]; }, }; export default grapesJSConfig;