upgrade cal
This commit is contained in:
2
src-tauri/Cargo.lock
generated
2
src-tauri/Cargo.lock
generated
@@ -667,7 +667,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "chrono-snap"
|
||||
version = "0.2.2"
|
||||
version = "0.2.3"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"base64 0.22.1",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "chrono-snap"
|
||||
version = "0.2.2"
|
||||
version = "0.2.3"
|
||||
description = "An app to record screens and events"
|
||||
authors = ["you"]
|
||||
edition = "2021"
|
||||
|
||||
@@ -227,3 +227,37 @@ pub fn get_overdue_reminders_count(path: &str, date: &str, minute: i32) -> anyho
|
||||
let count: i32 = stmt.query_row(params![date, minute], |row| row.get(0))?;
|
||||
Ok(count)
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
pub struct DayStatus {
|
||||
pub date: String,
|
||||
pub has_overdue: bool,
|
||||
pub has_upcoming: bool,
|
||||
}
|
||||
|
||||
pub fn get_reminders_by_month(path: &str, year_month: &str, today: &str, now_minute: i32) -> anyhow::Result<Vec<DayStatus>> {
|
||||
let conn = Connection::open(path)?;
|
||||
// 查找该月份内有提醒的所有日期
|
||||
let mut stmt = conn.prepare("
|
||||
SELECT date,
|
||||
MAX(CASE WHEN is_completed = 0 AND (date < ?2 OR (date = ?2 AND minute < ?3)) THEN 1 ELSE 0 END) as has_overdue,
|
||||
MAX(CASE WHEN is_completed = 0 AND (date > ?2 OR (date = ?2 AND minute >= ?3)) THEN 1 ELSE 0 END) as has_upcoming
|
||||
FROM reminders
|
||||
WHERE date LIKE ?1
|
||||
GROUP BY date
|
||||
")?;
|
||||
|
||||
let rows = stmt.query_map(params![format!("{}%", year_month), today, now_minute], |row| {
|
||||
Ok(DayStatus {
|
||||
date: row.get(0)?,
|
||||
has_overdue: row.get::<_, i32>(1)? == 1,
|
||||
has_upcoming: row.get::<_, i32>(2)? == 1,
|
||||
})
|
||||
})?;
|
||||
|
||||
let mut results = Vec::new();
|
||||
for row in rows {
|
||||
results.push(row?);
|
||||
}
|
||||
Ok(results)
|
||||
}
|
||||
|
||||
@@ -107,6 +107,13 @@ pub fn get_overdue_reminders_count(state: tauri::State<'_, AppState>, date: Stri
|
||||
crate::db::get_overdue_reminders_count(path, &date, minute).map_err(|e| e.to_string())
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn get_reminders_by_month(state: tauri::State<'_, AppState>, year_month: String, today: String, now_minute: i32) -> Result<Vec<crate::db::DayStatus>, String> {
|
||||
let path = state.db_path.lock().unwrap();
|
||||
let path = path.as_ref().ok_or("Database path not set")?;
|
||||
crate::db::get_reminders_by_month(path, &year_month, &today, now_minute).map_err(|e| e.to_string())
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn update_interval(state: tauri::State<'_, AppState>, seconds: u64) {
|
||||
state.capture_interval_secs.store(seconds, Ordering::SeqCst);
|
||||
|
||||
@@ -37,6 +37,7 @@ pub fn run() {
|
||||
engine::delete_reminder,
|
||||
engine::toggle_reminder,
|
||||
engine::get_overdue_reminders_count,
|
||||
engine::get_reminders_by_month,
|
||||
engine::write_file
|
||||
])
|
||||
.setup(|app| {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"$schema": "https://schema.tauri.app/config/2",
|
||||
"productName": "ChronoSnap",
|
||||
"version": "0.2.2",
|
||||
"version": "0.2.3",
|
||||
"identifier": "top.volan.chrono-snap",
|
||||
"build": {
|
||||
"beforeDevCommand": "pnpm dev",
|
||||
@@ -12,7 +12,7 @@
|
||||
"app": {
|
||||
"windows": [
|
||||
{
|
||||
"title": "瞬影 - 时间记录 v0.2.2",
|
||||
"title": "瞬影 - 时间记录 v0.2.3",
|
||||
"width": 1760,
|
||||
"height": 1100
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user