fix: 优化博主标识显示逻辑,支持图标模式

- 移除 adminBadge 为空的检查,允许仅通过邮箱识别博主
- 当未设置博主标签文字时,默认显示认证图标替代文本标签
- 更新管理后台标签说明,提示留空使用默认图标
- 添加博主图标专用样式,确保透明背景和正确颜色
This commit is contained in:
anghunk
2026-01-23 20:14:27 +08:00
parent 9bf0764476
commit 369f34f89d
4 changed files with 16 additions and 5 deletions

View File

@@ -22,7 +22,7 @@
<input v-model="commentAdminEmail" class="form-input" type="email" />
</div>
<div class="form-item">
<label class="form-label">博主标签文字</label>
<label class="form-label">博主标签文字留空使用默认图标</label>
<input v-model="commentAdminBadge" class="form-input" type="text" />
</div>
<div class="form-item">
@@ -468,7 +468,7 @@ async function load() {
]);
email.value = notifyRes.email || "";
commentAdminEmail.value = commentRes.adminEmail || "";
commentAdminBadge.value = commentRes.adminBadge || "博主";
commentAdminBadge.value = commentRes.adminBadge ?? "";
avatarPrefix.value = commentRes.avatarPrefix || "";
commentAdminEnabled.value = !!commentRes.adminEnabled;
allowedDomains.value = commentRes.allowedDomains

View File

@@ -39,7 +39,7 @@ export class CommentItem extends Component {
const { comment, isReply, adminEmail, adminBadge } = this.props;
const isPinned = typeof comment.priority === 'number' && comment.priority > 1;
const isReplying = this.props.replyingTo === comment.id;
const isAdmin = adminEmail && adminBadge && comment.email === adminEmail;
const isAdmin = adminEmail && comment.email === adminEmail;
const root = this.createElement('div', {
className: `cwd-comment-item ${isReply ? 'cwd-comment-reply' : ''}`,
@@ -86,7 +86,12 @@ export class CommentItem extends Component {
})
: this.createTextElement('span', comment.name, 'cwd-author-name'),
...(isAdmin ? [
this.createTextElement('span', `${adminBadge}`, 'cwd-admin-badge')
adminBadge
? this.createTextElement('span', `${adminBadge}`, 'cwd-admin-badge')
: this.createElement('span', {
className: 'cwd-admin-badge cwd-admin-badge-icon',
html: '<svg viewBox="0 0 22 22" aria-label="认证账号" role="img" class="cwd-admin-icon" style="width:15px;height:15px;fill:currentColor;vertical-align:-0.15em;"><g><path d="M20.396 11c-.018-.646-.215-1.275-.57-1.816-.354-.54-.852-.972-1.438-1.246.223-.607.27-1.264.14-1.897-.131-.634-.437-1.218-.882-1.687-.47-.445-1.053-.75-1.687-.882-.633-.13-1.29-.083-1.897.14-.273-.587-.704-1.086-1.245-1.44S11.647 1.62 11 1.604c-.646.017-1.273.213-1.813.568s-.969.854-1.24 1.44c-.608-.223-1.267-.272-1.902-.14-.635.13-1.22.436-1.69.882-.445.47-.749 1.055-.878 1.688-.13.633-.08 1.29.144 1.896-.587.274-1.087.705-1.443 1.245-.356.54-.555 1.17-.574 1.817.02.647.218 1.276.574 1.817.356.54.856.972 1.443 1.245-.224.606-.274 1.263-.144 1.896.13.634.433 1.218.877 1.688.47.443 1.054.747 1.687.878.633.132 1.29.084 1.897-.136.274.586.705 1.084 1.246 1.439.54.354 1.17.551 1.816.569.647-.016 1.276-.213 1.817-.567s.972-.854 1.245-1.44c.604.239 1.266.296 1.903.164.636-.132 1.22-.447 1.68-.907.46-.46.776-1.044.908-1.681s.075-1.299-.165-1.903c.586-.274 1.084-.705 1.439-1.246.354-.54.551-1.17.569-1.816zM9.662 14.85l-3.429-3.428 1.293-1.302 2.072 2.072 4.4-4.794 1.347 1.246z"></path></g></svg>'
})
] : []),
...(isPinned ? [
this.createTextElement('span', '置顶', 'cwd-pin-badge')

View File

@@ -163,7 +163,7 @@ export class CWDComments {
if (serverConfig.adminEmail) {
this.config.adminEmail = serverConfig.adminEmail;
}
if (serverConfig.adminEnabled && serverConfig.adminBadge) {
if (serverConfig.adminEnabled) {
this.config.adminBadge = serverConfig.adminBadge;
}
this.config.requireReview = !!serverConfig.requireReview;

View File

@@ -976,3 +976,9 @@
.cwd-btn-text:hover {
color: var(--cwd-primary);
}
.cwd-admin-badge.cwd-admin-badge-icon {
background: transparent;
padding: 0;
color: #db850d;
}