Older/WebApplication/HomePage.cpp
amass dc5b750056
Some checks failed
Deploy / Build (push) Failing after 53s
add webrtc test.
2025-01-12 00:46:14 +08:00

47 lines
1.6 KiB
C++

#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);
auto li = ul->addNew<Wt::WContainerWidget>();
li->setHtmlTagName("li");
li->addNew<Wt::WAnchor>(Wt::WLink(Wt::LinkType::InternalPath, "/wt/login"), "登录页面");
li = ul->addNew<Wt::WContainerWidget>();
li->setHtmlTagName("li");
li->addNew<Wt::WAnchor>(Wt::WLink(Wt::LinkType::InternalPath, "/wt/visitor/analysis"), "访客数据");
li = ul->addNew<Wt::WContainerWidget>();
li->setHtmlTagName("li");
li->addNew<Wt::WAnchor>(Wt::WLink(Wt::LinkType::InternalPath, "/wt/webrtc"), "WebRTC测试");
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");
}