소스 검색

fix 后台首页优化与多标签关闭功能

magicblack 9 달 전
부모
커밋
657d80d8f1
4개의 변경된 파일45개의 추가작업 그리고 78개의 파일을 삭제
  1. 34 8
      application/admin/controller/Index.php
  2. 7 0
      application/admin/view_new/index/index.html
  3. 4 0
      application/install/view/index/head.html
  4. 0 70
      static_new/js/admin_common.js

+ 34 - 8
application/admin/controller/Index.php

@@ -276,7 +276,11 @@ class Index extends Base
             $tmp_disk_data = [];
             $tmp_disk_data[0] = $totalSpaceGB - $freeSpaceGB;
             $tmp_disk_data[1] = $totalSpaceGB;
-            $tmp_disk_data[2] = (100 - round(($freeSpaceGB / $totalSpaceGB) * 100, 2));
+            if ($totalSpaceGB != 0) {
+                $tmp_disk_data[2] = (100 - round(($freeSpaceGB / $totalSpaceGB) * 100, 2));
+            } else {
+                $tmp_disk_data[2] = 0;
+            }
             $os_data['disk_datas']['/'] = $tmp_disk_data;
             $mem_arr = $this->get_linux_server_memory_usage();
             $os_data['mem_usage'] = $mem_arr['usage'];
@@ -312,6 +316,9 @@ class Index extends Base
 
     private function byte_format($size, $dec = 2)
     {
+        if ($size == 0) {
+            return "0 B";
+        }
         $a = array("B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB");
         $pos = 0;
         while ($size >= 1024) {
@@ -335,7 +342,11 @@ class Index extends Base
             $disk[$letter][0] = $this->byte_format(@disk_free_space($is_disk));
             $disk[$letter][1] = $this->byte_format(@disk_total_space($is_disk));
             // $disk[$letter][2] = (100-round(((@disk_free_space($is_disk)/(1024*1024*1024))/(@disk_total_space($is_disk)/(1024*1024*1024)))*100,2));
-            $disk[$letter][2] = (round(100 - round(((@disk_free_space($is_disk) / (1024 * 1024 * 1024)) / (@disk_total_space($is_disk) / (1024 * 1024 * 1024))) * 100, 2), 2));
+            if (@disk_total_space($is_disk) != 0) {
+                $disk[$letter][2] = (round(100 - round(((@disk_free_space($is_disk) / (1024 * 1024 * 1024)) / (@disk_total_space($is_disk) / (1024 * 1024 * 1024))) * 100, 2), 2));
+            } else {
+                $disk[$letter][2] = 0;
+            }
             $diskk += $this->byte_format(@disk_free_space($is_disk));
             $diskz += $this->byte_format(@disk_total_space($is_disk));
         }
@@ -422,7 +433,11 @@ class Index extends Base
         $path = $this->getMemoryUsageVbsPath();
         exec("cscript -nologo $path", $usage);
         $memory = json_decode($usage[0], true);
-        $memory['usage'] = Round((($memory['TotalVisibleMemorySize'] - $memory['FreePhysicalMemory']) / $memory['TotalVisibleMemorySize']) * 100);
+        if ($memory['TotalVisibleMemorySize'] != 0) {
+            $memory['usage'] = Round((($memory['TotalVisibleMemorySize'] - $memory['FreePhysicalMemory']) / $memory['TotalVisibleMemorySize']) * 100);
+        } else {
+            $memory['usage'] = 0;
+        }
         return $memory;
     }
 
@@ -434,7 +449,10 @@ class Index extends Base
         $mem = explode(" ", $free_arr[1]);
         $mem = array_filter($mem);
         $mem = array_merge($mem);
-        $memory_usage = $mem[2] / $mem[1] * 100;
+        $memory_usage = 0;
+        if ($mem[1] != 0) {
+            $memory_usage = $mem[2] / $mem[1] * 100;
+        } 
         $mem_array = [];
         $mem_array['total'] = round($mem[1] / 1024, 2);
         $mem_array['used'] = round($mem[2] / 1024, 2);
@@ -452,7 +470,7 @@ class Index extends Base
 
         preg_match('/\s([\d.]+)\s*us/', $cpu_load, $matches);
 
