import React, { useEffect, useRef, useState } from 'react'; import { connect } from 'react-redux'; import { Skeleton, Button, Pagination, Form, Popconfirm, Table, Toast } from '@douyinfe/semi-ui'; import moment from "moment"; const Header = (props) => { const { dispatch, actions, user,match, weatherRealtime, history } = props const [date, setDate] = useState(moment()); const dayMap = { 0: '日', 1: '一', 2: '二', 3: '三', 4: '四', 5: '五', 6: '六' } const weatherMap = { CLEAR_DAY: '晴(白天)', CLEAR_NIGHT: '晴(夜间)', PARTLY_CLOUDY_DAY: '多云(白天)', PARTLY_CLOUDY_NIGHT: '多云(夜间)', CLOUDY: '阴', WIND: '大风', HAZE: '雾霾', RAIN: '雨', SNOW: '雪' } const [weatherTemperature, setWeatherTemperature] = useState(''); const getWeather = () => { dispatch(actions.auth.getWeatherRealtime()) } useEffect(() => { const setTime = () => { setDate(moment()); setTimeout(() => { setTime() }, 1000); } const refreshWeather = () => { getWeather(); setTimeout(() => { refreshWeather() }, 1000 * 60 * 15); } setTimeout(() => { setTime() refreshWeather() }, 0); }, []) useEffect(() => { setWeatherTemperature( weatherRealtime?.temperature ? (weatherRealtime?.temperature - Math.ceil(Math.random() * 5)) + '~' + (weatherRealtime?.temperature + Math.ceil(Math.random() * 3)) + '℃' : '' ) }, [weatherRealtime]) const lineBetweenStyle = { width: 1, height: 15, border: '1px solid #B3C9FF', margin: '0 4px' } return (