国内流行的内容管理系统(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.

253 line
8.8KB

  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="120">版本号:</td>
  60. <td>V${dedebizInfo.result.server_version}</td>
  61. <td width="120">服务器系统:</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. if (rsp.result.core.code === 200) {
  78. dedebizInfo = JSON.parse(rsp.result.core.data);
  79. }
  80. let infoStr = `<table class="table table-borderless w-100">`;
  81. if (typeof rsp.result.domain !== "undefined") {
  82. infoStr += `
  83. <tr>
  84. <td width="90">授权域名:</td>
  85. <td>${rsp.result.domain}</td>
  86. <td width="90">授权版本:</td>
  87. <td>${rsp.result.auth_version}.x.x(时间:${rsp.result.auth_at})</td>
  88. </tr>
  89. <tr>
  90. <td>站点名称:</td>
  91. <td>${rsp.result.title}(${rsp.result.stype})</td>
  92. <td>证书组件:</td>
  93. <td>
  94. <a href="${cfg_biz_dedebizUrl}/auth/?domain=${rsp.result.domain}" target="_blank" class="btn btn-success btn-sm">授权证书</a>
  95. <a href="javascript:ViewDedeBIZ()" class="btn btn-primary btn-sm">组件信息</a>
  96. </td>
  97. </tr>
  98. `;
  99. }
  100. infoStr += "</table>";
  101. $("#system-info").html(infoStr);
  102. } else {
  103. $("#system-info").html(`
  104. <table class="table table-borderless w-100">
  105. <tr>
  106. <td>${rsp.msg}</td>
  107. </tr>
  108. <tr>
  109. <td>如果您已购买商业版授权,可以在我们的授权中心查询到相信关授权信息,查询结果与实际授权不对,可能购买了非商业授权,请及时与官方取得联系。</td>
  110. </tr>
  111. </table>
  112. `);
  113. }
  114. });
  115. }
  116. Date.prototype.Format = function (fmt) { //author: meizz
  117. var o = {
  118. "M+": this.getMonth() + 1, //月份
  119. "d+": this.getDate(), //日
  120. "h+": this.getHours(), //小时
  121. "m+": this.getMinutes(), //分
  122. "s+": this.getSeconds(), //秒
  123. "q+": Math.floor((this.getMonth() + 3) / 3), //季度
  124. "S": this.getMilliseconds() //毫秒
  125. };
  126. if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
  127. for (var k in o)
  128. if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
  129. return fmt;
  130. }
  131. function LoadStat() {
  132. $.get("index_body.php?dopost=get_statistics", function (data) {
  133. try {
  134. let rsp = JSON.parse(data);
  135. if (rsp.code == 200) {
  136. var tpv = parseInt(rsp.result.pv);
  137. var tuv = parseInt(rsp.result.uv);
  138. var tip = parseInt(rsp.result.ip);
  139. var tvv = parseInt(rsp.result.vv);
  140. $("#today_pv").html(tpv);
  141. $("#today_uv").html(tuv);
  142. $("#today_ip").html(tip);
  143. $("#today_vv").html(tvv);
  144. $.get("index_body.php?dopost=get_statistics&sdate=-1", function (data) {
  145. let rsp = JSON.parse(data);
  146. if (rsp.code == 200) {
  147. $("#total_pv").html(parseInt(rsp.result.pv) + tpv);
  148. $("#total_uv").html(parseInt(rsp.result.uv) + tuv);
  149. $("#total_ip").html(parseInt(rsp.result.ip) + tip);
  150. $("#total_vv").html(parseInt(rsp.result.vv) + tvv);
  151. }
  152. });
  153. }
  154. } catch (error) {
  155. console.log("加载统计信息失败")
  156. }
  157. });
  158. var d = new Date();
  159. d.setDate(d.getDate() - 1);
  160. var s = d.Format("yyyy-MM-dd");
  161. s = s.replaceAll("-", "");
  162. $.get("index_body.php?dopost=get_statistics&sdate=" + s, function (data) {
  163. try {
  164. let rsp = JSON.parse(data);
  165. if (rsp.code == 200) {
  166. $("#yestoday_pv").html(rsp.result.pv);
  167. $("#yestoday_uv").html(rsp.result.uv);
  168. $("#yestoday_ip").html(rsp.result.ip);
  169. $("#yestoday_vv").html(rsp.result.vv);
  170. }
  171. } catch (error) {
  172. console.log("加载统计信息失败")
  173. }
  174. });
  175. }
  176. async function LoadStatChart() {
  177. const ctx = document.getElementById('statChart').getContext('2d');
  178. let labels = [];
  179. let dates = [];
  180. let pvs = [];
  181. let ips = [];
  182. let uvs = [];
  183. let vvs = [];
  184. for (let i = 15; i > 0; i--) {
  185. var d = new Date();
  186. d.setDate(d.getDate() - i);
  187. var s = d.Format("yyyy-MM-dd");
  188. labels.push(d.Format("MM-dd"));
  189. s = s.replaceAll("-", "");
  190. dates.push(s);
  191. }
  192. let resp = await fetch("index_body.php?dopost=get_statistics_multi&sdates=" + dates.join(","));
  193. let data = await resp.json();
  194. if (data.code == 200) {
  195. data.result.forEach(e => {
  196. pvs.push(typeof e.pv == "undefined" ? 0 : e.pv);
  197. ips.push(typeof e.ip == "undefined" ? 0 : e.ip);
  198. uvs.push(typeof e.uv == "undefined" ? 0 : e.uv);
  199. vvs.push(typeof e.vv == "undefined" ? 0 : e.vv);
  200. });
  201. }
  202. const myChart = new Chart(ctx, {
  203. type: 'line',
  204. options: {
  205. responsive: true,
  206. plugins: {
  207. legend: {
  208. position: 'right',
  209. }
  210. }
  211. },
  212. data: {
  213. labels: labels,
  214. datasets: [
  215. {
  216. label: 'PV',
  217. data: pvs,
  218. borderColor: 'rgba(54, 162, 235, 1)',
  219. backgroundColor: 'rgba(54, 162, 235, 0.2)',
  220. borderWidth: 1
  221. }, {
  222. label: 'UV',
  223. data: uvs,
  224. borderColor: 'rgba(255, 206, 86, 1)',
  225. backgroundColor: 'rgba(255, 206, 86, 0.2)',
  226. borderWidth: 1
  227. }, {
  228. label: 'IP',
  229. data: ips,
  230. borderColor: 'rgba(255, 99, 132, 1)',
  231. backgroundColor: 'rgba(255, 99, 132, 0.2)',
  232. borderWidth: 1
  233. }
  234. , {
  235. label: 'VV',
  236. data: vvs,
  237. borderColor: 'rgba(75, 192, 192, 1)',
  238. backgroundColor: 'rgba(75, 192, 192, 0.2)',
  239. borderWidth: 1
  240. }
  241. ]
  242. },
  243. });
  244. }
  245. $(document).ready(function () {
  246. LoadServer();
  247. LoadStat();
  248. LoadStatChart();
  249. setInterval(function () {
  250. LoadServer();
  251. }, 60000)
  252. });