@@ -25,29 +25,6 @@ pub struct TrayManager {
2525 exit_id : MenuId ,
2626}
2727
28- struct MenuTexts {
29- capture : String ,
30- long_capture : String ,
31- exit : String ,
32- }
33- impl MenuTexts {
34- fn get ( lang : & str ) -> Self {
35- match lang. to_uppercase ( ) . as_str ( ) {
36- "CN" => Self {
37- capture : "截图" . to_string ( ) ,
38- long_capture : "长截图" . to_string ( ) ,
39- exit : "退出" . to_string ( ) ,
40- } ,
41- "EN" => Self {
42- capture : "Capture" . to_string ( ) ,
43- long_capture : "Long Capture" . to_string ( ) ,
44- exit : "Exit" . to_string ( ) ,
45- } ,
46- _ => Self :: get ( "EN" ) ,
47- }
48- }
49- }
50-
5128impl TrayManager {
5229 /// 创建新的托盘管理器实例
5330 ///
@@ -63,17 +40,17 @@ impl TrayManager {
6340 /// ### Panics
6441 /// - 如果嵌入的图标数据无效,会panic
6542 /// - 如果构建托盘图标失败,会panic
66- pub fn new ( lang : & str ) -> Self {
43+ pub fn new ( lang : bool ) -> Self {
6744 // 创建托盘图标
6845 let icon_data = include_bytes ! ( "../logo_raw" ) as & [ u8 ] ;
6946 let icon = Icon :: from_rgba ( icon_data. to_vec ( ) , 256 , 256 ) . expect ( "Embedded icon is invalid" ) ;
7047
7148 // 创建右键菜单(根据语言设置显示对应文本)
7249 let menu = Menu :: new ( ) ;
73- let menu_texts = MenuTexts :: get ( lang) ;
74- let menu_capture = MenuItem :: new ( & menu_texts . capture , true , None ) ;
75- let menu_long_capture = MenuItem :: new ( & menu_texts . long_capture , true , None ) ;
76- let menu_exit = MenuItem :: new ( & menu_texts . exit , true , None ) ;
50+ let menu_capture = MenuItem :: new ( if lang { "截图" } else { "Capture" } , true , None ) ;
51+ let menu_long_capture =
52+ MenuItem :: new ( if lang { "长截图" } else { "Long Capture" } , true , None ) ;
53+ let menu_exit = MenuItem :: new ( if lang { "退出" } else { "Exit" } , true , None ) ;
7754
7855 menu. append ( & menu_capture) . unwrap ( ) ;
7956 menu. append ( & menu_long_capture) . unwrap ( ) ;
0 commit comments