Merge branch 'master' into use-server-function

This commit is contained in:
Evan Almloff committed 2023-07-19 14:19:03 -07:00
1 parent f3d1600822
commit 7e2ef1260f
81 files changed
+483 -375

No files matched your search

+3 -3
View File
@@ -9,8 +9,8 @@ It is also very much usable as a template for your projects, if you're aiming to
Make sure you have Dioxus CLI installed (if you're unsure, run `cargo install dioxus-cli`).
You can run `dioxus serve` in this directory to start the web server locally, or run
`dioxus build --release` to build the project so you can deploy it on a separate web-server.
You can run `dx serve` in this directory to start the web server locally, or run
`dx build --release` to build the project so you can deploy it on a separate web-server.
## Project Structure
```
@@ -41,4 +41,4 @@ For service worker scripting (in JavaScript):
* [Service worker guide from PWABuilder](https://docs.pwabuilder.com/#/home/sw-intro)
* [Service worker examples, also from PWABuilder](https://github.com/pwa-builder/pwabuilder-serviceworkers)
If you want to stay as close to 100% Rust as possible, you can try using [wasi-worker](https://github.com/dunnock/wasi-worker) to replace the JS service worker file. The JSON manifest will still be required though.
If you want to stay as close to 100% Rust as possible, you can try using [wasi-worker](https://github.com/dunnock/wasi-worker) to replace the JS service worker file. The JSON manifest will still be required though.
+21 -6
View File
@@ -1,32 +1,47 @@
#![allow(non_snake_case)]
use dioxus::prelude::*;
use tokio::time::sleep;
fn main() {
dioxus_desktop::launch(App);
}
fn App(cx: Scope) -> Element {
let enable_directory_upload = use_state(cx, || false);
let files_uploaded: &UseRef<Vec<String>> = use_ref(cx, Vec::new);
cx.render(rsx! {
label {
input {
r#type: "checkbox",
checked: "{enable_directory_upload}",
oninput: move |evt| {
enable_directory_upload.set(evt.value.parse().unwrap());
},
},
"Enable directory upload"
}
input {
r#type: "file",
accept: ".txt, .rs",
accept: ".txt,.rs",
multiple: true,
directory: **enable_directory_upload,
onchange: |evt| {
to_owned![files_uploaded];
async move {
if let Some(file_engine) = &evt.files {
let files = file_engine.files();
for file_name in &files {
if let Some(file) = file_engine.read_file_to_string(file_name).await{
files_uploaded.write().push(file);
}
for file_name in files {
sleep(std::time::Duration::from_secs(1)).await;
files_uploaded.write().push(file_name);
}
}
}
},
}
},
div { "progress: {files_uploaded.read().len()}" },
ul {
for file in files_uploaded.read().iter() {
+1 -1
View File
@@ -30,7 +30,7 @@ enum Route {
#[redirect("/", || Route::BlogList {})]
#[redirect("/:name", |name: String| Route::BlogPost { name })]
#[end_nest]
#[route("/:...route")]
#[route("/:..route")]
PageNotFound {
route: Vec<String>,
},
+1 -1
View File
@@ -122,7 +122,7 @@ npx tailwindcss -i ./input.css -o ./public/tailwind.css --watch
- Run the following command in the root of the project to start the dioxus dev server:
```bash
dioxus serve --hot-reload
dx serve --hot-reload
```
- Open the browser to http://localhost:8080