Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

fix(desktop): 登录倒计时改次要档,分享图标单次描边,回调页纳入墨水守卫

kirozeng36f5b0e3b9a7
diff --git a/apps/desktop/src/renderer/components/login/LoginControls.tsx b/apps/desktop/src/renderer/components/login/LoginControls.tsx
index 3d0c28a2c7..c316b63234 100644
--- a/apps/desktop/src/renderer/components/login/LoginControls.tsx
+++ b/apps/desktop/src/renderer/components/login/LoginControls.tsx
@@ -670,7 +670,9 @@ export function LoginBackButton({
* Text_link(§4.7 状态表 + U-9 裁决):(70,238) 540×50 Regular 20 居中。
* - link:default #2A2828 underline(247:1612)/hover #4A4848(358:792,仅桌面)/
* pressed #1A1818(U-9,--login-link-pressed;underline·字号·字重不变);
- * - countdown/info 变体:#D4D4D4 无 underline 不可交互(247:1614);
+ * - countdown/info 变体:次要档(--login-secondary-text,2026-10-23 起;原 figma 247:1614
+ * 为 #D4D4D4,与占位同档只有 1.3~2.2:1,倒计时与「验证码已发送至 X」是要读的信息)
+ * 无 underline 不可交互;
* binding code 子态「验证码已发送至 X」提示复用本变体(demo bindingPanel)。
* 色变全走 CSS 类(hover:/active:),不改布局(design §2.3-1)。
*
@@ -708,7 +710,7 @@ export function LoginTextLink({
<span
data-testid={testId ?? 'login-text-link-countdown'}
className="absolute flex items-center justify-center overflow-hidden whitespace-nowrap"
- style={{ ...geometry, color: LOGIN_COLORS.controlPlaceholder, textOverflow: 'ellipsis' }}
+ style={{ ...geometry, color: LOGIN_COLORS.secondaryText, textOverflow: 'ellipsis' }}
>
{children}
</span>
@@ -1377,13 +1379,6 @@ function PersonIcon() {
function ShareIcon() {
return (
<svg width="100%" height="100%" viewBox="0 0 20 20" fill="none" aria-hidden>
- <path
- d="M12 1H19V8"
- stroke={LOGIN_COLORS.controlText}
- strokeWidth="2"
- strokeLinecap="round"
- strokeLinejoin="round"
- />
<path
d="M19 12.7368V17.5C19 18.3285 18.3285 19 17.5 19H2.5C1.67158 19 1 18.3285 1 17.5V2.5C1 1.67158 1.67158 1 2.5 1H7"
stroke={LOGIN_COLORS.controlText}
@@ -1391,8 +1386,10 @@ function ShareIcon() {
strokeLinecap="round"
strokeLinejoin="round"
/>
+ {/* 箭头的拐角与斜线尖端在右上角重叠:合成同一条 path,一次描边只上一次透明度;
+ 拆成两条 path 时,控件文字色是半透明墨水,交叠处会叠出深点(浅色)/亮点(深色)。 */}
<path
- d="M10.8999 9.09995L18.5499 1.44995"
+ d="M12 1H19V8M10.8999 9.09995L18.5499 1.44995"
stroke={LOGIN_COLORS.controlText}
strokeWidth="2"
strokeLinecap="round"
diff --git a/apps/desktop/src/renderer/components/login/__tests__/LoginPage.pr2a.harness.test.tsx b/apps/desktop/src/renderer/components/login/__tests__/LoginPage.pr2a.harness.test.tsx
index 0863476c2f..b3871b5b92 100644
--- a/apps/desktop/src/renderer/components/login/__tests__/LoginPage.pr2a.harness.test.tsx
+++ b/apps/desktop/src/renderer/components/login/__tests__/LoginPage.pr2a.harness.test.tsx
@@ -177,7 +177,7 @@ describe('method-choice', () => {
const hint = screen.getByTestId('login-sso-required-hint');
expect(hint.textContent).toBe('login.ssoRequired');
expect(hint.style.top).toBe('380px');
- expect(hint.getAttribute('style')).toContain('var(--login-control-placeholder)');
+ expect(hint.getAttribute('style')).toContain('var(--login-secondary-text)');
expect(screen.queryByTestId('login-method-personal')).toBeNull();
});
});
@@ -209,10 +209,10 @@ describe('verification-code', () => {
expect((screen.getByTestId('login-input') as HTMLInputElement).value).toBe('');
expect(screen.getByText('login.signIn').closest('button')?.disabled).toBe(true);
- // 倒计时首帧 60(247:1614 样式:placeholder 色无 underline 不可交互)
+ // 倒计时首帧 60(247:1614 样式:次要档、无 underline、不可交互)
const countdown = screen.getByTestId('login-resend-countdown');
expect(countdown.textContent).toBe('login.resendCountdown#60');
- expect(countdown.getAttribute('style')).toContain('var(--login-control-placeholder)');
+ expect(countdown.getAttribute('style')).toContain('var(--login-secondary-text)');
expect(countdown.className).not.toContain('underline');
// tick 后逐秒重算;到 0 切重发链接
act(() => vi.advanceTimersByTime(1_000));
@@ -381,7 +381,7 @@ describe('binding', () => {
expect(screen.getByText('login.binding.emailTitle')).toBeTruthy();
const sentTo = screen.getByTestId('login-binding-sent-to');
expect(sentTo.textContent).toBe('login.codeSentTo#[email protected]');
- expect(sentTo.getAttribute('style')).toContain('var(--login-control-placeholder)');
+ expect(sentTo.getAttribute('style')).toContain('var(--login-secondary-text)');
expect(screen.queryByTestId('login-resend-link')).toBeNull();
const button = screen.getByText('login.completeSignIn').closest('button') as HTMLButtonElement;
expect(button.disabled).toBe(true);
diff --git a/apps/desktop/src/renderer/themes/__tests__/loginInkLadder.test.ts b/apps/desktop/src/renderer/themes/__tests__/loginInkLadder.test.ts
index 3edfc79440..ff3481f3f6 100644
--- a/apps/desktop/src/renderer/themes/__tests__/loginInkLadder.test.ts
+++ b/apps/desktop/src/renderer/themes/__tests__/loginInkLadder.test.ts
@@ -2,6 +2,7 @@ import { describe, expect, it } from 'vitest';
import { cindyDark } from '../builtin/cindy-dark';
import { cindyLight } from '../builtin/cindy-light';
+import { renderOAuthResultPage } from '../../../main/oauthResultPage';
import { colorRegistry } from '../color-registry';
import '../colors';
@@ -33,3 +34,66 @@ describe('登录页文字档 = 主界面墨水阶梯', () => {
});
}
});
+
+/**
+ * 浏览器登录回调页(`oauthResultPage.ts`)在系统浏览器里打开,拿不到 renderer 的 token,
+ * 颜色以内联 CSS 变量写在三段规则里:浅色、强制深色(`data-theme="dark"`)、系统深色回退
+ * (`prefers-color-scheme: dark` 且未指定主题)。只比较注册 token 会漏掉这里,
+ * 所以直接解析生成的页面。标题 = 正文档,正文 = 次要档,错误码细节 = 三级档。
+ */
+const CALLBACK_VARS: ReadonlyArray<readonly [cssVar: string, inkTierId: string]> = [
+ ['--title', 'text-primary'],
+ ['--body', 'text-secondary'],
+ ['--detail', 'text-tertiary'],
+];
+
+function normalizeRgba(value: string): string {
+ const match = /^rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*([\d.]+)\s*\)$/.exec(value.trim());
+ if (!match) throw new Error(`不是 rgba 墨水色: ${value}`);
+ return `${match[1]},${match[2]},${match[3]},${Number(match[4])}`;
+}
+
+function callbackPageVars(theme: 'light' | 'dark' | undefined) {
+ const html = renderOAuthResultPage({
+ htmlLang: 'zh-CN',
+ theme,
+ pageKind: 'desktop-login',
+ copyKind: 'login.browserCallback',
+ variant: 'error',
+ title: 'title',
+ body: 'body',
+ detail: 'STATE_MISMATCH',
+ action: { href: 'cindy://login', label: 'back' },
+ });
+ const block = (pattern: RegExp) => {
+ const body = pattern.exec(html)?.[1];
+ if (body === undefined) throw new Error(`回调页缺少 CSS 规则: ${pattern}`);
+ return Object.fromEntries(
+ body
+ .split(';')
+ .map((declaration) => declaration.split(/:(.+)/))
+ .filter(([name, value]) => name?.startsWith('--') && value)
+ .map(([name, value]) => [name, value]),
+ ) as Record<string, string>;
+ };
+ return {
+ light: block(/:root\{([^}]*)\}/),
+ dark: block(/:root\[data-theme="dark"\]\{([^}]*)\}/),
+ systemDark: block(/@media\(prefers-color-scheme:dark\)\{:root:not\(\[data-theme\]\)\{([^}]*)\}/),
+ };
+}
+
+describe('浏览器登录回调页文字 = 主界面墨水阶梯', () => {
+ const vars = callbackPageVars(undefined);
+ for (const [rule, theme] of [
+ ['light', cindyLight],
+ ['dark', cindyDark],
+ ['systemDark', cindyDark],
+ ] as const) {
+ it.each(CALLBACK_VARS)(`${rule}: %s 与 %s 同值`, (cssVar, inkTierId) => {
+ const ink = theme.colors[inkTierId];
+ expect(vars[rule][cssVar], `${rule} 规则缺少 ${cssVar}`).toBeDefined();
+ expect(normalizeRgba(vars[rule][cssVar])).toBe(normalizeRgba(ink));
+ });
+ }
+});
diff --git a/apps/desktop/src/renderer/themes/colors.ts b/apps/desktop/src/renderer/themes/colors.ts
index 93fc419b39..20a6ace653 100644
--- a/apps/desktop/src/renderer/themes/colors.ts
+++ b/apps/desktop/src/renderer/themes/colors.ts
@@ -2485,7 +2485,7 @@ registerColor('login-control-border', GENERATED_DEFAULTS["login-control-border"]
registerColor('login-control-border-active', GENERATED_DEFAULTS["login-control-border-active"], 'Login — 控件 focus/filled 描边(亮色 #2A2828 / 暗色 #EEEEEE 反相)');
registerColor('login-control-border-disabled', GENERATED_DEFAULTS["login-control-border-disabled"], 'Login — disabled 控件描边(两模式同构,§16.5 disabled 特例)');
registerColor('login-control-text', GENERATED_DEFAULTS["login-control-text"], 'Login — 控件已填文本(墨水正文档 黑 88% / 白 82%)');
-registerColor('login-control-placeholder', GENERATED_DEFAULTS["login-control-placeholder"], 'Login — 控件 placeholder/countdown(墨水占位档 黑 32% / 白 30%)');
+registerColor('login-control-placeholder', GENERATED_DEFAULTS["login-control-placeholder"], 'Login — 控件 placeholder(墨水占位档 黑 32% / 白 30%);倒计时与提示文本走 login-secondary-text');
registerColor('login-title-text', GENERATED_DEFAULTS["login-title-text"], 'Login — 面板标题 32 Bold(墨水正文档 黑 88% / 白 82%)');
registerColor('login-secondary-text', GENERATED_DEFAULTS["login-secondary-text"], 'Login — 副标题/说明文字(墨水次要档 黑 56% / 白 55%)');
registerColor('login-primary-button-bg', GENERATED_DEFAULTS["login-primary-button-bg"], 'Login — 主按钮/第三方圆钮底(亮色深 #2A2828 / 暗色白 #EEEEEE 反相;社交圆图标保品牌色)');
diff --git a/docs/product-rules/region-and-editions.md b/docs/product-rules/region-and-editions.md
index d0e0c7229b..48794698fd 100644
--- a/docs/product-rules/region-and-editions.md
+++ b/docs/product-rules/region-and-editions.md
@@ -126,7 +126,7 @@ Cindy 是一个面向全球的产品。中国大陆版是它为当地法规、
| 项 | 现状 | 冲突条款 | 收敛难点 |
| --- | --- | --- | --- |
-| 登录页区域徽标 | 原设计规范规定国际区在标题旁显示红色 `Global` pill、中国大陆版不标。规范散落三处:`docs/design-rules/DESIGN.md` §16.1、`docs/design-rules/figma-component-spec.md` §4.10(2026-10-23 已移除)、`docs/design-rules/token-decision-table.md`(§3 的 `#df0c27` 语义与 `login-global-badge-bg` token)。落码在 `apps/desktop/src/renderer/components/login/LoginControls.tsx` 的 `LoginTitleBlock`(`LoginPage.tsx` 只负责传入) | §2.3 | **正在收敛**:PR #554 已将徽标翻转为 global 不标、`cn` / `dev` 标注,并同步修订 `DESIGN.md`。但它只改了三份设计源中的一份——`figma-component-spec.md` §4.10 与 `token-decision-table.md` 仍规定 `Global` pill 可见。**本行的删除条件是实现与三份设计源全部收敛,而不是 #554 单独合并** |
+| 登录页区域徽标 | 原设计规范规定国际区在标题旁显示红色 `Global` pill、中国大陆版不标。规范原散落三处:`docs/design-rules/DESIGN.md` §16.1、`docs/design-rules/figma-component-spec.md` §4.10、`docs/design-rules/token-decision-table.md`(§3 的 `#df0c27` 语义与 `login-global-badge-bg` token);其中 `figma-component-spec.md` 已于 2026-10-23 随该文档移除,不再是设计源。落码在 `apps/desktop/src/renderer/components/login/LoginControls.tsx` 的 `LoginTitleBlock`(`LoginPage.tsx` 只负责传入) | §2.3 | **正在收敛**:PR #554 已将徽标翻转为 global 不标、`cn` / `dev` 标注,并同步修订 `DESIGN.md`。但它只改了现存两份设计源中的一份——`token-decision-table.md` 仍规定 `Global` pill 可见。**本行的删除条件是实现与剩余设计源(`DESIGN.md`、`token-decision-table.md`)全部收敛,而不是 #554 单独合并** |
| 侧栏与移动端的区域标签 | 桌面侧栏 `apps/desktop/src/renderer/components/sidebar/UserInfoSection.tsx` 的 **§2.3 部分已收敛**:区域代号统一走 `apps/desktop/src/shared/regionCode.ts` 的 `CINDY_REGION_CODE`(cn → `CN`、dev → `Dev`、global 为 `null` 不标),Global 构建的版本行只剩版本号。**§2.5 部分未收敛**:cn 构建仍渲染代号 `CN`,不是本文规定的 `Mainland China`。`apps/mobile/src/settings/mobileSettings.ts:124` 的 debug 项两条都未收敛,仍输出 `Global` / `CN` | §2.5(桌面);§2.3、§2.5(移动端) | 属于调试 / 身份自查信息而非产品叙事表达,收敛优先级低于登录页。**`CN` → `Mainland China` 是待产品裁决项**,不是单纯落码:术语表把 `CN` / `Dev` 登记为 `proposed`(`i18n/GLOSSARY.md` region-code-cn / region-code-dev),且 `DESIGN.md` §16.3 现规定徽标值就是四语同文的区域代号——改判要同时动设计规范、术语表与三条消费链路(登录页徽标、侧栏版本行、issue 正文)。本行的删除条件是移动端补上 §2.3、且 `CN` 措辞冲突被裁决或重新归类 |
| 端点清单文件名 | `config/endpoint.json` 是中国大陆版,`config/endpoint.global.json` 才是 Global | §2.1 | 改名牵动构建脚本与发布链路 |
| Electron userData 目录名 | `cn` 为 `Cindy`、`global` 为 `CindyGlobal` | §2.1 | 已发布客户端的数据目录不能直接改名,需要迁移方案 |