perf: 添加定位签到

This commit is contained in:
kuaifan 2024-11-08 22:44:04 +08:00
parent 3b9c9872ca
commit 13fb884387
10 changed files with 109 additions and 20 deletions

View File

@ -1377,7 +1377,7 @@ class DialogController extends AbstractController
* @apiParam {Number} lat 纬度 * @apiParam {Number} lat 纬度
* @apiParam {String} title 位置名称 * @apiParam {String} title 位置名称
* @apiParam {String} [address] 位置地址 * @apiParam {String} [address] 位置地址
* @apiParam {String} [preview] 预览图片url * @apiParam {String} [thumb] 预览图片url
* *
* @apiSuccess {Number} ret 返回状态码1正确、0错误 * @apiSuccess {Number} ret 返回状态码1正确、0错误
* @apiSuccess {String} msg 返回信息(错误描述) * @apiSuccess {String} msg 返回信息(错误描述)
@ -1393,7 +1393,7 @@ class DialogController extends AbstractController
$lat = floatval(Request::input('lat')); $lat = floatval(Request::input('lat'));
$title = trim(Request::input('title')); $title = trim(Request::input('title'));
$address = trim(Request::input('address')); $address = trim(Request::input('address'));
$preview = trim(Request::input('preview')); $thumb = trim(Request::input('thumb'));
// //
if (empty($lng) || $lng < -180 || $lng > 180 if (empty($lng) || $lng < -180 || $lng > 180
|| empty($lat) || $lat < -90 || $lat > 90) { || empty($lat) || $lat < -90 || $lat > 90) {
@ -1412,7 +1412,7 @@ class DialogController extends AbstractController
'lat' => $lat, 'lat' => $lat,
'title' => $title, 'title' => $title,
'address' => $address, 'address' => $address,
'preview' => $preview, 'thumb' => $thumb,
]; ];
return WebSocketDialogMsg::sendMsg(null, $dialog_id, 'location', $msgData, $user->userid); return WebSocketDialogMsg::sendMsg(null, $dialog_id, 'location', $msgData, $user->userid);
} }

View File

