@@ -377,32 +377,33 @@ pub fn save(cfg: &Config, path: &std::path::Path) -> std::io::Result<()> {
377377 std:: fs:: rename ( & tmp, path)
378378}
379379
380- // 预置常用软件别名:key 为单字母模式代号,multi_key 为多字母模式代号,process 为小写 exe 名。
381- // 用户首次启动即生成;未运行的条目灰色排在末尾,不做启动器。
380+ // 预置常用软件条目:仅 name/process(用于识别与友好命名),代号(key/multi_key)一律留空——
381+ // 字母只能由用户显式配置(✎ 编辑面板或设置页),出厂不代分配。首次启动生成;
382+ // 未运行的条目灰色排在末尾,不做启动器;运行时未预置的程序同样追加、代号留空显示「·」。
382383fn default_programs ( ) -> Vec < Program > {
383- let p = |key : & str , mk : & str , name : & str , proc : & str | Program {
384- key : key . into ( ) ,
385- multi_key : mk . into ( ) ,
384+ let p = |name : & str , proc : & str | Program {
385+ key : String :: new ( ) ,
386+ multi_key : String :: new ( ) ,
386387 name : name. into ( ) ,
387388 process : proc. into ( ) ,
388389 } ;
389390 vec ! [
390- p( "c" , "ch" , " Chrome", "chrome.exe" ) ,
391- p( "e" , "ed" , " Edge", "msedge.exe" ) ,
392- p( "f" , "ff" , " Firefox", "firefox.exe" ) ,
393- p( "v" , "vs" , " VS Code", "code.exe" ) ,
394- p( "t" , "te" , " 终端", "windowsterminal.exe" ) ,
395- p( "p" , "ps" , " PowerShell", "powershell.exe" ) ,
396- p( "n" , "no" , " 记事本", "notepad.exe" ) ,
397- p( "r" , "ex" , " 资源管理器", "explorer.exe" ) ,
398- p( "s" , "sl" , " Slack", "slack.exe" ) ,
399- p( "d" , "di" , " Discord", "discord.exe" ) ,
400- p( "o" , "ou" , " Outlook", "outlook.exe" ) ,
401- p( "w" , "wo" , " Word", "winword.exe" ) ,
402- p( "x" , "xl" , " Excel", "excel.exe" ) ,
403- p( "y" , "wx" , " 微信", "wechat.exe" ) ,
404- p( "q" , "qq" , " QQ", "qq.exe" ) ,
405- p( "z" , "dd" , " 钉钉", "dingtalk.exe" ) ,
391+ p( "Chrome" , "chrome.exe" ) ,
392+ p( "Edge" , "msedge.exe" ) ,
393+ p( "Firefox" , "firefox.exe" ) ,
394+ p( "VS Code" , "code.exe" ) ,
395+ p( "终端" , "windowsterminal.exe" ) ,
396+ p( "PowerShell" , "powershell.exe" ) ,
397+ p( "记事本" , "notepad.exe" ) ,
398+ p( "资源管理器" , "explorer.exe" ) ,
399+ p( "Slack" , "slack.exe" ) ,
400+ p( "Discord" , "discord.exe" ) ,
401+ p( "Outlook" , "outlook.exe" ) ,
402+ p( "Word" , "winword.exe" ) ,
403+ p( "Excel" , "excel.exe" ) ,
404+ p( "微信" , "wechat.exe" ) ,
405+ p( "QQ" , "qq.exe" ) ,
406+ p( "钉钉" , "dingtalk.exe" ) ,
406407 ]
407408}
408409
@@ -543,11 +544,18 @@ mod tests {
543544
544545 #[ test]
545546 fn default_programs_present ( ) {
546- assert ! ( !default_programs( ) . is_empty( ) ) ;
547- // 默认代号单字母唯一
547+ let progs = default_programs ( ) ;
548+ assert ! ( !progs. is_empty( ) ) ;
549+ // 出厂不代分配代号:单字母/多字母代号一律留空,字母只能由用户显式配置
550+ for p in & progs {
551+ assert ! ( p. key. is_empty( ) , "默认不应预置单字母代号: {}" , p. name) ;
552+ assert ! ( p. multi_key. is_empty( ) , "默认不应预置多字母代号: {}" , p. name) ;
553+ assert ! ( !p. process. is_empty( ) && !p. name. is_empty( ) ) ;
554+ }
555+ // 预置进程名唯一
548556 let mut seen = std:: collections:: HashSet :: new ( ) ;
549- for p in default_programs ( ) {
550- assert ! ( seen. insert( p. key . clone( ) ) , "默认单字母代号重复 {}" , p. key ) ;
557+ for p in & progs {
558+ assert ! ( seen. insert( p. process . clone( ) ) , "默认进程名重复 {}" , p. process ) ;
551559 }
552560 }
553561
0 commit comments