尝试使用mac的指纹识别来授权,但是似乎没有效果

This commit is contained in:
2026-07-09 11:27:40 +08:00
parent b52db70015
commit 9b1cb668b1
9 changed files with 441 additions and 6 deletions
+6
View File
@@ -98,6 +98,9 @@ func Run() {
log.L().Error("init i18n", "error", err)
}
// Set the localized Touch ID prompt for keychain access (macOS).
setTouchIDPromptFromI18n()
a := &App{
fyneApp: app.NewWithID(paths.BundleID),
db: store,
@@ -358,6 +361,9 @@ func (a *App) changeLanguage(lang string) {
// Switch the active localizer.
i18n.SetLanguage(lang)
// Update the Touch ID prompt text for the new language.
setTouchIDPromptFromI18n()
// Rebuild everything that holds cached strings.
a.rebuildUI()
}
+14
View File
@@ -0,0 +1,14 @@
//go:build darwin
package ui
import (
"lmvpn/internal/i18n"
"lmvpn/internal/keychain"
)
// setTouchIDPromptFromI18n configures the localized Touch ID prompt
// text on the keychain store for the current language.
func setTouchIDPromptFromI18n() {
keychain.SetTouchIDPrompt(i18n.T("TouchIDPrompt"))
}
+7
View File
@@ -0,0 +1,7 @@
//go:build !darwin
package ui
// setTouchIDPromptFromI18n is a no-op on non-darwin platforms where
// Touch ID is not available.
func setTouchIDPromptFromI18n() {}
+13 -5
View File
@@ -3,12 +3,14 @@ package ui
import (
_ "embed"
"encoding/json"
"errors"
"fmt"
"net/url"
"time"
"lmvpn/internal/i18n"
"lmvpn/internal/ipc"
"lmvpn/internal/keychain"
"lmvpn/internal/model"
"lmvpn/internal/stats"
@@ -172,11 +174,17 @@ func (a *App) onConnect() {
password, err := a.kc.GetPassword(a.currentProfile.Name)
if err != nil {
fyne.Do(func() {
showError(i18n.T("DlgCredentialError"),
i18n.T("DlgCredentialErrorMsg"),
a.window)
a.stateLabel.SetText(i18n.T("StateDisconnected"))
a.setConnButtons(true, false)
if errors.Is(err, keychain.ErrUserCanceled) {
// User canceled the Touch ID / password prompt.
a.stateLabel.SetText(i18n.T("StateDisconnected"))
a.setConnButtons(true, false)
} else {
showError(i18n.T("DlgCredentialError"),
i18n.T("DlgCredentialErrorMsg"),
a.window)
a.stateLabel.SetText(i18n.T("StateDisconnected"))
a.setConnButtons(true, false)
}
})
return
}