content_all.html 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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. } else if (type === "copy-page") {
  62. url = `https://web.tianyunperfect.cn/simple/mycopy.html?id=${a}&share_id=${share_id}`;
  63. } else if (type === "nav-page") {
  64. url = `https://web.tianyunperfect.cn/simple/nav.html?id=${a}&share_id=${share_id}`;
  65. } else {
  66. continue;
  67. }
  68. listHtml += `<div class="item">
  69. <a href="${url}" target="_blank">${title}</a>
  70. <button class="delete-btn" data-id="${a}" data-version="${version}">&#10006;</button>
  71. </div>`;
  72. }
  73. $('#list').html(listHtml);
  74. $('.delete-btn').click(function () {
  75. let title = $(this).siblings('a').text(); // 获取标题
  76. if (confirm(`确认要删除 "${title}" 吗?`)) { // 在确认框中包含标题
  77. let id = $(this).data('id');
  78. let version = $(this).data('version');
  79. deleteData(id, version, $(this).closest('.item')); // 传递对应的DOM元素
  80. }
  81. });
  82. } else {
  83. alert(result.message);
  84. }
  85. });
  86. function deleteData(id, version, element) {
  87. $.ajax({
  88. url: 'https://web_history.tianyunperfect.cn/content/deleteById?id=' + id + '&version=' + version,
  89. type: 'DELETE',
  90. success: function (result) {
  91. if (result.code === 200) {
  92. // 删除对应的DOM元素
  93. element.remove();
  94. } else {
  95. alert(result.message);
  96. }
  97. },
  98. error: function () {
  99. alert('删除失败');
  100. }
  101. });
  102. }
  103. });
  104. </script>
  105. </body>
  106. </html>