Browse Source

细节优化

master
xsx 8 months ago
parent
commit
28ba0c2c13
  1. 6
      im-platform/src/main/java/com/bx/implatform/service/impl/FileServiceImpl.java
  2. 14
      im-uniapp/components/long-press-menu/long-press-menu.vue

6
im-platform/src/main/java/com/bx/implatform/service/impl/FileServiceImpl.java

@ -106,8 +106,10 @@ public class FileServiceImpl extends ServiceImpl<FileInfoMapper, FileInfo> imple
UploadImageVO vo = new UploadImageVO(); UploadImageVO vo = new UploadImageVO();
// 获取图片长度和宽度 // 获取图片长度和宽度
BufferedImage bufferedImage = ImageIO.read(file.getInputStream()); BufferedImage bufferedImage = ImageIO.read(file.getInputStream());
vo.setWidth(bufferedImage.getWidth()); if(!Objects.isNull(bufferedImage)){
vo.setHeight(bufferedImage.getHeight()); vo.setWidth(bufferedImage.getWidth());
vo.setHeight(bufferedImage.getHeight());
}
// 如果文件已存在,直接复用 // 如果文件已存在,直接复用
String md5 = DigestUtils.md5DigestAsHex(file.getInputStream()); String md5 = DigestUtils.md5DigestAsHex(file.getInputStream());
FileInfo fileInfo = findByMd5(md5, FileType.IMAGE.code()); FileInfo fileInfo = findByMd5(md5, FileType.IMAGE.code());

14
im-uniapp/components/long-press-menu/long-press-menu.vue

@ -1,6 +1,6 @@
<template> <template>
<view class="long-press-menu none-pointer-events"> <view class="long-press-menu none-pointer-events">
<view @longpress.stop="onLongPress($event)" @touchmove="onTouchMove" @touchend="onTouchEnd"> <view @longpress.prevent.stop="onLongPress($event)" @touchmove="onTouchMove" @touchend="onTouchEnd">
<slot></slot> <slot></slot>
</view> </view>
<view v-if="isShowMenu" class="menu-mask" @touchstart="onClose()" @contextmenu.prevent=""></view> <view v-if="isShowMenu" class="menu-mask" @touchstart="onClose()" @contextmenu.prevent=""></view>
@ -39,9 +39,9 @@ export default {
let style = ""; let style = "";
/* 因 非H5端不兼容 style 属性绑定 Object ,所以拼接字符 */ /* 因 非H5端不兼容 style 属性绑定 Object ,所以拼接字符 */
if (touches.clientY > (res.windowHeight / 2)) { if (touches.clientY > (res.windowHeight / 2)) {
style = `bottom:${res.windowHeight - touches.clientY}px;`; style = `bottom:${res.windowHeight - touches.clientY + 20}px;`;
} else { } else {
style = `top:${touches.clientY}px;`; style = `top:${touches.clientY + 20}px;`;
} }
if (touches.clientX > (res.windowWidth / 2)) { if (touches.clientX > (res.windowWidth / 2)) {
style += `right:${res.windowWidth - touches.clientX}px;`; style += `right:${res.windowWidth - touches.clientX}px;`;
@ -53,12 +53,18 @@ export default {
this.$nextTick(() => { this.$nextTick(() => {
this.isShowMenu = true; this.isShowMenu = true;
}); });
this.menuTouch = touches
} }
}) })
}, },
onTouchMove() { onTouchMove() {
this.onClose();
this.isTouchMove = true; this.isTouchMove = true;
let touches = e.touches[0];
// 50px
if (Math.abs(touches.clientX - this.menuTouch.clientX) > 50 ||
Math.abs(touches.clientY - this.menuTouch.clientY) > 50) {
this.onClose();
}
}, },
onTouchEnd() { onTouchEnd() {
this.isTouchMove = false; this.isTouchMove = false;

Loading…
Cancel
Save