Performance (#89)

* jre async

* mac support

* fixed some settings not being saved to file

* fixed older version of mac random crashing bug

* added specific mac version detection

* linux support for jre changes

* added app storage options

* tauri features change

* dependency fix

* removed debug statement

* restructured to not pass css through rust

* changed to os_info

* rerun cicd
This commit is contained in:
Wyatt Verchere
2023-04-19 11:44:44 -07:00
committed by GitHub
parent d414e07f41
commit 16e015b527
14 changed files with 164 additions and 82 deletions

View File

@@ -28,6 +28,7 @@ daedalus = {version = "0.1.15", features = ["bincode"] }
url = "2.2"
uuid = { version = "1.1", features = ["serde", "v4"] }
os_info = "3.7.0"
[features]
# by default Tauri runs in production mode

View File

@@ -9,32 +9,32 @@ use super::TheseusSerializableError;
/// Get all JREs that exist on the system
#[tauri::command]
pub async fn jre_get_all_jre() -> Result<Vec<JavaVersion>> {
Ok(jre::get_all_jre()?)
Ok(jre::get_all_jre().await?)
}
// Finds the isntallation of Java 7, if it exists
#[tauri::command]
pub async fn jre_find_jre_8_jres() -> Result<Vec<JavaVersion>> {
Ok(jre::find_java8_jres()?)
Ok(jre::find_java8_jres().await?)
}
// finds the installation of Java 17, if it exists
#[tauri::command]
pub async fn jre_find_jre_17_jres() -> Result<Vec<JavaVersion>> {
Ok(jre::find_java17_jres()?)
Ok(jre::find_java17_jres().await?)
}
// Finds the highest version of Java 18+, if it exists
#[tauri::command]
pub async fn jre_find_jre_18plus_jres() -> Result<Vec<JavaVersion>> {
Ok(jre::find_java18plus_jres()?)
Ok(jre::find_java18plus_jres().await?)
}
// Autodetect Java globals, by searching the users computer.
// Returns a *NEW* JavaGlobals that can be put into Settings
#[tauri::command]
pub async fn jre_autodetect_java_globals() -> Result<JavaGlobals> {
Ok(jre::autodetect_java_globals()?)
Ok(jre::autodetect_java_globals().await?)
}
// Gets key for the optimal JRE to use, for a given profile Profile

View File

@@ -15,10 +15,32 @@ async fn initialize_state(app: tauri::AppHandle) -> api::Result<()> {
Ok(())
}
// cfg only on mac os
// disables mouseover and fixes a random crash error only fixed by recent versions of macos
#[cfg(target_os = "macos")]
#[tauri::command]
async fn should_disable_mouseover() -> bool {
// We try to match version to 12.2 or higher. If unrecognizable to pattern or lower, we default to the css with disabled mouseover for safety
let os = os_info::get();
if let os_info::Version::Semantic(major, minor, _) = os.version() {
if *major >= 12 && *minor >= 3 {
// Mac os version is 12.3 or higher, we allow mouseover
return false;
}
}
true
}
#[cfg(not(target_os = "macos"))]
#[tauri::command]
async fn should_disable_mouseover() -> bool {
false
}
fn main() {
tauri::Builder::default()
.invoke_handler(tauri::generate_handler![
initialize_state,
should_disable_mouseover,
api::profile_create::profile_create_empty,
api::profile_create::profile_create,
api::profile::profile_remove,

View File

@@ -15,7 +15,11 @@
"all": false,
"protocol": {
"asset": true,
"assetScope": ["$APPDATA/caches/icons/*"]
"assetScope": [
"$APPDATA/caches/icons/*",
"$APPCONFIG/caches/icons/*",
"$CONFIG/caches/icons/*"
]
},
"window": {
"create": true,

View File

@@ -0,0 +1,3 @@
img {
pointer-events: none !important;
}

View File

@@ -6,11 +6,12 @@ import '../node_modules/omorphia/dist/style.css'
import '@/assets/stylesheets/global.scss'
import FloatingVue from 'floating-vue'
import { initialize_state } from '@/helpers/state'
import loadCssMixin from './mixins/macCssFix.js'
const pinia = createPinia()
initialize_state()
.then(() => {
createApp(App).use(router).use(pinia).use(FloatingVue).mount('#app')
createApp(App).use(router).use(pinia).use(FloatingVue).mixin(loadCssMixin).mount('#app')
})
.catch((err) => console.error(err))

View File

@@ -0,0 +1,27 @@
import { invoke } from '@tauri-apps/api/tauri'
import cssContent from '@/assets/stylesheets/macFix.css?inline'
export default {
async mounted() {
await this.checkDisableMouseover()
},
methods: {
async checkDisableMouseover() {
try {
// Fetch the CSS content from the Rust backend
const should_disable_mouseover = await invoke('should_disable_mouseover')
if (should_disable_mouseover) {
// Create a style element and set its content
const styleElement = document.createElement('style')
styleElement.innerHTML = cssContent
// Append the style element to the document's head
document.head.appendChild(styleElement)
}
} catch (error) {
console.error('Error checking OS version from Rust backend', error)
}
},
},
}