Embed wasm file, login on enter

This commit is contained in:
Dietrich 2021-06-24 12:40:33 +02:00 committed by Franz Dietrich
parent 51276d3831
commit fe1556b099
3 changed files with 12 additions and 8 deletions

View File

@ -17,12 +17,12 @@ dependencies = ["build_client_release", "build_server_release"]
description = "Build client" description = "Build client"
install_crate = { crate_name = "wasm-pack", binary = "wasm-pack", test_arg = "-V" } install_crate = { crate_name = "wasm-pack", binary = "wasm-pack", test_arg = "-V" }
command = "wasm-pack" command = "wasm-pack"
args = ["build", "app", "--target", "web", "--out-name", "app", "--dev"] args = ["build", "app", "--target", "web", "--out-name", "app", "--out-dir", "../pslink/static/wasm/", "--dev"]
[tasks.build_client_release] [tasks.build_client_release]
extend = "build_client" extend = "build_client"
description = "Build client in release mode" description = "Build client in release mode"
args = ["build", "app", "--target", "web", "--out-name", "app", "--release"] args = ["build", "app", "--target", "web", "--out-name", "app", "--out-dir", "../pslink/static/wasm/", "--release"]
[tasks.build_server] [tasks.build_server]
env = { SQLX_OFFLINE = 1 } env = { SQLX_OFFLINE = 1 }

View File

@ -6,6 +6,7 @@ pub mod pages;
use pages::list_links; use pages::list_links;
use pages::list_users; use pages::list_users;
use seed::window; use seed::window;
use seed::IF;
use seed::{attrs, button, div, input, label, log, prelude::*, App, Url, C}; use seed::{attrs, button, div, input, label, log, prelude::*, App, Url, C};
use shared::apirequests::users::LoginUser; use shared::apirequests::users::LoginUser;
use shared::datatypes::Lang; use shared::datatypes::Lang;
@ -391,11 +392,14 @@ fn view_login(lang: &I18n, model: &Model) -> Node<Msg> {
label![t("password")], label![t("password")],
input![ input![
input_ev(Ev::Input, |s| { Msg::PasswordChanged(s) }), input_ev(Ev::Input, |s| { Msg::PasswordChanged(s) }),
keyboard_ev(Ev::KeyDown, |keyboard_event| {
IF!(keyboard_event.key() == "Enter" => Msg::Login)
}),
attrs![ attrs![
At::Type => "password", At::Type => "password",
At::Placeholder => t("password"), At::Placeholder => t("password"),
At::Name => "password", At::Name => "password",
At::Value => model.login_data.password], At::Value => model.login_data.password],
el_ref(&model.login_form.password) el_ref(&model.login_form.password)
] ]
], ],

View File

@ -96,8 +96,8 @@ pub async fn wasm_app(config: web::Data<crate::ServerConfig>) -> Result<HttpResp
<body> <body>
<section id="app"><div class="lds-ellipsis">Loading: <div></div><div></div><div></div><div></div></div></section> <section id="app"><div class="lds-ellipsis">Loading: <div></div><div></div><div></div><div></div></div></section>
<script type="module"> <script type="module">
import init from '/app/pkg/app.js'; import init from '/static/wasm/app.js';
init('/app/pkg/app_bg.wasm'); init('/static/wasm/app_bg.wasm');
</script> </script>
</body> </body>
</html>"#, </html>"#,