directory_picture.html 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <div class="row cl">
  2. <table class="table table-border table-bordered table-bg">
  3. <thead>
  4. <tr class="text-c">
  5. <th>
  6. <strong>文件名</strong>
  7. </th>
  8. <th>
  9. <strong>文件大小</strong>
  10. </th>
  11. <th>
  12. <strong>最后修改时间</strong>
  13. </th>
  14. </tr>
  15. </thead>
  16. <tbody>
  17. </tbody>
  18. </table>
  19. </div>
  20. <script type="text/javascript">
  21. var data = {
  22. dirs: [],
  23. files: [],
  24. activeurl: '',
  25. activepath: ''
  26. }
  27. function maketbody() {
  28. let tbhtml = '';
  29. tbhtml += '<tr class="text-c" bgcolor="#FFFFFF" height="26" onMouseMove="javascript:this.bgColor=\'#FCFDEE\';" onMouseOut="javascript:this.bgColor=\'#FFFFFF\';">'
  30. tbhtml += '<td>'+(data.activeurl ? '<i class="Hui-iconfont Hui-iconfont-arrow1-top"></i>' : '') +'<a onclick="onlinepicture(\''+data.activeurl+'\')">上级目录</a></td>'
  31. tbhtml += '<td>当前目录:<span style="color:#f00;"> ./storage'+data.activepath+'</span></td><td></td></tr>'
  32. data.dirs.forEach((dir) => {
  33. tbhtml += '<tr class="text-c" style="height:26px; " onMouseMove="javascript:this.bgColor=\'#FCFDEE\';" onMouseOut="javascript:this.bgColor=\'#FFFFFF\';">'
  34. tbhtml += '<td style="text-align:left;"><img src="/static/images/icon/dir.png">'
  35. tbhtml += '<a onclick="onlinepicture(\''+data.activepath+'/'+dir+'\')">'+dir+'</a></td><td></td><td></td></tr>'
  36. });
  37. data.files.forEach((file) => {
  38. tbhtml += '<tr class="text-c" style="height:26px; " onMouseMove="javascript:this.bgColor=\'#FCFDEE\';" onMouseOut="javascript:this.bgColor=\'#FFFFFF\';">'
  39. tbhtml += '<td style="text-align:left;"><img src="/static/images/icon/'+file.extension+'.png">'
  40. tbhtml += '<a onclick="selcetimg(\'/storage'+data.activepath+'/'+file.filename+'\')">'+file.filename+'</a></td>'
  41. tbhtml += '<td>'+file.size+'</td><td></td></tr>'
  42. });
  43. document.querySelector('table tbody').innerHTML = tbhtml;
  44. }
  45. function onlinepicture(activepath) {
  46. $.ajax({
  47. url: '{:url("file_manager/explorer")}',
  48. type: 'GET',
  49. async: true,
  50. cache: false,
  51. data: 'activepath='+activepath,
  52. processData: false,
  53. contentType: 'application/x-www-form-urlencoded',
  54. dataType: "json",
  55. success: function (res) {
  56. if (res.code == 0) {
  57. // console.log(res);
  58. data.dirs = res.dirs
  59. data.files = res.files
  60. data.activeurl = res.activeurl
  61. data.activepath = res.activepath
  62. maketbody();
  63. }
  64. }
  65. });
  66. }
  67. function selcetimg(img) {
  68. $("#online_file").val(img);
  69. }
  70. onlinepicture(data.activepath);
  71. </script>