Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
feat(settings): add legal links to desktop about page (#583)
jiangyunhan-hub8cf6667e22b8
diff --git a/apps/desktop/src/renderer/components/settings/AboutSection.tsx b/apps/desktop/src/renderer/components/settings/AboutSection.tsxindex 331e2009a8..2e261564da 100644--- a/apps/desktop/src/renderer/components/settings/AboutSection.tsx+++ b/apps/desktop/src/renderer/components/settings/AboutSection.tsx@@ -22,6 +22,7 @@ import { useAnalyticsSettings } from '@/hooks/useAnalyticsSettings';import { DefaultOverrideControls } from './DefaultOverrideControls';import { StorageManagementCard } from './StorageManagementCard';import { CURRENT_CINDY_REGION } from '../../../shared/brandRegion';+import { LEGAL_LINKS } from '../../../shared/legalLinks';interface AgentVersionState {loading: boolean;@@ -141,6 +142,8 @@ export function AboutSection() {<DebugLogToggleRow /><Divider /><OpenLogsRow />+ <Divider />+ <LegalLinksRows /></div>{/* 存储空间(媒体总仓占用 / 清理 / 体检) */}@@ -154,6 +157,61 @@ export function AboutSection() {);}+export function LegalLinksRows() {+ const { t } = useTranslation();++ return (+ <>+ <LegalLinkRow+ label={t('settings.about.legal.termsOfServiceLabel')}+ url={LEGAL_LINKS.termsOfService}+ />+ <Divider />+ <LegalLinkRow+ label={t('settings.about.legal.privacyPolicyLabel')}+ url={LEGAL_LINKS.privacyPolicy}+ />+ </>+ );+}++function LegalLinkRow({ label, url }: { label: string; url: string }) {+ const { t } = useTranslation();++ const handleOpen = async () => {+ try {+ const result = await window.electronAPI.openExternal(url);+ if (!result.success) {+ toast.error(t('settings.about.legal.openFailed'));+ }+ } catch {+ toast.error(t('settings.about.legal.openFailed'));+ }+ };++ return (+ <div className="flex items-center justify-between gap-3 px-[18px] py-4">+ <span className="select-none text-13 text-[var(--settings-section-sublabel)]">{label}</span>+ <button+ aria-label={t('settings.about.legal.viewDocument', { document: label })}+ className={cn(+ '-mr-1 flex select-none items-center gap-1.5 rounded-full px-6 py-2.5',+ 'text-12 font-medium text-[var(--settings-section-title)]',+ 'border border-[var(--settings-theme-card-border)]',+ 'transition-colors hover:bg-[var(--surface-hover)] active:scale-[0.98]',+ 'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--focus-ring-soft)]',+ )}+ onClick={() => void handleOpen()}+ title={url}+ type="button"+ >+ {t('settings.about.legal.viewDocument', { document: label })}+ <ExternalLink aria-hidden size={13} strokeWidth={1.7} />+ </button>+ </div>+ );+}+function SocialLinksPanel() {const { t } = useTranslation();diff --git a/apps/desktop/src/renderer/components/settings/__tests__/AboutSection.legalLinks.test.tsx b/apps/desktop/src/renderer/components/settings/__tests__/AboutSection.legalLinks.test.tsxnew file mode 100644index 0000000000..748618ed37--- /dev/null+++ b/apps/desktop/src/renderer/components/settings/__tests__/AboutSection.legalLinks.test.tsx@@ -0,0 +1,78 @@+// @vitest-environment jsdom++import { cleanup, fireEvent, render, screen, waitFor } from '@testing-library/react';+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';++import { LEGAL_LINKS } from '../../../../shared/legalLinks';++const toast = vi.hoisted(() => ({+ error: vi.fn(),+}));++vi.mock('react-i18next', () => ({+ useTranslation: () => ({+ t: (key: string, options?: { document?: string }) =>+ options?.document ? `${key}:${options.document}` : key,+ }),+}));++vi.mock('@/lib/toast', () => ({+ toast,+}));++import { LegalLinksRows } from '../AboutSection';++const openExternal = vi.fn();++describe('AboutSection legal links', () => {+ beforeEach(() => {+ vi.clearAllMocks();+ openExternal.mockResolvedValue({ success: true });+ (window as unknown as { electronAPI: unknown }).electronAPI = {+ openExternal,+ };+ });++ afterEach(() => cleanup());++ it('renders both legal documents and opens the region-selected URLs externally', async () => {+ render(<LegalLinksRows />);++ const termsButton = screen.getByRole('button', {+ name: 'settings.about.legal.viewDocument:settings.about.legal.termsOfServiceLabel',+ });+ expect(termsButton.textContent).toContain(+ 'settings.about.legal.viewDocument:settings.about.legal.termsOfServiceLabel',+ );+ expect(termsButton.className).toContain('px-6');+ expect(termsButton.className).toContain('py-2.5');++ fireEvent.click(termsButton);+ await waitFor(() => expect(openExternal).toHaveBeenCalledWith(LEGAL_LINKS.termsOfService));++ const privacyButton = screen.getByRole('button', {+ name: 'settings.about.legal.viewDocument:settings.about.legal.privacyPolicyLabel',+ });+ expect(privacyButton.textContent).toContain(+ 'settings.about.legal.viewDocument:settings.about.legal.privacyPolicyLabel',+ );++ fireEvent.click(privacyButton);+ await waitFor(() => expect(openExternal).toHaveBeenCalledWith(LEGAL_LINKS.privacyPolicy));+ });++ it('shows the localized failure message when the system browser cannot open a document', async () => {+ openExternal.mockResolvedValueOnce({ success: false });+ render(<LegalLinksRows />);++ fireEvent.click(+ screen.getByRole('button', {+ name: 'settings.about.legal.viewDocument:settings.about.legal.privacyPolicyLabel',+ }),+ );++ await waitFor(() =>+ expect(toast.error).toHaveBeenCalledWith('settings.about.legal.openFailed'),+ );+ });+});diff --git a/apps/desktop/src/renderer/i18n/locales/en/common.json b/apps/desktop/src/renderer/i18n/locales/en/common.jsonindex 1a966cd764..1509beff61 100644--- a/apps/desktop/src/renderer/i18n/locales/en/common.json+++ b/apps/desktop/src/renderer/i18n/locales/en/common.json@@ -654,6 +654,12 @@"analyticsSaveFailed": "Failed to save usage statistics settings","debugLogLabel": "Debug logs","debugLogDescription": "When enabled, emits verbose debug logs: main/maker logger raised to debug level; new Claude Code sessions also log API request URL/status/latency, Node-level DNS/TCP/TLS handshake timing, and SDK internals. Output is large — turn off after troubleshooting. Always on in dev mode.",+ "legal": {+ "termsOfServiceLabel": "Terms of Service",+ "privacyPolicyLabel": "Privacy Policy",+ "viewDocument": "View {{document}}",+ "openFailed": "Unable to open the document. Check your system browser settings."+ },"social": {"title": "Connect with Cindy","discordLabel": "Discord",diff --git a/apps/desktop/src/renderer/i18n/locales/ja/common.json b/apps/desktop/src/renderer/i18n/locales/ja/common.jsonindex 2eb2dcee5d..c9a97d9954 100644--- a/apps/desktop/src/renderer/i18n/locales/ja/common.json+++ b/apps/desktop/src/renderer/i18n/locales/ja/common.json@@ -654,6 +654,12 @@"analyticsSaveFailed": "利用統計の設定を保存できませんでした","debugLogLabel": "デバッグログ","debugLogDescription": "有効にすると詳細なデバッグログを出力します:main/maker logger が debug レベルになり、新しい Claude Code セッションは API リクエスト URL/ステータス/レイテンシ、Node レベルの DNS/TCP/TLS ハンドシェイクのタイミング、SDK 内部情報も出力します。ログ量が大きいため、調査が終わったらオフにしてください。dev モードでは常に有効です。",+ "legal": {+ "termsOfServiceLabel": "利用規約",+ "privacyPolicyLabel": "プライバシーポリシー",+ "viewDocument": "{{document}}を表示",+ "openFailed": "文書を開けませんでした。システムのブラウザー設定を確認してください"+ },"social": {"title": "Cindy とつながる","discordLabel": "Discord",diff --git a/apps/desktop/src/renderer/i18n/locales/ko/common.json b/apps/desktop/src/renderer/i18n/locales/ko/common.jsonindex 5e1507b505..ffde6bbb31 100644--- a/apps/desktop/src/renderer/i18n/locales/ko/common.json+++ b/apps/desktop/src/renderer/i18n/locales/ko/common.json@@ -654,6 +654,12 @@"analyticsSaveFailed": "사용 통계 설정을 저장하지 못했습니다","debugLogLabel": "디버그 로그","debugLogDescription": "활성화하면 전체 디버그 로그를 출력합니다: main/maker logger가 debug 레벨로 올라가며, 새 Claude Code 세션은 API 요청 URL/상태/지연 시간, Node 레벨 DNS/TCP/TLS 핸드셰이크 타이밍 및 SDK 내부 정보도 출력합니다. 로그 양이 많으므로 문제 해결 후에는 꺼주세요. dev 모드에서는 항상 켜져 있습니다.",+ "legal": {+ "termsOfServiceLabel": "서비스 이용약관",+ "privacyPolicyLabel": "개인정보 처리방침",+ "viewDocument": "{{document}} 보기",+ "openFailed": "문서를 열 수 없습니다. 시스템 브라우저 설정을 확인해 주세요"+ },"social": {"title": "Cindy와 연결하기","discordLabel": "Discord",diff --git a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.jsonindex f1072777e5..092e004c05 100644--- a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json+++ b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json@@ -654,6 +654,12 @@"analyticsSaveFailed": "保存使用统计设置失败","debugLogLabel": "Debug 日志","debugLogDescription": "开启后输出全量调试日志:main/maker logger 抬到 debug 级,新建的 Claude Code 会话额外输出 API 请求 URL/状态/耗时、Node 层 DNS/TCP/TLS 握手时序,以及 SDK 内部信息。日志量较大,定位问题后请关闭。dev 模式下始终开启。",+ "legal": {+ "termsOfServiceLabel": "服务条款",+ "privacyPolicyLabel": "隐私协议",+ "viewDocument": "查看{{document}}",+ "openFailed": "无法打开文档,请检查系统浏览器设置"+ },"social": {"title": "和 Cindy 联系","discordLabel": "Discord",