From daca29b640bbf36fc82b0dadbf828be095c83a9c Mon Sep 17 00:00:00 2001 From: Wonder Date: Fri, 20 Mar 2026 20:34:28 +0800 Subject: [PATCH] =?UTF-8?q?Feat:=20=E6=94=AF=E6=8C=81=E5=89=AA=E5=88=87?= =?UTF-8?q?=E6=9D=BF=E8=B0=83=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cmd/main.go | 8 -------- internal/clipboard/clipboard.go | 29 ---------------------------- internal/clipboard/clipboard_test.go | 9 +++++++++ 3 files changed, 9 insertions(+), 37 deletions(-) create mode 100644 internal/clipboard/clipboard_test.go diff --git a/cmd/main.go b/cmd/main.go index 5a56137..184c656 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -21,14 +21,6 @@ func main() { os.Exit(1) } - // 获取API密钥 - // apiKey := getAPIKey() - // if apiKey == "" { - // fmt.Println("错误: 未设置API密钥") - // fmt.Println("请设置环境变量 SILICON_API_KEY 或在配置文件中指定") - // os.Exit(1) - // } - // 创建AI客户端 client := ai.NewClient(config.API) diff --git a/internal/clipboard/clipboard.go b/internal/clipboard/clipboard.go index 3a91ebe..3e628ad 100644 --- a/internal/clipboard/clipboard.go +++ b/internal/clipboard/clipboard.go @@ -1,39 +1,10 @@ package clipboard import ( - "fmt" - "runtime" - "github.com/atotto/clipboard" ) -var isClipboardAvailable bool - -func init() { - // 检测剪切板是否可用 - // Linux需要xclip或xsel - if runtime.GOOS == "linux" { - isClipboardAvailable = isXClipAvailable() - } else { - isClipboardAvailable = true - } -} - -func isXClipAvailable() bool { - // 简单检查,实际使用时会在调用时检测 - return true -} - // Write 将文本复制到剪切板 func Write(text string) error { - if !isClipboardAvailable { - return fmt.Errorf("clipboard not available on this system") - } return clipboard.WriteAll(text) } - -// WriteSilent 静默复制到剪切板,不返回错误 -func WriteSilent(text string) bool { - err := Write(text) - return err == nil -} diff --git a/internal/clipboard/clipboard_test.go b/internal/clipboard/clipboard_test.go new file mode 100644 index 0000000..f2e0c2e --- /dev/null +++ b/internal/clipboard/clipboard_test.go @@ -0,0 +1,9 @@ +package clipboard + +import ( + "testing" +) + +func TestWrite(t *testing.T) { + Write("你好鸭") +}