fix(qa): 周报固定对照布局并移除模式切换按钮
build / build (push) Successful in 1m7s

始终保留正文编辑与排版预览,删除三模式切换状态和不再使用的样式。
自动保存状态保持原位置,窄屏沿用上下对照,复制及下载不变。
验证:三个按钮不渲染且两侧始终存在先红后绿,复制/持久化保存状态机回归、完整门禁和原生备份恢复通过。
This commit is contained in:
姚章浩
2026-10-25 17:48:27 +08:00
parent c239a5ef0e
commit 1d880a0f49
4 changed files with 38 additions and 54 deletions
+6
View File
@@ -76,6 +76,12 @@
> `0.1.12`),由 `scripts/version.py` 从 git **算出来**;开发交付的独立说明写入本文件“开发快照”章节,并打 `snapshot/vX.Y.Z` 注释标签 ⇒ 每次开发交付均可追溯,
> 但"发布版本"仍然只能由人定(CI 不会自动升版本、不会打 tag)。
## 开发快照 snapshot/v0.1.63 - 2026-10-25
### Changed
- 周报固定保留编辑正文与排版预览的对照界面,移除编辑/预览/对照切换按钮及无用模式状态/样式;自动保存、复制排版内容和下载保持不变。
## 开发快照 snapshot/v0.1.62 - 2026-10-25
### Added
+25 -37
View File
@@ -17,8 +17,7 @@ interface Props {
export function QAWeekly({ onBeforeLeave }: Props) {
const [model] = useState(() => new WeeklyDraftEditorModel(currentQAWeekValue(), weeklyTransport))
const state = useSyncExternalStore(model.subscribe, model.getSnapshot, model.getSnapshot)
const [mode, setMode] = useState<'edit' | 'preview' | 'both'>('both'),
[replaceConfirm, setReplaceConfirm] = useState(false),
const [replaceConfirm, setReplaceConfirm] = useState(false),
[reloadConfirm, setReloadConfirm] = useState(false),
[periodReset, setPeriodReset] = useState(0),
[exporting, setExporting] = useState(false),
@@ -177,13 +176,6 @@ export function QAWeekly({ onBeforeLeave }: Props) {
</div>
</header>
<div className="qa-weekly-editor-toolbar">
<div className="qa-weekly-mode" aria-label="编辑与预览">
{(['edit', 'preview', 'both'] as const).map((value) => (
<button type="button" key={value} aria-pressed={mode === value} onClick={() => setMode(value)}>
{{ edit: '编辑', preview: '预览', both: '对照' }[value]}
</button>
))}
</div>
<span role="status" aria-live="polite" className="qa-weekly-editor-status" data-weekly-save-state={status}>
自动保存 ·{' '}
{
@@ -257,34 +249,30 @@ export function QAWeekly({ onBeforeLeave }: Props) {
<div ref={copyBody} hidden aria-hidden="true">
<QAAnswerMarkdown answer={state.text} />
</div>
<div className="qa-weekly-editor-layout" data-mode={mode}>
{mode !== 'preview' ? (
<div className="qa-weekly-writing">
<label htmlFor="qa-weekly-body">
周报草稿正文 <small>Markdown</small>
</label>
<textarea
id="qa-weekly-body"
aria-label="周报草稿正文"
value={state.text}
disabled={blocked}
spellCheck={false}
placeholder="生成并预填草稿,或直接输入。英文完整部分在上,中文在下;输入后自动保存。"
onChange={(e) => model.setText(e.target.value)}
onKeyDown={(e) => {
if ((e.ctrlKey || e.metaKey) && e.key.toLowerCase() === 's') {
e.preventDefault()
void model.beforeLeave()
}
}}
/>
</div>
) : null}
{mode !== 'edit' ? (
<article className="qa-weekly-preview" aria-label="周报预览">
{preview ? <QAAnswerMarkdown answer={preview} /> : <p className="qa-ops-muted">尚无草稿正文。</p>}
</article>
) : null}
<div className="qa-weekly-editor-layout" data-mode="both">
<div className="qa-weekly-writing">
<label htmlFor="qa-weekly-body">
周报草稿正文 <small>Markdown</small>
</label>
<textarea
id="qa-weekly-body"
aria-label="周报草稿正文"
value={state.text}
disabled={blocked}
spellCheck={false}
placeholder="生成并预填草稿,或直接输入。英文完整部分在上,中文在下;输入后自动保存。"
onChange={(e) => model.setText(e.target.value)}
onKeyDown={(e) => {
if ((e.ctrlKey || e.metaKey) && e.key.toLowerCase() === 's') {
e.preventDefault()
void model.beforeLeave()
}
}}
/>
</div>
<article className="qa-weekly-preview" aria-label="周报预览">
{preview ? <QAAnswerMarkdown answer={preview} /> : <p className="qa-ops-muted">尚无草稿正文。</p>}
</article>
</div>
{source && source.source === 'governance-master' ? (
<details className="qa-weekly-source">
+6
View File
@@ -9,6 +9,12 @@ describe('weekly report editor surface', () => {
expect(html).toContain('自动保存')
expect(html).toContain('周报周次下拉选择')
expect(html).toContain('预览')
expect(html).toContain('data-mode="both"')
expect(html).toContain('qa-weekly-writing')
expect(html).toContain('qa-weekly-preview')
for (const label of ['编辑', '预览', '对照'])
expect(html).not.toMatch(new RegExp('<button[^>]*>' + label + '</button>'))
expect(html).not.toContain('qa-weekly-mode')
expect(html).toContain('复制排版内容')
expect(html).toContain('下载 MD')
expect(html).not.toContain('复制 Markdown 原文')
+1 -17
View File
@@ -32,18 +32,9 @@
display: flex;
align-items: center;
gap: 16px;
justify-content: space-between;
justify-content: flex-end;
flex-wrap: wrap;
}
.qa-weekly-mode {
display: flex;
gap: 4px;
}
.qa-weekly-mode button[aria-pressed='true'] {
background: #eaf3ff;
color: #155cb5;
border-color: #a3c7f3;
}
.qa-weekly-editor-status {
font-size: 13px;
color: #64748b;
@@ -64,10 +55,6 @@
border-radius: 10px;
background: #fff;
}
.qa-weekly-editor-layout[data-mode='edit'],
.qa-weekly-editor-layout[data-mode='preview'] {
grid-template-columns: minmax(0, 1fr);
}
.qa-weekly-writing {
display: flex;
flex-direction: column;
@@ -122,9 +109,6 @@
min-height: 0;
max-height: none;
}
.qa-weekly-editor-layout[data-mode='preview'] .qa-weekly-preview {
border-left: 0;
}
.qa-weekly-source {
font-size: 12px;
color: #66778c;