tianyunperfect 1 год назад
Родитель
Сommit
8b4e917f9f
1 измененных файлов с 25 добавлено и 4 удалено
  1. 25 4
      simple-demo/send_memos.html

+ 25 - 4
simple-demo/send_memos.html

@@ -130,7 +130,7 @@
                         <el-image v-for="img in resourceMap[item.id]"
                                   :src="'https://memos_assert.tianyunperfect.cn/' + img['internal_path'] + '?width=150'"
                                   :preview-src-list="['https://memos_assert.tianyunperfect.cn/' + img['internal_path']]"
-                                  style="height: 200px; margin: 10px 10px 0 0; cursor: pointer">
+                                  style="max-height: 200px;max-width: 300px; margin: 10px 10px 0 0; cursor: pointer">
 
                         </el-image>
                     </div>
@@ -165,13 +165,15 @@
                 </el-date-picker>
             </div>
             <div>
-                <el-input ref="contentEdit" v-model="tmpItem.content" type="textarea" :autosize="{minRows: 2}"></el-input>
+                <el-input
+                        @paste.native="handlePaste2"
+                        ref="contentEdit" v-model="tmpItem.content" type="textarea" :autosize="{minRows: 2}"></el-input>
             </div>
             <div style="display: flex">
                 <div v-for="img in cloneFileIds">
                     <el-image :src="'https://memos_assert.tianyunperfect.cn/' + img['internal_path'] + '?width=150'"
                               :preview-src-list="['https://memos_assert.tianyunperfect.cn/' + img['internal_path']]"
-                              style="height: 200px; margin: 10px 10px 0 0; cursor: pointer">
+                              style="max-height: 200px;max-width: 300px; margin: 10px 10px 0 0; cursor: pointer">
                     </el-image>
                 </div>
 
@@ -309,6 +311,20 @@
                     });
                 }
             },
+            handlePaste2(e){
+                let file = this.getFileFromPaste(e);
+                // 对复制黏贴的类型进行判断,若是非文件类型,比如复制黏贴的文字,则不会调用上传文件的函数
+                if (file) {
+                    this.uploadFile(this.upload_url, file, {'Authorization': myHeaders['Authorization']}).then(res => {
+                        let fileId = res['id'];
+                        if (fileId) {
+                            let sourceRes = requestUtil.sync("https://web_history.tianyunperfect.cn/memos/resourceById", 'post', {ids: fileId}, {});
+                            let sourceRe = sourceRes['res'];
+                            this.cloneFileIds.push(...sourceRe)
+                        }
+                    });
+                }
+            },
             keyDown() {
                 // 如果是ctrl + enter \ meta + enter 则发送
                 if (event.ctrlKey || event.metaKey) {
@@ -394,10 +410,15 @@
                 let res = requestUtil.sync('https://web_history.tianyunperfect.cn/memos/update', 'post', {
                     id: this.tmpItem.id,
                     content: this.tmpItem.content,
-                    created_ts: this.tmpItem.created_ts
+                    created_ts: this.tmpItem.created_ts,
+                    resourceIdList: this.cloneFileIds.map(it => it.id)
                 }, {});
                 if (res.code === 200) {
                     this.msg('更新成功');
+                    // 更新主页面的图片
+                    this.resourceMap[this.tmpItem.id] = this.cloneFileIds;
+
+
                     // this.search();
                 }
                 this.dialogVisible = false;