mirror of
https://github.com/kuaifan/dootask.git
synced 2026-01-06 20:58:12 +00:00
perf: 添加定位签到
This commit is contained in:
parent
3b9c9872ca
commit
13fb884387
@ -1377,7 +1377,7 @@ class DialogController extends AbstractController
|
||||
* @apiParam {Number} lat 纬度
|
||||
* @apiParam {String} title 位置名称
|
||||
* @apiParam {String} [address] 位置地址
|
||||
* @apiParam {String} [preview] 预览图片(url)
|
||||
* @apiParam {String} [thumb] 预览图片(url)
|
||||
*
|
||||
* @apiSuccess {Number} ret 返回状态码(1正确、0错误)
|
||||
* @apiSuccess {String} msg 返回信息(错误描述)
|
||||
@ -1393,7 +1393,7 @@ class DialogController extends AbstractController
|
||||
$lat = floatval(Request::input('lat'));
|
||||
$title = trim(Request::input('title'));
|
||||
$address = trim(Request::input('address'));
|
||||
$preview = trim(Request::input('preview'));
|
||||
$thumb = trim(Request::input('thumb'));
|
||||
//
|
||||
if (empty($lng) || $lng < -180 || $lng > 180
|
||||
|| empty($lat) || $lat < -90 || $lat > 90) {
|
||||
@ -1412,7 +1412,7 @@ class DialogController extends AbstractController
|
||||
'lat' => $lat,
|
||||
'title' => $title,
|
||||
'address' => $address,
|
||||
'preview' => $preview,
|
||||
'thumb' => $thumb,
|
||||
];
|
||||
return WebSocketDialogMsg::sendMsg(null, $dialog_id, 'location', $msgData, $user->userid);
|
||||
}
|
||||
|
||||
@ -167,6 +167,10 @@ class WebSocketDialogMsg extends AbstractModel
|
||||
}
|
||||
break;
|
||||
|
||||
case 'location':
|
||||
$msg['thumb'] = Base::fillUrl($msg['thumb'] ?: "images/other/location.jpg");
|
||||
break;
|
||||
|
||||
case 'template':
|
||||
if ($msg['data']['thumb']) {
|
||||
$msg['data']['thumb']['url'] = Base::fillUrl($msg['data']['thumb']['url']);
|
||||
@ -582,6 +586,10 @@ class WebSocketDialogMsg extends AbstractModel
|
||||
$action = Doo::translate("语音");
|
||||
return "[{$action}]";
|
||||
|
||||
case 'location':
|
||||
$action = Doo::translate("位置");
|
||||
return "[{$action}] " . Base::cutStr($data['msg']['title'], 50);
|
||||
|
||||
case 'meeting':
|
||||
$action = Doo::translate("会议");
|
||||
return "[{$action}] " . Base::cutStr($data['msg']['name'], 50);
|
||||
@ -996,17 +1004,21 @@ class WebSocketDialogMsg extends AbstractModel
|
||||
$mtype = 'image';
|
||||
}
|
||||
} elseif ($type === 'location') {
|
||||
if (preg_match('/^https*:\/\//', $msg['preview'])) {
|
||||
$preview = file_get_contents($msg['preview']);
|
||||
if (empty($preview)) {
|
||||
if (preg_match('/^https*:\/\//', $msg['thumb'])) {
|
||||
$thumb = file_get_contents($msg['thumb']);
|
||||
if (empty($thumb)) {
|
||||
throw new ApiException('获取地图快照失败');
|
||||
}
|
||||
$filePath = "uploads/chat/" . date("Ym") . "/" . $dialog_id . "/" . md5s($msg['preview']) . ".jpg";
|
||||
Base::makeDir(dirname(public_path($filePath)));
|
||||
if (!Base::saveContentImage(public_path($filePath), $preview, 90)) {
|
||||
$fileUrl = "uploads/chat/" . date("Ym") . "/" . $dialog_id . "/" . md5s($msg['thumb']) . ".jpg";
|
||||
$filePath = public_path($fileUrl);
|
||||
Base::makeDir(dirname($filePath));
|
||||
if (!Base::saveContentImage($filePath, $thumb, 90)) {
|
||||
throw new ApiException('保存地图快照失败');
|
||||
}
|
||||
$msg['preview'] = $filePath;
|
||||
$imageSize = getimagesize($filePath);
|
||||
$msg['thumb'] = $fileUrl;
|
||||
$msg['width'] = $imageSize[0];
|
||||
$msg['height'] = $imageSize[1];
|
||||
}
|
||||
}
|
||||
if ($push_silence === null) {
|
||||
|
||||
BIN
public/images/other/location.jpg
Normal file
BIN
public/images/other/location.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 48 KiB |
14
resources/assets/js/functions/web.js
vendored
14
resources/assets/js/functions/web.js
vendored
@ -406,6 +406,8 @@ import {MarkdownPreview} from "../store/markdown";
|
||||
return `[${$A.L('接龙')}]` + $A.getMsgTextPreview(data.msg, imgClassName)
|
||||
case 'record':
|
||||
return `[${$A.L('语音')}]`
|
||||
case 'location':
|
||||
return `[${$A.L('位置')}] ${$A.cutString(data.msg.title, 50)}`
|
||||
case 'meeting':
|
||||
return `[${$A.L('会议')}] ${$A.cutString(data.msg.name, 50)}`
|
||||
case 'file':
|
||||
@ -1020,15 +1022,15 @@ import {MarkdownPreview} from "../store/markdown";
|
||||
will-change: transform;
|
||||
}
|
||||
|
||||
[style*="background:url"] *,
|
||||
[style*="background-image:url"] *,
|
||||
[style*="background: url"] *,
|
||||
[style*="background-image: url"] *,
|
||||
input,
|
||||
[background] *,
|
||||
.no-dark-content img,
|
||||
.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()}
|
||||
}
|
||||
|
||||
|
||||
@ -31,6 +31,8 @@
|
||||
<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"/>
|
||||
<!--位置-->
|
||||
<LocationMsg v-else-if="msgData.type === 'location'" :msg="msgData.msg"/>
|
||||
<!--会议-->
|
||||
<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 FileMsg from "./file.vue";
|
||||
import RecordMsg from "./record.vue";
|
||||
import LocationMsg from "./location.vue";
|
||||
import MeetingMsg from "./meet.vue";
|
||||
import WordChainMsg from "./word-chain.vue";
|
||||
import VoteMsg from "./vote.vue";
|
||||
@ -194,6 +197,7 @@ export default {
|
||||
VoteMsg,
|
||||
WordChainMsg,
|
||||
MeetingMsg,
|
||||
LocationMsg,
|
||||
RecordMsg,
|
||||
TextMsg,
|
||||
FileMsg,
|
||||
|
||||
@ -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>
|
||||
@ -1767,13 +1767,14 @@ export default {
|
||||
$A.modalError(`你选择的位置「${data.title}」不在签到范围内`)
|
||||
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,
|
||||
center: `${item.config.lng},${item.config.lat}`,
|
||||
markers: `${item.config.lng},${item.config.lat}`,
|
||||
width: 800,
|
||||
height: 480,
|
||||
zoom: 17,
|
||||
copyright: 1
|
||||
zoom: 19,
|
||||
copyright: 1,
|
||||
})
|
||||
this.sendLocationMsg({
|
||||
type: 'bd',
|
||||
@ -1781,7 +1782,7 @@ export default {
|
||||
lat: data.point.lat,
|
||||
title: data.title,
|
||||
address: data.address || '',
|
||||
preview
|
||||
thumb
|
||||
})
|
||||
})
|
||||
return;
|
||||
|
||||
1
resources/assets/sass/dark.scss
vendored
1
resources/assets/sass/dark.scss
vendored
@ -215,6 +215,7 @@ body.dark-mode-reverse {
|
||||
.dialog-content {
|
||||
.content-text,
|
||||
.content-record,
|
||||
.content-location,
|
||||
.content-meeting,
|
||||
.content-template {
|
||||
color: #ffffff !important;
|
||||
|
||||
@ -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 {
|
||||
padding: 4px 6px;
|
||||
color: $primary-title-color;
|
||||
@ -1722,6 +1758,10 @@
|
||||
}
|
||||
}
|
||||
|
||||
.content-location {
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.content-meeting {
|
||||
color: #ffffff;
|
||||
|
||||
@ -2572,6 +2612,7 @@ body.window-portrait {
|
||||
.dialog-item {
|
||||
.dialog-view {
|
||||
&.text,
|
||||
&.location,
|
||||
&.template {
|
||||
max-width: calc(100% - 80px);
|
||||
}
|
||||
|
||||
BIN
resources/assets/statics/public/images/other/location.jpg
Normal file
BIN
resources/assets/statics/public/images/other/location.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 48 KiB |
Loading…
x
Reference in New Issue
Block a user