mirror of
https://github.com/VirtualHotBar/NetMount.git
synced 2026-06-04 18:32:18 +08:00
set_window_shadow
This commit is contained in:
14
src-tauri/Cargo.lock
generated
14
src-tauri/Cargo.lock
generated
@@ -99,6 +99,7 @@ dependencies = [
|
||||
"once_cell",
|
||||
"phf 0.11.2",
|
||||
"rand 0.8.5",
|
||||
"raw-window-handle 0.6.1",
|
||||
"reqwest 0.11.27",
|
||||
"rfd",
|
||||
"serde",
|
||||
@@ -115,6 +116,7 @@ dependencies = [
|
||||
"tokio",
|
||||
"widestring",
|
||||
"winapi",
|
||||
"window-shadows",
|
||||
"winreg 0.10.1",
|
||||
"zip",
|
||||
]
|
||||
@@ -5296,6 +5298,18 @@ version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
||||
|
||||
[[package]]
|
||||
name = "window-shadows"
|
||||
version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "67ff424735b1ac21293b0492b069394b0a189c8a463fb015a16dea7c2e221c08"
|
||||
dependencies = [
|
||||
"cocoa",
|
||||
"objc",
|
||||
"raw-window-handle 0.5.2",
|
||||
"windows-sys 0.48.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "window-vibrancy"
|
||||
version = "0.5.0"
|
||||
|
||||
@@ -60,10 +60,14 @@ tauri-plugin-shell = "2.0.0-beta.7"
|
||||
tauri-plugin-os = "2.0.0-beta.6"
|
||||
tauri-plugin-fs = "2.0.0-beta.9"
|
||||
tauri-plugin-process = "2.0.0-beta.6"
|
||||
|
||||
raw-window-handle = "0.6"
|
||||
|
||||
[target.'cfg(windows)'.dependencies]
|
||||
winreg = "0.10.1"
|
||||
winapi = "0.3"
|
||||
widestring = "1.1"
|
||||
window-shadows = "0.2.2"
|
||||
|
||||
[target."cfg(not(any(target_os = \"android\", target_os = \"ios\")))".dependencies]
|
||||
tauri-plugin-single-instance = "2.0.0-beta.9"
|
||||
|
||||
6597
src-tauri/gen/schemas/windows-schema.json
Normal file
6597
src-tauri/gen/schemas/windows-schema.json
Normal file
File diff suppressed because it is too large
Load Diff
@@ -14,7 +14,7 @@ pub struct Config(pub serde_json::Value);
|
||||
impl Config {
|
||||
pub fn get(&self, key: String) -> Option<serde_json::Value> {
|
||||
let parts = key.split(".");
|
||||
Some(parts.fold(self.0, |value, part| *value.get(part).unwrap()))
|
||||
Some(parts.fold(self.0.clone(), |value, part| value.get(part).unwrap().clone()))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -58,13 +58,12 @@ impl<M: tauri::Manager<Runtime>> AppExt for M {
|
||||
self.get_webview_window("main").unwrap()
|
||||
}
|
||||
|
||||
fn app_locale(&self) -> &Locale {
|
||||
fn app_locale(&self) -> Locale {
|
||||
self.state::<LocaleState>()
|
||||
.deref()
|
||||
.0
|
||||
.read()
|
||||
.unwrap()
|
||||
.deref()
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
}
|
||||
@@ -215,7 +214,8 @@ pub fn init() -> anyhow::Result<()> {
|
||||
// set_devtools_state,
|
||||
fs_exist_dir,
|
||||
fs_make_dir,
|
||||
restart_self
|
||||
restart_self,
|
||||
get_available_ports
|
||||
])
|
||||
.setup(|app| {
|
||||
app.manage(ConfigState(RwLock::new(
|
||||
@@ -424,3 +424,8 @@ async fn write_config_file(config_data: Value, path: Option<&str>) -> Result<(),
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
fn get_available_ports(count: usize) -> Vec<u16> {
|
||||
return utils::get_available_ports(count);
|
||||
}
|
||||
|
||||
@@ -26,10 +26,25 @@ pub fn get_available_ports(count: usize) -> Vec<u16> {
|
||||
#[cfg(target_os = "windows")]
|
||||
pub fn set_window_shadow<R: Runtime>(app: &tauri::App<R>) {
|
||||
{
|
||||
let window = app.get_window("main").unwrap();
|
||||
set_shadow(&window, true).expect("Unsupported platform!");
|
||||
use raw_window_handle::HasRawWindowHandle;
|
||||
fn set_shadow<W: HasRawWindowHandle>(_window: &W, enabled: bool) -> Result<(), Box<dyn Error>> {
|
||||
set_shadow(_window, true).expect("Unsupported platform!");
|
||||
Ok(())
|
||||
}
|
||||
|
||||
let window_map = app.get_webview_window("main").unwrap().webview_windows();
|
||||
|
||||
// 假设webview_windows返回了一个包含窗口名(String)和窗口实例(WebviewWindow)的映射
|
||||
// 我们需要获取映射中的值(即WebviewWindow实例)
|
||||
if let Some(webview_window) = window_map.values().next() {
|
||||
|
||||
} else {
|
||||
eprintln!("No webview window found.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
#[tauri::command]
|
||||
pub fn find_first_available_drive_letter() -> Result<Option<String>, io::Error> {
|
||||
|
||||
@@ -34,14 +34,14 @@ async function startRclone() {
|
||||
`--rc-user=${nmConfig.framework.rclone.user}`,
|
||||
`--rc-pass=${nmConfig.framework.rclone.password}`,
|
||||
'--rc-allow-origin=' + window.location.origin || '*',
|
||||
'--config=' +formatPath( rcloneDataDir() + '/rclone.conf', osInfo.osType === "windows"),
|
||||
'--config=' + formatPath(rcloneDataDir() + '/rclone.conf', osInfo.osType === "windows"),
|
||||
];
|
||||
|
||||
if (nmConfig.framework.rclone.user === '') {
|
||||
args.push('--rc-no-auth')
|
||||
}
|
||||
|
||||
rcloneInfo.process.command = Command.create('rclone', args)
|
||||
rcloneInfo.process.command = Command.create('rclone', args)
|
||||
|
||||
rcloneInfo.process.log = ''
|
||||
const addLog = (data: string) => {
|
||||
@@ -49,8 +49,8 @@ async function startRclone() {
|
||||
rcloneInfo.process.log += data;
|
||||
}
|
||||
|
||||
rcloneInfo.process.command.stdout.on('data', (data:string) => addLog(data))
|
||||
rcloneInfo.process.command.stderr.on('data', (data:string) => addLog(data))
|
||||
rcloneInfo.process.command.stdout.on('data', (data: string) => addLog(data))
|
||||
rcloneInfo.process.command.stderr.on('data', (data: string) => addLog(data))
|
||||
|
||||
rcloneInfo.process.child = await rcloneInfo.process.command.spawn()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user