diff --git a/src-tauri/src/functionality/extension.rs b/src-tauri/src/functionality/extension.rs index ad85034a..975128c3 100644 --- a/src-tauri/src/functionality/extension.rs +++ b/src-tauri/src/functionality/extension.rs @@ -67,6 +67,7 @@ pub fn add_extension(win: &WebviewWindow, path: PathBuf) { .unwrap_or_default(); } +#[cfg(target_os = "windows")] pub fn load_extensions(win: &WebviewWindow) { log!("Loading extensions..."); @@ -75,21 +76,18 @@ pub fn load_extensions(win: &WebviewWindow) { // Read all files in the extensions dir if let Ok(files) = fs::read_dir(extensions_dir) { for file in files.flatten() { - let path = file.path(); - // Path can be file or folder, doesn't matter - let path = path.to_str().unwrap_or_default(); - let path = PathBuf::from(path); - - add_extension(win, path); + add_extension(win, file.path()); } } +} - // Refresh the page to ensure extensions are loaded - win.eval("window.location.reload();").unwrap_or_default(); +#[cfg(not(target_os = "windows"))] +pub fn load_extensions(_win: &WebviewWindow) { + log!("Extensions are unsupported on non-Windows platforms!"); } #[cfg(not(target_os = "windows"))] pub fn add_extension(_win: &WebviewWindow, _path: PathBuf) { - log!("Extension is unsupported on non-Windows platforms!"); + log!("Extensions are unsupported on non-Windows platforms!"); } diff --git a/src-tauri/src/functionality/window.rs b/src-tauri/src/functionality/window.rs index b9776cd4..97d11793 100644 --- a/src-tauri/src/functionality/window.rs +++ b/src-tauri/src/functionality/window.rs @@ -101,8 +101,15 @@ pub fn after_build(window: &tauri::WebviewWindow) { } } + // This should be the last extension loaded, the others are loaded early on add_extension(window, get_main_extension_path()); + #[cfg(target_os = "windows")] + { + // Refresh the page to ensure extensions are loaded + window.eval("window.location.reload();").unwrap_or_default(); + } + window_zoom_level(window.clone(), None); } diff --git a/src-tauri/src/processors/css_preprocess.rs b/src-tauri/src/processors/css_preprocess.rs index edc1f414..620a3a0b 100644 --- a/src-tauri/src/processors/css_preprocess.rs +++ b/src-tauri/src/processors/css_preprocess.rs @@ -23,6 +23,7 @@ pub async fn clear_css_cache() { } } +#[cfg(not(target_os = "windows"))] #[tauri::command] pub fn localize_imports(win: tauri::WebviewWindow, css: String, name: String) -> String { let reg = Regex::new(r#"(?m)^@import url\((?:"|'|)(?:|.+?)\/\/(.+?)(?:"|'|)\);"#).unwrap(); @@ -162,6 +163,14 @@ pub fn localize_imports(win: tauri::WebviewWindow, css: String, name: String) -> new_css } +#[cfg(target_os = "windows")] +#[tauri::command] +pub fn localize_imports(_win: tauri::WebviewWindow, css: String, _name: String) -> String { + log!("Windows no longer requires CSS imports to be localized"); + return css +} + +#[cfg(not(target_os = "windows"))] pub fn localize_images(win: tauri::WebviewWindow, css: String) -> String { let img_reg = Regex::new(r#"url\((?:'|"|)(http.+?)(?:'|"|)\)"#).unwrap(); let mut new_css = css.clone(); @@ -285,4 +294,4 @@ pub fn localize_images(win: tauri::WebviewWindow, css: String) -> String { } new_css -} +} \ No newline at end of file