From 85a65398d046b51b501ee9c28ba3e9ee28123010 Mon Sep 17 00:00:00 2001 From: Zhe Li Date: Sat, 16 Mar 2024 15:48:44 +0800 Subject: [PATCH] hide codes --- _locales/en/messages.json | 4 ++++ src/components/Popup/EntryComponent.vue | 4 +++- src/components/Popup/PreferencesPage.vue | 9 +++++++++ src/definitions/module-interface.d.ts | 1 + src/store/Menu.ts | 5 +++++ 5 files changed, 22 insertions(+), 1 deletion(-) diff --git a/_locales/en/messages.json b/_locales/en/messages.json index 03166ce27..186abf0e2 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -511,5 +511,9 @@ }, "permission_unknown_permission": { "message": "Unknown permission. If see this message, please send a bug report." + }, + "hide_codes": { + "message": "Hide codes", + "description": "Hide codes and show stars in popup. Users need to click the account to copy the code." } } diff --git a/src/components/Popup/EntryComponent.vue b/src/components/Popup/EntryComponent.vue index 904feeae5..ffc09dcb1 100644 --- a/src/components/Popup/EntryComponent.vue +++ b/src/components/Popup/EntryComponent.vue @@ -106,7 +106,7 @@ const computedPrototype = [ "encryption", ]), mapState("style", ["style"]), - mapState("menu", ["theme"]), + mapState("menu", ["theme", "hideCodes"]), ]; let computed = {}; @@ -142,6 +142,8 @@ export default Vue.extend({ return this.i18n.encrypted; } else if (code === CodeState.Invalid) { return this.i18n.invalid; + } else if (this.$store.state.menu.hideCodes) { + return code.replace(/\w/g, "*"); } else { return code; } diff --git a/src/components/Popup/PreferencesPage.vue b/src/components/Popup/PreferencesPage.vue index 7926e33b4..9db7ea5be 100644 --- a/src/components/Popup/PreferencesPage.vue +++ b/src/components/Popup/PreferencesPage.vue @@ -37,6 +37,7 @@ @change="migrateStorage()" /> + ( "passwordPolicyHint" ), + hideCodes: localStorage.hideCodes === "true", }, mutations: { setZoom: (state: MenuState, zoom: number) => { @@ -56,6 +57,10 @@ export class Menu implements Module { state.autolock = autolock; localStorage.autolock = autolock; }, + setHideCoes(state: MenuState, hideCodes: boolean) { + state.hideCodes = hideCodes; + localStorage.hideCodes = hideCodes; + }, }, namespaced: true, };