应该可以跑了,还没完全测试
This commit is contained in:
1 parent
7096384161
commit
9dbd544b47
11 files changed
+263
-76
No files matched your search
@@ -5,7 +5,7 @@ use serde::{Deserialize, Serialize};
|
||||
pub struct UserState {
|
||||
pub is_checkin_today: bool,
|
||||
pub level: UserLevel,
|
||||
pub checkin_unix_second: u64,
|
||||
pub checkin_unix_mills: u64,
|
||||
pub checkin_times_in_month: usize,
|
||||
pub checkin_days: Vec<u32>, //每月在哪天签到了
|
||||
}
|
||||
@@ -36,7 +36,7 @@ impl UserState {
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
is_checkin_today: false,
|
||||
checkin_unix_second: 0,
|
||||
checkin_unix_mills: 0 as u64,
|
||||
checkin_times_in_month: 0,
|
||||
checkin_days: Vec::new(),
|
||||
level: UserLevel::Bronze,
|
||||
@@ -45,9 +45,9 @@ impl UserState {
|
||||
|
||||
pub fn checkin(&mut self) {
|
||||
self.is_checkin_today = true;
|
||||
let unix_time = tokio::time::Instant::now().elapsed().as_secs();
|
||||
let unix_time = tokio::time::Instant::now().elapsed().as_millis() as u64;
|
||||
|
||||
self.checkin_unix_second = unix_time;
|
||||
self.checkin_unix_mills = unix_time;
|
||||
self.checkin_times_in_month += 1;
|
||||
let day = chrono::Utc::now().day();
|
||||
if !self.checkin_days.contains(&day) {
|
||||
|
||||
Reference in new issue
Block a user