fix: cannot detect service mode on home card

This commit is contained in:
wonfen 2025-03-19 05:25:38 +08:00
parent 74e441df5b
commit 61f019f194
3 changed files with 10 additions and 10 deletions

View File

@ -1,10 +1,8 @@
use chrono::Local; use chrono::Local;
use regex::Regex; use regex::Regex;
use reqwest::header::{HeaderMap, HeaderValue};
use reqwest::Client; use reqwest::Client;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use std::collections::HashMap; use std::collections::HashMap;
use std::error::Error;
use std::sync::Arc; use std::sync::Arc;
use tauri::command; use tauri::command;
use tokio::sync::Mutex; use tokio::sync::Mutex;

View File

@ -6,7 +6,6 @@ use crate::{
}; };
use anyhow::Result; use anyhow::Result;
use serde_yaml::Mapping; use serde_yaml::Mapping;
use tauri::Manager;
/// Patch Clash configuration /// Patch Clash configuration
pub async fn patch_clash(patch: Mapping) -> Result<()> { pub async fn patch_clash(patch: Mapping) -> Result<()> {

View File

@ -30,6 +30,9 @@ export const SystemInfoCard = () => {
{ suspense: false, revalidateOnFocus: false } { suspense: false, revalidateOnFocus: false }
); );
// 是否以sidecar模式运行
const isSidecarMode = runningMode === "sidecar";
// 初始化系统信息 // 初始化系统信息
useEffect(() => { useEffect(() => {
// 获取系统信息 // 获取系统信息
@ -123,10 +126,10 @@ export const SystemInfoCard = () => {
// 点击运行模式处理 // 点击运行模式处理
const handleRunningModeClick = useCallback(() => { const handleRunningModeClick = useCallback(() => {
if (runningMode === "sidecar") { if (isSidecarMode) {
onInstallService(); onInstallService();
} }
}, [runningMode, onInstallService]); }, [isSidecarMode, onInstallService]);
// 检查更新 // 检查更新
const onCheckUpdate = useLockFn(async () => { const onCheckUpdate = useLockFn(async () => {
@ -148,12 +151,12 @@ export const SystemInfoCard = () => {
// 运行模式样式 // 运行模式样式
const runningModeStyle = useMemo(() => ({ const runningModeStyle = useMemo(() => ({
cursor: runningMode === "sidecar" ? "pointer" : "default", cursor: isSidecarMode ? "pointer" : "default",
textDecoration: runningMode === "sidecar" ? "underline" : "none", textDecoration: isSidecarMode ? "underline" : "none",
"&:hover": { "&:hover": {
opacity: runningMode === "sidecar" ? 0.7 : 1, opacity: isSidecarMode ? 0.7 : 1,
}, },
}), [runningMode]); }), [isSidecarMode]);
// 只有当verge存在时才渲染内容 // 只有当verge存在时才渲染内容
if (!verge) return null; if (!verge) return null;
@ -203,7 +206,7 @@ export const SystemInfoCard = () => {
onClick={handleRunningModeClick} onClick={handleRunningModeClick}
sx={runningModeStyle} sx={runningModeStyle}
> >
{runningMode === "service" ? t("Service Mode") : t("Sidecar Mode")} {isSidecarMode ? t("Sidecar Mode") : t("Service Mode")}
</Typography> </Typography>
</Stack> </Stack>
<Divider /> <Divider />