(prevProps: LogProps)
| 182 | } |
| 183 | |
| 184 | componentDidUpdate(prevProps: LogProps) { |
| 185 | if (this.autoScroll && this.logRef && this.logRef.current) { |
| 186 | this.logRef.current.scrollTop = this.logRef.current.scrollHeight; |
| 187 | } |
| 188 | |
| 189 | if (!this.props.source) { |
| 190 | return; |
| 191 | } |
| 192 | |
| 193 | const ret = |
| 194 | typeof this.props.source === 'string' |
| 195 | ? resolveVariableAndFilter(this.props.source, this.props.data, '| raw') |
| 196 | : this.props.source; |
| 197 | |
| 198 | if (ret && isEffectiveApi(ret)) { |
| 199 | // todo 如果原来的请求还在,应该先取消 |
| 200 | isApiOutdated( |
| 201 | prevProps.source, |
| 202 | this.props.source, |
| 203 | prevProps.data, |
| 204 | this.props.data |
| 205 | ) && this.loadLogs(); |
| 206 | } else if ( |
| 207 | typeof ret === 'string' || |
| 208 | (Array.isArray(ret) && ret.every(item => typeof item === 'string')) |
| 209 | ) { |
| 210 | const prevRet = resolveVariableAndFilter( |
| 211 | prevProps.source, |
| 212 | prevProps.data, |
| 213 | '| raw' |
| 214 | ); |
| 215 | if (prevRet !== ret && ret) { |
| 216 | this.clear(); |
| 217 | this.addLines(Array.isArray(ret) ? ret : [ret]); |
| 218 | } |
| 219 | } |
| 220 | } |
| 221 | |
| 222 | // 如果向上滚动就停止自动滚动,除非滚到底部 |
| 223 | pauseOrResumeScrolling() { |
nothing calls this directly
no test coverage detected