chore: 添加缺失的静态资源文件
添加多个前端界面所需的图片、字体、音频等静态资源文件,包括: - 管理员后台的图标、背景图、组件图片 - 移动端页面的商品图片、用户中心图片、活动图标 - 第三方库的示例图片和字体文件 - 浏览器兼容性配置文件 - 图标字体文件(eot、ttf、woff、woff2格式) 这些资源是前端界面正常显示所必需的,之前可能因版本控制忽略或遗漏而缺失。
This commit is contained in:
75
vendor/topthink/think-throttle/tests/GCApp.php
vendored
Normal file
75
vendor/topthink/think-throttle/tests/GCApp.php
vendored
Normal file
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* 默认的 \think\App 的实例初始化后会在一些地方创建对它的引用,
|
||||
* 多数是在静态变量里,这就导致它不能被自动垃圾回收。
|
||||
* 因此创建 GCApp 作为其子类,添加清理这些引用的处理的方法。
|
||||
*/
|
||||
|
||||
namespace tests;
|
||||
|
||||
use think\App;
|
||||
use think\initializer\BootService;
|
||||
use think\initializer\Error;
|
||||
use think\initializer\RegisterService;
|
||||
use think\Model;
|
||||
use think\Validate;
|
||||
|
||||
|
||||
class GCError extends Error {
|
||||
/**
|
||||
* 从 parent::init() 中移除 register_shutdown_function
|
||||
* @param App $app
|
||||
*/
|
||||
public function init(App $app)
|
||||
{
|
||||
$this->app = $app;
|
||||
error_reporting(E_ALL);
|
||||
set_error_handler([$this, 'appError']);
|
||||
set_exception_handler([$this, 'appException']);
|
||||
// register_shutdown_function([$this, 'appShutdown']); // 移除
|
||||
}
|
||||
}
|
||||
|
||||
class GCValidate extends Validate {
|
||||
public static function cleanMaker() { static::$maker = []; }
|
||||
}
|
||||
|
||||
class GCModel extends Model {
|
||||
public static function cleanMaker() { static::$maker = []; }
|
||||
}
|
||||
|
||||
/**
|
||||
* 可被自动 gc 的,但需要手动调用 refClear 函数
|
||||
* Class GCApp
|
||||
* @package tests
|
||||
*/
|
||||
class GCApp extends App {
|
||||
protected $initializers = [ // 覆盖父类
|
||||
GCError::class, // 去掉 register_shutdown_function
|
||||
RegisterService::class, // 原来就有的
|
||||
BootService::class, // 原来就有的
|
||||
];
|
||||
|
||||
/**
|
||||
* 添加清理函数
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function refClear()
|
||||
{
|
||||
$this->route->clear(); // 清理路由规则
|
||||
// 清理绑定在 App 的实例
|
||||
$names = [];
|
||||
foreach ($this->getIterator() as $name=>$_v) {
|
||||
$names[] = $name;
|
||||
}
|
||||
foreach ($names as $name) {
|
||||
$this->delete($name);
|
||||
}
|
||||
// 清理异常 handler
|
||||
restore_error_handler();
|
||||
restore_exception_handler();
|
||||
GCValidate::cleanMaker();
|
||||
GCModel::cleanMaker();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user