Skip to content

Commit

Permalink
fix(custom-schema): fix schema not working for new opening and dialog…
Browse files Browse the repository at this point in the history
… not showing with certain route (#534)
  • Loading branch information
4o3F authored Mar 1, 2024
1 parent 2d0302d commit f8e58f1
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 2 deletions.
19 changes: 19 additions & 0 deletions backend/tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ mod enhance;
mod feat;
mod utils;

use crate::core::handle::Handle;
use crate::{
config::Config,
utils::{init, resolve},
Expand Down Expand Up @@ -92,6 +93,24 @@ fn main() -> std::io::Result<()> {
resolve::resolve_setup(app);
// setup custom scheme
let handle = app.handle().clone();
// For start new app from schema
#[cfg(not(target_os = "macos"))]
if let Some(url) = std::env::args().nth(1) {
log::info!(target: "app", "started with schema");
if Config::verge().data().enable_silent_start.unwrap_or(true) {
resolve::create_window(&handle.clone());
}
app.listen_global("init-complete", move |_| {
log::info!(target: "app", "frontend init-complete event received");
Handle::global()
.app_handle
.lock()
.as_ref()
.unwrap()
.emit_all("scheme-request-received", url.clone())
.unwrap();
});
}
log_err!(tauri_plugin_deep_link::register(
"clash-nyanpasu",
move |request| {
Expand Down
2 changes: 2 additions & 0 deletions backend/tauri/src/utils/init/logging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ use tracing_appender::{
non_blocking::{NonBlocking, WorkerGuard},
rolling::Rotation,
};
use tracing_log::log_tracer;
use tracing_subscriber::{filter, fmt, layer::SubscriberExt, reload, EnvFilter};

pub type ReloadSignal = (Option<config::logging::LoggingLevel>, Option<usize>);
Expand Down Expand Up @@ -130,6 +131,7 @@ pub fn init() -> Result<()> {
#[cfg(debug_assertions)]
let subscriber = subscriber.with(terminal_layer);

log_tracer::LogTracer::init()?;
tracing::subscriber::set_global_default(subscriber)
.map_err(|x| anyhow!("setup logging error: {}", x))?;
Ok(())
Expand Down
3 changes: 2 additions & 1 deletion src/pages/_layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { useVerge } from "@/hooks/use-verge";
import { getAxios } from "@/services/api";
import getSystem from "@/utils/get-system";
import { List, Paper, ThemeProvider, alpha } from "@mui/material";
import { listen } from "@tauri-apps/api/event";
import { emit, listen } from "@tauri-apps/api/event";
import { appWindow } from "@tauri-apps/api/window";
import dayjs from "dayjs";
import "dayjs/locale/ru";
Expand Down Expand Up @@ -104,6 +104,7 @@ export default function Layout() {
appWindow.show();
appWindow.unminimize();
appWindow.setFocus();
emit("init-complete");
}, 50);
}, []);

Expand Down
2 changes: 1 addition & 1 deletion src/pages/profiles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export default function ProfilePage() {
console.log(location.state.scheme);
viewerRef.current?.create();
}
}, []);
}, [location]);

const onImport = async () => {
if (!url) return;
Expand Down

0 comments on commit f8e58f1

Please sign in to comment.