@ -167,6 +167,10 @@ class WebSocketDialogMsg extends AbstractModel
} }
break; break;
case 'location':
$msg['thumb'] = Base::fillUrl($msg['thumb'] ?: "images/other/location.jpg");
break;
case 'template': case 'template':
if ($msg['data']['thumb']) { if ($msg['data']['thumb']) {
$msg['data']['thumb']['url'] = Base::fillUrl($msg['data']['thumb']['url']); $msg['data']['thumb']['url'] = Base::fillUrl($msg['data']['thumb']['url']);
@ -582,6 +586,10 @@ class WebSocketDialogMsg extends AbstractModel
$action = Doo::translate("语音"); $action = Doo::translate("语音");
return "[{$action}]"; return "[{$action}]";
case 'location':
$action = Doo::translate("位置");
return "[{$action}] " . Base::cutStr($data['msg']['title'], 50);
case 'meeting': case 'meeting':
$action = Doo::translate("会议"); $action = Doo::translate("会议");
return "[{$action}] " . Base::cutStr($data['msg']['name'], 50); return "[{$action}] " . Base::cutStr($data['msg']['name'], 50);
@ -996,17 +1004,21 @@ class WebSocketDialogMsg extends AbstractModel
$mtype = 'image'; $mtype = 'image';
} }
} elseif ($type === 'location') { } elseif ($type === 'location') {
if (preg_match('/^https*:\/\//', $msg['preview'])) { if (preg_match('/^https*:\/\//', $msg['thumb'])) {
$preview = file_get_contents($msg['preview']); $thumb = file_get_contents($msg['thumb']);
if (empty($preview)) { if (empty($thumb)) {
throw new ApiException('获取地图快照失败'); throw new ApiException('获取地图快照失败');
} }
$filePath = "uploads/chat/" . date("Ym") . "/" . $dialog_id . "/" . md5s($msg['preview']) . ".jpg"; $fileUrl = "uploads/chat/" . date("Ym") . "/" . $dialog_id . "/" . md5s($msg['thumb']) . ".jpg";
Base::makeDir(dirname(public_path($filePath))); $filePath = public_path($fileUrl);
if (!Base::saveContentImage(public_path($filePath), $preview, 90)) { Base::makeDir(dirname($filePath));
if (!Base::saveContentImage($filePath, $thumb, 90)) {
throw new ApiException('保存地图快照失败'); throw new ApiException('保存地图快照失败');
} }
$msg['preview'] = $filePath; $imageSize = getimagesize($filePath);
$msg['thumb'] = $fileUrl;
$msg['width'] = $imageSize[0];
$msg['height'] = $imageSize[1];
} }
} }
if ($push_silence === null) { if ($push_silence === null) {

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

View File

@ -406,6 +406,8 @@ import {MarkdownPreview} from "../store/markdown";
return `[${$A.L('接龙')}]` + $A.getMsgTextPreview(data.msg, imgClassName) return `[${$A.L('接龙')}]` + $A.getMsgTextPreview(data.msg, imgClassName)
case 'record': case 'record':
return `[${$A.L('语音')}]` return `[${$A.L('语音')}]`
case 'location':
return `[${$A.L('位置')}] ${$A.cutString(data.msg.title, 50)}`
case 'meeting': case 'meeting':
return `[${$A.L('会议')}] ${$A.cutString(data.msg.name, 50)}` return `[${$A.L('会议')}] ${$A.cutString(data.msg.name, 50)}`
case 'file': case 'file':
@ -1020,15 +1022,15 @@ import {MarkdownPreview} from "../store/markdown";
will-change: transform; will-change: transform;
} }
[style*="background:url"] *,
[style*="background-image:url"] *,
[style*="background: url"] *,
[style*="background-image: url"] *,
input, input,
[background] *,
.no-dark-content img, .no-dark-content img,
.no-dark-content canvas, .no-dark-content canvas,
.no-dark-content svg image { .no-dark-content svg image,
.no-dark-content [style*="background:url"],
.no-dark-content [style*="background-image:url"],
.no-dark-content [style*="background: url"],
.no-dark-content [style*="background-image: url"],
.no-dark-content [background] {
${this.utils.noneFilter()} ${this.utils.noneFilter()}
} }

View File

