更新文档
This commit is contained in:
@@ -69,6 +69,8 @@ const size_t MAX_PHOTO_BODY_SIZE = 512 * 1024;
|
||||
const char* DEFAULT_API_TOKEN = "atk_nKfVWLhMjL0RGSfRll3R_sdJS6IrIjuV";
|
||||
const char* DEFAULT_CORS_ORIGIN = "http://localhost";
|
||||
const char* DEFAULT_TIMESLOTS_JSON =
|
||||
"{\"time_slots\":[]}";
|
||||
const char* LEGACY_DEFAULT_TIMESLOTS_JSON =
|
||||
"{\"time_slots\":["
|
||||
"{\"name\":\"上午签到\",\"start_time\":\"08:00\",\"end_time\":\"09:30\",\"enabled\":true},"
|
||||
"{\"name\":\"中午签退\",\"start_time\":\"12:00\",\"end_time\":\"13:00\",\"enabled\":true},"
|
||||
@@ -139,6 +141,17 @@ std::string jsonEscape(const std::string& value) {
|
||||
return out.str();
|
||||
}
|
||||
|
||||
std::string jsonWithoutWhitespace(const std::string& value) {
|
||||
std::string compact;
|
||||
compact.reserve(value.size());
|
||||
for (char ch : value) {
|
||||
if (!std::isspace(static_cast<unsigned char>(ch))) {
|
||||
compact.push_back(ch);
|
||||
}
|
||||
}
|
||||
return compact;
|
||||
}
|
||||
|
||||
std::string csvEscape(const std::string& value) {
|
||||
bool needs_quotes = false;
|
||||
for (char c : value) {
|
||||
@@ -1300,6 +1313,11 @@ bool saveTimeSlots(const std::string& json_data) {
|
||||
|
||||
std::string readTimeSlots() {
|
||||
std::string content = sqliteGetKvValue("time_slots", DEFAULT_TIMESLOTS_JSON);
|
||||
if (jsonWithoutWhitespace(content) == jsonWithoutWhitespace(LEGACY_DEFAULT_TIMESLOTS_JSON)) {
|
||||
content = DEFAULT_TIMESLOTS_JSON;
|
||||
sqliteSetKvValue("time_slots", content);
|
||||
std::cout << "[TIMESLOTS] Legacy default configuration cleared" << std::endl;
|
||||
}
|
||||
std::cout << "[TIMESLOTS] Read " << content.size() << " bytes from SQLite" << std::endl;
|
||||
return content;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user