Skip to content

Commit

Permalink
Remove autostart
Browse files Browse the repository at this point in the history
  • Loading branch information
Borber committed Mar 7, 2024
1 parent d020fb5 commit e7fb017
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 87 deletions.
3 changes: 1 addition & 2 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
- 添加开机自启动教程
- 完善许可证的使用
- 将未使用的组件和图标移除出去
- 完善许可证的使用
56 changes: 0 additions & 56 deletions src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ tauri-build = { version = "2.0.0-beta", features = [] }
tauri = { version = "2.0.0-beta", features = ["tray-icon"] }
tauri-plugin-process = "2.0.0-beta"
tauri-plugin-single-instance = "2.0.0-beta"
tauri-plugin-autostart = "2.0.0-beta"

# For base
once_cell = "1"
Expand Down
4 changes: 0 additions & 4 deletions src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,6 @@ async fn main() {
tauri::Builder::default()
.plugin(tauri_plugin_process::init())
.plugin(tauri_plugin_single_instance::init(|_, _, _| {}))
.plugin(tauri_plugin_autostart::init(
tauri_plugin_autostart::MacosLauncher::LaunchAgent,
Some(vec![]),
))
.setup(setup::handler)
.invoke_handler(tauri::generate_handler![copy, open, translate, pin,])
.run(tauri::generate_context!())
Expand Down
25 changes: 1 addition & 24 deletions src-tauri/src/tray.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use tauri::{
tray::TrayIconBuilder,
AppHandle, Manager, Wry,
};
use tauri_plugin_autostart::AutoLaunchManager;

use crate::config::{self, MODE};

Expand All @@ -26,19 +25,6 @@ pub fn init(app: &AppHandle) -> Result<()> {

fn menu(handle: &AppHandle) -> Result<Menu<Wry>> {
let flag = MODE.load(Ordering::SeqCst);

let manager = handle.state::<AutoLaunchManager>();
let autostart_flag = manager.is_enabled().unwrap_or_default();

let autostart = CheckMenuItem::with_id(
handle,
"autostart",
"AutoStart",
true,
autostart_flag,
None::<&str>,
)
.expect("Failed to create menu item autostart");
let mirror = CheckMenuItem::with_id(handle, "mirror", "Mirror", true, flag, None::<&str>)
.expect("Failed to create menu item mirror");
let google = CheckMenuItem::with_id(handle, "google", "Google", true, !flag, None::<&str>)
Expand All @@ -55,7 +41,7 @@ fn menu(handle: &AppHandle) -> Result<Menu<Wry>> {
.expect("Failed to create submenu item mod.");
let exit = MenuItem::with_id(handle, "exit", "Exit", true, None::<&str>)
.expect("Failed to create menu item exit");
Menu::with_items(handle, &[&autostart, &mode, &about, &exit])
Menu::with_items(handle, &[&mode, &about, &exit])
.map_err(|_| anyhow::anyhow!("Failed to create menu"))
}

Expand All @@ -65,15 +51,6 @@ fn fresh(app: &AppHandle) {

fn handler(app: &AppHandle, event: MenuEvent) {
match event.id.as_ref() {
"autostart" => {
let manager = app.state::<AutoLaunchManager>();
let autostart_flag = manager.is_enabled().unwrap_or_default();
if autostart_flag {
let _ = manager.disable();
} else {
let _ = manager.enable();
}
}
"mirror" => {
config::mode(true);
}
Expand Down

0 comments on commit e7fb017

Please sign in to comment.