💄 style(vscode): 代码阅读「问过 N 次」的历史默认展开

This commit is contained in:
cruldra committed 2026-09-30 09:23:29 +08:00
1 parent 90268c7c67
commit de05d13dab
3 files changed
+10 -7

No files matched your search

@@ -29,11 +29,14 @@ describe('块下面的问答区', () => {
expect(render({})).toBe('')
})
it('问过、没展开:只露一行「问过 N 次」,点开才看历史', () => {
it('问过、没展开:一行「问过 N 次」,下面默认摊开灰字历史,没有输入框', () => {
const html = render({ history: HISTORY })
expect(html).toContain('data-collapsed')
expect(text(html)).toBe('问过 2 次')
expect(html).toContain('aria-expanded="false"')
expect(text(html)).toMatch(/^问过 2 次/)
expect(html).toContain('aria-expanded="true"')
expect(html.match(/data-history=""/g)).toHaveLength(2)
expect(text(html)).toContain('为什么普通用户不能看别人的资料?3 天前')
expect(text(html)).toContain('UserRole 还有哪些角色?昨天')
expect(html).not.toContain('<textarea')
})
@@ -255,10 +255,10 @@ export interface AskThreadProps {
/**
* 块下面的问答区(左边一条竖线):展开时是灰字的历史、当前这一轮、输入框;
* 没展开但问过的块只露一行「问过 N 次」,点开看灰字历史,读代码时一眼知道这里问过什么。
* 没展开但问过的块是一行「问过 N 次」、下面默认摊开灰字历史,点这一行收起 / 再摊开,读代码时一眼看到这里问过什么。
*/
export function AskThread({ history, asks, open, profiles, now = Date.now(), onSelectProfile, onAsk, onStop, onDelete, onClose }: AskThreadProps): ReactElement | null {
const [showHistory, setShowHistory] = useState(false)
const [showHistory, setShowHistory] = useState(true)
/** 正在看大图的那张 */
const [preview, setPreview] = useState<string>()
const lightbox = preview !== undefined && <ImagePreview url={preview} onClose={() => setPreview(undefined)} />