content_all.html 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>content_all</title>
  6. <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
  7. <script src="js/login.js"></script>
  8. <script src="js/util.js"></script>
  9. <style>
  10. .item {
  11. display: inline-block;
  12. margin-right: 20px; /* 调整间隔 */
  13. vertical-align: top;
  14. }
  15. .item a {
  16. margin-right: 10px; /* 链接和按钮之间的间隔 */
  17. }
  18. .delete-btn {
  19. font-size: 10px; /* 设置字体大小 */
  20. color: #f44336; /* 红色 */
  21. background: none;
  22. border: none;
  23. cursor: pointer;
  24. padding: 0;
  25. margin-left: 5px; /* 调整叉号与链接之间的间隔 */
  26. }
  27. .delete-btn:hover {
  28. color: #d32f2f; /* 悬停时颜色加深 */
  29. }
  30. </style>
  31. </head>
  32. <body>
  33. <ul id="list"></ul>
  34. <script>
  35. $(function () {
  36. if (!checkLogin()) {
  37. return;
  38. }
  39. let type = getQueryString("type");
  40. if (!type) {
  41. showMsg("没有类型", 2000);
  42. return;
  43. }
  44. $.getJSON('https://web_history.tianyunperfect.cn/content/getListByType?type=' + type, function (result) {
  45. if (result.code === 200) {
  46. let data = result.res;
  47. let listHtml = '';
  48. for (let i = 0; i < data.length; i++) {
  49. let a = data[i].id;
  50. let title = data[i].title;
  51. let version = data[i].version;
  52. // share_id
  53. let share_id = data[i].share_id;
  54. let url='';
  55. if (type === "mind-map") {
  56. url = `https://map.tianyunperfect.cn/?id=${a}&share_id=${share_id}`;
  57. }else if(type === "excel"){
  58. url = `https://excel.tianyunperfect.cn/?id=${a}&share_id=${share_id}`;
  59. }else if (type === "html"){
  60. url = `https://do.tianyunperfect.cn/?id=${a}&share_id=${share_id}`;
  61. }
  62. listHtml += `<div class="item">
  63. <a href="${url}" target="_blank">${title}</a>
  64. <button class="delete-btn" data-id="${a}" data-version="${version}">&#10006;</button>
  65. </div>`;
  66. }
  67. $('#list').html(listHtml);
  68. $('.delete-btn').click(function () {
  69. let title = $(this).siblings('a').text(); // 获取标题
  70. if (confirm(`确认要删除 "${title}" 吗?`)) { // 在确认框中包含标题
  71. let id = $(this).data('id');
  72. let version = $(this).data('version');
  73. deleteData(id, version);
  74. }
  75. });
  76. } else {
  77. alert(result.message);
  78. }
  79. });
  80. function deleteData(id, version) {
  81. if (type === "mind-map") {
  82. $.ajax({
  83. url: 'https://web_history.tianyunperfect.cn/content/deleteById?id=' + id + '&version=' + version,
  84. type: 'DELETE',
  85. success: function (result) {
  86. if (result.code === 200) {
  87. location.reload();
  88. } else {
  89. alert(result.message);
  90. }
  91. },
  92. error: function () {
  93. alert('删除失败');
  94. }
  95. });
  96. }
  97. }
  98. });
  99. </script>
  100. </body>
  101. </html>