diff --git a/app/Http/Controllers/IndexController.php b/app/Http/Controllers/IndexController.php
index 585625c18..c6f9cd525 100755
--- a/app/Http/Controllers/IndexController.php
+++ b/app/Http/Controllers/IndexController.php
@@ -338,30 +338,6 @@ class IndexController extends InvokeController
return abort(404);
}
- /**
- * 搜索表情
- * @return array
- */
- public function emo__search()
- {
- $key = Request::input('key');
- if (empty($key)) {
- return Base::retError("key empty");
- }
- return Cache::remember("emo__search:" . md5($key), now()->addDay(), function () use ($key) {
- $res = Ihttp::ihttp_get("http://www.adoutu.com/search?keyword=" . urlencode($key));
- if (Base::isError($res)) {
- return $res;
- }
- $content = Base::getMiddle($res['data'], '', '');
- preg_match_all("/
]*?alt=\"(\S+)\"[^>]*?>/", "[$1]", $text);
- $text = preg_replace("/
]*?>/", "[表情]", $text);
+ $text = preg_replace("/
]*?>/", "[动画表情]", $text);
$text = preg_replace("/
]*?>/", "[图片]", $text);
if (!$preserveHtml) {
$text = strip_tags($text);
@@ -558,15 +558,15 @@ class WebSocketDialogMsg extends AbstractModel
// 图片 [:IMAGE:className:width:height:src:alt:]
preg_match_all("/
(<\/img>)*/s", $text, $matchs);
foreach ($matchs[2] as $key => $base64) {
- $tmpPath = "uploads/chat/" . date("Ym") . "/" . $dialog_id . "/";
- Base::makeDir(public_path($tmpPath));
- $tmpPath .= md5s($base64) . "." . $matchs[1][$key];
- if (file_put_contents(public_path($tmpPath), base64_decode($base64))) {
- $imagesize = getimagesize(public_path($tmpPath));
- if (Base::imgThumb(public_path($tmpPath), public_path($tmpPath) . "_thumb.jpg", 320, 0)) {
- $tmpPath .= "_thumb.jpg";
+ $imagePath = "uploads/chat/" . date("Ym") . "/" . $dialog_id . "/";
+ Base::makeDir(public_path($imagePath));
+ $imagePath .= md5s($base64) . "." . $matchs[1][$key];
+ if (file_put_contents(public_path($imagePath), base64_decode($base64))) {
+ $imageSize = getimagesize(public_path($imagePath));
+ if (Base::imgThumb(public_path($imagePath), public_path($imagePath) . "_thumb.jpg", 320, 0)) {
+ $imagePath .= "_thumb.jpg";
}
- $text = str_replace($matchs[0][$key], "[:IMAGE:browse:{$imagesize[0]}:{$imagesize[1]}:{$tmpPath}::]", $text);
+ $text = str_replace($matchs[0][$key], "[:IMAGE:browse:{$imageSize[0]}:{$imageSize[1]}:{$imagePath}::]", $text);
}
}
// 表情图片
@@ -574,38 +574,73 @@ class WebSocketDialogMsg extends AbstractModel
foreach ($matchs[1] as $key => $str) {
preg_match("/data-asset=\"(.*?)\"/", $str, $matchAsset);
preg_match("/data-name=\"(.*?)\"/", $str, $matchName);
- if (file_exists(public_path($matchAsset[1]))) {
- $imagesize = getimagesize(public_path($matchAsset[1]));
- $text = str_replace($matchs[0][$key], "[:IMAGE:emoticon:{$imagesize[0]}:{$imagesize[1]}:{$matchAsset[1]}:{$matchName[1]}:]", $text);
+ $imageSize = null;
+ $imagePath = "";
+ $imageName = "";
+ if ($matchAsset[1] === "emosearch") {
+ preg_match("/src=\"(.*?)\"/", $str, $matchSrc);
+ if ($matchSrc) {
+ $srcMd5 = md5($matchSrc[1]);
+ $imagePath = "uploads/emosearch/" . substr($srcMd5, 0, 2) . "/" . substr($srcMd5, 32 - 2) . "/";
+ Base::makeDir(public_path($imagePath));
+ $imagePath .= md5s($matchSrc[1]);
+ if (file_exists(public_path($imagePath))) {
+ $imageSize = getimagesize(public_path($imagePath));
+ } else {
+ $image = file_get_contents($matchSrc[1]);
+ if ($image && file_put_contents(public_path($imagePath), $image)) {
+ $imageSize = getimagesize(public_path($imagePath));
+ // 添加后缀
+ if ($imageSize && !str_contains($imagePath, '.')) {
+ preg_match("/^image\/(png|jpg|jpeg|gif)$/", $imageSize['mime'], $matchMine);
+ if ($matchMine) {
+ $imageNewPath = $imagePath . "." . $matchMine[1];
+ if (rename(public_path($imagePath), public_path($imageNewPath))) {
+ $imagePath = $imageNewPath;
+ }
+ }
+ }
+ }
+ }
+ }
+ } elseif (file_exists(public_path($matchAsset[1]))) {
+ $imagePath = $matchAsset[1];
+ $imageName = $matchName[1];
+ $imageSize = getimagesize(public_path($matchAsset[1]));
+ }
+ if ($imageSize) {
+ $text = str_replace($matchs[0][$key], "[:IMAGE:emoticon:{$imageSize[0]}:{$imageSize[1]}:{$imagePath}:{$imageName}:]", $text);
+ } else {
+ $text = str_replace($matchs[0][$key], "[:IMAGE:browse:90:90:images/other/imgerr.jpg::]", $text);
}
}
// 其他网络图片
preg_match_all("/
]*?src=([\"'])(.*?\.(png|jpg|jpeg|gif))\\1[^>]*?>/is", $text, $matchs);
foreach ($matchs[2] as $key => $str) {
if (str_starts_with($str, "{{RemoteURL}}")) {
- $tmpPath = Base::leftDelete($str, "{{RemoteURL}}");
- $tmpPath = Base::rightDelete($tmpPath, "_thumb.jpg");
+ $imagePath = Base::leftDelete($str, "{{RemoteURL}}");
+ $imagePath = Base::rightDelete($imagePath, "_thumb.jpg");
} else {
- $tmpPath = "uploads/chat/" . date("Ym") . "/" . $dialog_id . "/";
- Base::makeDir(public_path($tmpPath));
- $tmpPath .= md5s($str) . "." . $matchs[3][$key];
+ $imagePath = "uploads/chat/" . date("Ym") . "/" . $dialog_id . "/";
+ Base::makeDir(public_path($imagePath));
+ $imagePath .= md5s($str) . "." . $matchs[3][$key];
}
- if (file_exists(public_path($tmpPath))) {
- $imagesize = getimagesize(public_path($tmpPath));
- if (Base::imgThumb(public_path($tmpPath), public_path($tmpPath) . "_thumb.jpg", 320, 0)) {
- $tmpPath .= "_thumb.jpg";
+ if (file_exists(public_path($imagePath))) {
+ $imageSize = getimagesize(public_path($imagePath));
+ if (Base::imgThumb(public_path($imagePath), public_path($imagePath) . "_thumb.jpg", 320, 0)) {
+ $imagePath .= "_thumb.jpg";
}
- $text = str_replace($matchs[0][$key], "[:IMAGE:browse:{$imagesize[0]}:{$imagesize[1]}:{$tmpPath}::]", $text);
+ $text = str_replace($matchs[0][$key], "[:IMAGE:browse:{$imageSize[0]}:{$imageSize[1]}:{$imagePath}::]", $text);
} else {
$image = file_get_contents($str);
if (empty($image)) {
$text = str_replace($matchs[0][$key], "[:IMAGE:browse:90:90:images/other/imgerr.jpg::]", $text);
- } else if (file_put_contents(public_path($tmpPath), $image)) {
- $imagesize = getimagesize(public_path($tmpPath));
- if (Base::imgThumb(public_path($tmpPath), public_path($tmpPath) . "_thumb.jpg", 320, 0)) {
- $tmpPath .= "_thumb.jpg";
+ } else if (file_put_contents(public_path($imagePath), $image)) {
+ $imageSize = getimagesize(public_path($imagePath));
+ if (Base::imgThumb(public_path($imagePath), public_path($imagePath) . "_thumb.jpg", 320, 0)) {
+ $imagePath .= "_thumb.jpg";
}
- $text = str_replace($matchs[0][$key], "[:IMAGE:browse:{$imagesize[0]}:{$imagesize[1]}:{$tmpPath}::]", $text);
+ $text = str_replace($matchs[0][$key], "[:IMAGE:browse:{$imageSize[0]}:{$imageSize[1]}:{$imagePath}::]", $text);
}
}
}
diff --git a/package.json b/package.json
index 99b0a2b9d..926d40b7d 100644
--- a/package.json
+++ b/package.json
@@ -51,6 +51,7 @@
"vue-clipboard2": "^0.3.3",
"vue-kityminder-ggg": "^1.3.10",
"vue-loader": "^15.9.8",
+ "vue-jsonp": "^2.0.0",
"vue-resize-observer": "^2.0.16",
"vue-router": "^3.5.3",
"vue-template-compiler": "^2.6.14",
diff --git a/resources/assets/js/functions/web.js b/resources/assets/js/functions/web.js
index c3331a410..f8f5e3ef0 100755
--- a/resources/assets/js/functions/web.js
+++ b/resources/assets/js/functions/web.js
@@ -373,7 +373,7 @@
getMsgTextPreview(text) {
if (!text) return '';
text = text.replace(/
]*?alt="(\S+)"[^>]*?>/g, "[$1]")
- text = text.replace(/
]*?>/g, `[${$A.L('表情')}]`)
+ text = text.replace(/
]*?>/g, `[${$A.L('动画表情')}]`)
text = text.replace(/
]*?>/g, `[${$A.L('图片')}]`)
text = text.replace(/ /g," ")
return text.replace(/<[^>]+>/g,"")
diff --git a/resources/assets/js/pages/manage/components/ChatInput/emoji.vue b/resources/assets/js/pages/manage/components/ChatInput/emoji.vue
index b7f2bd4ec..55caf1f91 100644
--- a/resources/assets/js/pages/manage/components/ChatInput/emoji.vue
+++ b/resources/assets/js/pages/manage/components/ChatInput/emoji.vue
@@ -1,15 +1,25 @@