1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="UTF-8">
- <title>folder-server</title>
- <link href="css/index.css" rel="stylesheet" />
- </head>
- <body>
- <div>
- <h1>folder-server</h1>
- <p>拖动目录到窗口,启动启动本地服务器访问!</p>
- <div id="drag-file">
- <p>拖动目录到窗口,启动启动本地服务器访问</p>
- </div>
- </div>
- <!-- You can also require other files to run in this process -->
- <script src="./js/renderer.js"></script>
- <script>
- (function () {
- var holder = document.getElementById('drag-file');
- holder.ondragover = () => {
- return false;
- };
- holder.ondragleave = () => {
- return false;
- };
- holder.ondragend = () => {
- return false;
- };
- holder.ondrop = (e) => {
- e.preventDefault();
- if (e.dataTransfer.files.length > 1) {// 如果拖动多个files,不做
- console.log("muti files")
- return;
- } else {// 如果拖动folder,做
- console.log("dir is:", e.dataTransfer.files[0].path)
- }
- return false;
- };
- })();
- </script>
- </body>
- </html>
|