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

254 lines
7.1KB

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