import config from '../../config'; import { wait } from '../../utils/tools'; import { calWeatherContour24H, calWeatherContourRadar } from '../rcview/calculator'; import { readYj24hContour } from './_'; function initState() { return { overallType: '24h', // 24h, radar }; } const shyjview = { state: initState(), reducers: { setOverallType(state, val) { return { ...state, overallType: val } }, reset() { return initState(); } }, effects: dispatch => ({ async showWeather24h(_, state) { dispatch.map.setCalculating(true); await wait(100); try { const contour = await calWeatherContour24H(); dispatch.runtime.setLayerSetting({ contour, dem: false }); dispatch.map.setLayerVisible({ ContourLayer: true }); } finally { dispatch.map.setCalculating(false); } // dispatch.runtime.setHome(); }, async showWeatherRadar(_, state) { dispatch.map.setCalculating(true); await wait(100); try { const contour = await calWeatherContourRadar(); dispatch.runtime.setLayerSetting({ contour, dem: false }); dispatch.map.setLayerVisible({ ContourLayer: true }); } finally { dispatch.map.setCalculating(false); } // dispatch.runtime.setHome(); }, async showYj24hContour(latest) { dispatch.map.setCalculating(true); await wait(100); try { console.log('latest', latest); const contour = await readYj24hContour(latest); dispatch.runtime.setLayerSetting({ contour, dem: false }); dispatch.map.setLayerVisible({ ContourLayer: true }); } finally { dispatch.map.setCalculating(false); } dispatch.runtime.setHome(); } }) }; export default shyjview;