fix(widget): 修复评论列表无评论时的文案显示问题

- 将硬编码的“暂无评论,快来抢沙发吧!”文案移至国际化文件,便于统一管理
- 在 CommentList 构造函数中注入翻译函数,确保组件能正确使用国际化文案
- 调整语言选择逻辑,优先使用用户配置的语言,其次使用服务器配置,最后自动检测
- 在开发工具中增加语言选择配置项,便于测试不同语言环境
This commit is contained in:
anghunk
2026-02-10 14:39:00 +08:00
parent 4d9e2d8d31
commit ccd558090c
4 changed files with 10 additions and 5 deletions

View File

@@ -35,6 +35,7 @@ export class CommentList extends Component {
*/
constructor(container, props = {}) {
super(container, props);
this.t = props.t || ((k) => k);
this.loadingComponent = null;
this.paginationComponent = null;
this.commentItems = new Map(); // 缓存 CommentItem 实例key 为 comment.id
@@ -120,7 +121,7 @@ export class CommentList extends Component {
const emptyEl = this.createElement('div', {
className: 'cwd-empty',
children: [
this.createTextElement('p', '暂无评论,快来抢沙发吧!', 'cwd-empty-text')
this.createTextElement('p', this.t('noComments'), 'cwd-empty-text')
]
});
root.appendChild(emptyEl);