add navbar register.
Some checks failed
Deploy / Build (push) Failing after 6m40s

This commit is contained in:
amass 2024-12-22 13:56:15 +08:00
parent 6ab3e2b22b
commit 3228553be5
6 changed files with 17 additions and 4 deletions

View File

@ -33,6 +33,13 @@ Application::Application(const Wt::WEnvironment &env, bool embedded) : Wt::WAppl
setTheme(std::make_shared<BulmaTheme>("bulma", !embedded));
if (!embedded) {
m_navigationBar = root()->addNew<NavigationBar>();
m_navigationBar->registerClicked.connect([this](){
if(m_loginPage){
m_loginPage->registerNewUser();
} else if(m_loginPageRef){
m_loginPageRef->registerNewUser();
}
});
m_root = root()->addNew<Wt::WContainerWidget>();
} else {
std::unique_ptr<Wt::WContainerWidget> topPtr = std::make_unique<Wt::WContainerWidget>();

View File

@ -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<WebToolkit::Server>::instance();
setInternalBasePath("/wt");
// setInternalBasePath("/wt");
model()->addPasswordAuth(&app->passwordService());
setRegistrationEnabled(true);
// setAttributeValue("style", "transform: translateY(-100px);");

View File

@ -27,7 +27,7 @@ constexpr auto Menu = R"(
constexpr auto Template = R"(
<div class="bulma-navbar-brand">
<a class="bulma-navbar-item" href="https://amass.fun">子非鱼</a>
<a class="bulma-navbar-item" href="/">子非鱼</a>
${navbar-burger role="button" class="bulma-navbar-burger" aria-label="menu" aria-expanded="false"}
</div>
${navbar-menu class="bulma-navbar-menu"}
@ -77,5 +77,5 @@ void NavigationBar::createLoginButtons() {
auto registerButton = loginItem->bindWidget("register-button", std::make_unique<Wt::WPushButton>("<strong>注册</strong>"));
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(); });
}

View File

@ -11,6 +11,7 @@ public:
~NavigationBar();
LoginPage *addLoginItem(std::unique_ptr<LoginPage> item);
std::unique_ptr<LoginPage> removeLoginItem();
Wt::Signal<> registerClicked;
protected:
void createLoginButtons();

View File

@ -99,3 +99,7 @@
.Wt-error {
color: hsl(var(--bulma-danger-h), var(--bulma-danger-s), var(--bulma-danger-on-scheme-l));
}
.is-pointer-cursor {
cursor: pointer !important;
}

View File

@ -72,7 +72,8 @@
</div>
<div class="Wt-buttons">
${lost-password} ${sep} ${register}
${lost-password} ${sep}
${register class="has-text-link is-pointer-cursor"}
</div>
</div>
</message>