feat: 改进评论系统管理员识别与样式展示
- 后端评论接口增加 isAdmin 字段,不再依赖前端邮箱比对 - 管理后台评论列表支持 Markdown 渲染并添加相应样式 - 前端组件移除 adminEmail 依赖,改用 comment.isAdmin 字段 - 添加 CSS 样式兼容其他框架导入的表情元素 - 更新文档说明部署流程
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
# 更新部署
|
||||
|
||||
重新拉取 GitHub 项目代码
|
||||
重新拉取 GitHub 项目代码。
|
||||
|
||||
## 后端更新
|
||||
|
||||
@@ -16,6 +16,8 @@ npm run deploy
|
||||
|
||||
## 前端更新
|
||||
|
||||
如果你的管理后台项目,是通过 GitHub 仓库部署到 Cloudflare Pages,不需要手动更新,只用拉取官方仓库代码,重新推送即可触发重新部署(无需手动)。
|
||||
|
||||
### 管理后台
|
||||
|
||||
如果使用官方后台不需要更新。
|
||||
@@ -35,4 +37,4 @@ npm run build
|
||||
|
||||
如果使用官方评论端 js `https://cwd.js.org/cwd.js`,不需要更新。
|
||||
|
||||
如果你想自己托管,请下载仓库 `/cwd-admin/public` 中最新的 `cwd.js` 文件。
|
||||
如果你想自行托管,请使用打包命令,对仓库 `@docs/widget` 文件夹进行构建,然后把 `dist` 文件夹中的最新的 `cwd.js` 文件上传到你托管的地方。
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -39,7 +39,8 @@ 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 && comment.email === adminEmail;
|
||||
// 使用后端返回的 isAdmin 字段,不再依赖前端邮箱比对
|
||||
const isAdmin = !!comment.isAdmin;
|
||||
|
||||
const root = this.createElement('div', {
|
||||
className: `cwd-comment-item ${isReply ? 'cwd-comment-reply' : ''}`,
|
||||
@@ -241,7 +242,7 @@ export class CommentItem extends Component {
|
||||
submitting: this.props.submitting,
|
||||
currentUser: this.props.currentUser,
|
||||
onUpdateUserInfo: this.props.onUpdateUserInfo,
|
||||
adminEmail: this.props.adminEmail,
|
||||
// adminEmail 已移除
|
||||
adminBadge: this.props.adminBadge,
|
||||
enableCommentLike: this.props.enableCommentLike,
|
||||
onReply: this.props.onReply,
|
||||
|
||||
@@ -97,7 +97,7 @@ export class CommentList extends Component {
|
||||
submitting: this.props.submitting,
|
||||
currentUser: this.props.currentUser,
|
||||
onUpdateUserInfo: this.props.onUpdateUserInfo,
|
||||
adminEmail: this.props.adminEmail,
|
||||
// adminEmail 已移除,改用 comment.isAdmin 字段
|
||||
adminBadge: this.props.adminBadge,
|
||||
enableCommentLike: this.props.enableCommentLike,
|
||||
onReply: (commentId) => this.handleReply(commentId),
|
||||
|
||||
@@ -367,7 +367,7 @@ export class CWDComments {
|
||||
submitting: state.submitting,
|
||||
currentUser: state.form,
|
||||
onUpdateUserInfo: (field, value) => this.store.updateFormField(field, value),
|
||||
adminEmail: this.config.adminEmail,
|
||||
// adminEmail 已移除,前端展示改用 isAdmin 字段
|
||||
adminBadge: this.config.adminBadge,
|
||||
enableCommentLike: this.config.enableCommentLike !== false,
|
||||
onRetry: () => this.store.loadComments(),
|
||||
|
||||
@@ -986,4 +986,11 @@
|
||||
background: transparent;
|
||||
padding: 0;
|
||||
color: #db850d;
|
||||
}
|
||||
|
||||
/* 兼容其他框架导入的样式 */
|
||||
.cwd-comment-content .tk-owo-emotion {
|
||||
display: inline-block;
|
||||
vertical-align: bottom;
|
||||
max-width: 40px;
|
||||
}
|
||||
Reference in New Issue
Block a user