chore: remove cache

This commit is contained in:
oomeow
2025-10-01 18:25:31 +08:00
Unverified
parent c70b2106fd
commit 984025f790
5 changed files with 19 additions and 32 deletions

View File

@@ -2,7 +2,6 @@ use tauri::Emitter;
use super::CmdResult;
use crate::{
cache::CacheProxy,
core::{
handle::{self, Handle},
tray::Tray,
@@ -92,10 +91,6 @@ pub async fn update_proxy_and_sync(group: String, proxy: String) -> CmdResult<()
proxy
);
let cache = CacheProxy::global();
let key = CacheProxy::make_key("proxies", "default");
cache.map.remove(&key);
if let Err(e) = Tray::global().update_menu().await {
logging!(error, Type::Cmd, "Failed to sync tray menu: {}", e);
}
@@ -113,7 +108,6 @@ pub async fn update_proxy_and_sync(group: String, proxy: String) -> CmdResult<()
Ok(())
}
Err(e) => {
println!("1111111111111111");
logging!(
error,
Type::Cmd,

View File

@@ -1,5 +1,4 @@
use crate::{
cache::{CacheService, SHORT_TERM_TTL},
config::Config,
core::service_ipc::{IpcCommand, send_ipc_request},
logging, logging_error,
@@ -333,28 +332,24 @@ pub async fn force_reinstall_service() -> Result<()> {
/// 检查服务版本 - 使用IPC通信
async fn check_service_version() -> Result<String> {
let cache = CacheService::global();
let key = CacheService::make_key("service", "version");
let version_arc = cache
.get_or_fetch(key, SHORT_TERM_TTL, || async {
logging!(info, Type::Service, true, "开始检查服务版本 (IPC)");
let payload = serde_json::json!({});
let response = send_ipc_request(IpcCommand::GetVersion, payload).await?;
let version_arc: Result<String> = {
logging!(info, Type::Service, true, "开始检查服务版本 (IPC)");
let payload = serde_json::json!({});
let response = send_ipc_request(IpcCommand::GetVersion, payload).await?;
let data = response
.data
.ok_or_else(|| anyhow::anyhow!("服务版本响应中没有数据"))?;
if let Some(nested_data) = data.get("data")
&& let Some(version) = nested_data.get("version").and_then(|v| v.as_str())
{
// logging!(info, Type::Service, true, "获取到服务版本: {}", version);
return Ok(version.to_string());
}
let data = response
.data
.ok_or_else(|| anyhow::anyhow!("服务版本响应中没有数据"))?;
if let Some(nested_data) = data.get("data")
&& let Some(version) = nested_data.get("version").and_then(|v| v.as_str())
{
// logging!(info, Type::Service, true, "获取到服务版本: {}", version);
Ok(version.to_string())
} else {
Ok("unknown".to_string())
})
.await;
}
};
match version_arc.as_ref() {
Ok(v) => Ok(v.clone()),

View File

@@ -1,7 +1,7 @@
#![allow(non_snake_case)]
#![recursion_limit = "512"]
mod cache;
// mod cache;
mod cmd;
pub mod config;
mod core;

View File

@@ -1,5 +1,4 @@
use crate::{
cache::CacheProxy,
config::Config,
core::{handle, timer::Timer, tray::Tray},
log_err, logging,
@@ -176,7 +175,6 @@ pub async fn entry_lightweight_mode() -> bool {
// 回到 In
set_state(LightweightState::In);
CacheProxy::global().clean_default_keys();
true
}

View File

@@ -12,7 +12,7 @@ export function useSystemState() {
"getRunningMode",
getRunningMode,
{
suspense: false,
suspense: true,
revalidateOnFocus: false,
},
);
@@ -21,7 +21,7 @@ export function useSystemState() {
// 获取管理员状态
const { data: isAdminMode = false } = useSWR("isAdmin", isAdmin, {
suspense: false,
suspense: true,
revalidateOnFocus: false,
});
@@ -29,7 +29,7 @@ export function useSystemState() {
"isServiceAvailable",
isServiceAvailable,
{
suspense: false,
suspense: true,
revalidateOnFocus: false,
onSuccess: (data) => {
console.log("[useSystemState] 服务状态更新:", data);