From dfd5faa3ac33421966743fe34344111b900386be Mon Sep 17 00:00:00 2001 From: Symb0x76 <109414174+Symb0x76@users.noreply.github.com> Date: Tue, 2 Sep 2025 17:01:55 +0800 Subject: [PATCH] feat(setting): add image key manual setting (#238) --- internal/chatlog/app.go | 29 +++++++++++++++++++++++++++++ internal/chatlog/ctx/context.go | 10 ++++++++++ 2 files changed, 39 insertions(+) diff --git a/internal/chatlog/app.go b/internal/chatlog/app.go index 2963ae9..d0ee2ce 100644 --- a/internal/chatlog/app.go +++ b/internal/chatlog/app.go @@ -484,6 +484,11 @@ func (a *App) settingSelected(i *menu.Item) { description: "配置数据解密密钥", action: a.settingDataKey, }, + { + name: "设置图片密钥", + description: "配置图片解密密钥", + action: a.settingImgKey, + }, { name: "设置数据目录", description: "配置微信数据文件所在目录", @@ -594,6 +599,30 @@ func (a *App) settingDataKey() { a.SetFocus(formView) } +// settingImgKey 设置图片密钥 (ImgKey) +func (a *App) settingImgKey() { + formView := form.NewForm("设置图片密钥") + + tempImgKey := a.ctx.ImgKey + + formView.AddInputField("图片密钥", tempImgKey, 0, nil, func(text string) { + tempImgKey = text + }) + + formView.AddButton("保存", func() { + a.ctx.SetImgKey(tempImgKey) + a.mainPages.RemovePage("submenu2") + a.showInfo("图片密钥已设置") + }) + + formView.AddButton("取消", func() { + a.mainPages.RemovePage("submenu2") + }) + + a.mainPages.AddPage("submenu2", formView, true, true) + a.SetFocus(formView) +} + // settingDataDir 设置数据目录 func (a *App) settingDataDir() { // 使用我们的自定义表单组件 diff --git a/internal/chatlog/ctx/context.go b/internal/chatlog/ctx/context.go index 54ec5e2..a54c34b 100644 --- a/internal/chatlog/ctx/context.go +++ b/internal/chatlog/ctx/context.go @@ -227,6 +227,16 @@ func (c *Context) SetDataDir(dir string) { c.Refresh() } +func (c *Context) SetImgKey(key string) { + c.mu.Lock() + defer c.mu.Unlock() + if c.ImgKey == key { + return + } + c.ImgKey = key + c.UpdateConfig() +} + func (c *Context) SetAutoDecrypt(enabled bool) { c.mu.Lock() defer c.mu.Unlock()