refactor(i18n): optimize translation handling with Arc<str> for better memory efficiency

refactor(tray): change menu text storage to use Arc<str> for improved performance
refactor(service): utilize SmartString for error messages to enhance memory management
This commit is contained in:
Tunglies
2025-10-28 00:26:20 +08:00
parent a9eb512f20
commit f39436f1d0
4 changed files with 36 additions and 23 deletions

View File

@@ -1,11 +1,11 @@
use crate::utils::i18n::t;
use smartstring::alias::String;
use std::sync::Arc;
macro_rules! define_menu {
($($field:ident => $const_name:ident, $id:expr, $text:expr),+ $(,)?) => {
#[derive(Debug)]
pub struct MenuTexts {
$(pub $field: String,)+
$(pub $field: Arc<str>,)+
}
pub struct MenuIds;

View File

@@ -23,6 +23,7 @@ use futures::future::join_all;
use parking_lot::Mutex;
use smartstring::alias::String;
use std::collections::HashMap;
use std::sync::Arc;
use std::{
fs,
sync::atomic::{AtomicBool, Ordering},
@@ -798,7 +799,7 @@ fn create_proxy_menu_item(
app_handle: &AppHandle,
show_proxy_groups_inline: bool,
proxy_submenus: Vec<Submenu<Wry>>,
proxies_text: &String,
proxies_text: &Arc<str>,
) -> Result<ProxyMenuItem> {
// 创建代理主菜单
let (proxies_submenu, inline_proxy_items) = if show_proxy_groups_inline {