mirror of
https://github.com/Grasscutters/Cultivation.git
synced 2026-02-06 02:06:29 +01:00
wipe registry option
This commit is contained in:
@@ -25,7 +25,8 @@
|
|||||||
"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"
|
"use_proxy": "Use Internal Proxy",
|
||||||
|
"wipe_login": "Wipe Login Cache"
|
||||||
},
|
},
|
||||||
"downloads": {
|
"downloads": {
|
||||||
"grasscutter_stable_data": "Download Grasscutter Stable Data",
|
"grasscutter_stable_data": "Download Grasscutter Stable Data",
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ fn main() {
|
|||||||
system_helpers::install_location,
|
system_helpers::install_location,
|
||||||
system_helpers::is_elevated,
|
system_helpers::is_elevated,
|
||||||
system_helpers::set_migoto_target,
|
system_helpers::set_migoto_target,
|
||||||
|
system_helpers::wipe_registry,
|
||||||
proxy::set_proxy_addr,
|
proxy::set_proxy_addr,
|
||||||
proxy::generate_ca_files,
|
proxy::generate_ca_files,
|
||||||
unzip::unzip,
|
unzip::unzip,
|
||||||
|
|||||||
@@ -2,6 +2,9 @@ use duct::cmd;
|
|||||||
use ini::Ini;
|
use ini::Ini;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
|
#[cfg(windows)]
|
||||||
|
use registry::{Data, Hive, Security};
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub fn run_program(path: String, args: Option<String>) {
|
pub fn run_program(path: String, args: Option<String>) {
|
||||||
// Without unwrap_or, this can crash when UAC prompt is denied
|
// Without unwrap_or, this can crash when UAC prompt is denied
|
||||||
@@ -127,6 +130,28 @@ pub fn set_migoto_target(path: String, migoto_path: String) -> bool {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
pub fn wipe_registry(exec_name: String) {
|
||||||
|
// Fetch the 'Internet Settings' registry key.
|
||||||
|
let settings =
|
||||||
|
match Hive::CurrentUser.open(format!("Software\\miHoYo\\{}", exec_name), Security::Write) {
|
||||||
|
Ok(s) => s,
|
||||||
|
Err(e) => {
|
||||||
|
println!("Error getting registry setting: {}", e);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Wipe login cache
|
||||||
|
match settings.set_value(
|
||||||
|
"MIHOYOSDK_ADL_PROD_OVERSEA_h1158948810",
|
||||||
|
&Data::String("".parse().unwrap()),
|
||||||
|
) {
|
||||||
|
Ok(_) => (),
|
||||||
|
Err(e) => println!("Error wiping registry: {}", e),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub fn is_elevated() -> bool {
|
pub fn is_elevated() -> bool {
|
||||||
|
|||||||
@@ -161,6 +161,12 @@ export default class ServerLaunchSection extends React.Component<IProps, IState>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// First wipe registry if we have to
|
||||||
|
await invoke('wipe_registry', {
|
||||||
|
// The exe is always PascalCase so we can get the dir using regex
|
||||||
|
execName: (await getGameExecutable())?.split('.exe')[0].replace(/([a-z\d])([A-Z])/g, '$1 $2'),
|
||||||
|
})
|
||||||
|
|
||||||
// Launch the program
|
// Launch the program
|
||||||
const gameExists = await invoke('dir_exists', {
|
const gameExists = await invoke('dir_exists', {
|
||||||
path: exe || config.game_install_path,
|
path: exe || config.game_install_path,
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ interface IState {
|
|||||||
encryption: boolean
|
encryption: boolean
|
||||||
patch_metadata: boolean
|
patch_metadata: boolean
|
||||||
use_internal_proxy: boolean
|
use_internal_proxy: boolean
|
||||||
|
wipe_login: boolean
|
||||||
swag: boolean
|
swag: boolean
|
||||||
|
|
||||||
// Swag stuff
|
// Swag stuff
|
||||||
@@ -59,6 +60,7 @@ export default class Options extends React.Component<IProps, IState> {
|
|||||||
encryption: false,
|
encryption: false,
|
||||||
patch_metadata: false,
|
patch_metadata: false,
|
||||||
use_internal_proxy: false,
|
use_internal_proxy: false,
|
||||||
|
wipe_login: false,
|
||||||
swag: false,
|
swag: false,
|
||||||
|
|
||||||
// Swag stuff
|
// Swag stuff
|
||||||
@@ -78,6 +80,7 @@ export default class Options extends React.Component<IProps, IState> {
|
|||||||
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)
|
this.toggleProxy = this.toggleProxy.bind(this)
|
||||||
|
this.toggleLoginWipe = this.toggleLoginWipe.bind(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
async componentDidMount() {
|
async componentDidMount() {
|
||||||
@@ -102,6 +105,7 @@ export default class Options extends React.Component<IProps, IState> {
|
|||||||
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,
|
use_internal_proxy: config.use_internal_proxy || false,
|
||||||
|
wipe_login: config.wipe_login || false,
|
||||||
swag: config.swag_mode || false,
|
swag: config.swag_mode || false,
|
||||||
|
|
||||||
// Swag stuff
|
// Swag stuff
|
||||||
@@ -262,6 +266,16 @@ export default class Options extends React.Component<IProps, IState> {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async toggleLoginWipe() {
|
||||||
|
const changedVal = !(await getConfigOption('wipe_login'))
|
||||||
|
|
||||||
|
await setConfigOption('wipe_login', changedVal)
|
||||||
|
|
||||||
|
this.setState({
|
||||||
|
wipe_login: changedVal,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<Menu closeFn={this.props.closeFn} className="Options" heading="Options">
|
<Menu closeFn={this.props.closeFn} className="Options" heading="Options">
|
||||||
@@ -302,6 +316,14 @@ export default class Options extends React.Component<IProps, IState> {
|
|||||||
<Checkbox onChange={this.toggleProxy} checked={this.state?.use_internal_proxy} id="useProxy" />
|
<Checkbox onChange={this.toggleProxy} checked={this.state?.use_internal_proxy} id="useProxy" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div className="OptionSection" id="menuOptionsContainerWipeLogin">
|
||||||
|
<div className="OptionLabel" id="menuOptionsLabelWipeLogin">
|
||||||
|
<Tr text="options.wipe_login" />
|
||||||
|
</div>
|
||||||
|
<div className="OptionValue" id="menuOptionsCheckboxWipeLogin">
|
||||||
|
<Checkbox onChange={this.toggleLoginWipe} checked={this.state?.wipe_login} id="wipeLogin" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<Divider />
|
<Divider />
|
||||||
|
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ let defaultConfig: Configuration
|
|||||||
debug_enabled: false,
|
debug_enabled: false,
|
||||||
patch_metadata: true,
|
patch_metadata: true,
|
||||||
use_internal_proxy: true,
|
use_internal_proxy: true,
|
||||||
|
wipe_login: false,
|
||||||
}
|
}
|
||||||
})()
|
})()
|
||||||
|
|
||||||
@@ -46,6 +47,7 @@ export interface Configuration {
|
|||||||
debug_enabled: boolean
|
debug_enabled: boolean
|
||||||
patch_metadata: boolean
|
patch_metadata: boolean
|
||||||
use_internal_proxy: boolean
|
use_internal_proxy: boolean
|
||||||
|
wipe_login: boolean
|
||||||
swag_mode?: boolean
|
swag_mode?: boolean
|
||||||
|
|
||||||
// Swag stuff
|
// Swag stuff
|
||||||
|
|||||||
Reference in New Issue
Block a user