Skip to content

Commit

Permalink
Update the text of menu item.
Browse files Browse the repository at this point in the history
  • Loading branch information
lsk569937453 committed Oct 16, 2024
1 parent 41155da commit dc21b8c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
8 changes: 4 additions & 4 deletions src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ use tauri::tray::TrayIconEvent;

use tauri::Manager;
fn main() -> Result<(), anyhow::Error> {
let sql_lite = AppState::new()?;
let app_state = AppState::new()?;
tauri::Builder::default()
.plugin(tauri_plugin_shell::init())
.plugin(tauri_plugin_dialog::init())
.plugin(tauri_plugin_fs::init())
.manage(sql_lite)
.manage(app_state)
.on_window_event(|window, event| {
if let tauri::WindowEvent::CloseRequested { api, .. } = event.clone() {
window.hide().unwrap();
Expand All @@ -38,8 +38,8 @@ fn main() -> Result<(), anyhow::Error> {
.build(),
)
.setup(|app| {
let quit = MenuItem::with_id(app, "quit".to_string(), "退出", true, None::<&str>)?;
let show = MenuItem::with_id(app, "show".to_string(), "显示", true, None::<&str>)?;
let quit = MenuItem::with_id(app, "quit".to_string(), "Quit", true, None::<&str>)?;
let show = MenuItem::with_id(app, "show".to_string(), "Show", true, None::<&str>)?;
let menu = Menu::with_items(app, &[&show, &quit])?;
let _ = TrayIconBuilder::new()
.icon(app.default_window_icon().unwrap().clone())
Expand Down
14 changes: 12 additions & 2 deletions src-tauri/src/sql_lite/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,13 @@ use std::sync::Arc;
pub struct AppState {
pub pool: Pool<SqliteConnectionManager>,
pub cancel_flag: Arc<AtomicBool>,
pub language: LanguageEnum,
}
#[derive(Clone)]
pub enum LanguageEnum {
Chinese,
English,
}

impl AppState {
pub fn new() -> Result<AppState, anyhow::Error> {
let home_dir = dirs::home_dir().ok_or(anyhow!("failed to get home directory"))?;
Expand All @@ -17,7 +22,12 @@ impl AppState {
.with_init(|c| c.execute_batch("PRAGMA journal_mode=wal;PRAGMA busy_timeout=60000;"));
let pool = r2d2::Pool::new(manager)?;
let cancel_flag = Arc::new(AtomicBool::new(false));
let language = LanguageEnum::English;
// let connection = Connection::open(db_path)?;
Ok(AppState { pool, cancel_flag })
Ok(AppState {
pool,
cancel_flag,
language,
})
}
}

0 comments on commit dc21b8c

Please sign in to comment.