mirror of
https://github.com/clash-verge-rev/clash-verge-rev
synced 2025-05-05 04:23:43 +08:00
feat: implement lightweight mode functionality and update related settings
This commit is contained in:
parent
f8dbc7bea0
commit
33d54b27f4
15
src-tauri/src/cmd/lighteweight.rs
Normal file
15
src-tauri/src/cmd/lighteweight.rs
Normal file
@ -0,0 +1,15 @@
|
||||
use crate::module::lightweight;
|
||||
|
||||
use super::CmdResult;
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn entry_lightweight_mode() -> CmdResult {
|
||||
lightweight::entry_lightweight_mode();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn exit_lightweight_mode() -> CmdResult {
|
||||
lightweight::exit_lightweight_mode();
|
||||
Ok(())
|
||||
}
|
@ -17,6 +17,7 @@ pub mod uwp;
|
||||
pub mod validate;
|
||||
pub mod verge;
|
||||
pub mod webdav;
|
||||
pub mod lighteweight;
|
||||
|
||||
// Re-export all command functions for backwards compatibility
|
||||
pub use app::*;
|
||||
@ -32,3 +33,4 @@ pub use uwp::*;
|
||||
pub use validate::*;
|
||||
pub use verge::*;
|
||||
pub use webdav::*;
|
||||
pub use lighteweight::*;
|
||||
|
@ -189,9 +189,6 @@ pub struct IVerge {
|
||||
|
||||
pub enable_tray_speed: Option<bool>,
|
||||
|
||||
/// 轻量模式 - 只保留内核运行
|
||||
pub enable_lite_mode: Option<bool>,
|
||||
|
||||
/// 自动进入轻量模式
|
||||
pub auto_enter_lite_mode: Option<bool>,
|
||||
|
||||
@ -299,7 +296,6 @@ impl IVerge {
|
||||
webdav_password: None,
|
||||
enable_tray_speed: Some(true),
|
||||
enable_global_hotkey: Some(true),
|
||||
enable_lite_mode: Some(false),
|
||||
auto_enter_lite_mode: Some(false),
|
||||
auto_enter_lite_mode_delay: Some(10),
|
||||
enable_dns_settings: Some(true),
|
||||
@ -385,7 +381,6 @@ impl IVerge {
|
||||
patch!(webdav_username);
|
||||
patch!(webdav_password);
|
||||
patch!(enable_tray_speed);
|
||||
patch!(enable_lite_mode);
|
||||
patch!(auto_enter_lite_mode);
|
||||
patch!(auto_enter_lite_mode_delay);
|
||||
patch!(enable_dns_settings);
|
||||
@ -478,7 +473,6 @@ pub struct IVergeResponse {
|
||||
pub webdav_username: Option<String>,
|
||||
pub webdav_password: Option<String>,
|
||||
pub enable_tray_speed: Option<bool>,
|
||||
pub enable_lite_mode: Option<bool>,
|
||||
pub auto_enter_lite_mode: Option<bool>,
|
||||
pub auto_enter_lite_mode_delay: Option<u16>,
|
||||
pub enable_dns_settings: Option<bool>,
|
||||
@ -545,7 +539,6 @@ impl From<IVerge> for IVergeResponse {
|
||||
webdav_username: verge.webdav_username,
|
||||
webdav_password: verge.webdav_password,
|
||||
enable_tray_speed: verge.enable_tray_speed,
|
||||
enable_lite_mode: verge.enable_lite_mode,
|
||||
auto_enter_lite_mode: verge.auto_enter_lite_mode,
|
||||
auto_enter_lite_mode_delay: verge.auto_enter_lite_mode_delay,
|
||||
enable_dns_settings: verge.enable_dns_settings,
|
||||
|
@ -41,18 +41,6 @@ impl Handle {
|
||||
window
|
||||
}
|
||||
|
||||
pub fn destroy_window(&self) -> Result<(), String> {
|
||||
if let Some(window) = self.get_window() {
|
||||
log_err!(window.close());
|
||||
}
|
||||
if let Some(window) = Self::global().get_window() {
|
||||
if let Some(webview) = window.get_webview_window("main") {
|
||||
log_err!(webview.destroy());
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn refresh_clash() {
|
||||
if let Some(window) = Self::global().get_window() {
|
||||
log_err!(window.emit("verge://refresh-clash-config", "yes"));
|
||||
|
@ -176,15 +176,13 @@ impl Hotkey {
|
||||
println!("Executing function directly");
|
||||
log::info!(target: "app", "Executing function directly");
|
||||
|
||||
// 获取轻量模式状态和全局热键状态
|
||||
let is_lite_mode = Config::verge().latest().enable_lite_mode.unwrap_or(false);
|
||||
// 获取全局热键状态
|
||||
let is_enable_global_hotkey = Config::verge()
|
||||
.latest()
|
||||
.enable_global_hotkey
|
||||
.unwrap_or(true);
|
||||
|
||||
// 在轻量模式下或配置了全局热键时,始终执行热键功能
|
||||
if is_lite_mode || is_enable_global_hotkey {
|
||||
|
||||
if is_enable_global_hotkey {
|
||||
f();
|
||||
} else if let Some(window) = app_handle.get_webview_window("main") {
|
||||
// 非轻量模式且未启用全局热键时,只在窗口可见且有焦点的情况下响应热键
|
||||
|
@ -2,7 +2,6 @@ use crate::{
|
||||
config::{Config, IVerge},
|
||||
core::{handle, hotkey, sysopt, tray, CoreManager},
|
||||
log_err,
|
||||
utils::resolve,
|
||||
};
|
||||
use anyhow::Result;
|
||||
use serde_yaml::Mapping;
|
||||
@ -68,7 +67,6 @@ pub async fn patch_verge(patch: IVerge, not_save_file: bool) -> Result<()> {
|
||||
let proxy_bypass = patch.system_proxy_bypass;
|
||||
let language = patch.language;
|
||||
let mixed_port = patch.verge_mixed_port;
|
||||
let lite_mode = patch.enable_lite_mode;
|
||||
#[cfg(target_os = "macos")]
|
||||
let tray_icon = patch.tray_icon;
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
@ -192,15 +190,6 @@ pub async fn patch_verge(patch: IVerge, not_save_file: bool) -> Result<()> {
|
||||
tray::Tray::global().update_click_behavior()?;
|
||||
}
|
||||
|
||||
// Handle lite mode switch
|
||||
if let Some(enable) = lite_mode {
|
||||
if enable {
|
||||
handle::Handle::global().destroy_window().ok();
|
||||
} else {
|
||||
resolve::create_window();
|
||||
}
|
||||
}
|
||||
|
||||
<Result<()>>::Ok(())
|
||||
};
|
||||
match res {
|
||||
|
@ -215,6 +215,9 @@ pub fn run() {
|
||||
// media unlock checker
|
||||
cmd::get_unlock_items,
|
||||
cmd::check_media_unlock,
|
||||
// light-weight model
|
||||
cmd::entry_lightweight_mode,
|
||||
cmd::exit_lightweight_mode,
|
||||
]);
|
||||
|
||||
#[cfg(debug_assertions)]
|
||||
@ -283,41 +286,6 @@ pub fn run() {
|
||||
api.prevent_close();
|
||||
let window = core::handle::Handle::global().get_window().unwrap();
|
||||
let _ = window.hide();
|
||||
|
||||
// 检查是否启用了自动进入 Lite Mode
|
||||
let verge = crate::config::Config::verge();
|
||||
let verge_config = verge.latest();
|
||||
let auto_enter_lite_mode = verge_config.auto_enter_lite_mode.unwrap_or(false);
|
||||
|
||||
if auto_enter_lite_mode {
|
||||
let delay_minutes = verge_config.auto_enter_lite_mode_delay.unwrap_or(10);
|
||||
let app_handle_clone = app_handle.clone();
|
||||
println!("自动进入 Lite Mode 已启用");
|
||||
// 启动一个线程,在指定延迟后启用 Lite Mode
|
||||
std::thread::spawn(move || {
|
||||
println!("等待 {} 分钟后自动进入 Lite Mode", delay_minutes);
|
||||
std::thread::sleep(std::time::Duration::from_secs(delay_minutes as u64 * 60));
|
||||
println!("Lite Mode 倒计时结束");
|
||||
|
||||
// 延迟后检查窗口是否仍然隐藏,如果是,则启用 Lite Mode
|
||||
let window_opt = app_handle_clone.get_webview_window("main");
|
||||
if let Some(window) = window_opt {
|
||||
if !window.is_visible().unwrap_or(true) {
|
||||
println!("倒计时结束,正在进入 Lite Mode...");
|
||||
// 应用 Lite Mode
|
||||
if let Err(e) = tauri::async_runtime::block_on(crate::feat::patch_verge(
|
||||
crate::config::IVerge {
|
||||
enable_lite_mode: Some(true),
|
||||
..Default::default()
|
||||
},
|
||||
false
|
||||
)) {
|
||||
println!("Lite Mode 进入失败: {:?}", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
tauri::WindowEvent::Focused(true) => {
|
||||
#[cfg(target_os = "macos")]
|
||||
|
25
src-tauri/src/module/lightweight.rs
Normal file
25
src-tauri/src/module/lightweight.rs
Normal file
@ -0,0 +1,25 @@
|
||||
use tauri::Manager;
|
||||
|
||||
use crate::{core::handle, log_err, utils::resolve};
|
||||
|
||||
|
||||
|
||||
pub fn entry_lightweight_mode() {
|
||||
println!("entry_lightweight_mode");
|
||||
log::debug!(target: "app", "entry_lightweight_mode");
|
||||
if let Some(window) = handle::Handle::global().get_window() {
|
||||
log_err!(window.close());
|
||||
}
|
||||
|
||||
if let Some(window) = handle::Handle::global().get_window() {
|
||||
if let Some(webview) = window.get_webview_window("main") {
|
||||
log_err!(webview.destroy());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn exit_lightweight_mode() {
|
||||
println!("exit_lightweight_mode");
|
||||
log::debug!(target: "app", "exit_lightweight_mode");
|
||||
resolve::create_window();
|
||||
}
|
@ -1,2 +1,3 @@
|
||||
pub mod mihomo;
|
||||
pub mod sysinfo;
|
||||
pub mod lightweight;
|
@ -12,6 +12,7 @@ import {
|
||||
import { useVerge } from "@/hooks/use-verge";
|
||||
import { BaseDialog, DialogRef, Notice, Switch } from "@/components/base";
|
||||
import { TooltipIcon } from "@/components/base/base-tooltip-icon";
|
||||
import { entry_lightweight_mode } from "@/services/cmds";
|
||||
|
||||
export const LiteModeViewer = forwardRef<DialogRef>((props, ref) => {
|
||||
const { t } = useTranslation();
|
||||
@ -34,15 +35,6 @@ export const LiteModeViewer = forwardRef<DialogRef>((props, ref) => {
|
||||
close: () => setOpen(false),
|
||||
}));
|
||||
|
||||
const onEnterLiteMode = useLockFn(async () => {
|
||||
try {
|
||||
await patchVerge({ enable_lite_mode: true });
|
||||
setOpen(false);
|
||||
} catch (err: any) {
|
||||
Notice.error(err.message || err.toString());
|
||||
}
|
||||
});
|
||||
|
||||
const onSave = useLockFn(async () => {
|
||||
try {
|
||||
await patchVerge({
|
||||
@ -58,7 +50,7 @@ export const LiteModeViewer = forwardRef<DialogRef>((props, ref) => {
|
||||
return (
|
||||
<BaseDialog
|
||||
open={open}
|
||||
title={t("Lite Mode Settings")}
|
||||
title={t("LightWeight Mode Settings")}
|
||||
contentSx={{ width: 450 }}
|
||||
okBtn={t("Save")}
|
||||
cancelBtn={t("Cancel")}
|
||||
@ -68,15 +60,15 @@ export const LiteModeViewer = forwardRef<DialogRef>((props, ref) => {
|
||||
>
|
||||
<List>
|
||||
<ListItem sx={{ padding: "5px 2px" }}>
|
||||
<ListItemText primary={t("Enter Lite Mode Now")} />
|
||||
<Typography
|
||||
variant="button"
|
||||
sx={{
|
||||
cursor: "pointer",
|
||||
color: "primary.main",
|
||||
"&:hover": { textDecoration: "underline" }
|
||||
<ListItemText primary={t("Enter LightWeight Mode Now")} />
|
||||
<Typography
|
||||
variant="button"
|
||||
sx={{
|
||||
cursor: "pointer",
|
||||
color: "primary.main",
|
||||
"&:hover": { textDecoration: "underline" }
|
||||
}}
|
||||
onClick={onEnterLiteMode}
|
||||
onClick={() => entry_lightweight_mode()}
|
||||
>
|
||||
{t("Enable")}
|
||||
</Typography>
|
||||
@ -84,11 +76,11 @@ export const LiteModeViewer = forwardRef<DialogRef>((props, ref) => {
|
||||
|
||||
<ListItem sx={{ padding: "5px 2px" }}>
|
||||
<ListItemText
|
||||
primary={t("Auto Enter Lite Mode")}
|
||||
primary={t("Auto Enter LightWeight Mode")}
|
||||
sx={{ maxWidth: "fit-content" }}
|
||||
/>
|
||||
<TooltipIcon
|
||||
title={t("Auto Enter Lite Mode Info")}
|
||||
title={t("Auto Enter LightWeight Mode Info")}
|
||||
sx={{ opacity: "0.7" }}
|
||||
/>
|
||||
<Switch
|
||||
@ -104,7 +96,7 @@ export const LiteModeViewer = forwardRef<DialogRef>((props, ref) => {
|
||||
{values.autoEnterLiteMode && (
|
||||
<>
|
||||
<ListItem sx={{ padding: "5px 2px" }}>
|
||||
<ListItemText primary={t("Auto Enter Lite Mode Delay")} />
|
||||
<ListItemText primary={t("Auto Enter LightWeight Mode Delay")} />
|
||||
<TextField
|
||||
autoComplete="off"
|
||||
size="small"
|
||||
@ -129,11 +121,11 @@ export const LiteModeViewer = forwardRef<DialogRef>((props, ref) => {
|
||||
}}
|
||||
/>
|
||||
</ListItem>
|
||||
|
||||
|
||||
<ListItem sx={{ padding: "5px 2px" }}>
|
||||
<Typography variant="body2" color="text.secondary" sx={{ fontStyle: "italic" }}>
|
||||
{t("When closing the window, Lite Mode will be automatically activated after _n minutes",
|
||||
{ n: values.autoEnterLiteModeDelay })}
|
||||
{t("When closing the window, LightWeight Mode will be automatically activated after _n minutes",
|
||||
{ n: values.autoEnterLiteModeDelay })}
|
||||
</Typography>
|
||||
</ListItem>
|
||||
</>
|
||||
|
@ -107,9 +107,9 @@ const SettingVergeAdvanced = ({ onError }: Props) => {
|
||||
<SettingItem onClick={openDevTools} label={t("Open Dev Tools")} />
|
||||
|
||||
<SettingItem
|
||||
label={t("Lite Mode Settings")}
|
||||
label={t("LightWeight Mode Settings")}
|
||||
extra={
|
||||
<TooltipIcon title={t("Lite Mode Info")} sx={{ opacity: "0.7" }} />
|
||||
<TooltipIcon title={t("LightWeight Mode Info")} sx={{ opacity: "0.7" }} />
|
||||
}
|
||||
onClick={() => liteModeRef.current?.open()}
|
||||
/>
|
||||
|
@ -436,8 +436,8 @@
|
||||
"Global Mode": "الوضع العالمي",
|
||||
"Direct Mode": "الوضع المباشر",
|
||||
"Enable Tray Speed": "تفعيل سرعة التراي",
|
||||
"Lite Mode": "وضع الأداء الخفيف",
|
||||
"Lite Mode Info": "إيقاف الواجهة الرسومية والإبقاء على تشغيل النواة",
|
||||
"LightWeight Mode": "وضع الأداء الخفيف",
|
||||
"LightWeight Mode Info": "إيقاف الواجهة الرسومية والإبقاء على تشغيل النواة",
|
||||
"Config Validation Failed": "فشل التحقق من تكوين الاشتراك، يرجى فحص ملف التكوين، تم التراجع عن التغييرات، تفاصيل الخطأ:",
|
||||
"Boot Config Validation Failed": "فشل التحقق من التكوين عند الإقلاع، تم استخدام التكوين الافتراضي، يرجى فحص ملف التكوين، تفاصيل الخطأ:",
|
||||
"Core Change Config Validation Failed": "فشل التحقق من التكوين عند تغيير النواة، تم استخدام التكوين الافتراضي، يرجى فحص ملف التكوين، تفاصيل الخطأ:",
|
||||
|
@ -451,14 +451,14 @@
|
||||
"Global Mode": "Global Mode",
|
||||
"Direct Mode": "Direct Mode",
|
||||
"Enable Tray Speed": "Enable Tray Speed",
|
||||
"Lite Mode": "Lightweight Mode",
|
||||
"Lite Mode Info": "Close the GUI and keep only the kernel running",
|
||||
"Lite Mode Settings": "Lite Mode Settings",
|
||||
"Enter Lite Mode Now": "Enter Lite Mode Now",
|
||||
"Auto Enter Lite Mode": "Auto Enter Lite Mode",
|
||||
"Auto Enter Lite Mode Info": "Enable to automatically activate Lite Mode after the window is closed for a period of time",
|
||||
"Auto Enter Lite Mode Delay": "Auto Enter Lite Mode Delay",
|
||||
"When closing the window, Lite Mode will be automatically activated after _n minutes": "When closing the window, Lite Mode will be automatically activated after {{n}} minutes",
|
||||
"LightWeight Mode": "Lightweight Mode",
|
||||
"LightWeight Mode Info": "Close the GUI and keep only the kernel running",
|
||||
"LightWeight Mode Settings": "LightWeight Mode Settings",
|
||||
"Enter LightWeight Mode Now": "Enter LightWeight Mode Now",
|
||||
"Auto Enter LightWeight Mode": "Auto Enter LightWeight Mode",
|
||||
"Auto Enter LightWeight Mode Info": "Enable to automatically activate LightWeight Mode after the window is closed for a period of time",
|
||||
"Auto Enter LightWeight Mode Delay": "Auto Enter LightWeight Mode Delay",
|
||||
"When closing the window, LightWeight Mode will be automatically activated after _n minutes": "When closing the window, LightWeight Mode will be automatically activated after {{n}} minutes",
|
||||
"Config Validation Failed": "Subscription configuration validation failed. Please check the subscription configuration file; modifications have been rolled back.",
|
||||
"Boot Config Validation Failed": "Boot subscription configuration validation failed. Started with the default configuration; please check the subscription configuration file.",
|
||||
"Core Change Config Validation Failed": "Configuration validation failed when switching the kernel. Started with the default configuration; please check the subscription configuration file.",
|
||||
|
@ -433,8 +433,8 @@
|
||||
"Global Mode": "حالت جهانی",
|
||||
"Direct Mode": "حالت مستقیم",
|
||||
"Enable Tray Speed": "فعال کردن سرعت ترای",
|
||||
"Lite Mode": "در فارسی",
|
||||
"Lite Mode Info": "رابط کاربری گرافیکی را ببندید و فقط هسته را در حال اجرا نگه دارید",
|
||||
"LightWeight Mode": "در فارسی",
|
||||
"LightWeight Mode Info": "رابط کاربری گرافیکی را ببندید و فقط هسته را در حال اجرا نگه دارید",
|
||||
"Config Validation Failed": "اعتبارسنجی پیکربندی اشتراک ناموفق بود، فایل پیکربندی را بررسی کنید، تغییرات برگشت داده شد، جزئیات خطا:",
|
||||
"Boot Config Validation Failed": "اعتبارسنجی پیکربندی هنگام راهاندازی ناموفق بود، پیکربندی پیشفرض استفاده شد، فایل پیکربندی را بررسی کنید، جزئیات خطا:",
|
||||
"Core Change Config Validation Failed": "اعتبارسنجی پیکربندی هنگام تغییر هسته ناموفق بود، پیکربندی پیشفرض استفاده شد، فایل پیکربندی را بررسی کنید، جزئیات خطا:",
|
||||
|
@ -432,8 +432,8 @@
|
||||
"Restore Success, App will restart in 1s": "Pemulihan Berhasil, Aplikasi akan dimulai ulang dalam 1 detik",
|
||||
"Failed to fetch backup files": "Gagal mengambil file cadangan",
|
||||
"Enable Tray Speed": "Aktifkan Tray Speed",
|
||||
"Lite Mode": "Mode Ringan",
|
||||
"Lite Mode Info": "Tutup GUI dan biarkan hanya kernel yang berjalan",
|
||||
"LightWeight Mode": "Mode Ringan",
|
||||
"LightWeight Mode Info": "Tutup GUI dan biarkan hanya kernel yang berjalan",
|
||||
"Config Validation Failed": "Validasi konfigurasi langganan gagal, periksa file konfigurasi, perubahan dibatalkan, detail kesalahan:",
|
||||
"Boot Config Validation Failed": "Validasi konfigurasi saat boot gagal, menggunakan konfigurasi default, periksa file konfigurasi, detail kesalahan:",
|
||||
"Core Change Config Validation Failed": "Validasi konfigurasi saat ganti inti gagal, menggunakan konfigurasi default, periksa file konfigurasi, detail kesalahan:",
|
||||
|
@ -433,8 +433,8 @@
|
||||
"Global Mode": "Глобальный режим",
|
||||
"Direct Mode": "Прямой режим",
|
||||
"Enable Tray Speed": "Включить скорость в лотке",
|
||||
"Lite Mode": "Облегченный режим",
|
||||
"Lite Mode Info": "Закройте графический интерфейс и оставьте работать только ядро",
|
||||
"LightWeight Mode": "Облегченный режим",
|
||||
"LightWeight Mode Info": "Закройте графический интерфейс и оставьте работать только ядро",
|
||||
"Config Validation Failed": "Ошибка проверки конфигурации подписки, проверьте файл конфигурации, изменения отменены, ошибка:",
|
||||
"Boot Config Validation Failed": "Ошибка проверки конфигурации при запуске, используется конфигурация по умолчанию, проверьте файл конфигурации, ошибка:",
|
||||
"Core Change Config Validation Failed": "Ошибка проверки конфигурации при смене ядра, используется конфигурация по умолчанию, проверьте файл конфигурации, ошибка:",
|
||||
|
@ -432,8 +432,8 @@
|
||||
"Global Mode": "Глобаль режим",
|
||||
"Direct Mode": "Туры режим",
|
||||
"Enable Tray Speed": "Трей скоростьне үстерү",
|
||||
"Lite Mode": "Җиңел Режим",
|
||||
"Lite Mode Info": "GUI-ны ябыгыз һәм бары тик төшне генә эшләтеп калдырыгыз",
|
||||
"LightWeight Mode": "Җиңел Режим",
|
||||
"LightWeight Mode Info": "GUI-ны ябыгыз һәм бары тик төшне генә эшләтеп калдырыгыз",
|
||||
"Config Validation Failed": "Язылу көйләү тикшерүе уңышсыз, көйләү файлын тикшерегез, үзгәрешләр кире кайтарылды, хата:",
|
||||
"Boot Config Validation Failed": "Йөкләү вакытында көйләү тикшерүе уңышсыз, стандарт көйләү кулланылды, көйләү файлын тикшерегез, хата:",
|
||||
"Core Change Config Validation Failed": "Ядро алыштырганда көйләү тикшерүе уңышсыз, стандарт көйләү кулланылды, көйләү файлын тикшерегез, хата:",
|
||||
|
@ -451,14 +451,14 @@
|
||||
"Global Mode": "全局模式",
|
||||
"Direct Mode": "直连模式",
|
||||
"Enable Tray Speed": "启用托盘速率",
|
||||
"Lite Mode": "轻量模式",
|
||||
"Lite Mode Info": "关闭GUI界面,仅保留内核运行",
|
||||
"Lite Mode Settings": "轻量模式设置",
|
||||
"Enter Lite Mode Now": "立即进入轻量模式",
|
||||
"Auto Enter Lite Mode": "自动进入轻量模式",
|
||||
"Auto Enter Lite Mode Info": "启用后,将在窗口关闭一段时间后自动激活轻量模式",
|
||||
"Auto Enter Lite Mode Delay": "自动进入轻量模式延迟",
|
||||
"When closing the window, Lite Mode will be automatically activated after _n minutes": "关闭窗口后,轻量模式将在 {{n}} 分钟后自动激活",
|
||||
"LightWeight Mode": "轻量模式",
|
||||
"LightWeight Mode Info": "关闭GUI界面,仅保留内核运行",
|
||||
"LightWeight Mode Settings": "轻量模式设置",
|
||||
"Enter LightWeight Mode Now": "立即进入轻量模式",
|
||||
"Auto Enter LightWeight Mode": "自动进入轻量模式",
|
||||
"Auto Enter LightWeight Mode Info": "启用后,将在窗口关闭一段时间后自动激活轻量模式",
|
||||
"Auto Enter LightWeight Mode Delay": "自动进入轻量模式延迟",
|
||||
"When closing the window, LightWeight Mode will be automatically activated after _n minutes": "关闭窗口后,轻量模式将在 {{n}} 分钟后自动激活",
|
||||
"Config Validation Failed": "订阅配置校验失败,请检查订阅配置文件,变更已撤销,错误详情:",
|
||||
"Boot Config Validation Failed": "启动订阅配置校验失败,已使用默认配置启动;请检查订阅配置文件,错误详情:",
|
||||
"Core Change Config Validation Failed": "切换内核时配置校验失败,已使用默认配置启动;请检查订阅配置文件,错误详情:",
|
||||
|
@ -37,7 +37,7 @@ import { BasePage } from "@/components/base";
|
||||
import { ClashInfoCard } from "@/components/home/clash-info-card";
|
||||
import { SystemInfoCard } from "@/components/home/system-info-card";
|
||||
import { useLockFn } from "ahooks";
|
||||
import { openWebUrl, patchVergeConfig } from "@/services/cmds";
|
||||
import { entry_lightweight_mode, openWebUrl, patchVergeConfig } from "@/services/cmds";
|
||||
import { TestCard } from "@/components/home/test-card";
|
||||
import { IpInfoCard } from "@/components/home/ip-info-card";
|
||||
|
||||
@ -259,8 +259,8 @@ const HomePage = () => {
|
||||
contentStyle={{ padding: 2 }}
|
||||
header={
|
||||
<Box sx={{ display: "flex", alignItems: "center" }}>
|
||||
<Tooltip title={t("Lite Mode")} arrow>
|
||||
<IconButton onClick={() => patchVergeConfig({ enable_lite_mode: true })} size="small" color="inherit">
|
||||
<Tooltip title={t("LightWeight Mode")} arrow>
|
||||
<IconButton onClick={() => entry_lightweight_mode()} size="small" color="inherit">
|
||||
<HistoryEduOutlined />
|
||||
</IconButton>
|
||||
</Tooltip>
|
||||
|
@ -324,3 +324,11 @@ export const getAppUptime = async () => {
|
||||
export const installService = async () => {
|
||||
return invoke<void>("install_service");
|
||||
};
|
||||
|
||||
export const entry_lightweight_mode = async () => {
|
||||
return invoke<void>("entry_lightweight_mode");
|
||||
}
|
||||
|
||||
export const exit_lightweight_mode = async () => {
|
||||
return invoke<void>("exit_lightweight_mode");
|
||||
}
|
1
src/services/types.d.ts
vendored
1
src/services/types.d.ts
vendored
@ -739,7 +739,6 @@ interface IVergeConfig {
|
||||
tun_tray_icon?: boolean;
|
||||
enable_tray_speed?: boolean;
|
||||
enable_tun_mode?: boolean;
|
||||
enable_lite_mode?: boolean;
|
||||
auto_enter_lite_mode?: boolean;
|
||||
auto_enter_lite_mode_delay?: number;
|
||||
enable_auto_launch?: boolean;
|
||||
|
Loading…
x
Reference in New Issue
Block a user