Merge branch 'develop'

This commit is contained in:
mzl
2025-07-29 09:00:04 +08:00
parent a551507e4d
commit d74b374198
106 changed files with 6754 additions and 1346 deletions
+76
View File
@@ -0,0 +1,76 @@
<?php
namespace app\command;
use app\common\model\InquiryLog;
use app\common\model\User;
use app\common\model\UserSn;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Helper\Table;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use support\Db;
class DomainCommand extends Command
{
protected static $defaultName = 'domain';
protected static $defaultDescription = '';
protected function execute(InputInterface $input, OutputInterface $output): int
{
$log = new InquiryLog();
$list = $log->orderBy('id', 'desc')->get();
foreach ($list as $item) {
if (!$item->content) {
continue;
}
$item->content = processRichTextImagesEnhanced($item->content);
$item->save();
$output->writeln("处理了{$item->id} \n");
}
return self::SUCCESS;
}
}
/**
* 增强版 - 处理富文本内容中的图片URL
*
* @param string $content 富文本HTML内容
* @param string $newDomain 新域名(如: https://fdesk.hnxinyouhe.com)
* @param string $oldDomain 旧域名(如: http://219.157.255.213:25326)
* @return string 处理后的富文本内容
*/
function processRichTextImagesEnhanced($content, $newDomain = 'https://fdesk.hnxinyouhe.com', $oldDomain = 'http://219.157.255.213:25326') {
// 标准化域名格式(去除末尾斜杠)
$newDomain = rtrim($newDomain, '/');
$oldDomain = rtrim($oldDomain, '/');
// 要处理的属性列表
$attributes = ['src', 'data-href', 'href', 'data-src', 'data-original'];
foreach ($attributes as $attr) {
// 情况1:替换旧域名为新域名
$content = preg_replace(
'/('.$attr.'=["\'])'.preg_quote($oldDomain, '/').'(\/uploads\/)/i',
'$1' . $newDomain . '$2',
$content
);
// 情况2:给无域名的路径添加新域名
$content = preg_replace(
'/('.$attr.'=["\'])(\/uploads\/)/i',
'$1' . $newDomain . '$2',
$content
);
// 情况3:处理可能存在的其他域名(可选)
$content = preg_replace(
'/('.$attr.'=["\'])(https?:\/\/[^\/]+)(\/uploads\/)/i',
'$1' . $newDomain . '$3',
$content
);
}
return $content;
}
+28
View File
@@ -0,0 +1,28 @@
<?php
namespace app\command;
use app\common\model\User;
use app\common\model\UserSn;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Helper\Table;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use support\Db;
class TbCommand extends Command
{
protected static $defaultName = 'tb-db';
protected static $defaultDescription = '';
protected function execute(InputInterface $input, OutputInterface $output): int
{
$user = new User();
$list = $user->all();
foreach ($list as $item) {
// UserSn::where('user_sn', $item->sn)->update(['user_id' => $item->id]);
}
return self::SUCCESS;
}
}