Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(custom-schema): fix custom schema #534

Merged
merged 1 commit into from
Mar 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading