代码同步

This commit is contained in:
wong
2025-05-12 10:06:38 +08:00
parent 2629ecf55a
commit d7d696ecc8
2 changed files with 73 additions and 24 deletions

View File

@@ -7,9 +7,10 @@ use think\facade\Route;
// 定义RESTful风格的API路由
Route::group('v1/', function () {
// 设备管理相关
Route::group('devices', function () {
Route::get('add-results', 'app\cunkebao\controller\device\GetAddResultedV1Controller@index'); // 更新设备任务配置
Route::get('add-results', 'app\cunkebao\controller\device\GetAddResultedDevicesController@index'); // 更新设备任务配置
Route::get(':id/related-accounts', 'app\cunkebao\controller\device\GetRelatedAccountsV1Controller@index'); // 设备关联微信账号路由
Route::get(':id/handle-logs', 'app\cunkebao\controller\device\GetDeviceHandleLogsV1Controller@index'); // 获取设备操作记录
Route::get('', 'app\cunkebao\controller\device\GetDeviceListV1Controller@index'); // 获取设备列表
@@ -22,14 +23,11 @@ Route::group('v1/', function () {
// 设备微信相关
Route::group('device/wechats', function () {
Route::get('', 'app\cunkebao\controller\wechat\GetWechatsOnDevicesV1Controller@index'); // 获取在线微信账号列表
Route::get(':id', 'app\cunkebao\controller\wechat\GetWechatOnDeviceSummarizeV1Controller@index'); // 获取微信号详情
Route::get('friends', 'app\cunkebao\controller\DeviceWechat@getFriends'); // 获取微信好友列表
Route::get('count', 'app\cunkebao\controller\DeviceWechat@count'); // 获取在线微信账号数量
Route::get('device-count', 'app\cunkebao\controller\DeviceWechat@deviceCount'); // 获取有登录微信的设备数量
Route::get('', 'app\cunkebao\controller\DeviceWechat@index'); // 获取在线微信账号列表
Route::get(':id', 'app\cunkebao\controller\DeviceWechat@detail'); // 获取微信号详情
Route::put('refresh', 'app\cunkebao\controller\DeviceWechat@refresh'); // 刷新设备微信状态
Route::post('transfer-friends', 'app\cunkebao\controller\DeviceWechat@transferFriends'); // 微信好友转移
});
@@ -84,7 +82,7 @@ Route::group('v1/', function () {
Route::group('chatroom', function () {
Route::get('', 'app\cunkebao\controller\chatroom\GetChatroomListV1Controller@index'); // 获取群列表
Route::get('getMemberList', 'app\cunkebao\controller\chatroom\GetChatroomListV1Controller@getMemberList'); // 获取群详情
});
// 计划任务相关路由

View File

@@ -1095,6 +1095,50 @@ class ContentLibraryController extends Controller
return 0; // 未知类型
}
// 分析内容中可能包含的链接或图片地址
if (!empty($content)) {
// 检查内容中是否有链接
$urlPattern = '/https?:\/\/[-A-Za-z0-9+&@#\/%?=~_|!:,.;]+[-A-Za-z0-9+&@#\/%=~_|]/';
preg_match_all($urlPattern, $content, $contentUrlMatches);
if (!empty($contentUrlMatches[0])) {
// 将内容中的链接添加到urls数组中(去重)
foreach ($contentUrlMatches[0] as $url) {
if (!in_array($url, $urls)) {
$urls[] = $url;
}
}
}
// 检查内容中是否包含图片或视频链接
foreach ($contentUrlMatches[0] ?? [] as $url) {
// 检查是否为图片文件
if (stripos($url, '.jpg') !== false ||
stripos($url, '.jpeg') !== false ||
stripos($url, '.png') !== false ||
stripos($url, '.gif') !== false ||
stripos($url, '.webp') !== false ||
stripos($url, '.bmp') !== false ||
stripos($url, 'image') !== false) {
if (!in_array($url, $resUrls)) {
$resUrls[] = $url;
}
}
// 检查是否为视频文件
if (stripos($url, '.mp4') !== false ||
stripos($url, '.mov') !== false ||
stripos($url, '.avi') !== false ||
stripos($url, '.wmv') !== false ||
stripos($url, '.flv') !== false ||
stripos($url, 'video') !== false) {
if (!in_array($url, $resUrls)) {
$resUrls[] = $url;
}
}
}
}
// 判断是否有小程序信息
if (strpos($content, '小程序') !== false || strpos($content, 'appid') !== false) {
return 5; // 小程序
@@ -1136,25 +1180,32 @@ class ContentLibraryController extends Controller
return 3; // 视频
}
// 判断内容是否纯链接
$isPureLink = false;
if (!empty($content) && !empty($urls)) {
$contentWithoutUrls = $content;
foreach ($urls as $url) {
$contentWithoutUrls = str_replace($url, '', $contentWithoutUrls);
}
// 如果去除链接后内容为空,则认为是纯链接
if (empty(trim($contentWithoutUrls))) {
$isPureLink = true;
}
}
// 如果内容是纯链接,判定为链接类型
if ($isPureLink) {
return 2; // 链接
}
// 优先判断内容文本
// 如果有文本内容(不仅仅是链接)
if (!empty($content)) {
// 判断内容是否主要为文本(排除链接部分)
$contentWithoutUrls = $content;
if (!empty($urls)) {
foreach ($urls as $url) {
$contentWithoutUrls = str_replace($url, '', $contentWithoutUrls);
}
}
// 如果去除链接后仍有文本内容(不考虑长度)
if (!empty(trim($contentWithoutUrls))) {
// 判断是否为图文类型
if ($hasImage) {
return 6; // 图文
} else {
return 4; // 纯文本
}
if (!empty($content) && !$isPureLink) {
// 如果有图片,则为图文类型
if ($hasImage) {
return 6; // 图文
} else {
return 4; // 纯文本
}
}