Fix: text overflow & speedtest logic

This commit is contained in:
Dreamacro 2019-07-02 10:56:50 +08:00
parent b151ea4cf5
commit 658a26c2fc
2 changed files with 15 additions and 17 deletions

View File

@ -57,24 +57,20 @@ export class Proxy extends React.Component<ProxyProps , ProxyState> {
EE.unsubscribe(Action.SPEED_NOTIFY, this.speedTest) EE.unsubscribe(Action.SPEED_NOTIFY, this.speedTest)
} }
getDelay = async (name: string) => {
if (isClashX()) {
const delay = await jsBridge.getProxyDelay(name)
return delay
}
const { data: { delay } } = await getProxyDelay(name)
return delay
}
speedTest = async () => { speedTest = async () => {
const { config } = this.props const { config } = this.props
if (isClashX()) { const [delay, err] = await to(this.getDelay(config.name))
const delay = await jsBridge.getProxyDelay(config.name) this.setState({ delay: err ? -1 : delay, hasError: !!err })
if (delay === 0) {
return this.setState({ hasError: true })
}
return this.setState({ delay })
}
const [res, err] = await to(getProxyDelay(config.name))
if (err) {
return this.setState({ hasError: true })
}
const { data: { delay } } = res
this.setState({ delay })
} }
render () { render () {

View File

@ -25,7 +25,9 @@
color: $color-primary-darken; color: $color-primary-darken;
font-size: 10px; font-size: 10px;
overflow: hidden; overflow: hidden;
word-break: break-all; word-break: keep-all;
white-space: nowrap;
text-overflow: ellipsis;
} }
.proxy-delay { .proxy-delay {