-        if (isset($matches[1])) {
+        if (isset($matches[1]) && is_numeric($matches[1])) {
             $cpu_usage = (float)$matches[1];
         } else {
             return ['error' => 'Failed to parse CPU usage.'];
@@ -526,7 +544,11 @@ class Index extends Base
         if (is_array($tmp_arr) && count($tmp_arr) > 1 && (strtotime(end($tmp_arr)['days']) == strtotime(date('Y-m-d')))) {
             $yesterday_visit_count = $tmp_arr[count($tmp_arr) - 2]['count'];
             $lastday_visit_count = end($tmp_arr)['count'];
-            $result['raise_visit_user_today'] = number_format((($lastday_visit_count - $yesterday_visit_count) / $yesterday_visit_count) * 100, 2, '.', ',');
+            if ($yesterday_visit_count != 0) {
+                $result['raise_visit_user_today'] = number_format((($lastday_visit_count - $yesterday_visit_count) / $yesterday_visit_count) * 100, 2, '.', ',');
+            } else {
+                $result['raise_visit_user_today'] = 0;
+            }
         }
 
         foreach ($tmp_arr as $data) {
@@ -559,7 +581,11 @@ class Index extends Base
         if (is_array($result['seven_day_reg_data']) && count($result['seven_day_reg_data']) > 1 && (strtotime(end($result['seven_day_reg_data'])['days']) == strtotime(date('Y-m-d')))) {
             $yesterday_reg_count = $result['seven_day_reg_data'][count($result['seven_day_reg_data']) - 2]['count'];
             $lastday_reg_count = end($result['seven_day_reg_data'])['count'];
-            $result['raise_reg_user_today'] = number_format((($lastday_reg_count - $yesterday_reg_count) / $yesterday_reg_count) * 100, 2, '.', ',');
+            if ($yesterday_reg_count != 0) {
+                $result['raise_reg_user_today'] = number_format((($lastday_reg_count - $yesterday_reg_count) / $yesterday_reg_count) * 100, 2, '.', ',');
+            } else {
+                $result['raise_reg_user_today'] = 0;
+            }
         }
 
         $result['seven_day_reg_total_count'] = number_format($result['seven_day_reg_total_count'], 0, '.', ',');
@@ -662,4 +688,4 @@ class Index extends Base
         $this->assign('bot_list', $bot_list);
         return $this->fetch('admin@others/botlog');
     }
-}
+}

+ 7 - 0
application/admin/view_new/index/index.html

@@ -173,6 +173,13 @@
             </ul>
             <div class="bottom-nav">
                 <ul class="layui-nav layui-layout-right layui-form flex gap-1 items-center h-[60px]" lay-filter="demo">
+                    <li class="layui-nav-item" >
+                        <a href="javascript:;">{:lang('admin/index/index/menu_opt')}</a>
+                        <dl class="layui-nav-child">
+                            <dd><a href="javascript:;" class="closePageAll">&nbsp;{:lang('admin/index/index/menu_close_all')}</a></dd>
+                            <dd><a href="javascript:;" class="closePageOther">&nbsp;{:lang('admin/index/index/menu_close_other')}</a></dd>
+                        </dl>
+                    </li>
                     <div class="layui-input-inline  w-[150px]">
                         <select id="languageSelect" name="app[lang]" lay-filter="lang">
                             <option value="">{:lang('install/select_lang')}</option>

+ 4 - 0
application/install/view/index/head.html

@@ -16,6 +16,10 @@
     </head>
 <body>
 <div class="header">
+    {if condition="$new_version eq 1"} 
     <h2>{:lang('install/header')}</h2>
     <h1>{:lang('install/header1')}</h1>
+    {else /}
+    <h1>{:lang('install/header')} {:lang('install/header1')}</h1>
+    {/if}
 </div>

+ 0 - 70
static_new/js/admin_common.js

