QoL changes & code formatting

This commit is contained in:
KingRainbow44
2022-06-01 17:28:48 -04:00
parent 2d2cf82751
commit 174a990c40
8 changed files with 20 additions and 23 deletions

View File

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

View File

@@ -7,11 +7,11 @@
<meta name="theme-color" content="#000000" /> <meta name="theme-color" content="#000000" />
<meta <meta
name="description" 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="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" /> <link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<title>React App</title> <title>Cultivation</title>
</head> </head>
<body> <body>
<noscript>You need to enable JavaScript to run this app.</noscript> <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( let private_key = rustls::PrivateKey(
pemfile::pkcs8_private_keys(&mut private_key_bytes) pemfile::pkcs8_private_keys(&mut private_key_bytes)
.expect("Failed to parse private key") .expect("Failed to parse private key")
.remove(0), .remove(0)
); );
let ca_cert = rustls::Certificate( let ca_cert = rustls::Certificate(
pemfile::certs(&mut ca_cert_bytes) pemfile::certs(&mut ca_cert_bytes)
.expect("Failed to parse CA certificate") .expect("Failed to parse CA certificate")
.remove(0), .remove(0)
); );
// Create the certificate authority. // Create the certificate authority.
@@ -168,26 +168,27 @@ pub fn generate_ca_files(path: &str) {
]; ];
// Create certificate. // Create certificate.
let cert_path = format!("{}\\ca", path);
let cert = Certificate::from_params(params).unwrap(); let cert = Certificate::from_params(params).unwrap();
let cert_crt = cert.serialize_pem().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) { match fs::create_dir(&cert_path) {
Ok(_) => {}, Ok(_) => {},
Err(e) => { Err(e) => {
println!("{}", e); println!("{}", e);
} }
}; };
println!("{}", cert_crt);
// Write the certificate to a file.
match fs::write(format!("{}\\cert.crt", &cert_path), cert_crt) { match fs::write(format!("{}\\cert.crt", &cert_path), cert_crt) {
Ok(_) => println!("Wrote certificate to {}", &cert_path), Ok(_) => println!("Wrote certificate to {}", &cert_path),
Err(e) => println!("Error writing certificate to {}: {}", &cert_path, e), 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) { match fs::write(format!("{}\\private.key", &cert_path), private_key) {
Ok(_) => println!("Wrote private key to {}", &cert_path), Ok(_) => println!("Wrote private key to {}", &cert_path),
Err(e) => println!("Error writing private key to {}: {}", &cert_path, e), Err(e) => println!("Error writing private key to {}: {}", &cert_path, e),

View File

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

View File

@@ -20,4 +20,4 @@ root.render(
// to log results (for example: reportWebVitals(console.log)) // to log results (for example: reportWebVitals(console.log))
// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals // or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
import reportWebVitals from './utils/reportWebVitals' 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 (Array.isArray(path)) path = path[0]
if (!path) return if (!path) return

View File

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

View File

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