Skip to content

Commit

Permalink
fix: exclude theme plugin from mobile build
Browse files Browse the repository at this point in the history
  • Loading branch information
sehnryr committed Nov 9, 2024
1 parent 87d359d commit b4321dc
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 34 deletions.
5 changes: 4 additions & 1 deletion src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ tar = "0.4.43"
tauri = { version = "2.0.6", features = ["protocol-asset"] }
tauri-plugin-log = "2.0.2"
tauri-plugin-store = "2.1.0"
tauri-plugin-theme = "2.1.2"
tauri-plugin-http = "2.0.3"
tokio = { version = "1.41.1", features = ["full"] }

# Dependencies for mobile targets
[target.'cfg(not(any(target_os = "android", target_os = "ios")))'.dependencies]
tauri-plugin-theme = "2.1.2"
3 changes: 1 addition & 2 deletions src-tauri/capabilities/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
"permissions": [
"core:default",
"store:default",
"log:default",
"theme:default"
"log:default"
]
}
73 changes: 42 additions & 31 deletions src-tauri/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,12 @@ async fn get_page_list(
#[cfg_attr(mobile, tauri::mobile_entry_point)]
pub fn run() {
let mut ctx = tauri::generate_context!();
tauri::Builder::default()
.plugin(tauri_plugin_theme::init(ctx.config_mut()))
let builder = tauri::Builder::default();

// Register the plugins
#[cfg(not(any(target_os = "android", target_os = "ios")))]
let builder = builder.plugin(tauri_plugin_theme::init(ctx.config_mut()));
let builder = builder
.plugin(tauri_plugin_http::init())
.plugin(
tauri_plugin_log::Builder::default()
Expand All @@ -203,35 +207,42 @@ pub fn run() {
.targets([Target::new(TargetKind::Stdout)])
.build(),
)
.plugin(tauri_plugin_store::Builder::default().build())
.setup(|app| {
let app_local_data_dir: PathBuf = app
.path()
.app_local_data_dir()
.expect("failed to get local app data dir");

let extensions_dir = app_local_data_dir.join(EXTENSIONS_DIR);
std::fs::create_dir_all(&extensions_dir).expect("failed to create extensions dir");

// Load the extensions.
let extensions = Extensions::from_dir(extensions_dir);
app.manage(extensions);

// Load the store.
let _store = app.store(STORE_FILE)?;

Ok(())
})
.invoke_handler(tauri::generate_handler![
get_extensions,
get_repository_extensions,
install_extension,
uninstall_extension,
get_manga_list,
get_manga_details,
get_chapter_list,
get_page_list
])
.plugin(tauri_plugin_store::Builder::default().build());

// Setup the app
let builder = builder.setup(|app| {
let app_local_data_dir: PathBuf = app
.path()
.app_local_data_dir()
.expect("failed to get local app data dir");

let extensions_dir = app_local_data_dir.join(EXTENSIONS_DIR);
std::fs::create_dir_all(&extensions_dir).expect("failed to create extensions dir");

// Load the extensions.
let extensions = Extensions::from_dir(extensions_dir);
app.manage(extensions);

// Load the store.
let _store = app.store(STORE_FILE)?;

Ok(())
});

// Register the commands
let builder = builder.invoke_handler(tauri::generate_handler![
get_extensions,
get_repository_extensions,
install_extension,
uninstall_extension,
get_manga_list,
get_manga_details,
get_chapter_list,
get_page_list
]);

// Run the application
builder
.run(ctx)
.expect("error while running tauri application");
}

0 comments on commit b4321dc

Please sign in to comment.