index.html 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>folder-server</title>
  6. <link href="css/index.css" rel="stylesheet" />
  7. </head>
  8. <body>
  9. <div>
  10. <h1>folder-server</h1>
  11. <p>拖动目录到窗口,启动启动本地服务器访问!</p>
  12. <div id="drag-file">
  13. <p>拖动目录到窗口,启动启动本地服务器访问</p>
  14. </div>
  15. </div>
  16. <!-- You can also require other files to run in this process -->
  17. <script src="./js/renderer.js"></script>
  18. <script>
  19. (function () {
  20. var holder = document.getElementById('drag-file');
  21. holder.ondragover = () => {
  22. return false;
  23. };
  24. holder.ondragleave = () => {
  25. return false;
  26. };
  27. holder.ondragend = () => {
  28. return false;
  29. };
  30. holder.ondrop = (e) => {
  31. e.preventDefault();
  32. if (e.dataTransfer.files.length > 1) {// 如果拖动多个files,不做
  33. console.log("muti files")
  34. return;
  35. } else {// 如果拖动folder,做
  36. console.log("dir is:", e.dataTransfer.files[0].path)
  37. }
  38. return false;
  39. };
  40. })();
  41. </script>
  42. </body>
  43. </html>