index.html 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <!doctype html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport"
  6. content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
  7. <meta http-equiv="X-UA-Compatible" content="ie=edge">
  8. <title>COS 上传队列</title>
  9. <link rel="stylesheet" href="style.css">
  10. </head>
  11. <body>
  12. <div class="page">
  13. <h1>COS 上传队列</h1>
  14. <div id="app">
  15. <form id="form">
  16. <div class="float-right">共{{total}}个文件</div>
  17. <input type="file" value="选择上传文件" multiple @change="selectedFile">
  18. </form>
  19. <table class="file-list">
  20. <colgroup>
  21. <col style="width:20%;">
  22. <col style="width:10%;">
  23. <col style="width:40%;">
  24. <col style="width:30%;">
  25. </colgroup>
  26. <tr class="file-item">
  27. <td>文件名</td>
  28. <td>大小</td>
  29. <td>进度</td>
  30. <td class="file-action">操作</td>
  31. </tr>
  32. <tr class="file-item" v-for="item in list">
  33. <td><span class="file-name">{{item.Key}}</span></td>
  34. <td>{{formatSize(item.size)}}</td>
  35. <td>
  36. <span class="file-progress" v-if="item.state==='uploading'">
  37. <span class="file-progress-loaded" :style="'width:'+item.percent*100+'%'"></span>
  38. </span>
  39. <span v-if="item.state==='success'">已完成</span>
  40. <span v-else-if="item.state==='waiting'">等待上传</span>
  41. <span v-else-if="item.state==='checking'">校验中({{parseInt(item.hashPercent*100)}}%)</span>
  42. <span v-else-if="item.state==='paused'">已暂停, 已传{{formatSize(item.loaded)}}</span>
  43. <span v-else-if="item.state==='canceled'">已取消</span>
  44. <span v-else>{{formatSize(item.speed)}}/s, 已传{{formatSize(item.loaded)}} {{parseInt(item.percent*100)}}%</span>
  45. </td>
  46. <td class="file-action">
  47. <a v-if="['waiting','checking','uploading'].includes(item.state)" href="javascript:void(0)" @click="pauseTask(item)">暂停</a>
  48. <a v-if="['error','paused'].includes(item.state)" href="javascript:void(0)" @click="restartTask(item)">开始</a>
  49. <a v-if="item.state!=='canceled'" href="javascript:void(0)" @click="cancelTask(item)">删除</a>
  50. </td>
  51. </tr>
  52. <tr class="file-item" v-if="!list.length">
  53. <td colspan="4" align="center">暂无上传文件</td>
  54. </tr>
  55. </table>
  56. </div>
  57. </div>
  58. <script src="../../dist/cos-js-sdk-v5.js"></script>
  59. <script src="../common/lodash.core.min.js"></script>
  60. <script src="../common/vue.min.js"></script>
  61. <script src="./index.js"></script>
  62. </body>
  63. </html>