mirror of
https://github.com/clash-verge-rev/clash-verge-rev
synced 2025-05-05 06:53:44 +08:00
feat: Allow open devtools
This commit is contained in:
parent
fba0f362a5
commit
d214c8e01b
@ -39,7 +39,7 @@ serde = { version = "1.0", features = ["derive"] }
|
|||||||
reqwest = { version = "0.11", features = ["json", "rustls-tls"] }
|
reqwest = { version = "0.11", features = ["json", "rustls-tls"] }
|
||||||
sysproxy = { git="https://github.com/zzzgydi/sysproxy-rs", branch = "main" }
|
sysproxy = { git="https://github.com/zzzgydi/sysproxy-rs", branch = "main" }
|
||||||
auto-launch = { git="https://github.com/zzzgydi/auto-launch", branch = "main" }
|
auto-launch = { git="https://github.com/zzzgydi/auto-launch", branch = "main" }
|
||||||
tauri = { version = "1.5", features = [ "path-all", "protocol-asset", "dialog-open", "notification-all", "icon-png", "clipboard-all", "global-shortcut-all", "process-all", "shell-all", "system-tray", "updater", "window-all"] }
|
tauri = { version = "1.5", features = [ "path-all", "protocol-asset", "dialog-open", "notification-all", "icon-png", "clipboard-all", "global-shortcut-all", "process-all", "shell-all", "system-tray", "updater", "window-all", "devtools"] }
|
||||||
|
|
||||||
[target.'cfg(windows)'.dependencies]
|
[target.'cfg(windows)'.dependencies]
|
||||||
runas = "=1.0.0" # 高版本会返回错误 Status
|
runas = "=1.0.0" # 高版本会返回错误 Status
|
||||||
|
@ -9,7 +9,7 @@ use anyhow::{Context, Result};
|
|||||||
use serde_yaml::Mapping;
|
use serde_yaml::Mapping;
|
||||||
use std::collections::{HashMap, VecDeque};
|
use std::collections::{HashMap, VecDeque};
|
||||||
use sysproxy::Sysproxy;
|
use sysproxy::Sysproxy;
|
||||||
use tauri::api;
|
use tauri::{api, Manager};
|
||||||
type CmdResult<T = ()> = Result<T, String>;
|
type CmdResult<T = ()> = Result<T, String>;
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
@ -294,6 +294,17 @@ pub fn copy_icon_file(path: String, name: String) -> CmdResult<String> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
pub fn open_devtools(app_handle: tauri::AppHandle) {
|
||||||
|
if let Some(window) = app_handle.get_window("main") {
|
||||||
|
if !window.is_devtools_open() {
|
||||||
|
window.open_devtools();
|
||||||
|
} else {
|
||||||
|
window.close_devtools();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub fn exit_app(app_handle: tauri::AppHandle) {
|
pub fn exit_app(app_handle: tauri::AppHandle) {
|
||||||
let _ = resolve::save_window_size_position(&app_handle, true);
|
let _ = resolve::save_window_size_position(&app_handle, true);
|
||||||
|
@ -57,6 +57,7 @@ fn main() -> std::io::Result<()> {
|
|||||||
cmds::test_delay,
|
cmds::test_delay,
|
||||||
cmds::get_app_dir,
|
cmds::get_app_dir,
|
||||||
cmds::copy_icon_file,
|
cmds::copy_icon_file,
|
||||||
|
cmds::open_devtools,
|
||||||
cmds::exit_app,
|
cmds::exit_app,
|
||||||
// cmds::update_hotkeys,
|
// cmds::update_hotkeys,
|
||||||
// profile
|
// profile
|
||||||
|
@ -10,7 +10,13 @@ import {
|
|||||||
Input,
|
Input,
|
||||||
Typography,
|
Typography,
|
||||||
} from "@mui/material";
|
} from "@mui/material";
|
||||||
import { exitApp, openAppDir, openCoreDir, openLogsDir } from "@/services/cmds";
|
import {
|
||||||
|
exitApp,
|
||||||
|
openAppDir,
|
||||||
|
openCoreDir,
|
||||||
|
openLogsDir,
|
||||||
|
openDevTools,
|
||||||
|
} from "@/services/cmds";
|
||||||
import { ArrowForward } from "@mui/icons-material";
|
import { ArrowForward } from "@mui/icons-material";
|
||||||
import { checkUpdate } from "@tauri-apps/api/updater";
|
import { checkUpdate } from "@tauri-apps/api/updater";
|
||||||
import { useVerge } from "@/hooks/use-verge";
|
import { useVerge } from "@/hooks/use-verge";
|
||||||
@ -27,6 +33,7 @@ import { LayoutViewer } from "./mods/layout-viewer";
|
|||||||
import { UpdateViewer } from "./mods/update-viewer";
|
import { UpdateViewer } from "./mods/update-viewer";
|
||||||
import getSystem from "@/utils/get-system";
|
import getSystem from "@/utils/get-system";
|
||||||
import { routers } from "@/pages/_routers";
|
import { routers } from "@/pages/_routers";
|
||||||
|
import { appWindow } from "@tauri-apps/api/window";
|
||||||
interface Props {
|
interface Props {
|
||||||
onError?: (err: Error) => void;
|
onError?: (err: Error) => void;
|
||||||
}
|
}
|
||||||
@ -304,6 +311,17 @@ const SettingVerge = ({ onError }: Props) => {
|
|||||||
</IconButton>
|
</IconButton>
|
||||||
</SettingItem>
|
</SettingItem>
|
||||||
|
|
||||||
|
<SettingItem label={t("Open Dev Tools")}>
|
||||||
|
<IconButton
|
||||||
|
color="inherit"
|
||||||
|
size="small"
|
||||||
|
sx={{ my: "2px" }}
|
||||||
|
onClick={openDevTools}
|
||||||
|
>
|
||||||
|
<ArrowForward />
|
||||||
|
</IconButton>
|
||||||
|
</SettingItem>
|
||||||
|
|
||||||
<SettingItem label={t("Exit")}>
|
<SettingItem label={t("Exit")}>
|
||||||
<IconButton
|
<IconButton
|
||||||
color="inherit"
|
color="inherit"
|
||||||
|
@ -123,6 +123,7 @@
|
|||||||
"Open Core Dir": "内核目录",
|
"Open Core Dir": "内核目录",
|
||||||
"Open Logs Dir": "日志目录",
|
"Open Logs Dir": "日志目录",
|
||||||
"Check for Updates": "检查更新",
|
"Check for Updates": "检查更新",
|
||||||
|
"Open Dev Tools": "打开开发者工具",
|
||||||
"Verge Version": "Verge 版本",
|
"Verge Version": "Verge 版本",
|
||||||
"theme.light": "浅色",
|
"theme.light": "浅色",
|
||||||
"theme.dark": "深色",
|
"theme.dark": "深色",
|
||||||
|
@ -213,6 +213,10 @@ export async function getPortableFlag() {
|
|||||||
return invoke<boolean>("get_portable_flag");
|
return invoke<boolean>("get_portable_flag");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function openDevTools() {
|
||||||
|
return invoke("open_devtools");
|
||||||
|
}
|
||||||
|
|
||||||
export async function exitApp() {
|
export async function exitApp() {
|
||||||
return invoke("exit_app");
|
return invoke("exit_app");
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user