mirror of
https://github.com/kuaifan/dootask.git
synced 2025-12-12 11:19:56 +00:00
perf: 审批评论优化显示缩略图
This commit is contained in:
parent
0e821d1c84
commit
7fdc7a47e3
@ -1064,8 +1064,9 @@ class ApproveController extends AbstractController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 全局评论
|
// 全局评论
|
||||||
|
unset($res['global_comment']);
|
||||||
if (isset($res['global_comments'])) {
|
if (isset($res['global_comments'])) {
|
||||||
foreach ($res['global_comments'] as $k => &$globalComment) {
|
foreach ($res['global_comments'] as $k => $globalComment) {
|
||||||
$info = User::whereUserid($globalComment['user_id'])->first();
|
$info = User::whereUserid($globalComment['user_id'])->first();
|
||||||
if (!$info) {
|
if (!$info) {
|
||||||
continue;
|
continue;
|
||||||
@ -1073,6 +1074,8 @@ class ApproveController extends AbstractController
|
|||||||
$res['global_comments'][$k]['userimg'] = User::getAvatar($info->userid, $info->userimg, $info->email, $info->nickname);
|
$res['global_comments'][$k]['userimg'] = User::getAvatar($info->userid, $info->userimg, $info->email, $info->nickname);
|
||||||
$res['global_comments'][$k]['nickname'] = $info->nickname;
|
$res['global_comments'][$k]['nickname'] = $info->nickname;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
$res['global_comments'] = [];
|
||||||
}
|
}
|
||||||
$info = User::whereUserid($res['start_user_id'])->first();
|
$info = User::whereUserid($res['start_user_id'])->first();
|
||||||
$res['userimg'] = $info ? User::getAvatar($info->userid, $info->userimg, $info->email, $info->nickname) : '';
|
$res['userimg'] = $info ? User::getAvatar($info->userid, $info->userimg, $info->email, $info->nickname) : '';
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<img :src="srcValue" :alt="alt">
|
<img :src="srcValue" :alt="alt" @error.once="onError">
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
@ -9,13 +9,20 @@ export default {
|
|||||||
src: {
|
src: {
|
||||||
default: ""
|
default: ""
|
||||||
},
|
},
|
||||||
|
errorSrc: {
|
||||||
|
default: ""
|
||||||
|
},
|
||||||
alt: {
|
alt: {
|
||||||
default: ""
|
default: ""
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
srcValue() {
|
srcValue({src}) {
|
||||||
const {src} = this;
|
return this.toSrc(src)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
toSrc(src) {
|
||||||
if (src.substring(0, 10) === "data:image" ||
|
if (src.substring(0, 10) === "data:image" ||
|
||||||
src.substring(0, 2) === "//" ||
|
src.substring(0, 2) === "//" ||
|
||||||
src.substring(0, 7) === "http://" ||
|
src.substring(0, 7) === "http://" ||
|
||||||
@ -25,6 +32,13 @@ export default {
|
|||||||
return src;
|
return src;
|
||||||
}
|
}
|
||||||
return $A.mainUrl(src)
|
return $A.mainUrl(src)
|
||||||
|
},
|
||||||
|
|
||||||
|
onError(e) {
|
||||||
|
if (!this.errorSrc) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
e.target.src = this.toSrc(this.errorSrc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -143,7 +143,7 @@
|
|||||||
</template>
|
</template>
|
||||||
</Timeline>
|
</Timeline>
|
||||||
|
|
||||||
<template v-if="datas.global_comment">
|
<template v-if="datas.global_comments">
|
||||||
<Divider/>
|
<Divider/>
|
||||||
<h3 class="approve-details-subtitle">{{$L('全文评论')}}</h3>
|
<h3 class="approve-details-subtitle">{{$L('全文评论')}}</h3>
|
||||||
<div class="approve-record-comment">
|
<div class="approve-record-comment">
|
||||||
@ -163,7 +163,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="content" style="display: flex; gap: 10px;">
|
<div class="content" style="display: flex; gap: 10px;">
|
||||||
<div v-for="(src,k) in getPictures(item.content)" :key="k" @click="onViewPicture(src, item.content, 2)">
|
<div v-for="(src,k) in getPictures(item.content)" :key="k" @click="onViewPicture(src, item.content, 2)">
|
||||||
<ImgView :src="src" class="img-view"/>
|
<ImgView :src="getPictureThumb(src)" class="img-view"/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -478,6 +478,10 @@ export default {
|
|||||||
return ''
|
return ''
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
// 获取图片缩略图
|
||||||
|
getPictureThumb(src) {
|
||||||
|
return src + '_thumb.' + src.split('.').pop()
|
||||||
|
},
|
||||||
// 打开图片
|
// 打开图片
|
||||||
onViewPicture(currentUrl, datas, type) {
|
onViewPicture(currentUrl, datas, type) {
|
||||||
if (type == 1) {
|
if (type == 1) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user