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): simplify share image footer (#2181)

Dash9d19859ae31e
diff --git a/apps/desktop/src/renderer/__tests__/shareConversationImage.test.ts b/apps/desktop/src/renderer/__tests__/shareConversationImage.test.ts
index d879b3a42f..76ab8a48d6 100644
--- a/apps/desktop/src/renderer/__tests__/shareConversationImage.test.ts
+++ b/apps/desktop/src/renderer/__tests__/shareConversationImage.test.ts
@@ -23,7 +23,6 @@ const {
redactTextNodes,
stripCloneAnchors,
stripInteractiveElements,
- websiteHost,
} = await import('@/lib/shareConversationImage');
beforeEach(() => {
@@ -268,55 +267,35 @@ describe('queryShareableMessageIds', () => {
});
});
-describe('websiteHost', () => {
- it('取 host,去掉协议与路径', () => {
- expect(websiteHost('https://cindy.app')).toBe('cindy.app');
- expect(websiteHost('https://cindy.com.cn/download')).toBe('cindy.com.cn');
- });
-
- it('解析不了就原样返回,空值返回空串', () => {
- expect(websiteHost('not a url')).toBe('not a url');
- expect(websiteHost(undefined)).toBe('');
- });
-});
-
describe('buildShareImageFooter', () => {
- it('形象与 logo 横向锁定,网址在下一行', () => {
+ it('形象与 logo 横向锁定,不附加网址', () => {
const footer = buildShareImageFooter({
logoSrc: 'logo.png',
characterSrc: 'character.jpg',
- siteHost: 'cindy.app',
});
const imgs = Array.from(footer.querySelectorAll('img'));
expect(imgs.map((el) => el.getAttribute('src'))).toEqual(['character.jpg', 'logo.png']);
expect(imgs[0].parentElement).toBe(imgs[1].parentElement);
- expect(footer.textContent).toBe('cindy.app');
+ expect(footer.textContent).toBe('');
});
- it('角色图标小尺寸、圆角并弱化色彩', () => {
+ it('角色图标保持小尺寸、圆角与源素材颜色', () => {
const footer = buildShareImageFooter({
logoSrc: 'logo.png',
characterSrc: 'character.jpg',
- siteHost: 'cindy.app',
});
const character = footer.querySelector('img');
expect(character?.style.width).toBe('40px');
expect(character?.style.height).toBe('40px');
expect(character?.style.borderRadius).toBe('8px');
expect(character?.style.objectFit).toBe('cover');
- expect(character?.style.filter).toBe('saturate(0.72) contrast(0.94)');
- expect(character?.style.opacity).toBe('0.9');
+ expect(character?.style.filter).toBe('');
+ expect(character?.style.opacity).toBe('');
});
it('没有形象时只放 logo', () => {
- const footer = buildShareImageFooter({ logoSrc: 'logo.png', siteHost: 'cindy.app' });
+ const footer = buildShareImageFooter({ logoSrc: 'logo.png' });
const imgs = Array.from(footer.querySelectorAll('img'));
expect(imgs.map((el) => el.getAttribute('src'))).toEqual(['logo.png']);
});
-
- it('没有 host 时不渲染网址行', () => {
- const footer = buildShareImageFooter({ logoSrc: 'logo.png', siteHost: '' });
- expect(footer.querySelector('img')).not.toBeNull();
- expect(footer.textContent).toBe('');
- });
});
diff --git a/apps/desktop/src/renderer/components/chat/ShareSelectionBar.tsx b/apps/desktop/src/renderer/components/chat/ShareSelectionBar.tsx
index 8eb1f8dfd8..add36dd152 100644
--- a/apps/desktop/src/renderer/components/chat/ShareSelectionBar.tsx
+++ b/apps/desktop/src/renderer/components/chat/ShareSelectionBar.tsx
@@ -28,13 +28,11 @@ import {
SHARE_EXCLUDE_ATTR,
ShareImageSelectionNotMountedError,
ShareImageTooLargeError,
- shareSiteHostForRegion,
} from '@/lib/shareConversationImage';
import { toast } from '@/lib/toast';
import { cn } from '@/lib/utils';
import { useBrandLogo } from '@/hooks/useBrandLogo';
import shareCharacterSrc from '@/assets/cindy-share-character.jpg';
-import { CURRENT_CINDY_REGION } from '../../../shared/brandRegion';
import { shareSelectionStore, useShareSelectionCount } from './shareSelectionStore';
const log = createLogger('ShareSelectionBar');
@@ -100,7 +98,6 @@ export function ShareSelectionBar({ sessionId, contentWidth, barWidth }: ShareSe
contentWidth,
logoSrc,
characterSrc: shareCharacterSrc,
- siteHost: shareSiteHostForRegion(CURRENT_CINDY_REGION),
});
}, [contentWidth, logoSrc, sessionId]);
diff --git a/apps/desktop/src/renderer/lib/shareConversationImage.ts b/apps/desktop/src/renderer/lib/shareConversationImage.ts
index 814ba1eb78..a31269f91d 100644
--- a/apps/desktop/src/renderer/lib/shareConversationImage.ts
+++ b/apps/desktop/src/renderer/lib/shareConversationImage.ts
@@ -15,7 +15,6 @@
* 改写,不碰 DOM 结构。
*/
-import type { CindyRegion } from '@cindy/maker-shared/brand-identity';
import { redactSensitiveText } from '@cindy/maker-shared/error-redaction';
import { diffChars } from 'diff';
@@ -31,17 +30,6 @@ export const SHARE_MESSAGE_ATTR = 'data-share-message-id';
/** 打了这个标记的元素是纯交互件(操作栏、复选框、hover 工具栏),不进图。 */
export const SHARE_EXCLUDE_ATTR = 'data-share-exclude';
-/** 分享图片页脚使用的品牌域名。dev 的行为语义归 cn 系。 */
-export const SHARE_SITE_HOST_BY_REGION: Readonly<Record<CindyRegion, string>> = Object.freeze({
- cn: 'cindy.cn',
- dev: 'cindy.cn',
- global: 'cindy.app',
-});
-
-export function shareSiteHostForRegion(region: CindyRegion): string {
- return SHARE_SITE_HOST_BY_REGION[region];
-}
-
/**
* 克隆体里必须清掉的锚点属性:离屏容器挂在 document 内,这些 data 属性会让
* 全局 querySelector(PrevMessageJumpChip 的 data-user-msg-id、消息导航的
@@ -68,8 +56,6 @@ export interface BuildShareImageOptions {
logoSrc: string;
/** 页脚 Cindy 角色主视觉的 URL(打包资源,同源)。 */
characterSrc?: string;
- /** 页脚网址文字(host,如 cindy.app)。 */
- siteHost: string;
}
/** 找不到任何选中消息的 DOM 时抛这个 —— 调用方据此 toast。 */
@@ -392,23 +378,19 @@ export interface ShareImageFooterAssets {
logoSrc: string;
/** Cindy 角色主视觉;缺省时页脚只有 logo。 */
characterSrc?: string;
- /** 网址文字(host,如 cindy.app)。 */
- siteHost: string;
}
/**
- * 品牌页脚:角色图标与 logo 横向锁定,网址在下一行,整体居中。
- * 角色图标仅承担品牌识别,通过小尺寸和轻度降饱和避免抢正文。
+ * 品牌页脚:角色图标与 logo 横向锁定、整体居中。
+ * 角色图标直接保留源素材颜色,不额外调色。
*/
export function buildShareImageFooter({
logoSrc,
characterSrc,
- siteHost,
}: ShareImageFooterAssets): HTMLElement {
const footer = document.createElement('div');
footer.className = 'flex flex-col items-center';
footer.style.paddingTop = '48px';
- footer.style.gap = '6px';
const lockup = document.createElement('div');
lockup.className = 'flex items-center justify-center';
@@ -422,8 +404,6 @@ export function buildShareImageFooter({
character.style.width = `${FOOTER_CHARACTER_PX}px`;
character.style.borderRadius = '8px';
character.style.objectFit = 'cover';
- character.style.filter = 'saturate(0.72) contrast(0.94)';
- character.style.opacity = '0.9';
character.style.flexShrink = '0';
character.setAttribute('loading', 'eager');
lockup.appendChild(character);
@@ -437,27 +417,9 @@ export function buildShareImageFooter({
logo.setAttribute('loading', 'eager');
lockup.appendChild(logo);
footer.appendChild(lockup);
-
- if (siteHost) {
- const site = document.createElement('span');
- site.textContent = siteHost;
- site.style.fontSize = '11px';
- site.style.color = 'var(--text-tertiary)';
- footer.appendChild(site);
- }
return footer;
}
-/** `https://cindy.app/` → `cindy.app`;解析失败回落原串。 */
-export function websiteHost(websiteUrl: string | undefined): string {
- if (!websiteUrl) return '';
- try {
- return new URL(websiteUrl).host;
- } catch {
- return websiteUrl;
- }
-}
-
/**
* 生成分享图片。产物为 PNG Blob;出口(剪贴板 / 另存为)由调用方决定。
*/
@@ -467,7 +429,6 @@ export async function buildShareImageBlob({
contentWidth,
logoSrc,
characterSrc,
- siteHost,
}: BuildShareImageOptions): Promise<Blob> {
const sourceNodes: HTMLElement[] = [];
for (const clientId of orderedSelectedIds) {
@@ -561,7 +522,6 @@ export async function buildShareImageBlob({
buildShareImageFooter({
logoSrc: footerLogo,
...(footerCharacter ? { characterSrc: footerCharacter } : {}),
- siteHost,
}),
);
diff --git a/docs/design-rules/DESIGN.md b/docs/design-rules/DESIGN.md
index 2e1260d2b2..08b23557b2 100644
--- a/docs/design-rules/DESIGN.md
+++ b/docs/design-rules/DESIGN.md
@@ -1059,9 +1059,9 @@ The splash wordmark is a separate asset pair (`assets/splash/wordmark.png`, whit
**Sanctioned brand surface — conversation-share export footer (approved 2026-08-06).**
- **Where**: the footer of PNG images generated by `renderer/lib/shareConversationImage.ts` only. The live conversation, selection mode, message stream, composer, and other working-UI surfaces remain neutral and must not display the character artwork.
-- **Lockup**: one static 40×40px product-approved Cindy character crop (8px radius), followed by the active theme's 24px-high wordmark with an 8px gap; the regional host sits below in tertiary text (`cindy.cn` for `cn` / `dev`, `cindy.app` for `global`). The character stays deliberately quiet (`saturate(0.72) contrast(0.94)`, 0.9 opacity) so message content remains primary.
+- **Lockup**: one static 40×40px product-approved Cindy character crop (8px radius), followed by the active theme's 24px-high wordmark with an 8px gap. Do not append a website or regional host. The character keeps the source asset's original color and opacity without component-authored filtering.
- **Constraints**: no animation, shadow, decorative background, additional brand color, enlarged hero treatment, or alternate character composition. This approval identifies the source of an exported Cindy conversation; it is not precedent for adding mascots to cards, dialogs, tool output, or other share-adjacent UI.
-- **Theme boundary**: Light and Dark use their matching wordmark assets and semantic tertiary text. The same static character crop may be used in both modes because it is an exported brand asset, not a UI color surface.
+- **Theme boundary**: Light and Dark use their matching wordmark assets. The same static character crop may be used in both modes because it is an exported brand asset, not a UI color surface.
**Sanctioned brand surface — mobile download dialog (approved 2026-07-25).**