From 927e16d8617bd015c9e1dc30aaeb4c0c96d07298 Mon Sep 17 00:00:00 2001 From: john Date: Sat, 4 Jul 2026 14:32:36 +0800 Subject: [PATCH] fix(brand): force visible platform-brand footer on published pages MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Inject serve-time CSS so author styles cannot hide TKMind · 智趣 with low opacity, which made pages like weather.html look brandless. Co-authored-by: Cursor --- mindspace-page-tag.mjs | 28 ++++++++++++++++++++++++++++ mindspace-page-tag.test.mjs | 11 +++++++++++ mindspace-public-delivery.mjs | 4 ++-- skills/static-page-publish/SKILL.md | 2 +- wechat/prompts/page-generate.mjs | 2 +- 5 files changed, 43 insertions(+), 4 deletions(-) diff --git a/mindspace-page-tag.mjs b/mindspace-page-tag.mjs index e3cc082..721772a 100644 --- a/mindspace-page-tag.mjs +++ b/mindspace-page-tag.mjs @@ -1,6 +1,20 @@ export const MINDSPACE_PAGE_TAG_ATTR = 'data-mindspace-page-tag'; export const MINDSPACE_PAGE_TAG_PLATFORM_BRAND = 'platform-brand'; export const PLATFORM_BRAND_TEXT = 'TKMind · 智趣'; +export const PLATFORM_BRAND_STYLE_ID = 'mindspace-platform-brand-style'; + +const PLATFORM_BRAND_VISIBILITY_STYLE = ``; const PLATFORM_BRAND_INNER_RE = /(?:TKMind\s*·\s*智趣|contact@tkmind\.(?:ai|cn)|📧[^<]*tkmind)/i; const SIMPLE_BRAND_ELEMENT_RE = @@ -49,6 +63,20 @@ export function ensurePlatformBrandFooter(html) { return `${normalized}\n${footer}`; } +/** Override author CSS that hides the platform brand line (e.g. opacity 0.25). */ +export function injectPlatformBrandVisibilityStyle(html) { + const source = String(html ?? ''); + if (!hasPlatformBrandMarker(source) || source.includes(PLATFORM_BRAND_STYLE_ID)) return source; + if (/<\/head>/i.test(source)) { + return source.replace(/<\/head>/i, `${PLATFORM_BRAND_VISIBILITY_STYLE}\n`); + } + return `${PLATFORM_BRAND_VISIBILITY_STYLE}${source}`; +} + +export function preparePublishedPlatformBrand(html) { + return injectPlatformBrandVisibilityStyle(ensurePlatformBrandFooter(html)); +} + export function prepareHtmlPageBrandMarkers(html) { return ensurePlatformBrandPageTags(html); } diff --git a/mindspace-page-tag.test.mjs b/mindspace-page-tag.test.mjs index c45461e..d69cbe8 100644 --- a/mindspace-page-tag.test.mjs +++ b/mindspace-page-tag.test.mjs @@ -5,7 +5,9 @@ import { MINDSPACE_PAGE_TAG_PLATFORM_BRAND, ensurePlatformBrandFooter, ensurePlatformBrandPageTags, + injectPlatformBrandVisibilityStyle, normalizePlatformBrandHtml, + PLATFORM_BRAND_STYLE_ID, prepareHtmlPageBrandMarkers, } from './mindspace-page-tag.mjs'; @@ -30,6 +32,15 @@ test('prepareHtmlPageBrandMarkers keeps existing marker', () => { assert.equal(result.match(new RegExp(MINDSPACE_PAGE_TAG_ATTR, 'g'))?.length, 1); }); +test('injectPlatformBrandVisibilityStyle adds readable brand css', () => { + const html = + '' + + `

TKMind · 智趣

`; + const result = injectPlatformBrandVisibilityStyle(html); + assert.match(result, new RegExp(`id="${PLATFORM_BRAND_STYLE_ID}"`)); + assert.match(result, /opacity:\s*1 !important/); +}); + test('ensurePlatformBrandFooter appends brand line when marker is missing', () => { const html = '
content
'; const result = ensurePlatformBrandFooter(html); diff --git a/mindspace-public-delivery.mjs b/mindspace-public-delivery.mjs index 5f585e7..9566ffd 100644 --- a/mindspace-public-delivery.mjs +++ b/mindspace-public-delivery.mjs @@ -1,7 +1,7 @@ import crypto from 'node:crypto'; import fs from 'node:fs'; import path from 'node:path'; -import { ensurePlatformBrandFooter } from './mindspace-page-tag.mjs'; +import { preparePublishedPlatformBrand } from './mindspace-page-tag.mjs'; const INLINE_SCRIPT_PATTERN = /]*\bsrc\b)[^>]*>([\s\S]*?)<\/script>/gi; @@ -68,7 +68,7 @@ export function decorateMindSpacePublishedHtml({ } try { - nextHtml = ensurePlatformBrandFooter(nextHtml); + nextHtml = preparePublishedPlatformBrand(nextHtml); nextHtml = injectOgTags(nextHtml, { origin: context.origin, pageUrl: context.pageUrl, diff --git a/skills/static-page-publish/SKILL.md b/skills/static-page-publish/SKILL.md index ec3f63c..3cb9029 100644 --- a/skills/static-page-publish/SKILL.md +++ b/skills/static-page-publish/SKILL.md @@ -102,7 +102,7 @@ description: 在专属 MindSpace 目录生成可公开访问的静态 HTML 报

TKMind · 智趣

``` -带 `data-mindspace-page-tag` 的区域为平台固定信息:用户在编辑模式中不可见、不可改;预览与发布后正常显示。 +带 `data-mindspace-page-tag` 的区域为平台固定信息:用户在编辑模式中不可见、不可改;预览与发布后正常显示。**禁止**把该行 CSS 透明度设过低(如 `opacity: 0.25`),否则页内看不见品牌。 ## 按需附带文件下载(Word / PDF) diff --git a/wechat/prompts/page-generate.mjs b/wechat/prompts/page-generate.mjs index 9436931..55006f0 100644 --- a/wechat/prompts/page-generate.mjs +++ b/wechat/prompts/page-generate.mjs @@ -28,7 +28,7 @@ export function buildPageGenerateAgentPrompt(intent, { wantsDocx = false } = {}) ' - ``', ' - ``', ' tag/accent/subtitle 必须与页面主题一致;有 hero 图时 cover 指向同目录 raster 图(jpg/png)。', - '6. 页脚加 `

TKMind · 智趣

`(必须,禁止省略或用邮箱/tkmind.ai 代替)。', + '6. 页脚加 `

TKMind · 智趣

`(必须;禁止省略、不要用邮箱/tkmind.ai,也不要把该行 opacity 设太低导致看不见)。', '7. 回复里只给一个正式域名链接;没有落盘或缺少上述元数据就不要发链接。', '', buildCurrentTimeAgentPrefix({ timezone: scheduleTimezone }),