Browse Source

发布通知再认证

添加通知时存密码,在点击发布通知的时候再次验证密码。
JunboXu 3 years ago
parent
commit
b780ba7b3d
2 changed files with 34 additions and 21 deletions
  1. 3 0
      src/components/Notice/Notice.vue
  2. 31 21
      src/pages/EditorPage.vue

+ 3 - 0
src/components/Notice/Notice.vue

@@ -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,6 +328,7 @@
       inputPassword: function (newVal, oldVal) {
         if(newVal&&newVal!==oldVal){
           axios.get(`/api/checkPWD/${newVal}`).then(res=>{
+            // 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('没有权限');
+
         }
+        })
+
+
       }
     },