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

258 lines
8.9KB

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