Make clippy happy

This commit is contained in:
Jonathan Kelley committed 2024-01-05 12:54:39 -08:00
1 parent cbed09b95c
commit bc857bf339
9 files changed
+20 -14

No files matched your search

+2 -2
View File
@@ -6,13 +6,13 @@ This calculator version uses React-style state management. All state is held as
use dioxus::events::*; use dioxus::events::*;
use dioxus::html::input_data::keyboard_types::Key; use dioxus::html::input_data::keyboard_types::Key;
use dioxus::prelude::*; use dioxus::prelude::*;
use dioxus_desktop::{Config, WindowBuilder}; use dioxus_desktop::{Config, LogicalSize, WindowBuilder};
fn main() { fn main() {
let config = Config::new().with_window( let config = Config::new().with_window(
WindowBuilder::default() WindowBuilder::default()
.with_title("Calculator") .with_title("Calculator")
.with_inner_size(dioxus_desktop::LogicalSize::new(300.0, 500.0)), .with_inner_size(LogicalSize::new(300.0, 500.0)),
); );
dioxus_desktop::launch_cfg(app, config); dioxus_desktop::launch_cfg(app, config);
+1 -1
View File
@@ -21,7 +21,7 @@ use dioxus::events::*;
use dioxus::html::input_data::keyboard_types::Key; use dioxus::html::input_data::keyboard_types::Key;
use dioxus::html::MouseEvent; use dioxus::html::MouseEvent;
use dioxus::prelude::*; use dioxus::prelude::*;
use dioxus_desktop::wry::application::dpi::LogicalSize; use dioxus_desktop::tao::dpi::LogicalSize;
use dioxus_desktop::{Config, WindowBuilder}; use dioxus_desktop::{Config, WindowBuilder};
fn main() { fn main() {
+1 -1
View File
@@ -1,7 +1,7 @@
use dioxus::prelude::*; use dioxus::prelude::*;
use dioxus_desktop::tao::event::Event as WryEvent;
use dioxus_desktop::tao::event::WindowEvent; use dioxus_desktop::tao::event::WindowEvent;
use dioxus_desktop::use_wry_event_handler; use dioxus_desktop::use_wry_event_handler;
use dioxus_desktop::wry::application::event::Event as WryEvent;
use dioxus_desktop::{Config, WindowCloseBehaviour}; use dioxus_desktop::{Config, WindowCloseBehaviour};
fn main() { fn main() {
+1
View File
@@ -87,6 +87,7 @@ impl<P: 'static> App<P> {
// Set the event converter // Set the event converter
dioxus_html::set_event_converter(Box::new(SerializedHtmlEventConverter)); dioxus_html::set_event_converter(Box::new(SerializedHtmlEventConverter));
// Allow hotreloading to work - but only in debug mode
#[cfg(all(feature = "hot-reload", debug_assertions))] #[cfg(all(feature = "hot-reload", debug_assertions))]
app.connect_hotreload(); app.connect_hotreload();
+4 -3
View File
@@ -102,13 +102,14 @@ impl DesktopService {
/// Send a list of mutations to the webview /// Send a list of mutations to the webview
pub(crate) fn send_edits(&self, edits: Mutations) { pub(crate) fn send_edits(&self, edits: Mutations) {
crate::edits::apply_edits( if let Some(bytes) = crate::edits::apply_edits(
edits, edits,
&mut self.channel.borrow_mut(), &mut self.channel.borrow_mut(),
&mut self.templates.borrow_mut(), &mut self.templates.borrow_mut(),
&self.max_template_count, &self.max_template_count,
) ) {
.map(|bytes| self.edit_queue.add_edits(bytes)); self.edit_queue.add_edits(bytes)
}
} }
/// Create a new window using the props and window builder /// Create a new window using the props and window builder
+3
View File
@@ -32,6 +32,9 @@ mod launch;
// Reexport tao and wry, might want to re-export other important things // Reexport tao and wry, might want to re-export other important things
pub use tao; pub use tao;
pub use tao::dpi::{LogicalPosition, LogicalSize};
pub use tao::event::WindowEvent;
pub use tao::window::WindowBuilder;
pub use wry; pub use wry;
// Public exports // Public exports
+7 -5
View File
@@ -11,6 +11,8 @@ use wry::{
static MINIFIED: &str = include_str!("./minified.js"); static MINIFIED: &str = include_str!("./minified.js");
static DEFAULT_INDEX: &str = include_str!("./index.html"); static DEFAULT_INDEX: &str = include_str!("./index.html");
// todo: clean this up a bit
#[allow(clippy::too_many_arguments)]
pub(super) async fn desktop_handler( pub(super) async fn desktop_handler(
request: Request<Vec<u8>>, request: Request<Vec<u8>>,
custom_head: Option<String>, custom_head: Option<String>,
@@ -107,7 +109,7 @@ fn build_index_file(
Response::builder() Response::builder()
.header("Content-Type", "text/html") .header("Content-Type", "text/html")
.header("Access-Control-Allow-Origin", "*") .header("Access-Control-Allow-Origin", "*")
.body(index.into_bytes().into()) .body(index.into())
} }
/// Construct the inline script that boots up the page and bridges the webview with rust code. /// Construct the inline script that boots up the page and bridges the webview with rust code.
@@ -136,10 +138,10 @@ fn module_loader(root_id: &str, headless: bool) -> String {
) )
} }
//// Get the assset directory, following tauri/cargo-bundles directory discovery approach /// Get the assset directory, following tauri/cargo-bundles directory discovery approach
//// ///
//// Defaults to the current directory if no asset directory is found, which is useful for development when the app /// Defaults to the current directory if no asset directory is found, which is useful for development when the app
//// isn't bundled. /// isn't bundled.
fn get_asset_root_or_default() -> PathBuf { fn get_asset_root_or_default() -> PathBuf {
get_asset_root().unwrap_or_else(|| Path::new(".").to_path_buf()) get_asset_root().unwrap_or_else(|| Path::new(".").to_path_buf())
} }
+1 -1
View File
@@ -113,7 +113,7 @@ impl WebviewInstance {
} }
for (name, handler) in cfg.protocols.drain(..) { for (name, handler) in cfg.protocols.drain(..) {
webview = webview.with_custom_protocol(name, move |r| handler(r)) webview = webview.with_custom_protocol(name, handler);
} }
const INITIALIZATION_SCRIPT: &str = r#" const INITIALIZATION_SCRIPT: &str = r#"
@@ -49,7 +49,6 @@ use crate::prelude::{Navigator, RouterContext};
/// # let _ = vdom.rebuild(); /// # let _ = vdom.rebuild();
/// ``` /// ```
#[must_use] #[must_use]
#[deprecated = "Prefer acquiring the router directly with `dioxus_router::router()`"]
pub fn use_navigator(cx: &ScopeState) -> &Navigator { pub fn use_navigator(cx: &ScopeState) -> &Navigator {
&*cx.use_hook(|| { &*cx.use_hook(|| {
let router = cx let router = cx