feat(web): token 数以 K 输入显示,已存凭证显示掩码占位(FIX-8)

- 新增 UnitInput 与 kind=tokens:上下文预算、单次 token 上限、自定义模型上下文窗口以 K 输入(允许小数),存储仍为原始 token 数;校验与提示用 K 表述;列表/详情 token 数统一 K/M 简写(formatTokens)
- 新增 SecretInput 与 kind=secret:已保存时显示「已设置 ••••••••」(有服务端掩码时带末 4 位),聚焦直接输入替换,留空保持,「清除」确认后保存生效;替换模型服务、TMDB、网页搜索、下载器、媒体服务器、浏览器服务、站点账号、Passkey、本机 Token 各处
- 统一只写凭证服务端语义:省略或空串 = 不变,null = 清除(contracts secretInput);下载器/媒体服务器新增清除;站点凭证同类更新可留空保持密码/Cookie/API Key/TOTP,TOTP 可 null 清除,不再误删 TOTP 与 UA
- contextBudget 最小值 4096→4000、contextWindow 1024→1000,便于按 K 填写
- 测试:换算与校验、SecretInput 渲染与状态、各接口留空不变/显式清除

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
rootandClaude Opus 5.5 committed 2026-09-30 00:10:46 +08:00
1 parent 68f53390f6
commit fa344a7184
39 files changed
+1175 -232

No files matched your search

+7 -4
View File
@@ -186,19 +186,22 @@ export type SiteHealthResult = z.infer<typeof SiteHealthResult>;
const CredLabel = z.string().min(1).max(80).default("default");
const CredSecret = z.string().min(1).max(16384);
/** 已有同类账号时可省略或留空 = 保持已存的值(只写凭证统一语义);新账号或换类型时必填 */
const CredSecretKeep = z.string().max(16384).optional();
const CredUa = z.string().min(1).max(500);
/**
* PUT /sites/{id}/credentials 新格式(按 kind 判别)。按 (siteId, label) 建立或更新账号;明文加密为 secret,不回显。
* 更新凭证:账号回到 unknown,关闭该站 site-auth / site-login 待处理。
* 同类账号更新时 password / cookie / apiKey 省略或空串 = 保持原值;totpSecret 省略或空串 = 保持,null = 清除。
*/
export const SiteCredentialsBody = z.discriminatedUnion("kind", [
z.object({
kind: z.literal("password"),
label: CredLabel,
username: z.string().min(1).max(200),
password: CredSecret,
password: CredSecretKeep,
/** TOTP 密钥(base32);表单有二次验证字段时自动填当前 6 位码 */
totpSecret: z.string().min(1).max(200).optional(),
totpSecret: z.string().max(200).nullable().optional(),
/** 只换 Cookie:登录成功后凭证类型落为 cookie,密码与 TOTP 丢弃 */
saveCookieOnly: z.boolean().optional(),
userAgent: CredUa.optional(),
@@ -207,11 +210,11 @@ export const SiteCredentialsBody = z.discriminatedUnion("kind", [
z.object({
kind: z.literal("cookie"),
label: CredLabel,
cookie: CredSecret,
cookie: CredSecretKeep,
userAgent: CredUa.optional(),
enabled: z.boolean().optional(),
}),
z.object({ kind: z.literal("api_key"), label: CredLabel, apiKey: CredSecret, enabled: z.boolean().optional() }),
z.object({ kind: z.literal("api_key"), label: CredLabel, apiKey: CredSecretKeep, enabled: z.boolean().optional() }),
/** passkey 附加到同账号(RSS / 下载用,不参与登录);账号不存在时新建 passkey 型账号 */
z.object({ kind: z.literal("passkey"), label: CredLabel, passkey: CredSecret, enabled: z.boolean().optional() }),
]);