作者 lms

合并分支 'lms' 到 'master'

v6优化程序



查看合并请求 !274
... ... @@ -3,11 +3,10 @@
namespace App\Console\Commands;
use App\Http\Controllers\File\FileController;
use App\Models\ProjectAssociation\ProjectAssociation;
use App\Models\File\DataFile;
use App\Models\ProjectAssociation\ProjectAssociation;
use App\Services\CosService;
use Dompdf\Dompdf;
use Dompdf\Options;
use Barryvdh\DomPDF\Facade\Pdf;
use Illuminate\Console\Command;
use Illuminate\Http\File;
... ... @@ -57,6 +56,17 @@ class ProjectFilePDF extends Command
parent::__construct();
}
// public function handle()
// {
// $project_data = [];
// $html = $this->html($project_data);
// $filename = hash('md5', $this->time . '-' . '$project_id' . '-' . '$friend_id' . '-' . '$user_id');
// $this->savePDF($html, $filename);
//// $this->testStreamPdf($html, $filename);
//// $file_path = $this->savePDF2($html, $filename);
// return 0;
// }
public function start(): int
{
# 0 - 未生成
... ... @@ -115,37 +125,21 @@ class ProjectFilePDF extends Command
*/
public function savePDF($html, $filename)
{
$pdf_path = public_path('PDF/');
if (!file_exists($pdf_path)) {
mkdir($pdf_path, 0777, true);
}
// 指定保存路径和文件名
$savePath = $pdf_path . $filename . '.pdf';
if (file_exists($savePath)) {
echo '文件已经存在';
// return 0;
return 0;
}
// todo 生成中文有问题
# 实例化并使用dompdf类
// $options = new Options();
// $options->setDefaultFont('arial');
// $dompdf = new Dompdf($options);
$dompdf = new Dompdf();
$dompdf->loadHtml($html);
#(可选)设置纸张大小和方向
$dompdf->setPaper('A4', 'landscape');
# 将HTML渲染为PDF
$dompdf->render();
// 获取PDF内容
$pdfContent = $dompdf->output();
$path = '/V6/PDF/' . $this->time;
// 将PDF内容保存到文件
@file_put_contents($savePath, $pdfContent);
$pdf = PDF::loadHTML($html);
$pdf->save($savePath);
$path = '/V6/PDF/' . $this->time;
// 创建一个文件实例
$file = new File($savePath);
return $this->CosService->uploadFile($file, $path, $filename . '.pdf');
... ... @@ -158,12 +152,7 @@ class ProjectFilePDF extends Command
*/
protected function html($item)
{
$html = '<html>';
$html .= '<body style="font-family:arial">';
$html .= '<h1>Hello, World!</h1>';
$html .= '<p>中文内容ffffff</p>';
$html .= '</body>';
$html .= '</html>';
return $html;
$font_path = storage_path('fonts\msyh.ttf');
return '<html><head><title>Laravel</title><meta http-equiv=\'Content-Type\' content=\'text/html; charset=utf-8\'/><style>body{ font-family: \'msyh\'; } @font-face { font-family: \'msyh\'; font-style: normal; font-weight: normal; src: url(' . $font_path . ') format(\'truetype\'); }</style></head><body><div class=\'container\'><div class=\'content\'><p style=\'font-family: msyh, DejaVu Sans,sans-serif;\'>献给母亲的爱</p><div style=\'font-family: msyh, DejaVu Sans,sans-serif;\' class=\'title\'>Laravel 5中文测试</div><div class=\'title\'>测试三askjdhfkjasdhf</div></div></div></body></html>';
}
}
... ...
... ... @@ -5,10 +5,10 @@
"keywords": ["framework", "laravel"],
"license": "MIT",
"require": {
"barryvdh/laravel-dompdf": "^2.0",
"bensampo/laravel-enum": "^4.2",
"beyondcode/laravel-websockets": "^1.14",
"doctrine/dbal": "^3.6",
"dompdf/dompdf": "^2.0",
"fruitcake/laravel-cors": "^2.0",
"guzzlehttp/guzzle": "^7.0.1",
"hashids/hashids": "^4.1",
... ... @@ -19,11 +19,10 @@
"mongodb/mongodb": "^1.6",
"mrgoon/aliyun-sms": "^2.0",
"phpoffice/phpspreadsheet": "^1.28",
"swooletw/laravel-swoole": "^2.13",
"qcloud/cos-sdk-v5": "^v2.6.6"
"qcloud/cos-sdk-v5": "^v2.6.6",
"swooletw/laravel-swoole": "^2.13"
},
"require-dev": {
"barryvdh/laravel-ide-helper": "^2.13",
"facade/ignition": "^2.5",
"fakerphp/faker": "^1.9.1",
"laravel/sail": "^1.0.1",
... ...
... ... @@ -4,6 +4,7 @@
*/
use App\Http\Controllers\Aside;
use App\Http\Controllers\Bside\ProjectAssociation\ProjectAssociationController;
use Illuminate\Support\Facades\Route;
... ... @@ -13,7 +14,7 @@ Route::middleware(['aloginauth'])->group(function () {
Route::any('/editPassword', [Aside\Com\IndexController::class, 'editPassword'])->name('admin.editPassword.white');
Route::get('/logout', [Aside\LoginController::class, 'logout'])->name('admin.logout.white');
Route::any('/getAccessAddress', [Aside\LoginController::class, 'getAccessAddress'])->name('admin.getAccessAddress');//获取B端地址
Route::post('/aicc/wechat', [\App\Http\Controllers\Bside\ProjectAssociation\ProjectAssociationController::class, 'saveWeChatData'])->name('admin.aicc.wechat');
//会员相关
Route::prefix('user')->group(function () {
//会员管理
... ... @@ -70,6 +71,8 @@ Route::middleware(['aloginauth'])->group(function () {
Route::any('/del', [Aside\Ai\AiCommandController::class, 'del'])->name('admin.ai_del');
//发送记录
Route::any('/log', [Aside\Ai\AiLogController::class, 'lists'])->name('admin.lists');
// 绑定AICC微信应用
Route::post('/wechat', [ProjectAssociationController::class, 'saveWeChatData'])->name('admin.aicc.wechat');
});
//特殊模块权限设置
Route::prefix('special')->group(function () {
... ...