tianyun 2 년 전
부모
커밋
346700e336
3개의 변경된 파일32개의 추가작업 그리고 172개의 파일을 삭제
  1. 0 166
      simple-demo/history_list.html
  2. 7 0
      simple-demo/push.sh
  3. 25 6
      simple-demo/webp.html

+ 0 - 166
simple-demo/history_list.html

@@ -1,166 +0,0 @@
-<!DOCTYPE html>
-<html lang="en">
-<head>
-    <meta charset="UTF-8">
-    <!--<meta name="viewport" content="width=device-width, initial-scale=1">-->
-    <script src="https://web.tianyunperfect.cn/util.js"></script>
-    <title>历史 URL 列表</title>
-    <script src="js/axios.min.js"></script>
-    <script src="js/vue.min.js"></script>
-    <script src="https://api.map.baidu.com/api?v=2.0&ak=WMYeXwq7z0VcaiUXTuYTGPZsm8Selmfd"></script>
-    <style>
-        .container {
-            width: 500px;
-            height: 50px;
-            margin: 20px auto;
-        }
-        .parent {
-            width: 100%;
-            height: 42px;
-            top: 4px;
-            position: relative;
-        }
-
-        .parent > input:first-of-type {
-            /*输入框高度设置为40px, border占据2px,总高度为42px*/
-            width: 380px;
-            height: 40px;
-            border: 1px solid #ccc;
-            font-size: 16px;
-            outline: none;
-        }
-
-        .parent > input:first-of-type:focus {
-            border: 1px solid #317ef3;
-            padding-left: 10px;
-        }
-
-        .parent > input:last-of-type {
-            /*button按钮border并不占据外围大小,设置高度42px*/
-            width: 100px;
-            height: 44px;
-            position: absolute;
-            background: #317ef3;
-            border: 1px solid #317ef3;
-            color: #fff;
-            font-size: 16px;
-            outline: none;
-        }
-    </style>
-</head>
-<body>
-<div id="tby">
-    <div class="container">
-        <form action="" class="parent">
-            <input type="text" v-model="msg">
-            <input type="button" value="搜索" @click="search">
-        </form>
-    </div>
-    <table>
-        <thead>
-        <tr>
-            <td>id</td>
-            <td>时间</td>
-            <td>网址</td>
-            <td>url</td>
-        </tr>
-        </thead>
-        <tbody>
-        <tr v-for="(item,index) in list">
-            <td>{{item.id}}</td>
-            <td>{{new Date(item.create_time).format("yyyy-MM-dd hh:mm:ss")}}</td>
-            <td>
-                <a :href="item.url"
-                   target="_blank">{{item.title}}</a>
-            </td>
-            <td>{{item.url}}</td>
-        </tr>
-        </tbody>
-    </table>
-    <!-- 分页按钮 -->
-    <div class="page-icon">
-        <button class="firstPage" @click="first_click">第一页</button>
-        <button class="beforePage" @click="prev_click">上一页</button>
-        <button>第<input v-model="page" @change="choose_page" type="text" value="1"/>页</button>
-        <button class="nextPage" @click="next_click">下一页</button>
-    </div>
-
-
-</div>
-
-
-<script>
-
-    Date.prototype.format = function (fmt) {
-        var o = {
-            "M+": this.getMonth() + 1,                 //月份
-            "d+": this.getDate(),                    //日
-            "h+": this.getHours(),                   //小时
-            "m+": this.getMinutes(),                 //分
-            "s+": this.getSeconds(),                 //秒
-            "q+": Math.floor((this.getMonth() + 3) / 3), //季度
-            "S": this.getMilliseconds()             //毫秒
-        };
-        if (/(y+)/.test(fmt)) {
-            fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
-        }
-        for (var k in o) {
-            if (new RegExp("(" + k + ")").test(fmt)) {
-                fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
-            }
-        }
-        return fmt;
-    }
-
-    const scrollElement = (el) => {
-        document.querySelector(el).scrollIntoView({behavior: 'smooth'});
-    }
-
-    let _this = new Vue({
-        el: '#tby',
-        data: {
-            page: 1,
-            size: 30,
-            msg: "",
-            list: []
-        },
-        mounted: function () {
-            this.search();
-        },
-        methods: {
-            first_click: function () {
-                this.page = 1;
-                this.search();
-            },
-            prev_click: function () {
-                this.page -= 1;
-                this.search();
-            },
-            choose_page: function () {
-                this.search();
-            },
-            next_click: function () {
-                this.page += 1;
-                this.search();
-            },
-            getParam: function () {
-                let obj = {};
-                obj['title'] = this.msg;
-                obj['page'] = this.page;
-                obj['size'] = this.size;
-                return obj;
-            },
-            search: function () {
-                axios.get("https://api.tianyunperfect.cn/web_history/search", {params: this.getParam()}).then(res => {
-                    if (res.data.code === 1) {
-                        _this.list = res.data.data.list;
-                    }
-                });
-            }
-        }
-    });
-
-
-</script>
-</body>
-</html>

+ 7 - 0
simple-demo/push.sh

@@ -0,0 +1,7 @@
+remote=root@www.tianyunperfect.cn
+
+
+# 在本地执行的代码,比如上传文件到服务器 scp 本地文件 user@ip:远程目录
+scp -r ../simple-demo/* ${remote}:/www/wwwroot/web.tianyunperfect.cn/simple
+
+echo ok

+ 25 - 6
simple-demo/webp.html

@@ -32,12 +32,24 @@
 
     // 监听粘贴事件
     document.addEventListener("paste", (event) => {
-        // 获取粘贴板数据
-        const items = event.clipboardData.items;
+        handleClipboardItems(event.clipboardData.items);
+    });
+
+    // 监听拖拽事件
+    document.addEventListener("dragover", (event) => {
+        event.preventDefault();
+    });
+
+    document.addEventListener("drop", (event) => {
+        event.preventDefault();
+        handleClipboardItems(event.dataTransfer.items);
+    });
+
+    // 处理粘贴板或拖拽项
+    function handleClipboardItems(items) {
         if (!items) {
             return;
         }
-
         // 查找图片数据
         for (let i = 0; i < items.length; i++) {
             if (items[i].type.indexOf("image") !== -1) {
@@ -65,9 +77,16 @@
                         // 将压缩后的webp图片展示在页面上
                         const webpUrl = URL.createObjectURL(webpBlob);
                         imageDisplay.src = webpUrl;
-                        document.getElementById("status").innerText = " 已压缩 ☺";
-                        document.getElementById("afterSize").innerText = formatSize(webpBlob.size);
 
+                        // 转换为base64编码
+                        const reader = new FileReader();
+                        reader.onloadend = () => {
+                            // You can further process or use the base64Data as needed
+                            document.getElementById("status").innerText = " 已压缩 ☺";
+                            document.getElementById("afterSize").innerText = formatSize(webpBlob.size);
+                            imageDisplay.src = reader.result;
+                        };
+                        reader.readAsDataURL(webpBlob);
                     }, "image/webp", 0.8);
                 };
                 image.src = imageUrl;
@@ -76,7 +95,7 @@
                 event.preventDefault();
             }
         }
-    });
+    }
 </script>
 </body>
 </html>