From 3228553be5b09bacb8707109c5189d13a14ca7df Mon Sep 17 00:00:00 2001 From: amass Date: Sun, 22 Dec 2024 13:56:15 +0800 Subject: [PATCH] add navbar register. --- WebApplication/Application.cpp | 7 +++++++ WebApplication/LoginPage.cpp | 2 +- WebApplication/NavigationBar.cpp | 4 ++-- WebApplication/NavigationBar.h | 1 + resources/app.css | 4 ++++ resources/auth_css_theme.xml | 3 ++- 6 files changed, 17 insertions(+), 4 deletions(-) diff --git a/WebApplication/Application.cpp b/WebApplication/Application.cpp index 4498353..6dbf99c 100644 --- a/WebApplication/Application.cpp +++ b/WebApplication/Application.cpp @@ -33,6 +33,13 @@ Application::Application(const Wt::WEnvironment &env, bool embedded) : Wt::WAppl setTheme(std::make_shared("bulma", !embedded)); if (!embedded) { m_navigationBar = root()->addNew(); + m_navigationBar->registerClicked.connect([this](){ + if(m_loginPage){ + m_loginPage->registerNewUser(); + } else if(m_loginPageRef){ + m_loginPageRef->registerNewUser(); + } + }); m_root = root()->addNew(); } else { std::unique_ptr topPtr = std::make_unique(); diff --git a/WebApplication/LoginPage.cpp b/WebApplication/LoginPage.cpp index 9f0390b..74ea8f7 100644 --- a/WebApplication/LoginPage.cpp +++ b/WebApplication/LoginPage.cpp @@ -7,7 +7,7 @@ LoginPage::LoginPage(const Wt::Auth::AuthService &baseAuth, Wt::Auth::AbstractUserDatabase &users, Wt::Auth::Login &login) : Wt::Auth::AuthWidget(baseAuth, users, login) { auto app = Amass::Singleton::instance(); - setInternalBasePath("/wt"); + // setInternalBasePath("/wt"); model()->addPasswordAuth(&app->passwordService()); setRegistrationEnabled(true); // setAttributeValue("style", "transform: translateY(-100px);"); diff --git a/WebApplication/NavigationBar.cpp b/WebApplication/NavigationBar.cpp index bbc82b5..40d4d61 100644 --- a/WebApplication/NavigationBar.cpp +++ b/WebApplication/NavigationBar.cpp @@ -27,7 +27,7 @@ constexpr auto Menu = R"( constexpr auto Template = R"(
- 子非鱼 + 子非鱼 ${navbar-burger role="button" class="bulma-navbar-burger" aria-label="menu" aria-expanded="false"}
${navbar-menu class="bulma-navbar-menu"} @@ -77,5 +77,5 @@ void NavigationBar::createLoginButtons() { auto registerButton = loginItem->bindWidget("register-button", std::make_unique("注册")); registerButton->setTextFormat(Wt::TextFormat::XHTML); - registerButton->clicked().connect([]() { Wt::WApplication::instance()->setInternalPath("/wt/register", true); }); + registerButton->clicked().connect(this, [this](const Wt::WMouseEvent &e) { registerClicked.emit(); }); } diff --git a/WebApplication/NavigationBar.h b/WebApplication/NavigationBar.h index d5968e7..ea2a7a1 100644 --- a/WebApplication/NavigationBar.h +++ b/WebApplication/NavigationBar.h @@ -11,6 +11,7 @@ public: ~NavigationBar(); LoginPage *addLoginItem(std::unique_ptr item); std::unique_ptr removeLoginItem(); + Wt::Signal<> registerClicked; protected: void createLoginButtons(); diff --git a/resources/app.css b/resources/app.css index 5be0dde..3522e11 100644 --- a/resources/app.css +++ b/resources/app.css @@ -98,4 +98,8 @@ .Wt-error { color: hsl(var(--bulma-danger-h), var(--bulma-danger-s), var(--bulma-danger-on-scheme-l)); +} + +.is-pointer-cursor { + cursor: pointer !important; } \ No newline at end of file diff --git a/resources/auth_css_theme.xml b/resources/auth_css_theme.xml index 556c700..a9d98dc 100644 --- a/resources/auth_css_theme.xml +++ b/resources/auth_css_theme.xml @@ -72,7 +72,8 @@
- ${lost-password} ${sep} ${register} + ${lost-password} ${sep} + ${register class="has-text-link is-pointer-cursor"}