diff --git a/icon.png b/icon.png new file mode 100644 index 0000000..a85a32e Binary files /dev/null and b/icon.png differ diff --git a/main.go b/main.go index 6c226a5..05f6863 100644 --- a/main.go +++ b/main.go @@ -118,12 +118,17 @@ func main() { } func getDefinition(word, sourceLang, targetLang string) ([]byte, error) { - wordKey := fmt.Sprintf("%s-%s:%s", sourceLang, targetLang, word) + // --- 新增:将接收到的单词统一转换为小写进行处理 --- + normalizedWord := strings.ToLower(word) + // --- 标准化结束 --- + + // 后续所有操作都使用这个标准化后的单词 + wordKey := fmt.Sprintf("%s-%s:%s", sourceLang, targetLang, normalizedWord) var cachedDefinition string err := db.QueryRow("SELECT definition FROM cache WHERE word_key = ?", wordKey).Scan(&cachedDefinition) if err == nil { - log.Printf("Cache hit from SQLite for key: %s", wordKey) + log.Printf("Cache hit for key: %s (Original: '%s')", wordKey, word) return []byte(cachedDefinition), nil } @@ -134,7 +139,8 @@ func getDefinition(word, sourceLang, targetLang string) ([]byte, error) { if !ok { return nil, fmt.Errorf("unsupported language pair: %s", promptKey) } - prompt := strings.Replace(promptTemplate, "${word}", word, -1) + // 使用标准化后的单词去填充Prompt + prompt := strings.Replace(promptTemplate, "${word}", normalizedWord, -1) requestBody, _ := json.Marshal(map[string]interface{}{"model": config.API.Model, "messages": []map[string]string{{"role": "user", "content": prompt}}}) req, _ := http.NewRequest("POST", config.API.URL, bytes.NewBuffer(requestBody)) diff --git a/static/goldendict-tutorial.html b/static/goldendict-tutorial.html new file mode 100644 index 0000000..2ed49b5 --- /dev/null +++ b/static/goldendict-tutorial.html @@ -0,0 +1,194 @@ + + + + + + GoldenDict 集成教程 - AI 词典 + + + +

如何将 AI 词典添加到 GoldenDict

+
+

通过本教程,您可以将这个强大的实时AI词典无缝集成到您本地的 GoldenDict 软件中,获得顶级的桌面端查词体验。

+ +
+
重要说明
+

GoldenDict 无法动态传递您选择的语言对。因此,您需要为您希望使用的**每一个语言对**(例如“英→汉”、“德→英”等)都单独添加一个词典条目。

+

为了简化这个过程,我们提供了下面的 **URL生成器** 和常用示例。

+
+ +
+
URL 生成器
+
+ + + + + + +
+

生成的URL (请复制):

+ + +
+
+
+ +
+
设置步骤
+
    +
  1. 打开 GoldenDict, 进入 编辑词典 (快捷键 F3)。
  2. +
  3. 点击 网站 标签页, 然后点击 添加... 按钮。
  4. +
  5. 在弹出的窗口中填写信息: +
      +
    • 启用: ✅ (务必勾选)
    • +
    • 名称: 建议使用能识别的名称, 例如 AI 词典 (英→汉)
    • +
    • 地址: 从上方的 **URL生成器** 或下方的常用示例中,复制对应的URL并粘贴到这里。
    • +
    +
  6. +
  7. 点击 确定 保存。
  8. +
  9. **重复第3、4步**为您需要的其他语言对添加更多词典。
  10. +
  11. 全部添加完毕后,点击主设置窗口的 确定 使设置生效。
  12. +
+
+ +
+
常用语言对示例
+

为方便起见,这里提供一些常用组合的URL。请根据您的服务器地址(本地或远程)进行修改。

+ +
+ +

完成!

+

现在,您可以在 GoldenDict 中查词了。您添加的每一个语言对都会作为一个独立的标签页显示结果。

+
+ + 返回词典主页 + + + + \ No newline at end of file diff --git a/static/index.html b/static/index.html index 1a824eb..3e063c3 100644 --- a/static/index.html +++ b/static/index.html @@ -3,27 +3,118 @@ - AI Dictionary + AI 词典 @@ -62,7 +153,10 @@
+ - - + + \ No newline at end of file