mirror of
https://github.com/VirtualHotBar/NetMount.git
synced 2026-05-31 16:34:05 +08:00
跨平台
This commit is contained in:
@@ -59,6 +59,8 @@ pub fn is_autostart() -> io::Result<bool> {
|
||||
pub fn set_autostart(enabled: bool) -> io::Result<()> {
|
||||
use std::fs::File;
|
||||
use std::io::prelude::*;
|
||||
use std::path::Path;
|
||||
|
||||
let exe_path = env::current_exe()?;
|
||||
let exe_path_str = exe_path
|
||||
.to_str()
|
||||
@@ -109,8 +111,8 @@ WantedBy=multi-user.target
|
||||
}
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
pub fn is_autostart(service_name: &str) -> bool {
|
||||
pub fn is_autostart() -> io::Result<bool> {
|
||||
use std::path::Path;
|
||||
let file_path = format!("/etc/systemd/system/{}.service", service_name);
|
||||
Path::new(&file_path).exists()
|
||||
let file_path = format!("/etc/systemd/system/{}.service", "netmount");
|
||||
Ok(Path::new(&file_path).exists())
|
||||
}
|
||||
|
||||
@@ -18,8 +18,11 @@ mod localized;
|
||||
use crate::autostart::is_autostart;
|
||||
use crate::autostart::set_autostart;
|
||||
use crate::utils::download_with_progress;
|
||||
#[cfg(target_os = "windows")]
|
||||
use crate::utils::find_first_available_drive_letter;
|
||||
#[cfg(target_os = "windows")]
|
||||
use crate::utils::set_window_shadow;
|
||||
#[cfg(target_os = "windows")]
|
||||
use crate::utils::is_winfsp_installed;
|
||||
|
||||
//use crate::localized::LANGUAGE_PACK;
|
||||
@@ -40,10 +43,6 @@ fn main() {
|
||||
|
||||
// 根据不同的操作系统配置Tauri Builder
|
||||
let builder = tauri::Builder::default()
|
||||
.setup(|app| {
|
||||
set_window_shadow(app); // 设置窗口阴影
|
||||
Ok(())
|
||||
})
|
||||
.system_tray(tray::menu()) // 设置系统托盘菜单
|
||||
.on_system_tray_event(tray::handler) // 设置系统托盘事件处理器
|
||||
.invoke_handler(tauri::generate_handler![
|
||||
@@ -60,7 +59,10 @@ fn main() {
|
||||
let builder = builder.invoke_handler(tauri::generate_handler![
|
||||
get_winfsp_install_state,
|
||||
get_available_drive_letter
|
||||
]);
|
||||
]).setup(|app| {
|
||||
set_window_shadow(app); // 设置窗口阴影
|
||||
Ok(())
|
||||
});
|
||||
|
||||
// 运行Tauri应用,使用`generate_context!()`来加载应用配置
|
||||
builder.run(tauri::generate_context!()).expect("error while running tauri application");
|
||||
|
||||
@@ -7,6 +7,7 @@ use std::fs;
|
||||
use std::io::{self, Write};
|
||||
//use tauri::AppHandle;
|
||||
|
||||
#[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!");
|
||||
|
||||
@@ -18,6 +18,7 @@ import { setLocalized } from "./language/localized"
|
||||
import { checkNotice } from "./update/notice"
|
||||
|
||||
async function init(setStartStr: Function) {
|
||||
|
||||
setStartStr(t('init'))
|
||||
|
||||
listenWindow()
|
||||
@@ -27,6 +28,7 @@ async function init(setStartStr: Function) {
|
||||
setStartStr(t('read_config'))
|
||||
await readNmConfig()
|
||||
|
||||
|
||||
if (nmConfig.settings.startHide) {
|
||||
windowsHide()
|
||||
}
|
||||
|
||||
@@ -9,11 +9,10 @@ import { rclone_api_post } from "../../../utils/rclone/request"
|
||||
|
||||
//列举存储
|
||||
async function reupMount(noRefreshUI?: boolean) {
|
||||
|
||||
const mountPoints = (await rclone_api_post(
|
||||
'/mount/listmounts',
|
||||
)).mountPoints
|
||||
rcloneInfo.mountList = []
|
||||
rcloneInfo.mountList = [];
|
||||
|
||||
if (mountPoints) {
|
||||
mountPoints.forEach((tiem: any) => {
|
||||
|
||||
@@ -36,6 +36,7 @@ let appStarting = false
|
||||
async function appStart(setStartStr: Function) {
|
||||
if (appStarting) { return }//避免重新执行
|
||||
appStarting = true
|
||||
1
|
||||
await init(setStartStr)//初始化功能
|
||||
|
||||
reactRoot.render(<React.StrictMode>
|
||||
|
||||
@@ -26,8 +26,12 @@ async function startRclone() {
|
||||
rcloneInfo.process.command = new Command('rclone', args)
|
||||
|
||||
rcloneInfo.process.log=''
|
||||
rcloneInfo.process.command.stdout.on('data', (data) => { rcloneInfo.process.log += data })
|
||||
rcloneInfo.process.command.stderr.on('data', (data) => { rcloneInfo.process.log += data })
|
||||
const addLog= (data:string) => { rcloneInfo.process.log += data ;
|
||||
console.log(data);
|
||||
}
|
||||
|
||||
rcloneInfo.process.command.stdout.on('data',(data) => addLog(data))
|
||||
rcloneInfo.process.command.stderr.on('data', (data) => addLog(data))
|
||||
|
||||
rcloneInfo.process.child = await rcloneInfo.process.command.spawn()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user