mirror of
https://github.com/kokororin/typecho-plugin-Access.git
synced 2025-03-23 16:20:22 +08:00
feat: optimize console page has migration check logic
This commit is contained in:
parent
059d94be2f
commit
92f6e3ab49
@ -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();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示旧版本数据数量
|
||||
*
|
||||
|
@ -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();
|
||||
}
|
||||
},
|
||||
});
|
||||
});
|
@ -5,7 +5,6 @@ include 'menu.php';
|
||||
require_once __DIR__ . '/../Access_Bootstrap.php';
|
||||
$access = new Access_Core();
|
||||
?>
|
||||
<script defer src="<?php $options->pluginUrl('Access/page/console.js')?>"></script>
|
||||
<div class="main">
|
||||
<div class="body container">
|
||||
<div class="typecho-page-title">
|
||||
@ -16,7 +15,9 @@ $access = new Access_Core();
|
||||
<ul class="typecho-option-tabs fix-tabs clearfix">
|
||||
<li<?=($access->action == 'overview' ? ' class="current"' : '')?>><a href="<?php $options->adminUrl('extending.php?panel=' . Access_Plugin::$panel . '&action=overview'); ?>"><?php _e('访问概览'); ?></a></li>
|
||||
<li<?=($access->action == 'logs' ? ' class="current"' : '')?>><a href="<?php $options->adminUrl('extending.php?panel=' . Access_Plugin::$panel . '&action=logs'); ?>"><?php _e('访问日志'); ?></a></li>
|
||||
<li<?=($access->action == 'migration' ? ' class="current"' : '')?> style="display: none" id="migration-tab-li"><a href="<?php $options->adminUrl('extending.php?panel=' . Access_Plugin::$panel . '&action=migration'); ?>"><?php _e('数据迁移'); ?></a></li>
|
||||
<?php if ($access->hasMigration): ?>
|
||||
<li<?=($access->action == 'migration' ? ' class="current"' : '')?>><a href="<?php $options->adminUrl('extending.php?panel=' . Access_Plugin::$panel . '&action=migration'); ?>"><?php _e('数据迁移'); ?></a></li>
|
||||
<?php endif ?>
|
||||
<li><a href="<?php $options->adminUrl('options-plugin.php?config=Access') ?>"><?php _e('插件设置'); ?></a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user