Older/WebApplication/HomePage.cpp

51 lines
1.8 KiB
C++
Raw Permalink Normal View History

2024-12-02 01:18:57 +08:00
#include "HomePage.h"
#include "Dialog.h"
#include <Wt/WApplication.h>
#include <Wt/WLineEdit.h>
#include <Wt/WPushButton.h>
HomePage::HomePage() {
addStyleClass("bulma-content");
auto p = addWidget(std::make_unique<Wt::WText>("这是一个结合 C++ Web Toolkit 和 CSS Bulma 框架的前后端一体应用程序。"));
p->setInline(false);
auto ul = addWidget(std::make_unique<Wt::WContainerWidget>());
ul->setList(true);
2025-01-04 14:04:27 +08:00
auto li = ul->addNew<Wt::WContainerWidget>();
2024-12-02 01:18:57 +08:00
li->setHtmlTagName("li");
2025-01-04 14:04:27 +08:00
li->addNew<Wt::WAnchor>(Wt::WLink(Wt::LinkType::InternalPath, "/wt/login"), "登录页面");
li = ul->addNew<Wt::WContainerWidget>();
2025-01-16 04:48:31 +08:00
li->setHtmlTagName("li");
li->addNew<Wt::WAnchor>(Wt::WLink(Wt::LinkType::InternalPath, "/wt/task"), "任务清单");
li = ul->addNew<Wt::WContainerWidget>();
2024-12-02 01:18:57 +08:00
li->setHtmlTagName("li");
2025-01-04 14:04:27 +08:00
li->addNew<Wt::WAnchor>(Wt::WLink(Wt::LinkType::InternalPath, "/wt/visitor/analysis"), "访客数据");
2024-12-02 01:18:57 +08:00
2025-01-12 00:46:14 +08:00
li = ul->addNew<Wt::WContainerWidget>();
li->setHtmlTagName("li");
li->addNew<Wt::WAnchor>(Wt::WLink(Wt::LinkType::InternalPath, "/wt/webrtc"), "WebRTC测试");
2024-12-02 01:18:57 +08:00
addWidget(std::make_unique<Wt::WText>("Your name, please ? "));
m_nameEdit = addWidget(std::make_unique<Wt::WLineEdit>());
m_nameEdit->setFocus();
auto b = addWidget(std::make_unique<Wt::WPushButton>("点击我!"));
b->setMargin(5, Wt::Side::Left);
addWidget(std::make_unique<Wt::WBreak>());
m_greeting = addWidget(std::make_unique<Wt::WText>());
b->clicked().connect(this, &HomePage::greet);
m_nameEdit->enterPressed().connect(this, &HomePage::greet);
addWidget(std::make_unique<Dialog>());
}
void HomePage::greet() {
m_greeting->setText("Hello there, " + m_nameEdit->text());
Wt::WApplication::instance()->setInternalPath("/hello");
}