diff --git a/src/api/comment.js b/src/api/comment.js
new file mode 100644
index 00000000..cd583d62
--- /dev/null
+++ b/src/api/comment.js
@@ -0,0 +1,92 @@
+import service from '@/utils/service'
+
+const baseUrl = '/api/admin'
+
+const commentApi = {}
+
+/**
+ * Lists comment.
+ * @param {String} target
+ * @param {Object} view
+ */
+function latestComment(target, top, status) {
+ return service({
+ url: `${baseUrl}/${target}/comments/latest`,
+ params: {
+ top: top,
+ status: status
+ },
+ method: 'get'
+ })
+}
+
+/**
+ * Creates a comment.
+ * @param {String} target
+ * @param {Object} comment
+ */
+function createComment(target, comment) {
+ return service({
+ url: `${baseUrl}/${target}/comments`,
+ method: 'post',
+ data: comment
+ })
+}
+
+// List latest comment
+
+commentApi.latestPostComment = (top, status) => {
+ return latestComment('posts', top, status)
+}
+commentApi.latestSheetComment = (top, status) => {
+ return latestComment('sheets', top, status)
+}
+commentApi.latestJournalComment = (top, status) => {
+ return latestComment('journals', top, status)
+}
+
+// Creation api
+
+commentApi.createPostComment = comment => {
+ return createComment('posts', comment)
+}
+
+commentApi.createSheetComment = comment => {
+ return createComment('sheets', comment)
+}
+
+commentApi.createJournalComment = comment => {
+ return createComment('journals', comment)
+}
+
+commentApi.createComment = (comment, type) => {
+ if (type === 'sheet') {
+ return commentApi.createSheetComment(comment)
+ }
+
+ if (type === 'journal') {
+ return commentApi.createJournalComment(comment)
+ }
+
+ return commentApi.createPostComment(comment)
+}
+
+commentApi.commentStatus = {
+ PUBLISHED: {
+ color: 'green',
+ status: 'success',
+ text: '已发布'
+ },
+ AUDITING: {
+ color: 'yellow',
+ status: 'warning',
+ text: '待审核'
+ },
+ RECYCLE: {
+ color: 'red',
+ status: 'error',
+ text: '回收站'
+ }
+}
+
+export default commentApi
diff --git a/src/api/postComment.js b/src/api/postComment.js
index 0beada8f..8a81c1fb 100644
--- a/src/api/postComment.js
+++ b/src/api/postComment.js
@@ -2,9 +2,9 @@ import service from '@/utils/service'
const baseUrl = '/api/admin/posts/comments'
-const commentApi = {}
+const postCommentApi = {}
-commentApi.listLatest = (top, status) => {
+postCommentApi.listLatest = (top, status) => {
return service({
url: `${baseUrl}/latest`,
params: {
@@ -15,7 +15,7 @@ commentApi.listLatest = (top, status) => {
})
}
-commentApi.query = params => {
+postCommentApi.query = params => {
return service({
url: baseUrl,
params: params,
@@ -23,21 +23,21 @@ commentApi.query = params => {
})
}
-commentApi.updateStatus = (commentId, status) => {
+postCommentApi.updateStatus = (commentId, status) => {
return service({
url: `${baseUrl}/${commentId}/status/${status}`,
method: 'put'
})
}
-commentApi.delete = commentId => {
+postCommentApi.delete = commentId => {
return service({
url: `${baseUrl}/${commentId}`,
method: 'delete'
})
}
-commentApi.create = comment => {
+postCommentApi.create = comment => {
return service({
url: baseUrl,
data: comment,
@@ -45,7 +45,7 @@ commentApi.create = comment => {
})
}
-commentApi.commentStatus = {
+postCommentApi.commentStatus = {
PUBLISHED: {
color: 'green',
status: 'success',
@@ -63,4 +63,4 @@ commentApi.commentStatus = {
}
}
-export default commentApi
+export default postCommentApi
diff --git a/src/components/Tools/HeaderComment.vue b/src/components/Tools/HeaderComment.vue
index 3e50d6f1..1c6ff3ba 100644
--- a/src/components/Tools/HeaderComment.vue
+++ b/src/components/Tools/HeaderComment.vue
@@ -11,30 +11,95 @@
>
-
-
+
-
-
-
- {{ item.author }}:
-
-
- {{ item.createTime | timeAgo }}
-
-
-
-
+
+
+
+
+
+ {{ item.author }}:
+
+
+ {{ item.createTime | timeAgo }}
+
+
+
+
+
+
+
+
+
+
+
+ {{ item.author }}:
+
+
+ {{ item.createTime | timeAgo }}
+
+
+
+
+
+
+
+
+
+
+
+ {{ item.author }}:
+
+
+ {{ item.createTime | timeAgo }}
+
+
+
+
+
+
@@ -55,7 +120,7 @@