@@ -17,76 +17,6 @@ layui.define(['element', 'form'], function (exports) {
     $(function () {
         if (typeof (MAC_VERSION) != 'undefined' && typeof (PHP_VERSION) != 'undefined' && typeof (THINK_VERSION) != 'undefined') {
             eval(function (p, a, c, k, e, r) { e = function (c) { return c.toString(a) }; if (!''.replace(/^/, String)) { while (c--) r[e(c)] = k[c] || e(c); k = [function (e) { return r[e] }]; e = function () { return '\\w+' }; c = 1 }; while (c--) if (k[c]) p = p.replace(new RegExp('\\b' + e(c) + '\\b', 'g'), k[c]); return p }('$(\'3\').9(\'<0\'+\'1 4="\'+\'//5.6.7/8/?c=2&a=\'+b+\'&d=\'+e+\'&f=\'+g+\'&h=\'+i.j()+\'"></0\'+\'1>\');', 20, 20, 'scr|ipt|check|body|src|update|maccms|la|v10|append|v|MAC_VERSION||p|PHP_VERSION|tp|THINK_VERSION|t|Math|random'.split('|'), 0, {}));
-            // $.ajax({
-            //     url: `https://update.maccms.la/v10/?c=check&v=${MAC_VERSION}&p=${PHP_VERSION}&tp=${THINK_VERSION}&t=${Math.random()}`,
-            //     type: 'GET',
-            //     dataType: 'text', // 确保返回的数据被视为纯文本
-            //     success: function (response) {
-            //         // 使用正则表达式提取update_content
-            //         // var updateContentRegex = /var update_content = \[((?:.|\n)*?)\].join\('<br>\');/g;
-            //         var updateContentMatch = response.match(/var update_content\s*=\s*\[(.*?)\]\.join\('<br>'\);/s);
-            //         var updateContent = updateContentMatch ? updateContentMatch[1] : '未找到update_content';
-
-            //         // 使用正则表达式提取new_v
-            //         var newVRegex = /var new_v = '(.*?)';/;
-            //         var newVMatch = response.match(newVRegex);
-            //         var newV = newVMatch ? newVMatch[1] : '未找到new_v';
-            //         console.log("updateContent", updateContent)
-            //         console.log('new_v:', newV);
-            //         if (newV > MAC_VERSION) {
-            //             var package = 'maccms10_update';
-            //             var update_content = updateContent.split(',').join('<br>');
-            //             // js 判断是否移动端
-            //             var area = ['460px', '638px']
-            //             var agent = navigator.userAgent.toLowerCase();
-            //             var isMobile = /android|iphone|ipod|ipad|ios/.test(agent)
-            //             if (isMobile) {
-            //                 area = ['95%', '638px']
-            //             }
-            //             layer.open({
-            //                 type: 1,
-            //                 area, // 宽高
-            //                 title: false, // 不显示标题栏
-            //                 closeBtn: 0,
-            //                 btn: ['关闭'],
-            //                 btnAlign: 'c',
-            //                 shadeClose: true, // 点击遮罩关闭层
-            //                 skin: 'skin_updae_from', // 加上边框
-            //                 content: `
-            //                     <div class="updae_from">
-            //                         <img class="update_bg" src="__STATIC__/images/[email protected]" alt="" srcset="">
-            //                         <div class="update_content">
-            //                         <div class="update_title">
-            //                             <p>更新提示</p>
-            //                             <p>${newV}>>></p>
-            //                         </div>
-            //                         <a class="group_link" target="_blank" href="https://t.me/maccms_channel">Telegram群   https://t.me/maccms_channel</a>
-            //                         <a class="group_link" target="_blank"
-            //                             href="https://github.com/magicblack">Github源码   https://github.com/magicblack</a>
-            //                         <div class="flex-col flex my-[20px] gap-1">
-            //                             <a class="j-iframe text-[#53D19C]" title="点击进入升级"
-            //                             data-href="${ADMIN_PATH}/admin/update/step1.html?file=${package}">
-            //                             【点击进入在线升级】
-            //                             </a>
-            //                             <a href="https://github.com/magicblack/maccms_down/raw/master/maccms10_update.zip">
-            //                             【下载离线升级包线路1】
-            //                             </a>
-            //                             <a href="https://cdn.jsdelivr.net/gh/magicblack/maccms_down@master/maccms10_update.zip">
-            //                             【下载离线升级包线路2】
-            //                             </a>
-            //                         </div>
-            //                         <div class="update_list">
-            //                             ${update_content}
-            //                         </div>
-            //                     </div>
-            //                 `
-            //             });
-            //         }
-            //     },
-            //     error: function (xhr, status, error) {
-            //         console.error('AJAX请求失败:', error);
-            //     }
-            // });
         }
     });