tianyun 1 vuosi sitten
vanhempi
commit
85c8d48b29
1 muutettua tiedostoa jossa 66 lisäystä ja 8 poistoa
  1. 66 8
      simple-demo/send_memos.html

+ 66 - 8
simple-demo/send_memos.html

@@ -13,9 +13,10 @@
             font-family: "LXGW WenKai Screen", sans-serif !important;
         }
 
-        img{
+        img {
             border: 1px solid #b7b6b6;
         }
+
         .editClass button {
             display: block;
             margin-top: 5px;
@@ -82,7 +83,9 @@
             <el-link href="https://memos.tianyunperfect.cn/">memos主页</el-link>
             <!--        页码输入框,默认为1,修改触发查询-->
             <span style="margin-left: 20px">页码:</span>
-            <el-input style="width: 50px; margin-left: 20px" v-model="page" @change="search"></el-input>
+            <el-input type="number" style="width: 80px; margin-left: 20px" v-model="page" @change="search"></el-input>
+            <span style="margin-left: 20px">大小:</span>
+            <el-input type="number" style="width: 80px; margin-left: 20px" v-model="size" @change="search" step="10"></el-input>
             <!--输入框,绑定回车事件,触发查询-->
             <el-input style="margin-left: 30px; width: 70vw; padding-left: 10px" placeholder="搜索" v-model="searchStr" @change="search"></el-input>
             <br><br>
@@ -119,7 +122,7 @@
                                 placeholder="选择日期时间">
                         </el-date-picker>
                     </div>
-                    <div >
+                    <div>
                         <el-input v-model="item.content" type="textarea" :autosize="{minRows: 2}" disabled="true"></el-input>
                     </div>
                     <div>
@@ -131,9 +134,18 @@
                         </el-image>
                     </div>
                 </el-col>
-                <el-col :span="8">
+                <el-col :span="4">
+                    <div class="editClass">
+                        <div v-for="cTag in commonTags">
+                            <el-tag style="margin-left: 10px">{{cTag}}</el-tag>
+                            <el-button style="display: inline;margin-left: 0" size="mini" @click="addTag(item,cTag)">新增</el-button>
+                            <el-button style="display: inline;margin-left: 0" size="mini" @click="delTag(item,cTag)">删除</el-button>
+                        </div>
+                    </div>
+                </el-col>
+                <el-col :span="4">
                     <div class="editClass">
-                        <el-button size="small"  @click="window.open('https://memos.tianyunperfect.cn/m/' + item.resource_name)">跳转</el-button>
+                        <el-button size="small" @click="window.open('https://memos.tianyunperfect.cn/m/' + item.resource_name)">跳转</el-button>
                         <el-button size="small" @click="edit(item)">编辑</el-button>
 
                         <el-button size="small" @click="archive(item)">归档</el-button>
@@ -156,7 +168,7 @@
                         placeholder="选择日期时间">
                 </el-date-picker>
             </div>
-            <div >
+            <div>
                 <el-input v-model="tmpItem.content" type="textarea" :autosize="{minRows: 2}"></el-input>
             </div>
             <div style="display: flex">
@@ -186,19 +198,26 @@
         'Content-type': 'application/json',
         'Authorization': authStr
     };
+
+    function getRandomId() {
+        return Math.random().toString(36).substr(2);
+    }
+
     let vm = new Vue({
         el: '#app',
         data: {
             tmpItem: {},
             dialogVisible: false,
             page: 1,
+            size: 10,
             searchStr: '',
             contentStr: '',
             tagChecked: [],
             allTags: [],
             contentList: [],
             sendBtnAble: true,
-            resourceMap: {} // 资源map
+            resourceMap: {}, // 资源map,
+            commonTags: ['日记', '备份', '梦记']
         },
         watch: {
             tagChecked: function () {
@@ -207,6 +226,9 @@
             },
             page: function () {
                 this.search();
+            },
+            size: function () {
+                this.search();
             }
         },
         mounted() {
@@ -214,6 +236,42 @@
             this.search();
         },
         methods: {
+            addTag(item, cTag) {
+                let content = item.content;
+                // 如果已经有了,就不添加
+                if (content.indexOf(cTag) !== -1) {
+                    return;
+                }
+                item.content = '#' + cTag + ' ' + content;
+                // 提交记录
+                let res = requestUtil.sync('https://web_history.tianyunperfect.cn/memos/update', 'post', {
+                    id: item.id,
+                    content: item.content,
+                    created_ts: item.created_ts
+                }, {});
+                if (res.code === 200) {
+                    showMsg('更新成功', 1);
+                    this.search();
+                }
+            },
+            delTag(item, cTag) {
+                let content = item.content;
+                // 如果没有,就不删除
+                if (content.indexOf(cTag) === -1) {
+                    return;
+                }
+                item.content = content.replace('#' + cTag + " ", '');
+                // 提交记录
+                let res = requestUtil.sync('https://web_history.tianyunperfect.cn/memos/update', 'post', {
+                    id: item.id,
+                    content: item.content,
+                    created_ts: item.created_ts
+                }, {});
+                if (res.code === 200) {
+                    showMsg('更新成功', 1);
+                    this.search();
+                }
+            },
             del(item) {
                 // 提醒是否删除
                 this.$confirm('此操作将永久删除该文件, 是否继续?', '提示', {confirmButtonText: '确定', cancelButtonText: '取消', type: 'warning'}).then(() => {
@@ -286,7 +344,7 @@
                 document.documentElement.scrollTo(0, 0);
                 this.resourceMap = {};
 
-                let params = {'search': this.searchStr, tag_str: this.tagChecked.join(','), page: this.page, page_size: 100};
+                let params = {'search': this.searchStr, tag_str: this.tagChecked.join(','), page: this.page, page_size: this.size};
                 let url = 'https://web_history.tianyunperfect.cn/memos/list';
                 let urlWithParams = requestUtil.buildUrl(url, params);
                 let res = requestUtil.sync(urlWithParams, 'get', null, myHeaders);