Sfoglia il codice sorgente

Merge branch 'dev' into 'master'

发布通知再认证

添加通知时存密码,在点击发布通知的时候再次验证密码。

See merge request !3

guochao 3 anni fa
parent
commit
d85a306abc
2 ha cambiato i file con 39 aggiunte e 26 eliminazioni
  1. 8 5
      src/components/Notice/Notice.vue
  2. 31 21
      src/pages/EditorPage.vue

+ 8 - 5
src/components/Notice/Notice.vue

@@ -5,8 +5,8 @@
         <div-header :header="'大赛通知'" class="notice-header-title">
         </div-header>
         <div>
-          <Input type="password" v-model="inputPassword" placeholder="请输入内容" size="small" class="add-notice-password"></Input>
-          <Button type="primary" plain class="add-notice" @click="handleAddNotice" :disabled="enableAddNotice">添加通知
+          <Input type="password" v-model="inputPassword" placeholder="请输入验证码添加通知" size="small" class="add-notice-password"></Input>
+          <Button type="primary" plain class="add-notice" @click="handleAddNotice" v-if="enableAddNotice">添加通知
           </Button>
         </div>
       </div>
@@ -141,7 +141,7 @@
         </div-header>
         <div>
           <Input v-model="inputPassword" placeholder="请输入内容" size="small" class="add-notice-password"></Input>
-          <Button type="primary" plain class="add-notice" @click="handleAddNotice" :disabled="enableAddNotice">添加通知
+          <Button v-if="enableAddNotice" type="primary" plain class="add-notice" @click="handleAddNotice" >添加通知
           </Button>
         </div>
       </div>
@@ -297,7 +297,7 @@
     },
     data() {
       return {
-        enableAddNotice: true,
+        enableAddNotice: false,
         inputPassword: '',
         noticeList:[]
       }
@@ -308,6 +308,8 @@
     methods: {
       ...mapActions(["setIsPsw"]),
       handleAddNotice() {
+        localStorage.setItem('validCode',this.inputPassword);
+        console.log(this.inputPassword);
         this.setIsPsw(true);
         router.push({path: `/Editor/`});
         this.inputPassword = '';
@@ -326,7 +328,8 @@
       inputPassword: function (newVal, oldVal) {
         if(newVal&&newVal!==oldVal){
           axios.get(`/api/checkPWD/${newVal}`).then(res=>{
-            this.enableAddNotice = !res.data
+            // console.log(res);            
+            this.enableAddNotice = res.data
           })
         }
       }

+ 31 - 21
src/pages/EditorPage.vue

@@ -100,29 +100,39 @@
         this.editor.setData(this.editor.getData() + ret);
       },
       handleSubmit() {
-        this.notice.content = this.editor.getData();
-        this.notice.isThirdParty = this.thirdParty ? 1 : 0;
-        let canSubmit = this.notice.title && this.notice.content;
-        if (canSubmit) {
-          if (this.notice.id) { //更新
-            this.notice.isChangingCreateTime = this.isChangingCreateTime ? 1 : 0;
-            axios.put(`/api/update/${this.notice.id}`, this.notice).then(res => {
-              if (res.status === 200) {
-                this.$Message.info('发布成功!');
-                router.push('/');
-              }
-            })
-          } else { //创建
-            axios.post('/api/create', this.notice).then(res => {
-              if (res.status === 200) {
-                this.$Message.info('发布成功!');
-                router.push('/');
-              }
-            })
+        let validCode = localStorage.getItem("validCode");
+        axios.get(`/api/checkPWD/${validCode}`).then(res=>{
+        if (res.data) {
+          this.notice.content = this.editor.getData();
+          this.notice.isThirdParty = this.thirdParty ? 1 : 0;
+          let canSubmit = this.notice.title && this.notice.content;
+          if (canSubmit) {
+            if (this.notice.id) { //更新
+              this.notice.isChangingCreateTime = this.isChangingCreateTime ? 1 : 0;
+              axios.put(`/api/update/${this.notice.id}`, this.notice).then(res => {
+                if (res.status === 200) {
+                  this.$Message.info('发布成功!');
+                  router.push('/');
+                }
+              })
+            } else { //创建
+              axios.post('/api/create', this.notice).then(res => {
+                if (res.status === 200) {
+                  this.$Message.info('发布成功!');
+                  router.push('/');
+                }
+              })
+            }
+          } else {
+            this.$Message.warning('通知标题和内容不能为空!');
           }
-        } else {
-          this.$Message.warning('通知标题和内容不能为空!');
+        }else{
+            this.$Message.warning('没有权限');
+
         }
+        })
+
+
       }
     },