123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 |
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="UTF-8">
- <title>content_all</title>
- <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
- <script src="js/login.js"></script>
- <script src="js/util.js"></script>
- <style>
- .item {
- display: inline-block;
- margin-right: 20px; /* 调整间隔 */
- vertical-align: top;
- }
- .item a {
- margin-right: 10px; /* 链接和按钮之间的间隔 */
- }
- .delete-btn {
- font-size: 10px; /* 设置字体大小 */
- color: #f44336; /* 红色 */
- background: none;
- border: none;
- cursor: pointer;
- padding: 0;
- margin-left: 5px; /* 调整叉号与链接之间的间隔 */
- }
- .delete-btn:hover {
- color: #d32f2f; /* 悬停时颜色加深 */
- }
- </style>
- </head>
- <body>
- <ul id="list"></ul>
- <script>
- $(function () {
- if (!checkLogin()) {
- return;
- }
- let type = getQueryString("type");
- if (!type) {
- showMsg("没有类型", 2000);
- return;
- }
- $.getJSON('https://web_history.tianyunperfect.cn/content/getListByType?type=' + type, function (result) {
- if (result.code === 200) {
- let data = result.res;
- let listHtml = '';
- for (let i = 0; i < data.length; i++) {
- let a = data[i].id;
- let title = data[i].title;
- let version = data[i].version;
- // share_id
- let share_id = data[i].share_id;
- let url = '';
- if (type === "mind-map") {
- url = `https://map.tianyunperfect.cn/?id=${a}&share_id=${share_id}`;
- } else if (type === "excel") {
- url = `https://excel.tianyunperfect.cn/?id=${a}&share_id=${share_id}`;
- } else if (type === "html") {
- url = `https://do.tianyunperfect.cn/?id=${a}&share_id=${share_id}`;
- } else if (type === "copy-page") {
- url = `https://web.tianyunperfect.cn/simple/mycopy.html?id=${a}&share_id=${share_id}`;
- } else if (type === "nav-page") {
- url = `https://web.tianyunperfect.cn/simple/nav.html?id=${a}&share_id=${share_id}`;
- } else {
- continue;
- }
- listHtml += `<div class="item">
- <a href="${url}" target="_blank">${title}</a>
- <button class="delete-btn" data-id="${a}" data-version="${version}">✖</button>
- </div>`;
- }
- $('#list').html(listHtml);
- $('.delete-btn').click(function () {
- let title = $(this).siblings('a').text(); // 获取标题
- if (confirm(`确认要删除 "${title}" 吗?`)) { // 在确认框中包含标题
- let id = $(this).data('id');
- let version = $(this).data('version');
- deleteData(id, version, $(this).closest('.item')); // 传递对应的DOM元素
- }
- });
- } else {
- alert(result.message);
- }
- });
- function deleteData(id, version, element) {
- $.ajax({
- url: 'https://web_history.tianyunperfect.cn/content/deleteById?id=' + id + '&version=' + version,
- type: 'DELETE',
- success: function (result) {
- if (result.code === 200) {
- // 删除对应的DOM元素
- element.remove();
- } else {
- alert(result.message);
- }
- },
- error: function () {
- alert('删除失败');
- }
- });
- }
- });
- </script>
- </body>
- </html>
|