fix(media-card): 修复媒体卡片文字过长被裁切的问题

修改了媒体卡片内容的文字样式,移除文本溢出省略和强制不换行设置,改为支持自动换行;新增测试用例验证长文字的换行展示行为。
This commit is contained in:
duanshuwen
2026-08-27 15:47:53 +08:00
parent c381eb8b38
commit e68876e455
2 changed files with 27 additions and 3 deletions

View File

@@ -0,0 +1,14 @@
import { readFileSync } from "node:fs";
import { describe, expect, it } from "vitest";
const styles = readFileSync(new URL("../styles.css", import.meta.url), "utf8");
describe("媒体素材卡片文字", () => {
it("长标题和长 URL 应换行展示而不是被裁切", () => {
const cardTextRule = styles.match(/\.media-card-content strong,[\s\S]*?\.media-card-content small \{([\s\S]*?)\n\}/)?.[1] ?? "";
expect(cardTextRule).toContain("overflow-wrap: anywhere;");
expect(cardTextRule).toContain("word-break: break-word;");
expect(cardTextRule).toContain("white-space: normal;");
});
});

View File

@@ -425,13 +425,23 @@ input {
gap: 5px;
padding: 10px;
}
.media-card-content strong,
.media-card-content span,
.media-card-content small {
display: block;
overflow-wrap: anywhere;
word-break: break-word;
white-space: normal;
}
.media-card-content strong {
color: var(--ink);
line-height: 1.45;
}
.media-card-content span,
.media-card-content small {
overflow: hidden;
color: var(--muted);
font-size: 11px;
text-overflow: ellipsis;
white-space: nowrap;
line-height: 1.45;
}
.media-card-content small {
color: #94a3b8;