summaryrefslogtreecommitdiff
path: root/src/components/APIConfig.js
diff options
context:
space:
mode:
authorHaishan <[email protected]>2018-10-26 01:02:59 +0800
committerHaishan <[email protected]>2018-10-27 14:28:25 +0800
commitabfab4f1adb40e3463fa9e90aff3e92bfdf03693 (patch)
tree46347cc195d59a2b0622752c71742b82476cce69 /src/components/APIConfig.js
parent4e7efe2accc67a63f9e3bc4ed4365acefb4fb883 (diff)
ui(proxy): new UI for proxy page
Diffstat (limited to 'src/components/APIConfig.js')
-rw-r--r--src/components/APIConfig.js23
1 files changed, 21 insertions, 2 deletions
diff --git a/src/components/APIConfig.js b/src/components/APIConfig.js
index ce2b7fe..4e85a69 100644
--- a/src/components/APIConfig.js
+++ b/src/components/APIConfig.js
@@ -33,6 +33,10 @@ class APIConfig extends Component {
secret: this.props.apiConfig.secret
};
+ componentDidMount() {
+ this.content.focus();
+ }
+
handleInputOnChange = e => {
const target = e.target;
const { name } = target;
@@ -46,15 +50,30 @@ class APIConfig extends Component {
this.setState({ [name]: value });
};
- handleConfirmOnClick = () => {
+ updateClashAPIConfig() {
const { hostname, port, secret } = this.state;
this.props.updateClashAPIConfig({ hostname, port, secret });
+ }
+
+ handleConfirmOnClick = () => {
+ this.updateClashAPIConfig();
+ };
+
+ handleContentOnKeyDown = e => {
+ // enter keyCode is 13
+ if (e.keyCode !== 13) return;
+ this.updateClashAPIConfig();
};
render() {
const { hostname, port, secret } = this.state;
return (
- <div className={s0.root}>
+ <div
+ className={s0.root}
+ ref={e => (this.content = e)}
+ tabIndex="1"
+ onKeyDown={this.handleContentOnKeyDown}
+ >
<div className={s0.header}>RESTful API config for Clash</div>
<div className={s0.body}>
<div className={s0.group}>