tianyun 1 year ago
parent
commit
e187d4555b
1 changed files with 73 additions and 0 deletions
  1. 73 0
      simple-demo/content_all.html

+ 73 - 0
simple-demo/content_all.html

@@ -0,0 +1,73 @@
+<!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>
+</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;
+                    if (type === "mind-map") {
+                        let url = `https://map.tianyunperfect.cn/?id=${a}&version=${version}&share_id=${share_id}&r=0`;
+                        listHtml += '<li><a href="' + url + '" target="_blank">' + title + '</a>&nbsp;&nbsp;&nbsp;<button class="delete-btn" data-id="' + a + '" data-version="' + version + '">删除</button></li>';
+                    }
+                }
+                $('#list').html(listHtml);
+
+                $('.delete-btn').click(function () {
+                    if (confirm('确认要删除吗?')) {
+                        let id = $(this).data('id');
+                        let version = $(this).data('version');
+                        deleteData(id, version);
+                    }
+                });
+            } else {
+                alert(result.message);
+            }
+        });
+
+        function deleteData(id, version) {
+            if (type === "mind-map") {
+                $.ajax({
+                    url: 'https://web_history.tianyunperfect.cn/content/deleteById?id=' + id + '&version=' + version,
+                    type: 'DELETE',
+                    success: function (result) {
+                        if (result.code === 200) {
+                            location.reload();
+                        } else {
+                            alert(result.message);
+                        }
+                    },
+                    error: function () {
+                        alert('删除失败');
+                    }
+                });
+            }
+        }
+    });
+</script>
+</body>
+</html>