make proxy optional

This commit is contained in:
SpikeHD
2022-07-19 17:14:55 -07:00
parent 8ff06f6d29
commit 3799ec648d
4 changed files with 34 additions and 3 deletions

View File

@@ -24,7 +24,8 @@
"language": "Select Language", "language": "Select Language",
"background": "Set Custom Background (link or image file)", "background": "Set Custom Background (link or image file)",
"theme": "Set Theme", "theme": "Set Theme",
"patch_metadata": "Automatically Patch Metadata" "patch_metadata": "Automatically Patch Metadata",
"use_proxy": "Use Internal Proxy"
}, },
"downloads": { "downloads": {
"grasscutter_stable_data": "Download Grasscutter Stable Data", "grasscutter_stable_data": "Download Grasscutter Stable Data",

View File

@@ -121,8 +121,10 @@ export default class ServerLaunchSection extends React.Component<{}, IState> {
process: proc_name || game_exe process: proc_name || game_exe
}) })
// Connect to proxy if (config.use_internal_proxy) {
await invoke('connect', { port: 8365, certificatePath: await dataDir() + '\\cultivation\\ca' }) // Connect to proxy
await invoke('connect', { port: 8365, certificatePath: await dataDir() + '\\cultivation\\ca' })
}
// Open server as well if the options are set // Open server as well if the options are set
if (config.grasscutter_with_game) { if (config.grasscutter_with_game) {

View File

@@ -32,6 +32,7 @@ interface IState {
theme: string theme: string
encryption: boolean encryption: boolean
patch_metadata: boolean patch_metadata: boolean
use_internal_proxy: boolean
swag: boolean swag: boolean
// Swag stuff // Swag stuff
@@ -54,6 +55,7 @@ export default class Options extends React.Component<IProps, IState> {
theme: '', theme: '',
encryption: false, encryption: false,
patch_metadata: false, patch_metadata: false,
use_internal_proxy: false,
swag: false, swag: false,
// Swag stuff // Swag stuff
@@ -69,6 +71,7 @@ export default class Options extends React.Component<IProps, IState> {
this.toggleEncryption = this.toggleEncryption.bind(this) this.toggleEncryption = this.toggleEncryption.bind(this)
this.restoreMetadata = this.restoreMetadata.bind(this) this.restoreMetadata = this.restoreMetadata.bind(this)
this.toggleMetadata = this.toggleMetadata.bind(this) this.toggleMetadata = this.toggleMetadata.bind(this)
this.toggleProxy = this.toggleProxy.bind(this)
} }
async componentDidMount() { async componentDidMount() {
@@ -92,6 +95,7 @@ export default class Options extends React.Component<IProps, IState> {
theme: config.theme || 'default', theme: config.theme || 'default',
encryption: await translate(encEnabled ? 'options.enabled' : 'options.disabled'), encryption: await translate(encEnabled ? 'options.enabled' : 'options.disabled'),
patch_metadata: config.patch_metadata || false, patch_metadata: config.patch_metadata || false,
use_internal_proxy: config.use_internal_proxy || false,
swag: config.swag_mode || false, swag: config.swag_mode || false,
// Swag stuff // Swag stuff
@@ -219,6 +223,16 @@ export default class Options extends React.Component<IProps, IState> {
}) })
} }
async toggleProxy() {
const changedVal = !(await getConfigOption('use_internal_proxy'))
await setConfigOption('use_internal_proxy', changedVal)
this.setState({
use_internal_proxy: changedVal,
})
}
render() { render() {
return ( return (
<Menu closeFn={this.props.closeFn} className="Options" heading="Options"> <Menu closeFn={this.props.closeFn} className="Options" heading="Options">
@@ -252,6 +266,18 @@ export default class Options extends React.Component<IProps, IState> {
/> />
</div> </div>
</div> </div>
<div className="OptionSection" id="menuOptionsContainerUseProxy">
<div className="OptionLabel" id="menuOptionsLabelUseProxy">
<Tr text="options.use_proxy" />
</div>
<div className="OptionValue" id="menuOptionsCheckboxUseProxy">
<Checkbox
onChange={this.toggleProxy}
checked={this.state?.use_internal_proxy}
id="useProxy"
/>
</div>
</div>
<Divider /> <Divider />

View File

@@ -22,6 +22,7 @@ let defaultConfig: Configuration
https_enabled: false, https_enabled: false,
debug_enabled: false, debug_enabled: false,
patch_metadata: true, patch_metadata: true,
use_internal_proxy: true,
} }
})() })()
@@ -45,6 +46,7 @@ export interface Configuration {
https_enabled: boolean https_enabled: boolean
debug_enabled: boolean debug_enabled: boolean
patch_metadata: boolean patch_metadata: boolean
use_internal_proxy: boolean
swag_mode?: boolean swag_mode?: boolean
// Swag stuff // Swag stuff