Add tauri_plugin_single_instance
This commit is contained in:
46
src-tauri/Cargo.lock
generated
46
src-tauri/Cargo.lock
generated
@@ -127,6 +127,30 @@ dependencies = [
|
||||
"pin-project-lite",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "async-executor"
|
||||
version = "1.13.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "30ca9a001c1e8ba5149f91a74362376cc6bc5b919d92d988668657bd570bdcec"
|
||||
dependencies = [
|
||||
"async-task",
|
||||
"concurrent-queue",
|
||||
"fastrand",
|
||||
"futures-lite",
|
||||
"slab",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "async-fs"
|
||||
version = "2.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ebcd09b382f40fcd159c2d695175b2ae620ffa5f3bd6f664131efff4e8b9e04a"
|
||||
dependencies = [
|
||||
"async-lock",
|
||||
"blocking",
|
||||
"futures-lite",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "async-io"
|
||||
version = "2.3.4"
|
||||
@@ -3508,6 +3532,7 @@ dependencies = [
|
||||
"tauri-plugin-os",
|
||||
"tauri-plugin-process",
|
||||
"tauri-plugin-shell",
|
||||
"tauri-plugin-single-instance",
|
||||
"tauri-plugin-updater",
|
||||
"tiktoken-rs",
|
||||
"url",
|
||||
@@ -4519,6 +4544,21 @@ dependencies = [
|
||||
"tokio",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tauri-plugin-single-instance"
|
||||
version = "2.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a25ac834491d089699a2bc9266a662faf373c9f779f05a2235bc6e4d9e61769a"
|
||||
dependencies = [
|
||||
"log",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"tauri",
|
||||
"thiserror",
|
||||
"windows-sys 0.59.0",
|
||||
"zbus",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tauri-plugin-updater"
|
||||
version = "2.0.2"
|
||||
@@ -5872,9 +5912,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7b8e3d6ae3342792a6cc2340e4394334c7402f3d793b390d2c5494a4032b3030"
|
||||
dependencies = [
|
||||
"async-broadcast",
|
||||
"async-executor",
|
||||
"async-fs",
|
||||
"async-io",
|
||||
"async-lock",
|
||||
"async-process",
|
||||
"async-recursion",
|
||||
"async-task",
|
||||
"async-trait",
|
||||
"blocking",
|
||||
"derivative",
|
||||
"enumflags2",
|
||||
"event-listener",
|
||||
|
||||
@@ -42,4 +42,5 @@ custom-protocol = ["tauri/custom-protocol"]
|
||||
# crate-type = ["staticlib", "cdylib", "rlib", "lib"]
|
||||
|
||||
[target.'cfg(not(any(target_os = "android", target_os = "ios")))'.dependencies]
|
||||
tauri-plugin-single-instance = "2"
|
||||
tauri-plugin-updater = "2"
|
||||
|
||||
@@ -10,10 +10,10 @@ use base64::{engine::general_purpose, Engine as _};
|
||||
use reqwest::header::{HeaderMap, HeaderName, HeaderValue};
|
||||
use serde_json::json;
|
||||
use serde_json::Value;
|
||||
use tauri::path::BaseDirectory;
|
||||
use std::collections::HashMap;
|
||||
use std::io::Write;
|
||||
use std::{path::Path, time::Duration};
|
||||
use tauri::path::BaseDirectory;
|
||||
use tauri::Manager;
|
||||
use tauri::{AppHandle, Emitter};
|
||||
|
||||
@@ -326,14 +326,13 @@ fn run_py_server(handle: tauri::AppHandle, py_path: String) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
#[tauri::command]
|
||||
async fn streamed_fetch(
|
||||
id: String,
|
||||
url: String,
|
||||
headers: String,
|
||||
body: String,
|
||||
app: AppHandle
|
||||
app: AppHandle,
|
||||
) -> String {
|
||||
//parse headers
|
||||
let headers_json: Value = match serde_json::from_str(&headers) {
|
||||
@@ -419,7 +418,6 @@ async fn streamed_fetch(
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
use std::path::PathBuf;
|
||||
// Copyright 2019-2024 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
@@ -462,7 +460,18 @@ fn handle_file_associations(app: AppHandle, files: Vec<PathBuf>) {
|
||||
}
|
||||
|
||||
fn main() {
|
||||
tauri::Builder::default()
|
||||
let mut builder = tauri::Builder::default();
|
||||
|
||||
#[cfg(desktop)]
|
||||
{
|
||||
builder = builder.plugin(tauri_plugin_single_instance::init(|app, args, cwd| {
|
||||
let _ = app.get_webview_window("main")
|
||||
.expect("no main window")
|
||||
.set_focus();
|
||||
}));
|
||||
}
|
||||
|
||||
builder
|
||||
.plugin(tauri_plugin_http::init())
|
||||
.plugin(tauri_plugin_shell::init())
|
||||
.plugin(tauri_plugin_process::init())
|
||||
@@ -530,7 +539,6 @@ fn main() {
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
fn header_map_to_json(header_map: &HeaderMap) -> serde_json::Value {
|
||||
|
||||
Reference in New Issue
Block a user