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

271 lines
9.5KB

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