CC_SDK/UI/MainWindow.cpp

64 lines
2.2 KiB
C++
Raw Normal View History

2025-04-25 19:37:53 +08:00
#include "MainWindow.h"
#include "CCUnzip.h"
MainWindow::MainWindow() {
CTL::UnZip::ZipFile("D:/DownLoad/AAVV","D:/DownLoad/AAVVS.zip");
this->SetClose([this]() {
CC::Println("MainWindow Close");
});
this->SetTitle("AppMainWindow");
auto IP = CTL::Socket::GetLocalIP(CTL::IPV6)[0];
this->SetURL(CC::format("http://[%s]:8080",IP.c_str()));
// this->SetURL("https://ys.mihoyo.com/cloud/?utm_source=default#/");
this->SetWindowSize({1440, 900});
this->SetWindowPos({100, 100});
this->SetWindowIcon("../icon.ico");
m_WebServlet.SetIPType(CTL::IPV6);
const bool F = m_WebServlet.Init(Any,8080);
m_WebServlet.SetTimeout(1000 * 30);
m_WebServlet.AddStaticPath("../static");
m_WebServlet.AddStaticPath("../static/dist");
m_WebServlet.SetWebServlet("/", [this](CTL::Request& request, CTL::Response& res){
res.ResponseFile("../static/index.html",200);
});
m_WebServlet.SetWebServlet("/dist", [this](CTL::Request& request, CTL::Response& res){
res.ResponseFile("../static/dist/index.html",200);
});
m_WebServlet.SetWebServlet("/UpFile", [this](CTL::Request& request, CTL::Response& res){
bool F = request.GetMediaFiles([this](const CCVector<char>& data,size_t size) {
CCFileOutStream file("../ABC.png", std::ios::out | std::ios::binary | std::ios::app);
if (file.is_open()) {
file.write(data.data(), size).flush();
return true;
}
else {
return false;
}
});
res.Write(F ? "OK" : "ERROR",200);
});
m_WebServlet.SetWebServlet("/ABC", [this](CTL::Request& request, CTL::Response& res){
res.SendRedirect("/html/index.html");
});
if (F){
CTL::Thread([this]() {
m_WebServlet.Running();
}).Start();
}
CTL::TrayMenu trayMenu;
trayMenu.SetMenuTitle("AppMainWindow应用程序");
trayMenu.SetIcon("../icon.ico");
trayMenu.AddItem("退出",[this]() {
CC::Println("退出");
this->Close();
});
trayMenu.ShowMenu();
CTL::Thread::Sleep(1000 * 1000);
}
MainWindow::~MainWindow() {
CC::Println("销毁");
}