Skip to content

Commit

Permalink
Correcting asynchronous loading logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Mehver committed Apr 15, 2024
1 parent 45a5688 commit 5a27a62
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 8 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

57 changes: 50 additions & 7 deletions src/component/SideBar/KeyboardMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,21 @@ class KeyboardMenu extends Component {
}

componentDidMount() {
api_get_system_info().then(data => {
this.setState({serverIsMac: data.volume === 'Darwin'});
});
if (this.state.serverIsMac) {
this.context.setKeyboardDataSendMod('b');
}
api_get_system_info()
.then(data => {
this.setState({serverIsMac: data.volume === 'Darwin'});
})
.then(() => {
if (this.state.serverIsMac) {
this.context.setKeyboardDataSendMod('b');
}
});
}

handleRadioChange = (event) => {
this.context.setKeyboardDataSendMod(event.target.value);
};

// 输入框实时更新
handleInputChange = (event) => {
this.setState({inputText: event.target.value});
Expand Down Expand Up @@ -126,6 +133,42 @@ class KeyboardMenu extends Component {
{this.state.serverIsMac ? (
<Typography style={{fontSize: '1rem'}}>*MacOS ASCII Only</Typography>
) : (
// <RadioGroup
// row
// value={this.context.keyboardDataSendMod}
// onChange={this.handleRadioChange}
// >
// <FormControlLabel
// value="a"
// control={
// <Radio
// sx={{
// color: secondaryColor,
// '&.Mui-checked': {
// color: secondaryColor,
// },
// }}
// color="secondary"
// />
// }
// label="Paste"
// />
// <FormControlLabel
// value="b"
// control={
// <Radio
// sx={{
// color: secondaryColor,
// '&.Mui-checked': {
// color: secondaryColor,
// },
// }}
// color="secondary"
// />
// }
// label="Type"
// />
// </RadioGroup>
<>
<Radio
checked={this.context.keyboardDataSendMod === 'a'}
Expand All @@ -142,7 +185,7 @@ class KeyboardMenu extends Component {
}}
color='secondary'
/>
<Typography style={{fontSize: '1rem'}}>Past</Typography>
<Typography style={{fontSize: '1rem'}}>Paste</Typography>
<Radio
checked={this.context.keyboardDataSendMod === 'b'}
onChange={() => {
Expand Down

0 comments on commit 5a27a62

Please sign in to comment.