增加扩展机制定位文件;将common模块实现扩展模式;发布新版本;

This commit is contained in:
2023-09-25 17:07:38 +08:00
parent 3dcf336bbc
commit 184dae8185
65 changed files with 3093 additions and 2751 deletions

View File

@@ -2,37 +2,8 @@
namespace app\common\controller;
use think\facade\Cache;
use base\common\controller\TimerControllerBase;
class TimerController extends ToolsController
class TimerController extends TimerControllerBase
{
protected $frequency = null;
public function initialize()
{
parent::initialize();
if (is_integer($this->frequency)) {
$this->protectVisit($this->frequency);
}
}
protected function protectVisit(int $frequency)
{
$cache_tag = 'timer_protect';
$cache_key = 'timer_protect_' . md5($this->request->url());
$last_exec_time = Cache::get($cache_key, 0);
if ($last_exec_time >= time() - $frequency) {
return $this->error('请不要频繁请求');
}
Cache::tag($cache_tag)->set($cache_key, time());
}
}