mirror of
https://github.com/zhamao-robot/zhamao-framework.git
synced 2026-07-21 15:45:36 +08:00
update plugin docs and add some helper functions
This commit is contained in:
@@ -18,12 +18,14 @@ use ZM\Framework;
|
||||
use ZM\Logger\ConsoleLogger;
|
||||
use ZM\Middleware\MiddlewareHandler;
|
||||
use ZM\Plugin\OneBot\BotMap;
|
||||
use ZM\Plugin\ZMPlugin;
|
||||
use ZM\Schedule\Timer;
|
||||
use ZM\Store\Database\DBException;
|
||||
use ZM\Store\Database\DBQueryBuilder;
|
||||
use ZM\Store\Database\DBWrapper;
|
||||
use ZM\Store\KV\KVInterface;
|
||||
use ZM\Store\KV\Redis\RedisWrapper;
|
||||
use ZM\ZMApplication;
|
||||
|
||||
// 防止重复引用引发报错
|
||||
if (function_exists('zm_internal_errcode')) {
|
||||
@@ -345,3 +347,19 @@ function ws_socket(int $flag = 1): WSServerSocketBase
|
||||
}
|
||||
return $a;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建炸毛框架应用
|
||||
*/
|
||||
function zm_create_app(): ZMApplication
|
||||
{
|
||||
return new ZMApplication();
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建炸毛框架的插件对象
|
||||
*/
|
||||
function zm_create_plugin(): ZMPlugin
|
||||
{
|
||||
return new ZMPlugin();
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ class Framework
|
||||
public const VERSION_ID = 712;
|
||||
|
||||
/** @var string 版本名称 */
|
||||
public const VERSION = '3.1.7';
|
||||
public const VERSION = '3.1.8';
|
||||
|
||||
/**
|
||||
* @var RuntimePreferences 运行时偏好(环境信息&参数)
|
||||
|
||||
@@ -53,7 +53,7 @@ class PluginManager
|
||||
continue;
|
||||
}
|
||||
|
||||
// 先看有没有 zmplugin.json,没有则不是正常的插件,发个 notice 然后跳过
|
||||
// 先看有没有 composer.json,没有则不是正常的插件,发个 notice 然后跳过
|
||||
$meta_file = $item . '/composer.json';
|
||||
if (!is_file($meta_file)) {
|
||||
logger()->notice('插件目录 {dir} 没有插件元信息(composer.json),跳过扫描。', ['dir' => $item]);
|
||||
@@ -382,7 +382,7 @@ class PluginManager
|
||||
++$file_added;
|
||||
}
|
||||
// 找有没有 main,没有 main 就不添加 stub
|
||||
$main = (json_decode(file_get_contents($dir . '/zmplugin.json'), true)['main'] ?? 'main.php');
|
||||
$main = (json_decode(file_get_contents($dir . '/composer.json'), true)['extra']['zm-plugin-main'] ?? 'main.php');
|
||||
if (file_exists(zm_dir($dir . '/' . $main)) && $phar->offsetExists($main)) {
|
||||
$command_context?->info('设置插件默认入口文件 ' . $main);
|
||||
$phar->setStub($phar->setDefaultStub($main));
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace ZM\Plugin;
|
||||
use ZM\Exception\PluginException;
|
||||
|
||||
/**
|
||||
* 插件的元信息对象,对应 zmplugin.json
|
||||
* 插件的元信息对象
|
||||
*/
|
||||
class PluginMeta implements \JsonSerializable
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user