QoL changes & code formatting

This commit is contained in:
KingRainbow44 2022-06-01 17:28:48 -04:00
parent 2d2cf82751
commit 174a990c40
No known key found for this signature in database
GPG Key ID: FC2CB64B00D257BE
8 changed files with 20 additions and 23 deletions

View File

@ -1,6 +1,6 @@
{
"name": "cultivation",
"version": "0.1.0",
"version": "1.0.0",
"private": true,
"dependencies": {
"@tauri-apps/api": "^1.0.0-rc.5",

View File

@ -7,11 +7,11 @@
<meta name="theme-color" content="#000000" />
<meta
name="description"
content="Tauri-powered Grasscutter launcher"
content="Tauri-powered anime game launcher"
/>
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<title>React App</title>
<title>Cultivation</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>

View File

@ -82,13 +82,13 @@ pub async fn create_proxy(proxy_port: u16, certificate_path: String) {
let private_key = rustls::PrivateKey(
pemfile::pkcs8_private_keys(&mut private_key_bytes)
.expect("Failed to parse private key")
.remove(0),
.remove(0)
);
let ca_cert = rustls::Certificate(
pemfile::certs(&mut ca_cert_bytes)
.expect("Failed to parse CA certificate")
.remove(0),
.remove(0)
);
// Create the certificate authority.
@ -168,26 +168,27 @@ pub fn generate_ca_files(path: &str) {
];
// Create certificate.
let cert_path = format!("{}\\ca", path);
let cert = Certificate::from_params(params).unwrap();
let cert_crt = cert.serialize_pem().unwrap();
let cert_path = format!("{}\\ca", path);
let private_key = cert.serialize_private_key_pem();
// Make certificate directory.
match fs::create_dir(&cert_path) {
Ok(_) => {},
Err(e) => {
println!("{}", e);
}
};
println!("{}", cert_crt);
// Write the certificate to a file.
match fs::write(format!("{}\\cert.crt", &cert_path), cert_crt) {
Ok(_) => println!("Wrote certificate to {}", &cert_path),
Err(e) => println!("Error writing certificate to {}: {}", &cert_path, e),
}
let private_key = cert.serialize_private_key_pem();
// Write the private key to a file.
match fs::write(format!("{}\\private.key", &cert_path), private_key) {
Ok(_) => println!("Wrote private key to {}", &cert_path),
Err(e) => println!("Error writing private key to {}: {}", &cert_path, e),

View File

@ -6,8 +6,8 @@
"distDir": "../build"
},
"package": {
"productName": "cultivation",
"version": "0.1.0"
"productName": "Cultivation",
"version": "1.0.0"
},
"tauri": {
"allowlist": {

View File

@ -20,4 +20,4 @@ root.render(
// to log results (for example: reportWebVitals(console.log))
// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
import reportWebVitals from './utils/reportWebVitals'
reportWebVitals()
reportWebVitals(console.log)

View File

@ -72,8 +72,6 @@ export default class DirInput extends React.Component<IProps, IState> {
]
})
}
if (Array.isArray(path)) path = path[0]
if (!path) return

View File

@ -6,7 +6,6 @@ import './Options.css'
import { setConfigOption, getConfig, getConfigOption } from '../../../utils/configuration'
import Checkbox from '../common/Checkbox'
import Divider from './Divider'
import { invoke } from '@tauri-apps/api'
interface IProps {
closeFn: () => void;
@ -81,8 +80,8 @@ export default class Options extends React.Component<IProps, IState> {
})
}
setCustomBackground() {
setConfigOption('customBackground', this.state.bg_url_or_path)
setCustomBackground(value: string) {
setConfigOption('customBackground', value)
}
render() {
@ -132,7 +131,7 @@ export default class Options extends React.Component<IProps, IState> {
<Tr text="options.background" />
</div>
<div className='OptionValue'>
<DirInput onChange={this.setCustomBackground} readonly={false} value={this.state?.bg_url_or_path} extensions={['png', 'jpg', 'jpeg']} />
<DirInput onChange={this.setCustomBackground} value={this.state?.bg_url_or_path} extensions={['png', 'jpg', 'jpeg']} readonly={false} />
</div>
</div>

View File

@ -40,11 +40,10 @@ export interface Configuration {
}
export async function setConfigOption(key: string, value: any): Promise<void> {
const config = await getConfig()
Object.assign(config, { [key]: value })
const config: any = await getConfig()
config[key] = value
await saveConfig(config)
await saveConfig(<Configuration> config)
}
export async function getConfigOption(key: string): Promise<any> {