feat(creator-studio): two-row masthead with site logo and user avatar

顶栏改为知乎式两行结构:第一行左侧站点 LOGO、右侧当前用户头像,
第二行只保留正文工具条并居中,同时移除「Jio / 写文章」字样。

- bootstrap payload 新增 site/viewer 身份字段(复用 jio_get_site_logo_url
  与 jio_get_avatar_url,前端不拼 URL、不做权限判断)
- 拆分 draft 类型、TinyMCE 块运行时、顶栏组件,index.tsx 1065 → 735 行
- 清理死代码:未调用的 keepCaretInsideCode、永远无法打开的代码语言弹窗
  (setCodeLanguage 只会收到 null,codeTargetRef 从未赋值)及其样式,
  以及顶栏移除后失效的 bar-left/brand/mode/save-draft/ghost/primary 规则
- 契约测试、本地预览与截图脚本同步到新 DOM

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
kate522andClaude Opus 5 committed 2026-11-08 22:20:10 +08:00
1 parent 5f31c58df2
commit 1970db0b56
17 files changed
+602 -580

No files matched your search

+2 -1
View File
@@ -31,7 +31,8 @@ const URL = process.argv[2] || 'https://localhost/jio-preview.html';
await page.waitForFunction(() => window.tinymce?.get('jio-creator-content'), { timeout: 20000 });
const before = await page.evaluate(() => ({
fixed: getComputedStyle(document.querySelector('.jio-creator__bar')).position === 'fixed',
// 两行顶栏由外层容器整体固定,工具条本身不再单独 fixed。
fixed: getComputedStyle(document.querySelector('.jio-creator__top')).position === 'fixed',
toolbar: !!document.querySelector('[role="toolbar"]'),
editor: !!window.tinymce?.get('jio-creator-content'),
}));
+24
View File
@@ -73,6 +73,30 @@ const mockBootstrap = {
media: { maxBytes: 5242880, batch: 6 },
rest: { root: 'https://localhost/wp-json/', nonce: 'preview' },
urls: { submit: '#', newPost: '#', center: '#' },
// 预览用内联 SVG,避免本地截图时依赖真实站点资源。
site: {
home: '#',
name: 'Jio',
logo:
'data:image/svg+xml;charset=utf-8,' +
encodeURIComponent(
'<svg xmlns="http://www.w3.org/2000/svg" width="132" height="30" viewBox="0 0 132 30">' +
'<text x="0" y="23" font-family="Songti SC, Noto Serif SC, serif" font-size="24" font-weight="700" fill="#1d5f52">Jio</text>' +
'<text x="42" y="23" font-family="system-ui, sans-serif" font-size="13" fill="#7d8683">写作中心</text>' +
'</svg>'
),
},
viewer: {
avatar:
'data:image/svg+xml;charset=utf-8,' +
encodeURIComponent(
'<svg xmlns="http://www.w3.org/2000/svg" width="72" height="72" viewBox="0 0 72 72">' +
'<rect width="72" height="72" fill="#dbe7e2"/>' +
'<circle cx="36" cy="28" r="12" fill="#8fb3a8"/>' +
'<path d="M12 72c0-13.3 10.7-24 24-24s24 10.7 24 24z" fill="#8fb3a8"/>' +
'</svg>'
),
},
captcha: { enabled: false },
creator: {
saveUrl: '#',
+4 -2
View File
@@ -55,14 +55,16 @@ const PREFIX = process.argv[3] || 'C:/Users/Xing/Desktop/WP-Date/data/wordpress/
};
};
return {
masthead: pick('.jio-creator__masthead'),
brandLogo: pick('.jio-creator__brand-logo'),
avatar: pick('.jio-creator__me-avatar'),
bar: pick('.jio-creator__bar'),
title: pick('.jio-creator__title textarea'),
settings: pick('.jio-creator__settings'),
canvas: pick('.jio-creator__canvas'),
toolbar: pick('.jio-creator__toolbar-tools'),
editor: pick('.jio-creator__editor .mce-edit-area'),
primaryBtn: pick('.jio-creator__primary'),
ghostBtn: pick('.jio-creator__ghost'),
publishBtn: pick('.jio-creator__status-primary'),
pageBg: getComputedStyle(document.body).backgroundColor,
};
});
+3 -1
View File
@@ -74,12 +74,14 @@ if (!EDGE) {
await new Promise((r) => setTimeout(r, 3000));
const state = await page.evaluate(() => ({
hasMasthead: !!document.querySelector('.jio-creator__masthead'),
hasBrandLogo: !!document.querySelector('.jio-creator__brand-logo'),
hasAvatar: !!document.querySelector('.jio-creator__me-avatar'),
hasBar: !!document.querySelector('.jio-creator__bar'),
hasToolbar: !!document.querySelector('.jio-creator__toolbar-tools'),
hasTinyMce: !!window.tinymce?.get('jio-creator-content'),
hasEditorFrame: !!document.querySelector('.mce-tinymce iframe, .tox-tinymce iframe'),
hasTitle: !!document.querySelector('.jio-creator__title textarea'),
hasSaveDraft: !!document.querySelector('.jio-creator__save-draft'),
toolbarActions: Array.from(document.querySelectorAll('.jio-creator__toolbar-tools button')).map((button) => button.getAttribute('aria-label') || button.textContent.trim()),
saveText: (document.querySelector('.jio-creator__save') || {}).textContent,
rejections: window.__jioRejections || [],