Anyon e634118a22 refactor(plugin): 迁移 v8 插件化组件体系
将 v6 中直接放在本地 app 的后台与微信能力迁移为 v8 插件组件,并把运行时基础能力沉淀到独立插件包。

主要内容:

- 新增 think-library、system、worker、static、install 等基础插件包。

- 新增 account、payment、wechat-client、wechat-service、wemall、wuma 等业务插件包。

- 移除 v6 的 app/admin 与 app/wechat 本地应用实现,改由插件分发接管。

- 将 Helper 能力彻底并入 System,统一为 plugin\system\helper\* 命名空间。

- 同步插件迁移发布清单与根 route 占位,保证安装发布流程可复现。
2026-05-08 15:30:46 +08:00

71 lines
2.8 KiB
PHP

<?php
declare(strict_types=1);
/**
* +----------------------------------------------------------------------
* | ThinkAdmin Plugin for ThinkAdminDeveloper
* +----------------------------------------------------------------------
* | Copyright (c) 2014~2026 ThinkAdmin [ thinkadmin.top ]
* +----------------------------------------------------------------------
* | Official Website: https://thinkadmin.top
* +----------------------------------------------------------------------
* | Licensed: https://mit-license.org
* | Disclaimer: https://thinkadmin.top/disclaimer
* | Vip Rights: https://thinkadmin.top/vip-introduce
* +----------------------------------------------------------------------
* | Gitee Repository: https://gitee.com/zoujingli/ThinkAdmin
* | Github Repository: https://github.com/zoujingli/ThinkAdmin
* +----------------------------------------------------------------------
*/
namespace plugin\wuma\service;
use think\admin\Exception;
use think\admin\Service;
use think\admin\Storage;
/**
* 证书图片生成服务
* @class CertService
*/
class CertService extends Service
{
/**
* 绘制证书图片.
* @throws Exception
*/
public static function create(string $target, array $items): string
{
$file = Storage::down($target)['file'];
if (empty($file) || !file_exists($file) || filesize($file) < 10) {
throw new Exception('读取图片模板失败!');
}
// 加载背景图
[$sw, $wh] = getimagesize($file);
[$tw, $th] = [intval(504 * 1.5), intval(713 * 1.5)];
$font = __DIR__ . '/extra/font01.ttf';
$target = imagecreatetruecolor($tw, $th);
$source = imagecreatefromstring(file_get_contents($file));
imagecopyresampled($target, $source, 0, 0, 0, 0, $tw, $th, $sw, $wh);
foreach ($items as $item) {
if ($item['state']) {
[$x, $y] = [intval($tw * $item['point']['x'] / 100), intval($th * $item['point']['y'] / 100)];
if (preg_match('|^rgba\(\s*([\d.]+),\s*([\d.]+),\s*([\d.]+),\s*([\d.]+)\)$|', $item['color'], $matchs)) {
[, $r, $g, $b, $a] = $matchs;
$black = imagecolorallocatealpha($target, intval($r), intval($g), intval($b), intval((1 - (float)$a) * 127));
} else {
$black = imagecolorallocate($target, 0x00, 0x00, 0x00);
}
imagefttext($target, $item['size'], 0, $x, intval($y + $item['size'] / 2 + 16), $black, $font, $item['value']);
}
}
ob_start();
imagepng($target);
$base64 = base64_encode(ob_get_contents());
ob_end_clean();
imagedestroy($target);
imagedestroy($source);
return "data:image/png;base64,{$base64}";
}
}