Skip to content

Commit

Permalink
open with
Browse files Browse the repository at this point in the history
  • Loading branch information
hanaTsuk1 committed Aug 17, 2024
1 parent 8a0f6b8 commit 2abaf67
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 22 deletions.
5 changes: 3 additions & 2 deletions src-tauri/Cargo.lock

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

1 change: 1 addition & 0 deletions src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ futures-util = "0.3"
path-slash = "0.2.1"
derive_more = { version = "1", features = ["full"] }
reqwest = "0.12.4"
open = "5.3.0"

[package.metadata.bin]
# cargo-run-bin
Expand Down
31 changes: 12 additions & 19 deletions src-tauri/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,25 @@ mod database;
mod error;
mod server;

use std::collections::HashMap;
use std::env::{current_dir, current_exe};
use std::os::windows::process::CommandExt;
use std::path::PathBuf;
use std::process::Command;
use std::sync::Mutex;
use std::{thread, time::Duration};
use std::{
collections::HashMap,
env::{current_dir, current_exe},
path::PathBuf,
sync::Mutex,
thread,
time::Duration,
};

use anyhow::anyhow;
use lazy_static::lazy_static;
use parse_changelog::Changelog;
use reqwest::StatusCode;
use runas::Command as SudoCommand;
use tauri::WebviewWindow;
use tauri::{
menu::{Menu, MenuItem},
tray::{MouseButton, MouseButtonState, TrayIconBuilder, TrayIconEvent},
AppHandle, Emitter, Manager,
AppHandle, Emitter, Manager, WebviewUrl, WebviewWindow, WebviewWindowBuilder, Wry,
};
use tauri::{WebviewUrl, WebviewWindowBuilder, Wry};
use tauri_plugin_autostart::MacosLauncher;
use tauri_plugin_log::{Target, TargetKind, TimezoneStrategy};
use tauri_plugin_sql::{DbInstances, Migration, MigrationKind};
Expand All @@ -43,8 +42,6 @@ lazy_static! {
static ref SERVER_PORT: Mutex<u16> = Mutex::new(15785);
}

const CREATE_NO_WINDOW: u32 = 0x8000000;

#[derive(Clone, serde::Serialize)]
struct Payload {
args: Vec<String>,
Expand Down Expand Up @@ -215,12 +212,8 @@ pub fn run() {
}

#[tauri::command]
fn open_with(path: String, arg: String) -> Result<()> {
let mut command = Command::new(path);
command.arg(arg);
command.creation_flags(CREATE_NO_WINDOW);
command.output()?;
Ok(())
fn open_with_detached(path: String, arg: String) -> Result<()> {
Ok(open::with_detached(arg, path)?)
}

tauri::Builder::default()
Expand Down Expand Up @@ -269,7 +262,7 @@ pub fn run() {
is_enabled_admin_autostart,
restart_api_service,
is_api_service_active,
open_with,
open_with_detached,
begin_transaction,
execute_transaction,
select_transaction,
Expand Down
2 changes: 1 addition & 1 deletion src/components/timeline/graph/TimelineRemark.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ async function openWith() {
notify.info({
text: t('timelineGraph.remark.wait'),
})
await invoke('open_with', {
await invoke('open_with_detached', {
path: props.raw.program.path,
arg: props.raw.arg,
})
Expand Down

0 comments on commit 2abaf67

Please sign in to comment.