| | |
| | | html: '', |
| | | } |
| | | |
| | | loaded = false |
| | | |
| | | UNSAFE_componentWillMount () { |
| | | const { data, initdata } = this.props |
| | | let _config = fromJS(this.props.config).toJS() |
| | |
| | | if (_sync && data) { |
| | | _data = data[_config.dataName] || {} |
| | | _sync = false |
| | | this.loaded = true |
| | | } else if (_sync && initdata) { |
| | | _data = initdata || {} |
| | | _sync = false |
| | | this.loaded = true |
| | | } |
| | | } else { |
| | | _data = {} |
| | | this.loaded = true |
| | | } |
| | | |
| | | if (_config.css) { |
| | |
| | | } |
| | | |
| | | componentDidMount () { |
| | | const { config } = this.state |
| | | |
| | | MKEmitter.addListener('reloadData', this.reloadData) |
| | | |
| | | if (config.$cache && !this.loaded) { |
| | | Api.getLCacheConfig(config.uuid).then(res => { |
| | | if (!res || this.loaded) return |
| | | |
| | | this.setState({data: res[0]}, () => { |
| | | this.renderView() |
| | | }) |
| | | }) |
| | | } |
| | | } |
| | | |
| | | shouldComponentUpdate (nextProps, nextState) { |
| | |
| | | _data = nextProps.data[config.dataName] |
| | | } |
| | | |
| | | this.setState({sync: false, data: _data}, () => { |
| | | this.loaded = true |
| | | |
| | | this.setState({sync: false, data: _data}) |
| | | |
| | | if (!is(fromJS(this.state.data), fromJS(_data))) { |
| | | setTimeout(() => { |
| | | this.renderView() |
| | | }) |
| | | }, 10) |
| | | } |
| | | } else if (config.setting.useMSearch && nextProps.mainSearch && !is(fromJS(this.props.mainSearch), fromJS(nextProps.mainSearch))) { |
| | | this.setState({}, () => { |
| | | this.loadData() |
| | |
| | | data: {}, |
| | | loading: false |
| | | }) |
| | | this.loaded = true |
| | | return |
| | | } |
| | | |
| | |
| | | if (result.status) { |
| | | let _data = result.data || {} |
| | | |
| | | this.loaded = true |
| | | if (config.$cache) { |
| | | Api.writeCacheConfig(config.uuid, result.data || '') |
| | | } |
| | | |
| | | this.setState({ |
| | | data: _data, |
| | | loading: false |
| | | }, () => { |
| | | this.renderView() |
| | | }) |
| | | |
| | | if (!is(fromJS(this.state.data), fromJS(_data))) { |
| | | setTimeout(() => { |
| | | this.renderView() |
| | | }, 10) |
| | | } |
| | | } else { |
| | | this.setState({ |
| | | loading: false |