diff --git a/Access_Core.php b/Access_Core.php index 3a1c538..c777c0c 100644 --- a/Access_Core.php +++ b/Access_Core.php @@ -11,6 +11,7 @@ class Access_Core public $config; public $action; public $title; + public $hasMigration; public $logs = array(); public $overview = array(); public $referer = array(); @@ -52,6 +53,7 @@ class Access_Core $this->title = _t('访问概览'); break; } + $this->hasMigration = (new Access_Migration($this->request))->exists(); } /** diff --git a/Access_Migration.php b/Access_Migration.php index bf436c2..8b37aaf 100644 --- a/Access_Migration.php +++ b/Access_Migration.php @@ -23,6 +23,25 @@ class Access_Migration { $this->config = Typecho_Widget::widget('Widget_Options')->plugin('Access'); } + /** + * 显示是否存在旧版数据 + * + * @access public + * @return bool + * @throws Exception + */ + public function exists() + { + $prefix = $this->db->getPrefix(); + if ($this->db->fetchRow($this->db->query("SHOW TABLES LIKE '{$prefix}access';", Typecho_Db::READ))) { + return true; + } + if ($this->db->fetchRow($this->db->query("SHOW TABLES LIKE '{$prefix}access_log';", Typecho_Db::READ))) { + return true; + } + return false; + } + /** * 显示旧版本数据数量 * diff --git a/page/console.js b/page/console.js deleted file mode 100644 index d255e39..0000000 --- a/page/console.js +++ /dev/null @@ -1,13 +0,0 @@ -$().ready(function () { - $.ajax({ - url: "/access/migration", - method: "get", - dataType: "json", - data: { rpc: 'overview' }, - success: function (res) { - if (res.data.total > 0) { - $('#migration-tab-li').show(); - } - }, - }); -}); diff --git a/page/console.php b/page/console.php index f7c7bc2..1f7cc7c 100644 --- a/page/console.php +++ b/page/console.php @@ -5,7 +5,6 @@ include 'menu.php'; require_once __DIR__ . '/../Access_Bootstrap.php'; $access = new Access_Core(); ?> -
@@ -16,7 +15,9 @@ $access = new Access_Core();
    action == 'overview' ? ' class="current"' : '')?>> action == 'logs' ? ' class="current"' : '')?>> - action == 'migration' ? ' class="current"' : '')?> style="display: none" id="migration-tab-li"> + hasMigration): ?> + action == 'migration' ? ' class="current"' : '')?>> +