国内流行的内容管理系统(CMS)多端全媒体解决方案 https://www.dedebiz.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

249 lines
8.7KB

  1. function AddNew() {
  2. $DE('addTab').style.display = 'block';
  3. }
  4. function CloseTab(tb) {
  5. $DE(tb).style.display = 'none';
  6. }
  7. function ListAll() {
  8. $DE('editTab').style.display = 'block';
  9. fetch('index_body.php?dopost=editshow').then(resp => resp.text()).then((d) => {
  10. $DE('editTabBody').innerHTML = d;
  11. });
  12. }
  13. function ShowWaitDiv() {
  14. $DE('loaddiv').style.display = 'block';
  15. return true;
  16. }
  17. function DedeCopyToClipboard(text) {
  18. if (navigator.clipboard) {
  19. navigator.clipboard.writeText(text);
  20. } else {
  21. var textarea = document.createElement('textarea');
  22. document.body.appendChild(textarea);
  23. //隐藏此输入框
  24. textarea.style.position = 'fixed';
  25. textarea.style.clip = 'rect(0 0 0 0)';
  26. textarea.style.top = '10px';
  27. textarea.style.display = 'none';
  28. textarea.value = text;
  29. textarea.select();
  30. document.execCommand('copy', true);
  31. document.body.removeChild(textarea);
  32. }
  33. }
  34. $(function () {
  35. $.get("index_testenv.php", function (data) {
  36. if (data !== '') {
  37. $("#body-tips").html(data);
  38. }
  39. });
  40. $.get("index_body.php?dopost=get_articles", function (data) {
  41. if (data !== '') {
  42. $("#system-word").html(data);
  43. }
  44. });
  45. });
  46. function Copyinfo() {
  47. var val = document.getElementById('text');
  48. window.getSelection().selectAllChildren(val);
  49. document.execCommand("Copy");
  50. alert("成功复制环境配置信息");
  51. }
  52. //Dedebiz info
  53. var dedebizInfo;
  54. function ViewDedeBIZ() {
  55. console.log(dedebizInfo);
  56. ShowMsg(`
  57. <table class="table table-borderless w-100">
  58. <tr>
  59. <td width="90">版本号:</td>
  60. <td>V${dedebizInfo.result.server_version}</td>
  61. <td width="90">服务器系统:</td>
  62. <td>${dedebizInfo.result.server_goos}(${dedebizInfo.result.server_goarch})</td>
  63. </tr>
  64. <tr>
  65. <td>运行时间:</td>
  66. <td>${dedebizInfo.result.server_run_time}</td>
  67. <td>内存占用:</td>
  68. <td>${dedebizInfo.result.server_memory_usage}%</td>
  69. </tr>
  70. </table>
  71. `);
  72. }
  73. function LoadServer() {
  74. $.get("index_body.php?dopost=system_info", function (data) {
  75. let rsp = JSON.parse(data);
  76. if (rsp.code === 200) {
  77. let infoStr = `<table class="table table-borderless w-100">`;
  78. if (typeof rsp.result.domain !== "undefined") {
  79. infoStr += `
  80. <tr>
  81. <td width="90">授权域名:</td>
  82. <td>${rsp.result.domain}</td>
  83. <td width="90">授权版本:</td>
  84. <td>${rsp.result.auth_version}.x.x(时间:${rsp.result.auth_at})</td>
  85. </tr>
  86. <tr>
  87. <td>站点名称:</td>
  88. <td>${rsp.result.title}(${rsp.result.stype})</td>
  89. <td>证书组件:</td>
  90. <td>
  91. <a href="${cfg_biz_dedebizUrl}/auth/?domain=${rsp.result.domain}" target="_blank" class="btn btn-success btn-sm">授权证书</a>
  92. <a href="javascript:ViewDedeBIZ()" class="btn btn-primary btn-sm">组件信息</a>
  93. </td>
  94. </tr>
  95. `;
  96. }
  97. infoStr += "</table>";
  98. $("#system-info").html(infoStr);
  99. } else {
  100. $("#system-info").html(`
  101. <table class="table table-borderless w-100">
  102. <tr>
  103. <td>${rsp.msg}</td>
  104. </tr>
  105. <tr>
  106. <td>如果您已购买商业版授权,可以在我们的授权中心查询到相信关授权信息,如果查询结果与实际授权不符,则说明您可能购买了非法商业授权,请及时与我们取得联系。</td>
  107. </tr>
  108. </table>
  109. `);
  110. }
  111. });
  112. }
  113. Date.prototype.Format = function (fmt) { //author: meizz
  114. var o = {
  115. "M+": this.getMonth() + 1, //月份
  116. "d+": this.getDate(), //日
  117. "h+": this.getHours(), //小时
  118. "m+": this.getMinutes(), //分
  119. "s+": this.getSeconds(), //秒
  120. "q+": Math.floor((this.getMonth() + 3) / 3), //季度
  121. "S": this.getMilliseconds() //毫秒
  122. };
  123. if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
  124. for (var k in o)
  125. if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
  126. return fmt;
  127. }
  128. function LoadStat() {
  129. $.get("index_body.php?dopost=get_statistics", function (data) {
  130. try {
  131. let rsp = JSON.parse(data);
  132. if (rsp.code == 200) {
  133. var tpv = parseInt(rsp.result.pv);
  134. var tuv = parseInt(rsp.result.uv);
  135. var tip = parseInt(rsp.result.ip);
  136. var tvv = parseInt(rsp.result.vv);
  137. $("#today_pv").html(tpv);
  138. $("#today_uv").html(tuv);
  139. $("#today_ip").html(tip);
  140. $("#today_vv").html(tvv);
  141. $.get("index_body.php?dopost=get_statistics&sdate=-1", function (data) {
  142. let rsp = JSON.parse(data);
  143. if (rsp.code == 200) {
  144. $("#total_pv").html(parseInt(rsp.result.pv) + tpv);
  145. $("#total_uv").html(parseInt(rsp.result.uv) + tuv);
  146. $("#total_ip").html(parseInt(rsp.result.ip) + tip);
  147. $("#total_vv").html(parseInt(rsp.result.vv) + tvv);
  148. }
  149. });
  150. }
  151. } catch (error) {
  152. console.log("加载统计信息失败")
  153. }
  154. });
  155. var d = new Date();
  156. d.setDate(d.getDate() - 1);
  157. var s = d.Format("yyyy-MM-dd");
  158. s = s.replaceAll("-", "");
  159. $.get("index_body.php?dopost=get_statistics&sdate=" + s, function (data) {
  160. try {
  161. let rsp = JSON.parse(data);
  162. if (rsp.code == 200) {
  163. $("#yestoday_pv").html(rsp.result.pv);
  164. $("#yestoday_uv").html(rsp.result.uv);
  165. $("#yestoday_ip").html(rsp.result.ip);
  166. $("#yestoday_vv").html(rsp.result.vv);
  167. }
  168. } catch (error) {
  169. console.log("加载统计信息失败")
  170. }
  171. });
  172. }
  173. async function LoadStatChart() {
  174. const ctx = document.getElementById('statChart').getContext('2d');
  175. let labels = [];
  176. let dates = [];
  177. let pvs = [];
  178. let ips = [];
  179. let uvs = [];
  180. let vvs = [];
  181. for (let i = 15; i > 0; i--) {
  182. var d = new Date();
  183. d.setDate(d.getDate() - i);
  184. var s = d.Format("yyyy-MM-dd");
  185. labels.push(d.Format("MM-dd"));
  186. s = s.replaceAll("-", "");
  187. dates.push(s);
  188. }
  189. let resp = await fetch("index_body.php?dopost=get_statistics_multi&sdates=" + dates.join(","));
  190. let data = await resp.json();
  191. if (data.code == 200) {
  192. data.result.forEach(e => {
  193. pvs.push(typeof e.pv == "undefined" ? 0 : e.pv);
  194. ips.push(typeof e.ip == "undefined" ? 0 : e.ip);
  195. uvs.push(typeof e.uv == "undefined" ? 0 : e.uv);
  196. vvs.push(typeof e.vv == "undefined" ? 0 : e.vv);
  197. });
  198. }
  199. const myChart = new Chart(ctx, {
  200. type: 'line',
  201. options: {
  202. responsive: true,
  203. plugins: {
  204. legend: {
  205. position: 'right',
  206. }
  207. }
  208. },
  209. data: {
  210. labels: labels,
  211. datasets: [
  212. {
  213. label: 'PV',
  214. data: pvs,
  215. borderColor: 'rgba(54, 162, 235, 1)',
  216. backgroundColor: 'rgba(54, 162, 235, 0.2)',
  217. borderWidth: 1
  218. }, {
  219. label: 'UV',
  220. data: uvs,
  221. borderColor: 'rgba(255, 206, 86, 1)',
  222. backgroundColor: 'rgba(255, 206, 86, 0.2)',
  223. borderWidth: 1
  224. }, {
  225. label: 'IP',
  226. data: ips,
  227. borderColor: 'rgba(255, 99, 132, 1)',
  228. backgroundColor: 'rgba(255, 99, 132, 0.2)',
  229. borderWidth: 1
  230. }
  231. , {
  232. label: 'VV',
  233. data: vvs,
  234. borderColor: 'rgba(75, 192, 192, 1)',
  235. backgroundColor: 'rgba(75, 192, 192, 0.2)',
  236. borderWidth: 1
  237. }
  238. ]
  239. },
  240. });
  241. }
  242. $(document).ready(function () {
  243. LoadServer();
  244. LoadStat();
  245. LoadStatChart();
  246. setInterval(function () {
  247. LoadServer();
  248. }, 60000)
  249. });