fix: 发送图片显示错误
This commit is contained in:
parent
164f3275f4
commit
88d38ba8d1
@ -725,7 +725,7 @@ class Base
|
||||
public static function getHost($var = '')
|
||||
{
|
||||
if (empty($var)) {
|
||||
$var = self::url();
|
||||
$var = url("/");
|
||||
}
|
||||
$arr = parse_url($var);
|
||||
return $arr['host'];
|
||||
@ -738,6 +738,7 @@ class Base
|
||||
*/
|
||||
public static function fillUrl($str = '')
|
||||
{
|
||||
global $_A;
|
||||
if (is_array($str)) {
|
||||
foreach ($str as $key => $item) {
|
||||
$str[$key] = Base::fillUrl($item);
|
||||
@ -756,7 +757,14 @@ class Base
|
||||
) {
|
||||
return $str;
|
||||
} else {
|
||||
return self::url($str);
|
||||
if ($_A['__fill_url_remote_url'] === true) {
|
||||
return "{{RemoteURL}}" . $str;
|
||||
}
|
||||
try {
|
||||
return url($str);
|
||||
} catch (\Throwable) {
|
||||
return self::getSchemeAndHost() . "/" . $str;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -773,25 +781,12 @@ class Base
|
||||
}
|
||||
return $str;
|
||||
}
|
||||
return Base::leftDelete($str, self::url() . '/');
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取url
|
||||
* @param $path
|
||||
* @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\Routing\UrlGenerator|string
|
||||
*/
|
||||
public static function url($path = '')
|
||||
{
|
||||
try {
|
||||
$url = url($path);
|
||||
if (str_starts_with($url, "http://localhost/")) {
|
||||
$url = "http://localhost:" . env("APP_PORT", "80") . "/" . substr($url, 17);
|
||||
}
|
||||
$find = url('');
|
||||
} catch (\Throwable) {
|
||||
$url = self::getSchemeAndHost() . "/" . $path;
|
||||
$find = self::getSchemeAndHost();
|
||||
}
|
||||
return $url;
|
||||
return Base::leftDelete($str, $find . '/');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -33,6 +33,11 @@ class WebSocketDialogMsgTask extends AbstractTask
|
||||
|
||||
public function start()
|
||||
{
|
||||
global $_A;
|
||||
$_A = [
|
||||
'__fill_url_remote_url' => true,
|
||||
];
|
||||
//
|
||||
$msg = WebSocketDialogMsg::find($this->id);
|
||||
if (empty($msg)) {
|
||||
return;
|
||||
|
20
resources/assets/js/functions/web.js
vendored
20
resources/assets/js/functions/web.js
vendored
@ -76,6 +76,26 @@
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 格式化websocket的消息
|
||||
* @param data
|
||||
*/
|
||||
formatWebsocketMessageDetail(data) {
|
||||
if ($A.isJson(data)) {
|
||||
for (let key in data) {
|
||||
if (!data.hasOwnProperty(key)) continue;
|
||||
data[key] = $A.formatWebsocketMessageDetail(data[key]);
|
||||
}
|
||||
} else if ($A.isArray(data)) {
|
||||
data.forEach((val, index) => {
|
||||
data[index] = $A.formatWebsocketMessageDetail(val);
|
||||
});
|
||||
} else if (typeof data === "string") {
|
||||
data = data.replace(/\{\{RemoteURL\}\}/g, this.apiUrl('../'))
|
||||
}
|
||||
return data;
|
||||
},
|
||||
|
||||
/**
|
||||
* 格式化时间
|
||||
* @param date
|
||||
|
10
resources/assets/js/store/actions.js
vendored
10
resources/assets/js/store/actions.js
vendored
@ -1956,11 +1956,11 @@ export default {
|
||||
//
|
||||
state.ws = new WebSocket(url);
|
||||
state.ws.onopen = (e) => {
|
||||
console.log("[WS] Open", $A.formatDate())
|
||||
// console.log("[WS] Open", $A.formatDate())
|
||||
state.wsOpenNum++;
|
||||
};
|
||||
state.ws.onclose = (e) => {
|
||||
console.log("[WS] Close", $A.formatDate())
|
||||
// console.log("[WS] Close", $A.formatDate())
|
||||
state.ws = null;
|
||||
//
|
||||
clearTimeout(state.wsTimeout);
|
||||
@ -1969,7 +1969,7 @@ export default {
|
||||
}, 3000);
|
||||
};
|
||||
state.ws.onerror = (e) => {
|
||||
console.log("[WS] Error", $A.formatDate())
|
||||
// console.log("[WS] Error", $A.formatDate())
|
||||
state.ws = null;
|
||||
//
|
||||
clearTimeout(state.wsTimeout);
|
||||
@ -1979,7 +1979,7 @@ export default {
|
||||
};
|
||||
state.ws.onmessage = (e) => {
|
||||
// console.log("[WS] Message", e);
|
||||
const msgDetail = $A.jsonParse(e.data);
|
||||
const msgDetail = $A.formatWebsocketMessageDetail($A.jsonParse(e.data));
|
||||
const {type, msgId} = msgDetail;
|
||||
switch (type) {
|
||||
case "open":
|
||||
@ -2003,7 +2003,7 @@ export default {
|
||||
try {
|
||||
call(msgDetail);
|
||||
} catch (err) {
|
||||
console.log("[WS] Callerr", err);
|
||||
// console.log("[WS] Callerr", err);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user