Elevation check & comment fixes

This commit is contained in:
KingRainbow44
2022-06-06 00:01:13 -04:00
parent 2007157e4c
commit 0b24a2bb22
3 changed files with 25 additions and 9 deletions

View File

@@ -27,9 +27,10 @@ lazy_static! {
} }
fn main() { fn main() {
// Start the game process watcher.
process_watcher(); process_watcher();
// Make BG folder if it doesn't exist // Make BG folder if it doesn't exist.
let bg_folder = format!("{}/bg", system_helpers::install_location()); let bg_folder = format!("{}/bg", system_helpers::install_location());
if !std::path::Path::new(&bg_folder).exists() { if !std::path::Path::new(&bg_folder).exists() {
std::fs::create_dir_all(&bg_folder).unwrap(); std::fs::create_dir_all(&bg_folder).unwrap();
@@ -51,6 +52,7 @@ fn main() {
system_helpers::open_in_browser, system_helpers::open_in_browser,
system_helpers::copy_file, system_helpers::copy_file,
system_helpers::install_location, system_helpers::install_location,
system_helpers::is_elevated,
proxy::set_proxy_addr, proxy::set_proxy_addr,
proxy::generate_ca_files, proxy::generate_ca_files,
unzip::unzip, unzip::unzip,
@@ -73,17 +75,17 @@ fn process_watcher() {
// Start a thread so as to not block the main thread. // Start a thread so as to not block the main thread.
thread::spawn(|| { thread::spawn(|| {
let mut s = System::new_all(); let mut system = System::new_all();
loop { loop {
// Refresh system info // Refresh system info
s.refresh_all(); system.refresh_all();
// Grab the game process name // Grab the game process name
let proc = WATCH_GAME_PROCESS.lock().unwrap().to_string(); let proc = WATCH_GAME_PROCESS.lock().unwrap().to_string();
if !&proc.is_empty() { if !&proc.is_empty() {
let proc_with_name = s.processes_by_exact_name(&proc); let proc_with_name = system.processes_by_exact_name(&proc);
let mut exists = false; let mut exists = false;
for _p in proc_with_name { for _p in proc_with_name {
@@ -107,7 +109,7 @@ fn is_game_running() -> bool {
// Grab the game process name // Grab the game process name
let proc = WATCH_GAME_PROCESS.lock().unwrap().to_string(); let proc = WATCH_GAME_PROCESS.lock().unwrap().to_string();
return !&proc.is_empty(); return !proc.is_empty();
} }
#[tauri::command] #[tauri::command]
@@ -146,8 +148,8 @@ async fn req_get(url: String) -> String {
} }
#[tauri::command] #[tauri::command]
async fn get_theme_list(dataDir: String) -> Vec<HashMap<String, String>> { async fn get_theme_list(data_dir: String) -> Vec<HashMap<String, String>> {
let theme_loc = format!("{}/themes", dataDir); let theme_loc = format!("{}/themes", data_dir);
// Ensure folder exists // Ensure folder exists
if !std::path::Path::new(&theme_loc).exists() { if !std::path::Path::new(&theme_loc).exists() {

View File

@@ -85,4 +85,9 @@ pub fn install_location() -> String {
exe_path.pop(); exe_path.pop();
return exe_path.to_str().unwrap().to_string(); return exe_path.to_str().unwrap().to_string();
}
#[tauri::command]
pub fn is_elevated() -> bool {
return is_elevated::is_elevated();
} }

View File

@@ -18,11 +18,19 @@ async function generateCertificates() {
await invoke('generate_ca_files', { path: await dataDir() + '\\cultivation' }) await invoke('generate_ca_files', { path: await dataDir() + '\\cultivation' })
} }
async function generateCertInfo() {
console.log({
certificatePath: await dataDir() + '\\cultivation\\ca',
isAdmin: await invoke('is_elevated')
})
alert('check your dev console and send that in #cultivation')
}
function none() { function none() {
alert('none') alert('none')
} }
class Test extends React.Component<any, any>{ class Debug extends React.Component<any, any>{
render() { render() {
return ( return (
<div className="App"> <div className="App">
@@ -30,9 +38,10 @@ class Test extends React.Component<any, any>{
<button onClick={startProxy}>start proxy</button> <button onClick={startProxy}>start proxy</button>
<button onClick={stopProxy}>stop proxy</button> <button onClick={stopProxy}>stop proxy</button>
<button onClick={generateCertificates}>generate certificates</button> <button onClick={generateCertificates}>generate certificates</button>
<button onClick={generateCertInfo}>generate certificate info</button>
</div> </div>
) )
} }
} }
export default Test export default Debug