mirror of
https://github.com/Grasscutters/Cultivation.git
synced 2025-12-14 16:14:48 +01:00
fix up dirinput
This commit is contained in:
@@ -20,7 +20,7 @@ export default class TopBar extends React.Component<IProps, IState> {
|
|||||||
super(props)
|
super(props)
|
||||||
|
|
||||||
app.getVersion().then(version => {
|
app.getVersion().then(version => {
|
||||||
this.setState({ version })
|
this.state = { version }
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import './DirInput.css'
|
|||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
value?: string
|
value?: string
|
||||||
|
onChange?: (value: string) => void
|
||||||
}
|
}
|
||||||
|
|
||||||
interface IState {
|
interface IState {
|
||||||
@@ -24,10 +25,23 @@ export default class DirInput extends React.Component<IProps, IState> {
|
|||||||
this.handleIconClick = this.handleIconClick.bind(this)
|
this.handleIconClick = this.handleIconClick.bind(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
handleIconClick() {
|
async handleIconClick() {
|
||||||
open().then(path => {
|
let path = await open({
|
||||||
console.log(path)
|
filters: [
|
||||||
|
{ name: 'Executable files', extensions: ['exe'] }
|
||||||
|
]
|
||||||
})
|
})
|
||||||
|
|
||||||
|
if (Array.isArray(path)) path = path[0]
|
||||||
|
if (!path) return
|
||||||
|
|
||||||
|
this.setState({
|
||||||
|
value: path
|
||||||
|
})
|
||||||
|
|
||||||
|
console.log(this.state)
|
||||||
|
|
||||||
|
if (this.props.onChange) this.props.onChange(path)
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
|||||||
@@ -21,6 +21,10 @@ export default class TextInput extends React.Component<IProps, IState> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static getDerivedStateFromProps(props: IProps, state: IState) {
|
||||||
|
return { value: props.value || '' }
|
||||||
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<input readOnly={this.props.readOnly || false} placeholder={this.props.placeholder || ''} className="TextInput" value={this.state.value} onChange={(e) => {
|
<input readOnly={this.props.readOnly || false} placeholder={this.props.placeholder || ''} className="TextInput" value={this.state.value} onChange={(e) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user