Преглед изворни кода

update 编辑删除,发布样式优化

arvin пре 6 година
родитељ
комит
72177fcb8e
3 измењених фајлова са 54 додато и 11 уклоњено
  1. 16 10
      components/topics/editor.vue
  2. 1 1
      pages/cert/type/_id.vue
  3. 37 0
      pages/user/_id.vue

+ 16 - 10
components/topics/editor.vue

@@ -44,7 +44,7 @@
       filterable
       allow-create
       default-first-option
-      placeholder="每个标签以逗号隔开、最多5个,如:技术,经验"
+      placeholder="每个标签以enter键隔开、最多5个,如:技术,经验"
     >
       <el-option
         v-for="item in tagOptions"
@@ -353,18 +353,22 @@ export default {
   .sub-title {
     margin-bottom: 28px;
     min-height: 18px;
-    font-size: 13px;
+    font-size: 14px;
     font-family: PingFangSC-Regular;
     font-weight: 400;
     color: rgba(145, 154, 167, 1);
     line-height: 18px;
-    /* border-left: 2px solid #0093fd; */
-    .el-input__inner {
+    border: 0;
+    .el-textarea__inner {
       height: 18px;
       line-height: 18px;
+      border: 0;
+      padding-left: 0;
     }
   }
   .avatar-uploader .el-upload {
+    width: 160px;
+    height: 110px;
     border: 1px dashed #d9d9d9;
     border-radius: 6px;
     cursor: pointer;
@@ -373,6 +377,8 @@ export default {
     img {
       width: 100%;
       height: auto;
+      object-fit: contain;
+      object-position: top left;
     }
   }
   .avatar-uploader .el-upload:hover {
@@ -381,9 +387,9 @@ export default {
   .avatar-uploader-icon {
     font-size: 28px;
     color: #8c939d;
-    width: 178px;
-    height: 178px;
-    line-height: 178px;
+    width: 160px;
+    height: 110px;
+    line-height: 110px;
     text-align: center;
   }
   .avatar {
@@ -400,12 +406,12 @@ export default {
     line-height: 18px;
   }
   .ql-toolbar {
-    border-width: 1px 0 0 0;
+    border-width: 1px 0 0 0 !important;
   }
   .quill-editor {
     height: 450px;
-    border-left: 0;
-    border-right: 0;
+    border-left: 0 !important;
+    border-right: 0 !important;
     font-size: 14px;
     line-height: 25px;
   }

+ 1 - 1
pages/cert/type/_id.vue

@@ -123,7 +123,7 @@ export default {
           }).then(async () => {
             if (!this.detail.is_free_apply) location.href = `/pay?product_type=12&product_id=${this.detail.id}&next=/cert`
             else {
-              await this.$post('/api/cert/apply', { user_cert_id: this.detail.user_cert_id })
+              await this.$axios.$post('/api/cert/apply', { user_cert_id: this.detail.user_cert_id })
               this.$message({
                 message: '申请成功',
                 type: 'success'

+ 37 - 0
pages/user/_id.vue

@@ -40,6 +40,8 @@
                 <span class="create-time">{{art.updated_at}}</span>
               </div>
               <div class="art-counts-info">
+                <a v-if="idInfo.has_edit_delete_access" class="delete" @click.stop="handleDelete(art)">删除</a>
+                <a v-if="idInfo.has_edit_delete_access" class="edit" :href="`/topics/${art.id}/edit`">编辑</a>
                 <div class="good">
                   <img src="~@/assets/img/community/good_icon.png">
                   <span class="good-count">{{art.like_count}}</span>
@@ -135,6 +137,29 @@ export default {
         this.idInfo = res.data;
       }
     },
+    async handleDelete(topic) {
+      console.log(topic)
+      await this.needLogin();
+      if (!this.idInfo.has_edit_delete_access) {
+        this.$message.error('你没有该文章的操作权限');
+      }
+      this.$confirm(`<p>确认删除该文章吗?</p>`, '提示', {
+        dangerouslyUseHTMLString: true,
+      }).then(async () => {
+        this.$axios.$post('/api/community/topic/delete', { topic_id: topic.id })
+        .then(() => {
+          this.$message({
+            message: '删除成功',
+            type: 'success'
+          })
+        }).catch(() => {
+          this.$message.error('该文章不存在')
+          setTimeout(() => location.reload(), 1000)
+        })
+      }).catch(err => {
+        console.log('cancel')
+      });
+    },
     clickLancer({ id }) {
       this.$router.push(`https://www.proginn.com/cert/type/${id}`);
     },
@@ -507,4 +532,16 @@ export default {
   align-items: center;
   margin: 20px 0;
 }
+.edit,
+.delete {
+  display: inline-block;
+  margin: 0 12px;
+  font-size: 12px;
+  font-weight:500;
+  line-height: 15px;
+  color:rgba(48,142,255,1);
+}
+.delete {
+  color:rgba(153,153,153,1);
+}
 </style>