history_list.html 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <!--<meta name="viewport" content="width=device-width, initial-scale=1">-->
  6. <script src="https://web.tianyunperfect.cn/util.js"></script>
  7. <title>历史 URL 列表</title>
  8. <script src="js/axios.min.js"></script>
  9. <script src="js/vue.min.js"></script>
  10. <script src="https://api.map.baidu.com/api?v=2.0&ak=WMYeXwq7z0VcaiUXTuYTGPZsm8Selmfd"></script>
  11. <style>
  12. .container {
  13. width: 500px;
  14. height: 50px;
  15. margin: 20px auto;
  16. }
  17. .parent {
  18. width: 100%;
  19. height: 42px;
  20. top: 4px;
  21. position: relative;
  22. }
  23. .parent > input:first-of-type {
  24. /*输入框高度设置为40px, border占据2px,总高度为42px*/
  25. width: 380px;
  26. height: 40px;
  27. border: 1px solid #ccc;
  28. font-size: 16px;
  29. outline: none;
  30. }
  31. .parent > input:first-of-type:focus {
  32. border: 1px solid #317ef3;
  33. padding-left: 10px;
  34. }
  35. .parent > input:last-of-type {
  36. /*button按钮border并不占据外围大小,设置高度42px*/
  37. width: 100px;
  38. height: 44px;
  39. position: absolute;
  40. background: #317ef3;
  41. border: 1px solid #317ef3;
  42. color: #fff;
  43. font-size: 16px;
  44. outline: none;
  45. }
  46. </style>
  47. </head>
  48. <body>
  49. <div id="tby">
  50. <div class="container">
  51. <form action="" class="parent">
  52. <input type="text" v-model="msg">
  53. <input type="button" value="搜索" @click="search">
  54. </form>
  55. </div>
  56. <table>
  57. <thead>
  58. <tr>
  59. <td>id</td>
  60. <td>时间</td>
  61. <td>网址</td>
  62. <td>url</td>
  63. </tr>
  64. </thead>
  65. <tbody>
  66. <tr v-for="(item,index) in list">
  67. <td>{{item.id}}</td>
  68. <td>{{new Date(item.create_time).format("yyyy-MM-dd hh:mm:ss")}}</td>
  69. <td>
  70. <a :href="item.url"
  71. target="_blank">{{item.title}}</a>
  72. </td>
  73. <td>{{item.url}}</td>
  74. </tr>
  75. </tbody>
  76. </table>
  77. <!-- 分页按钮 -->
  78. <div class="page-icon">
  79. <button class="firstPage" @click="first_click">第一页</button>
  80. <button class="beforePage" @click="prev_click">上一页</button>
  81. <button>第<input v-model="page" @change="choose_page" type="text" value="1"/>页</button>
  82. <button class="nextPage" @click="next_click">下一页</button>
  83. </div>
  84. </div>
  85. <script>
  86. Date.prototype.format = function (fmt) {
  87. var o = {
  88. "M+": this.getMonth() + 1, //月份
  89. "d+": this.getDate(), //日
  90. "h+": this.getHours(), //小时
  91. "m+": this.getMinutes(), //分
  92. "s+": this.getSeconds(), //秒
  93. "q+": Math.floor((this.getMonth() + 3) / 3), //季度
  94. "S": this.getMilliseconds() //毫秒
  95. };
  96. if (/(y+)/.test(fmt)) {
  97. fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
  98. }
  99. for (var k in o) {
  100. if (new RegExp("(" + k + ")").test(fmt)) {
  101. fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
  102. }
  103. }
  104. return fmt;
  105. }
  106. const scrollElement = (el) => {
  107. document.querySelector(el).scrollIntoView({behavior: 'smooth'});
  108. }
  109. let _this = new Vue({
  110. el: '#tby',
  111. data: {
  112. page: 1,
  113. size: 30,
  114. msg: "",
  115. list: []
  116. },
  117. mounted: function () {
  118. this.search();
  119. },
  120. methods: {
  121. first_click: function () {
  122. this.page = 1;
  123. this.search();
  124. },
  125. prev_click: function () {
  126. this.page -= 1;
  127. this.search();
  128. },
  129. choose_page: function () {
  130. this.search();
  131. },
  132. next_click: function () {
  133. this.page += 1;
  134. this.search();
  135. },
  136. getParam: function () {
  137. let obj = {};
  138. obj['title'] = this.msg;
  139. obj['page'] = this.page;
  140. obj['size'] = this.size;
  141. return obj;
  142. },
  143. search: function () {
  144. axios.get("https://api.tianyunperfect.cn/web_history/search", {params: this.getParam()}).then(res => {
  145. if (res.data.code === 1) {
  146. _this.list = res.data.data.list;
  147. }
  148. });
  149. }
  150. }
  151. });
  152. </script>
  153. </body>
  154. </html>