Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions flutter/wind_send/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,17 @@ dependencies:
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^1.0.8

shared_preferences: ^2.2.2
shared_preferences: ^2.5.4
flutter_localization: ^0.3.3
device_info_plus: ^11.5.0
path_provider: ^2.1.1
file_picker: ^10.3.7
share_handler: ^0.0.23
file_picker: ^10.3.8
# share_handler: ^0.0.23
share_handler:
git:
url: https://github.com/doraemonkeys/share_handler
path: share_handler
ref: main
# https://github.com/ShoutSocial/share_handler/tree/main/share_handler
#listen_sharing_intent: ^1.9.2
# receive_sharing_intent:
Expand All @@ -62,10 +67,10 @@ dependencies:
# https://github.com/superlistapp/super_native_extensions/tree/main/super_clipboard
# https://github.com/superlistapp/super_native_extensions/issues/325
super_clipboard: ^0.9.1
network_info_plus: ^6.1.1
network_info_plus: ^7.0.0
collection: ^1.18.0
share_plus: ^11.1.0
fluttertoast: ^8.2.14
share_plus: ^12.0.1
fluttertoast: ^9.0.0
# open_filex: ^4.6.0
open_filex:
git:
Expand All @@ -85,6 +90,7 @@ dependencies:
saf_util: ^0.11.0
fast_file_picker: ^0.4.8


dev_dependencies:
flutter_test:
sdk: flutter
Expand Down
6 changes: 3 additions & 3 deletions windSend-rs/Cargo.lock

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

4 changes: 2 additions & 2 deletions windSend-rs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ cipher = "0.4"
chrono = "0.4.42"
subslice = "0.2.3"
regex = "1.12"
winreg = "0.55"
arboard = { version = "3.6", features = [
"core-graphics",
"image",
Expand Down Expand Up @@ -96,10 +95,11 @@ tao = "0.34"
tray-icon = "0.21"
reqwest = { version = "0.12", features = ["multipart", "cookies"] }
# rfd 0.14.0 在ubuntu上编译失败
rfd = "0.15"
rfd = "0.16"

# windows dependencies
[target.'cfg(target_os = "windows")'.dependencies]
winreg = "0.55"
win-toast-notify = "0.1.6"

[target.'cfg(not(target_os = "windows"))'.dependencies]
Expand Down
4 changes: 2 additions & 2 deletions windSend-rs/src/relay/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -398,8 +398,8 @@ impl SaltCache {
if let (Some(p), Some(_)) = (&self.cur_pwd, &self.salt_b64)
&& *p == *pwd
{
return (self.kdf_key, self.salt_b64.clone());
}
return (self.kdf_key, self.salt_b64.clone());
}
(None, None)
}

Expand Down
56 changes: 37 additions & 19 deletions windSend-rs/src/utils/auto_start.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

use std::borrow::Cow;
use tracing::error;
#[cfg(target_os = "windows")]
use winreg::RegKey;
#[cfg(target_os = "windows")]
use winreg::enums::*;
pub struct StartHelper {
exe_name: String,
Expand All @@ -22,32 +24,44 @@ impl StartHelper {
}

pub fn set_auto_start(&self) -> Result<(), Box<dyn std::error::Error>> {
// #[cfg(target_os = "windows")]
// {
// self.set_win_auto_start()
// }
// #[cfg(not(any(target_os = "linux", target_os = "windows", target_os = "macos")))]
match std::env::consts::OS {
"windows" => self.set_win_auto_start(),
"macos" => self.set_mac_auto_start(),
"linux" => self.set_linux_auto_start(),
_ => Err(format!("unsupported os: {}", std::env::consts::OS).into()),
#[cfg(target_os = "windows")]
{
self.set_win_auto_start()
}
#[cfg(target_os = "macos")]
{
self.set_mac_auto_start()
}
#[cfg(target_os = "linux")]
{
self.set_linux_auto_start()
}
#[cfg(not(any(target_os = "windows", target_os = "macos", target_os = "linux")))]
{
Err(format!("unsupported os: {}", std::env::consts::OS).into())
}
}

pub fn unset_auto_start(&self) -> Result<(), Box<dyn std::error::Error>> {
// #[cfg(target_os = "windows")]
// {
// self.unset_win_auto_start()
// }
match std::env::consts::OS {
"windows" => self.unset_win_auto_start(),
"macos" => self.unset_mac_auto_start(),
"linux" => self.unset_linux_auto_start(),
_ => Err(format!("unsupported os: {}", std::env::consts::OS).into()),
#[cfg(target_os = "windows")]
{
self.unset_win_auto_start()
}
#[cfg(target_os = "macos")]
{
self.unset_mac_auto_start()
}
#[cfg(target_os = "linux")]
{
self.unset_linux_auto_start()
}
#[cfg(not(any(target_os = "windows", target_os = "macos", target_os = "linux")))]
{
Err(format!("unsupported os: {}", std::env::consts::OS).into())
}
}

#[cfg(target_os = "windows")]
fn set_win_auto_start(&self) -> Result<(), Box<dyn std::error::Error>> {
match self.set_win_auto_start_with_reg() {
Ok(_) => {
Expand All @@ -61,6 +75,7 @@ impl StartHelper {
}
}

#[cfg(target_os = "windows")]
fn cleanup_vbs_start_file(&self) -> Result<(), Box<dyn std::error::Error>> {
let win_user_home_dir =
home::home_dir().ok_or("failed to get current windows user home dir")?;
Expand All @@ -77,6 +92,7 @@ impl StartHelper {
Ok(())
}

#[cfg(target_os = "windows")]
fn set_win_auto_start_with_vbs(&self) -> Result<(), Box<dyn std::error::Error>> {
// C:\Users\*\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup
// 获取当前Windows用户的home directory.
Expand Down Expand Up @@ -118,6 +134,7 @@ impl StartHelper {
Ok(())
}

#[cfg(target_os = "windows")]
fn set_win_auto_start_with_reg(&self) -> Result<(), Box<dyn std::error::Error>> {
let exe_path = std::env::current_exe()?;
let exe_path_str = exe_path.to_str().ok_or("exe path contains invalid UTF-8")?;
Expand Down Expand Up @@ -199,6 +216,7 @@ impl StartHelper {
Ok(())
}

#[cfg(target_os = "windows")]
fn unset_win_auto_start(&self) -> Result<(), Box<dyn std::error::Error>> {
// 删除注册表项
let hkcu = RegKey::predef(HKEY_CURRENT_USER);
Expand Down