@ -31,6 +31,8 @@
<FileMsg v-else-if="msgData.type === 'file'" :msg="msgData.msg" @viewFile="viewFile" @downFile="downFile"/> <FileMsg v-else-if="msgData.type === 'file'" :msg="msgData.msg" @viewFile="viewFile" @downFile="downFile"/>
<!--录音--> <!--录音-->
<RecordMsg v-else-if="msgData.type === 'record'" :msgId="msgData.id" :msg="msgData.msg" @playRecord="playRecord"/> <RecordMsg v-else-if="msgData.type === 'record'" :msgId="msgData.id" :msg="msgData.msg" @playRecord="playRecord"/>
<!--位置-->
<LocationMsg v-else-if="msgData.type === 'location'" :msg="msgData.msg"/>
<!--会议--> <!--会议-->
<MeetingMsg v-else-if="msgData.type === 'meeting'" :msg="msgData.msg" @openMeeting="openMeeting"/> <MeetingMsg v-else-if="msgData.type === 'meeting'" :msg="msgData.msg" @openMeeting="openMeeting"/>
<!--接龙--> <!--接龙-->
@ -178,6 +180,7 @@ import longpress from "../../../../directives/longpress";
import TextMsg from "./text.vue"; import TextMsg from "./text.vue";
import FileMsg from "./file.vue"; import FileMsg from "./file.vue";
import RecordMsg from "./record.vue"; import RecordMsg from "./record.vue";
import LocationMsg from "./location.vue";
import MeetingMsg from "./meet.vue"; import MeetingMsg from "./meet.vue";
import WordChainMsg from "./word-chain.vue"; import WordChainMsg from "./word-chain.vue";
import VoteMsg from "./vote.vue"; import VoteMsg from "./vote.vue";
@ -194,6 +197,7 @@ export default {
VoteMsg, VoteMsg,
WordChainMsg, WordChainMsg,
MeetingMsg, MeetingMsg,
LocationMsg,
RecordMsg, RecordMsg,
TextMsg, TextMsg,
FileMsg, FileMsg,

View File

@ -0,0 +1,28 @@
<template>
<div class="content-location no-dark-content">
<div class="location-title">{{msg.title}}</div>
<div v-if="msg.address" class="location-address">{{msg.address}}</div>
<div class="location-preview" :style="imageStyle(msg)"></div>
</div>
</template>
<script>
export default {
props: {
msg: Object,
},
methods: {
imageStyle({width, height, thumb}) {
if (!thumb) {
return {};
}
const style = {
backgroundImage: `url(${thumb})`,
}
if (width && height) {
style.backgroundSize = `${width}px ${height}px`;
}
return style;
}
}
}
</script>

View File

@ -1767,13 +1767,14 @@ export default {
$A.modalError(`你选择的位置「${data.title}」不在签到范围内`) $A.modalError(`你选择的位置「${data.title}」不在签到范围内`)
return return
} }
const preview = $A.urlAddParams('https://api.map.baidu.com/staticimage/v2', { const thumb = $A.urlAddParams('https://api.map.baidu.com/staticimage/v2', {
ak: item.config.key, ak: item.config.key,
center: `${item.config.lng},${item.config.lat}`, center: `${item.config.lng},${item.config.lat}`,
markers: `${item.config.lng},${item.config.lat}`,
width: 800, width: 800,
height: 480, height: 480,
zoom: 17, zoom: 19,
copyright: 1 copyright: 1,
}) })
this.sendLocationMsg({ this.sendLocationMsg({
type: 'bd', type: 'bd',
@ -1781,7 +1782,7 @@ export default {
lat: data.point.lat, lat: data.point.lat,
title: data.title, title: data.title,
address: data.address || '', address: data.address || '',
preview thumb
}) })
}) })
return; return;

View File

@ -215,6 +215,7 @@ body.dark-mode-reverse {
.dialog-content { .dialog-content {
.content-text, .content-text,
.content-record, .content-record,
.content-location,
.content-meeting, .content-meeting,
.content-template { .content-template {
color: #ffffff !important; color: #ffffff !important;

View File

@ -1098,6 +1098,42 @@
} }
} }
.content-location {
display: flex;
flex-direction: column;
align-items: flex-start;
color: $primary-title-color;
width: 260px;
max-width: 100%;
.location-title {
width: 100%;
font-size: 14px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.location-address {
width: 100%;
font-size: 12px;
opacity: 0.6;
word-break: break-all;
text-overflow: ellipsis;
overflow: hidden;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
}
.location-preview {
width: calc(100% + 16px);
height: 110px;
margin: 4px -8px -8px;
border-radius: 0 0 6px 6px;
background-repeat: no-repeat;
background-size: cover;
background-position: center;
}
}
.content-meeting { .content-meeting {
padding: 4px 6px; padding: 4px 6px;
color: $primary-title-color; color: $primary-title-color;
@ -1722,6 +1758,10 @@
} }
} }
.content-location {
color: #ffffff;
}
.content-meeting { .content-meeting {
color: #ffffff; color: #ffffff;
@ -2572,6 +2612,7 @@ body.window-portrait {
.dialog-item { .dialog-item {
.dialog-view { .dialog-view {
&.text, &.text,
&.location,
&.template { &.template {
max-width: calc(100% - 80px); max-width: calc(100% - 80px);
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB