feat(密钥设置): 掩码框加眼睛核对,且按键隔离

用户点名:青果 Authpwd 是 •••••••• 且没有任何查看手段,填错只能靠猜。抽
useSecretVisibility(单槽)与 useKeyedSecretVisibility(循环卡用),眼睛按钮件沿用
登录页那对 svg 命名——登录页的 inline 是第一遍抄,这是第二遍,之后只改一处。

按键隔离不是细节:外观专利与货源查询共用同一段循环模板,共用一个布尔会变成
"我核对我手里这把"顺手把用户没打算看的另一把也摊在屏幕上。

射程按用户拍板"一起补":Authpwd、jikip 套餐 key、两张 LLM 密钥卡;弹窗外的
Aliprice 密码不在本面板、未动。三条红线:默认掩码、状态不落 localStorage 不进日志
上报、保存成功/重读配置/切供应商/卸载四处一律收回掩码。

判据:tests/密钥显隐状态机.test.ts 8 支(含"面板里不许再出现没挂眼睛的裸密码框"
这条防复发的尺子)+ tests/mount/密钥面板authpwd显隐.mount.test.ts 6 支。
本面 node --test 994/994、vitest 9 文件 55 例、vue-tsc rc=0。
This commit is contained in:
2026-11-02 16:19:32 +08:00
parent 7e64c12dd6
commit 2cbd99ed4f
6 changed files with 647 additions and 29 deletions
@@ -42,16 +42,23 @@
<div class="secret-field">
<label class="field-label" :for="`secret-input-${module.moduleKey}`">接口密钥</label>
<input
:id="`secret-input-${module.moduleKey}`"
v-model="moduleStates[module.moduleKey].input"
class="secret-input"
type="password"
:placeholder="placeholderOf(module.moduleKey)"
autocomplete="off"
spellcheck="false"
:disabled="busy"
/>
<div class="password-field">
<input
:id="`secret-input-${module.moduleKey}`"
v-model="moduleStates[module.moduleKey].input"
class="secret-input"
:type="llmVisibility.inputTypeOf(module.moduleKey)"
:placeholder="placeholderOf(module.moduleKey)"
autocomplete="off"
spellcheck="false"
:disabled="busy"
/>
<SecretVisibilityToggle
:visible="llmVisibility.visibleOf(module.moduleKey)"
:disabled="busy"
@toggle="llmVisibility.toggle(module.moduleKey)"
/>
</div>
</div>
<div v-if="channelSwitchNeedsValue(module.moduleKey)" class="inline-warn">
@@ -136,21 +143,29 @@
:disabled="busy || proxyLocked"
@input="proxyDirty = true"
/>
<input
v-model="proxyPassword"
class="secret-input"
type="password"
placeholder="Authpwd"
autocomplete="off"
spellcheck="false"
:disabled="busy || proxyLocked"
@input="proxyDirty = true"
/>
<div class="password-field">
<input
v-model="proxyPassword"
class="secret-input"
:type="proxyPasswordType"
placeholder="Authpwd"
autocomplete="off"
spellcheck="false"
:disabled="busy || proxyLocked"
@input="proxyDirty = true"
/>
<SecretVisibilityToggle
:visible="proxyPasswordVisible"
:disabled="busy || proxyLocked"
@toggle="toggleProxyPasswordVisibility"
/>
</div>
</div>
<div class="proxy-plan-hint">
青果没有可填的提取链接:保存时用 Authkey / Authpwd 自动拼出
<code>overseas.proxy.qg.net/get?key=…&amp;format=json</code>(Basic 认证也带在同一条链接里),
本地与后台密钥各存一份。服务端的商标检测用的就是这条链接,不填账密它会按「未配置代理」拦下任务。
Authpwd 默认掩码,点输入框右侧的眼睛可核对;保存成功后自动回到掩码。
</div>
</div>
@@ -178,15 +193,22 @@
/>
</div>
<div class="proxy-plan-row proxy-plan-row--single">
<input
v-model="proxyPlanKey"
class="secret-input"
type="password"
:placeholder="proxyPlanKeyPlaceholder"
autocomplete="off"
spellcheck="false"
:disabled="proxyPlanLoading || proxyPlanSaving"
/>
<div class="password-field">
<input
v-model="proxyPlanKey"
class="secret-input"
:type="planKeyType"
:placeholder="proxyPlanKeyPlaceholder"
autocomplete="off"
spellcheck="false"
:disabled="proxyPlanLoading || proxyPlanSaving"
/>
<SecretVisibilityToggle
:visible="planKeyVisible"
:disabled="proxyPlanLoading || proxyPlanSaving"
@toggle="togglePlanKeyVisibility"
/>
</div>
</div>
<div class="secret-actions">
<button
@@ -285,6 +307,8 @@ import {
userProxyPatch,
} from '@/shared/utils/api-secret-proxy-config'
import { useProxyBalance, useProxyPlan } from '@/shared/composables/useProxyPlan'
import { useKeyedSecretVisibility, useSecretVisibility } from '@/shared/composables/useSecretVisibility'
import SecretVisibilityToggle from '@/shared/components/SecretVisibilityToggle.vue'
import { createModuleView, proxyCheckPresentation, type ModuleState } from '@/shared/utils/api-secret-module-view'
const props = withDefaults(
@@ -322,6 +346,32 @@ const proxyProvider = ref<ProxyProviderKey>(DEFAULT_PROXY_PROVIDER)
/** 青果隧道端点的代理账密(Authkey/Authpwd):只存本机 app.json,不上报服务端。 */
const proxyAccount = ref('')
const proxyPassword = ref('')
/**
* 面板里每一把"掩码输入"的显隐,同一个出处(2026-11-02 用户点名:填错了看不见,只能靠猜)。
* 眼睛只切自己那一格的 type;状态不落 localStorage、不进日志与上报,
* 重新读取本机配置 / 切供应商 / 保存成功 / 组件卸载全部回到掩码(与「保存成功即清空输入」同一口径)。
*
* LLM 那两把(外观专利/货源查询)共用同一段循环模板 ⇒ 必须按键隔离,
* 否则点一张卡的眼睛会把另一张也摊成明文。
*/
const {
visible: proxyPasswordVisible,
inputType: proxyPasswordType,
toggle: toggleProxyPasswordVisibility,
reset: resetProxyPasswordVisibility,
} = useSecretVisibility()
const {
visible: planKeyVisible,
inputType: planKeyType,
toggle: togglePlanKeyVisibility,
reset: resetPlanKeyVisibility,
} = useSecretVisibility()
const llmVisibility = useKeyedSecretVisibility()
function resetSecretVisibility() {
resetProxyPasswordVisibility()
resetPlanKeyVisibility()
llmVisibility.resetAll()
}
const proxyLoading = ref(false)
const proxyLoadFailed = ref(false)
const proxyReady = ref(false)
@@ -396,6 +446,8 @@ function selectProxyProvider(provider: ProxyProviderKey) {
proxyDirty.value = true
proxyCheckResult.value = null
proxyCheckError.value = ''
// 换的是「哪一家的账密」,明文状态没有理由跟着走过去
resetSecretVisibility()
}
@@ -532,6 +584,8 @@ async function loadProxyConfig() {
proxyLoadFailed.value = false
proxyReady.value = false
proxyDirty.value = false
// 每次重新读取本机配置=换号或重开弹窗:读到的可能就是另一个账号的 Authpwd,不许还亮着明文
resetSecretVisibility()
const api = getPywebviewApi()
proxySupported.value = Boolean(api?.read_config && api?.save_config)
@@ -652,6 +706,9 @@ async function saveAll(options: { requireAll?: boolean } = {}): Promise<boolean>
}
// 保存后不再自动检测:检测一律由用户手动点击「检测」触发
// 保存成功=账密已落到本机与服务端,界面没有理由还把 Authpwd 亮着明文;
// 失败分支不动(那时用户正需要核对填错在哪一位)。
resetSecretVisibility()
refreshSnapshots()
return true
} catch (error) {
@@ -696,6 +753,8 @@ onMounted(() => {
onUnmounted(() => {
if (unsubscribe) unsubscribe()
// 卸载即回到掩码:弹窗若是 v-show 留着复用,重载路径上不该还显示着上一个账号的明文
resetSecretVisibility()
})
defineExpose({ saveAll, reload })