mirror of
https://github.com/Grasscutters/Cultivation.git
synced 2025-12-12 23:24:35 +01:00
wipe registry option
This commit is contained in:
@@ -25,7 +25,8 @@
|
||||
"background": "Set Custom Background (link or image file)",
|
||||
"theme": "Set Theme",
|
||||
"patch_metadata": "Automatically Patch Metadata",
|
||||
"use_proxy": "Use Internal Proxy"
|
||||
"use_proxy": "Use Internal Proxy",
|
||||
"wipe_login": "Wipe Login Cache"
|
||||
},
|
||||
"downloads": {
|
||||
"grasscutter_stable_data": "Download Grasscutter Stable Data",
|
||||
|
||||
@@ -46,6 +46,7 @@ fn main() {
|
||||
system_helpers::install_location,
|
||||
system_helpers::is_elevated,
|
||||
system_helpers::set_migoto_target,
|
||||
system_helpers::wipe_registry,
|
||||
proxy::set_proxy_addr,
|
||||
proxy::generate_ca_files,
|
||||
unzip::unzip,
|
||||
|
||||
@@ -2,6 +2,9 @@ use duct::cmd;
|
||||
use ini::Ini;
|
||||
use std::path::PathBuf;
|
||||
|
||||
#[cfg(windows)]
|
||||
use registry::{Data, Hive, Security};
|
||||
|
||||
#[tauri::command]
|
||||
pub fn run_program(path: String, args: Option<String>) {
|
||||
// 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)]
|
||||
#[tauri::command]
|
||||
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
|
||||
const gameExists = await invoke('dir_exists', {
|
||||
path: exe || config.game_install_path,
|
||||
|
||||
@@ -34,6 +34,7 @@ interface IState {
|
||||
encryption: boolean
|
||||
patch_metadata: boolean
|
||||
use_internal_proxy: boolean
|
||||
wipe_login: boolean
|
||||
swag: boolean
|
||||
|
||||
// Swag stuff
|
||||
@@ -59,6 +60,7 @@ export default class Options extends React.Component<IProps, IState> {
|
||||
encryption: false,
|
||||
patch_metadata: false,
|
||||
use_internal_proxy: false,
|
||||
wipe_login: false,
|
||||
swag: false,
|
||||
|
||||
// Swag stuff
|
||||
@@ -78,6 +80,7 @@ export default class Options extends React.Component<IProps, IState> {
|
||||
this.restoreMetadata = this.restoreMetadata.bind(this)
|
||||
this.toggleMetadata = this.toggleMetadata.bind(this)
|
||||
this.toggleProxy = this.toggleProxy.bind(this)
|
||||
this.toggleLoginWipe = this.toggleLoginWipe.bind(this)
|
||||
}
|
||||
|
||||
async componentDidMount() {
|
||||
@@ -102,6 +105,7 @@ export default class Options extends React.Component<IProps, IState> {
|
||||
encryption: await translate(encEnabled ? 'options.enabled' : 'options.disabled'),
|
||||
patch_metadata: config.patch_metadata || false,
|
||||
use_internal_proxy: config.use_internal_proxy || false,
|
||||
wipe_login: config.wipe_login || false,
|
||||
swag: config.swag_mode || false,
|
||||
|
||||
// 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() {
|
||||
return (
|
||||
<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" />
|
||||
</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 />
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ let defaultConfig: Configuration
|
||||
debug_enabled: false,
|
||||
patch_metadata: true,
|
||||
use_internal_proxy: true,
|
||||
wipe_login: false,
|
||||
}
|
||||
})()
|
||||
|
||||
@@ -46,6 +47,7 @@ export interface Configuration {
|
||||
debug_enabled: boolean
|
||||
patch_metadata: boolean
|
||||
use_internal_proxy: boolean
|
||||
wipe_login: boolean
|
||||
swag_mode?: boolean
|
||||
|
||||
// Swag stuff
|
||||
|
||||
Reference in New Issue
Block a user