跳到主要内容

Claude Cage · 面向 Claude 的隔离开发环境,支持桌面工作台、多账号、远程部署与移动端连接。上游 Lee-xeo/Claude-Cage 完整源码镜像,非灵栈原创;主许可 MIT,第三方组件遵循各自许可。来源:https://github.com/Lee-xeo/Claude-Cage 。手动同步,不附带 Release 安装包。

浏览文件

typing.go

42 行 · 1.3 KB历史下载
1package maclogin
2
3type loginKey struct {
4 code int
5 shift bool
6}
7
8// These are the physical ANSI keys used by the installer's US login layout.
9func passwordKeys(password string) ([]loginKey, bool) {
10 rows := []struct {
11 characters string
12 code int
13 }{
14 {"aA", 0}, {"sS", 1}, {"dD", 2}, {"fF", 3}, {"hH", 4}, {"gG", 5}, {"zZ", 6}, {"xX", 7}, {"cC", 8}, {"vV", 9},
15 {"bB", 11}, {"qQ", 12}, {"wW", 13}, {"eE", 14}, {"rR", 15}, {"yY", 16}, {"tT", 17},
16 {"1!", 18}, {"2@", 19}, {"3#", 20}, {"4$", 21}, {"6^", 22}, {"5%", 23}, {"=+", 24}, {"9(", 25}, {"7&", 26}, {"-_", 27}, {"8*", 28}, {"0)", 29},
17 {"]}", 30}, {"oO", 31}, {"uU", 32}, {"[{", 33}, {"iI", 34}, {"pP", 35}, {"lL", 37}, {"jJ", 38}, {"'\"", 39}, {"kK", 40}, {";:", 41}, {"\\|", 42}, {",<", 43}, {"/?", 44}, {"nN", 45}, {"mM", 46}, {".>", 47}, {"`~", 50}, {" ", 49},
18 }
19 if len(password) < 8 || len(password) > 256 {
20 return nil, false
21 }
22 result := make([]loginKey, 0, len(password))
23 for _, ch := range password {
24 found := false
25 for _, row := range rows {
26 for index, candidate := range row.characters {
27 if ch == candidate {
28 result = append(result, loginKey{row.code, index == 1})
29 found = true
30 break
31 }
32 }
33 if found {
34 break
35 }
36 }
37 if !found {
38 return nil, false
39 }
40 }
41 return result, true
42}