-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmain.cpp
60 lines (58 loc) · 1.98 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include "webview/webview.h"
#include "ui/index.hpp"
#include "ui/student.hpp"
#include "ui/vote.hpp"
#include "tool/json.h"
#include "data.hpp"
#include <iostream>
int WINAPI WinMain(HINSTANCE /*hInst*/, HINSTANCE /*hPrevInst*/,
LPSTR /*lpCmdLine*/, int /*nCmdShow*/) {
try {
webview::webview w(false, nullptr);
w.set_title("vote - 上课抽签工具");
w.set_size(880, 620, WEBVIEW_HINT_NONE);
w.bind("changeToIndex",[&](const std::string &req) -> std::string {
w.set_html(ui::IndexHTML);
return "[]";
});
w.bind("changeToStudent",[&](const std::string &req) -> std::string {
w.set_html(ui::StudentHTML);
return "[]";
});
w.bind("changeToVote",[&](const std::string &req) -> std::string {
w.set_html(ui::VoteHTML);
return "[]";
});
w.bind("addClass",[&](const std::string &req) -> std::string {
database::addClass(GetCallString(req,0));
return "[]";
});
w.bind("getClass",[&](const std::string &req) -> std::string {
return database::getClassJSON();
});
w.bind("removeClass",[&](const std::string &req) -> std::string {
database::deleteClass(GetCallString(req,0));
return "[]";
});
w.bind("getStudents",[&](const std::string &req) -> std::string {
return MakeStudentList(GetAllStudents(GetCallString(req,0)));
});
w.bind("addStudent",[&](const std::string &req) -> std::string {
AddStudent(GetCallString(req,0),GetCallString(req,1),GetCallString(req,2));
return "[]";
});
w.bind("deleteStudent",[&](const std::string &req) -> std::string {
DeleteStudent(GetCallString(req,0),GetCallString(req,1));
return "[]";
});
w.bind("getRandomStudents",[&](const std::string &req) -> std::string {
return MakeStudentList(GetRandomStudents(GetCallString(req,0),GetCallInt(req,1)));
});
w.set_html(ui::IndexHTML);
w.run();
} catch (const webview::exception &e) {
std::cerr << e.what() << '\n';
return 1;
}
return 0;
}