Commit 2efb1ca6 authored by 以墨为白's avatar 以墨为白 🎧
parents bc07c430 f1c9d809
// 定义粘贴函数
const onPaste = (event) => {
// 剪贴板没数据,则直接返回
if (!event.clipboardData || !event.clipboardData.items) {
return;
}
// 封装Promise
return new Promise((resovle, reject) => {
for(let i = 0, len = event.clipboardData.items.length; i < len; i++) {
const item = event.clipboardData.items[i];
if (item.kind === 'string') {
// let str = event.clipboardData.getData('text');
// resovle({
// data: str
// });
let reg = /<\/?.+?\/?>/g; // 匹配粘贴文本中的html标签
item.getAsString(str => {
resovle({
data: str.replace(reg, '').replace(/(\r\n)|(\n)/g, '') // 去掉换行符
})
})
} else if (item.kind === 'file') {
const file = item.getAsFile();
if (item.type.match('^image/')) {
// 处理图片
handleImage(file, (data) => {
resovle(data)
})
} else {
// 其他文件直接返回
resovle({
data: file,
type: 'file'
})
}
} else {
reject(new Error('不支持粘贴该类型'));
}
}
})
}
/**
* 图片处理
* @param {*} file 图片
* @param {*} callback 回调
* @param {*} maxWidth
* @returns
*/
function handleImage(file, callback, maxWidth = 200) {
console.log('粘贴的图片', file);
if (!file || !/\/(?:png|jpg|jpeg|gif)/i.test(file.type)) {
console.log('图片格式不支持');
return;
}
const reader = new FileReader();
reader.onload = function () {
const result = this.result;
console.log('compressedDataUrl', result);
let img = new Image();
img.onload = function() {
let compressedDataUrl = compress(img, file.type, maxWidth, true);
let url = compress(img, file.type, maxWidth, false);
img = null;
callback({
data: file,
compressedDataUrl,
url,
type: 'image'
})
}
img.src = result;
};
reader.readAsDataURL(file);
}
/**
* 图片压缩
* @param {*} img 图片对象
* @param {*} type 图片类型
* @param {*} maxWidth 图片最大宽度
* @param {*} flag
*/
function compress(img, type, maxWidth, flag) {
let canvas = document.createElement('canvas');
let ctx2 = canvas.getContext('2d');
let ratio = img.width / img.height;
let width = img.width, height = img.height;
// 根据flag判断是否压缩图片
if (flag) {
// 压缩后的图片展示在输入框
width = maxWidth;
height = maxWidth / ratio; // 维持图片宽高比
}
canvas.width = width;
canvas.height = height;
ctx2.fillStyle = '#fff';
ctx2.fillRect(0, 0, canvas.width, canvas.height);
ctx2.drawImage(img, 0, 0, width, height);
let base64Data = canvas.toDataURL(type, 0.75);
if (type === 'image/gif') {
let regx = /(?<=data:image).*?(?=;base64)/; // 正则表示时在用于replace时,根据浏览器的不同,有的需要为字符串
base64Data = base64Data.replace(regx, '/gif');
}
canvas = null;
ctx2 = null;
return base64Data;
}
export default onPaste;
\ No newline at end of file
This diff is collapsed.
...@@ -25,26 +25,19 @@ export default { ...@@ -25,26 +25,19 @@ export default {
elDragDialog elDragDialog
}, },
props: { props: {
// visible: Boolean,
peopleList: Array peopleList: Array
}, },
methods: { methods: {
handleClose() { handleClose() {
this.dialogVisible = false; this.dialogVisible = false;
// this.$emit('handleCancel');
}, },
showDialog() { showDialog() {
this.dialogVisible = true; this.dialogVisible = true;
}, },
handleDialogOpen() { handleDialogOpen() {
// this.dialogVisible = this.$props.visible;
this.personList = this.$props.peopleList; this.personList = this.$props.peopleList;
} }
}, }
// mounted() {
// this.dialogVisible = this.$props.visible;
// this.personList = this.$props.peopleList;
// }
} }
</script> </script>
......
<template> <template>
<el-dialog v-el-drag-dialog title="发送公告" :visible.sync="dialogVisible" width="30%" :before-close="handleClose"> <el-dialog v-el-drag-dialog title="发送公告" :visible.sync="dialogVisible" width="30%" :before-close="handleClose"
@open="handleDialogOpen">
<div class="notice"> <div class="notice">
<el-form ref="form" :model="form" label-width="80px"> <el-form ref="form" :model="form" label-width="80px">
<el-form-item label="标题"> <el-form-item label="标题">
...@@ -37,7 +38,7 @@ export default { ...@@ -37,7 +38,7 @@ export default {
title: '', title: '',
content: '', content: '',
attachment: '', attachment: '',
messageForm:null messageForm: null
}, },
formatFile: format_file(), formatFile: format_file(),
myStompClient: null, myStompClient: null,
...@@ -59,7 +60,7 @@ export default { ...@@ -59,7 +60,7 @@ export default {
this.dialogVisible = false; this.dialogVisible = false;
// this.$emit('handleCancel'); // this.$emit('handleCancel');
}, },
showDialog(){ showDialog() {
this.dialogVisible = true; this.dialogVisible = true;
}, },
handleChange(file, fileList) { handleChange(file, fileList) {
...@@ -68,16 +69,16 @@ export default { ...@@ -68,16 +69,16 @@ export default {
upLoadFiles('CHAT', fd).then(res => { upLoadFiles('CHAT', fd).then(res => {
this.form.attachment = res; this.form.attachment = res;
let type = file.name.split('.')[1]; let type = file.name.split('.')[1];
if(type=='png'||type=='jpg'){ if (type == 'png' || type == 'jpg') {
this.form.messageForm = 'PICTURE'; this.form.messageForm = 'PICTURE';
}else if(type=='mp4'){ } else if (type == 'mp4') {
this.form.messageForm = 'VIDEO'; this.form.messageForm = 'VIDEO';
}else if(type=='xlsx'||type=='xls'){ } else if (type == 'xlsx' || type == 'xls') {
this.form.messageForm = 'EXCEL'; this.form.messageForm = 'EXCEL';
}else{ } else {
this.form.messageForm = 'TEXT'; this.form.messageForm = 'TEXT';
} }
}); });
}, },
handleRemove() { }, handleRemove() { },
...@@ -95,18 +96,24 @@ export default { ...@@ -95,18 +96,24 @@ export default {
//订阅聊天室主题,订阅功能中设置ID: //订阅聊天室主题,订阅功能中设置ID:
this.stompClient.subscribe('/topic/multicast/' + e.id, data => { this.stompClient.subscribe('/topic/multicast/' + e.id, data => {
this.$emit('handleCancel'); this.$emit('handleCancel');
this.$emit('showInfo',true, this.currentChatRoom); this.$emit('showInfo', true, this.currentChatRoom);
}, { id: "multicast" + e.id + new Date().getTime() }); }, { id: "multicast" + e.id + new Date().getTime() });
}) })
}, },
handleDialogOpen() {
this.myStompClient = this.$props.stompClient;
this.currentChatRoom = this.$props.currentChatRoomInfo;
this.analogDataList = this.$props.analogData;
this.listChatroom(this.analogDataList);
}
}, },
mounted() { // mounted() {
this.dialogVisible = this.$props.visible; // this.dialogVisible = this.$props.visible;
this.myStompClient = this.$props.stompClient; // this.myStompClient = this.$props.stompClient;
this.currentChatRoom = this.$props.currentChatRoomInfo; // this.currentChatRoom = this.$props.currentChatRoomInfo;
this.analogDataList = this.$props.analogData; // this.analogDataList = this.$props.analogData;
this.listChatroom(this.analogDataList); // this.listChatroom(this.analogDataList);
} // }
} }
</script> </script>
......
...@@ -73,7 +73,8 @@ ...@@ -73,7 +73,8 @@
:class="['everyDayNewCard', 'cardType' + item1.teamInfo.teamType]"> :class="['everyDayNewCard', 'cardType' + item1.teamInfo.teamType]">
<div class="everyDayNewCardTitle" v-text="item1.title"></div> <div class="everyDayNewCardTitle" v-text="item1.title"></div>
<div class="everyDayNewCardContent"> <div class="everyDayNewCardContent">
<div class="left-everyDayNew" :style="{ width: item1.attachment ? '50%' : '100%' }"> <div class="left-everyDayNew"
:style="{ width: item1.attachment ? '50%' : '100%' }">
<div class="everyDayNewCardInfo"> <div class="everyDayNewCardInfo">
<span v-text="item1.time"></span>&emsp; <span v-text="item1.time"></span>&emsp;
来源:<span class="newsSource" v-text="item1.from"></span> 来源:<span class="newsSource" v-text="item1.from"></span>
...@@ -86,7 +87,7 @@ ...@@ -86,7 +87,7 @@
</el-image> </el-image>
</template> </template>
<template v-else-if="item1.type == 'VIDEO'"> <template v-else-if="item1.type == 'VIDEO'">
<video :src="item1.url" controls loop> <video :src="item1.url" controls loop>
</video> </video>
</template> </template>
<template v-else-if="item1.type == 'EXCEL'"> <template v-else-if="item1.type == 'EXCEL'">
...@@ -107,14 +108,11 @@ ...@@ -107,14 +108,11 @@
</div> </div>
</div> </div>
</transition> </transition>
<NoticeDialog v-if="visible" ref="myNotice" @handleCancel="closeDialog" :stompClient="stompClient" <NoticeDialog ref="myNotice" :stompClient="stompClient"
:currentChatRoomInfo="currentChatRoomInfo" :analogData="analogData" @showInfo="showInfo"></NoticeDialog> :currentChatRoomInfo="currentChatRoomInfo" :analogData="analogData" @showInfo="showInfo"></NoticeDialog>
<ChatRoomDialog v-if="chatRoomVisible" :visible="chatRoomVisible" ref="myChatRoom" <ChatRoomDialog ref="myChatRoom" :analogData="analogData" :currentChatRoomInfo="currentChatRoomInfo" :stompClient="stompClient">
@handleCancel="closeDialogChatRoom" :analogData="analogData" :currentChatRoomInfo="currentChatRoomInfo"
:stompClient="stompClient">
</ChatRoomDialog> </ChatRoomDialog>
<ChatRoomPeople ref="myChatRoomPeople" @handleCancel="closeDialogChatRoomPeople" <ChatRoomPeople ref="myChatRoomPeople" :peopleList="peopleList"></ChatRoomPeople>
:peopleList="peopleList"></ChatRoomPeople>
<el-tooltip placement="left" class="myButtonList" v-if="isInfo"> <el-tooltip placement="left" class="myButtonList" v-if="isInfo">
<div class="myTools" slot="content"> <div class="myTools" slot="content">
<div> <div>
...@@ -183,9 +181,9 @@ export default { ...@@ -183,9 +181,9 @@ export default {
], ],
avatar: avatar, avatar: avatar,
sendMessage: '', sendMessage: '',
visible: false, // visible: false,
chatRoomVisible: false, // chatRoomVisible: false,
chatRoomPeopleVisible: false, // chatRoomPeopleVisible: false,
peopleList: [], peopleList: [],
// chatMessageList: [], // chatMessageList: [],
currentChatRoomInfo: {}, currentChatRoomInfo: {},
...@@ -254,7 +252,6 @@ export default { ...@@ -254,7 +252,6 @@ export default {
tmpArr = this.publicNoticeList.filter(item => { return item.fromUserId == user && item.createTime.slice(0, 10) == day }); tmpArr = this.publicNoticeList.filter(item => { return item.fromUserId == user && item.createTime.slice(0, 10) == day });
} }
tmpArr.forEach(item => { tmpArr.forEach(item => {
console.log(item);
let obj = { time: '', news: [] }; let obj = { time: '', news: [] };
let fileUrl = null; let fileUrl = null;
fileUrl = item.attachment ? 'api/rest/file/viewPicture/CHAT?objectName=' + item.attachment : null; fileUrl = item.attachment ? 'api/rest/file/viewPicture/CHAT?objectName=' + item.attachment : null;
...@@ -290,11 +287,11 @@ export default { ...@@ -290,11 +287,11 @@ export default {
const divscll = document.getElementById('chatContent'); const divscll = document.getElementById('chatContent');
divscll.scrollTop = divscll.scrollHeight; divscll.scrollTop = divscll.scrollHeight;
}, },
closeDialog() { // closeDialog() {
this.visible = false; // this.visible = false;
}, // },
sendNotice() { sendNotice() {
this.visible = true; // this.visible = true;
this.$nextTick(() => { this.$nextTick(() => {
this.$refs.myNotice.showDialog(); this.$refs.myNotice.showDialog();
}) })
...@@ -302,29 +299,25 @@ export default { ...@@ -302,29 +299,25 @@ export default {
// this.$refs.myNotice.showDialog(); // this.$refs.myNotice.showDialog();
// } // }
}, },
closeDialogChatRoom() { // closeDialogChatRoom() {
this.chatRoomVisible = false; // this.chatRoomVisible = false;
}, // },
showChatRoom() { showChatRoom() {
this.chatRoomVisible = true; // this.chatRoomVisible = true;
// this.$nextTick(() => { this.$nextTick(() => {
// this.$refs.myChatRoom.showDialog(); this.$refs.myChatRoom.showDialog();
// }) })
// if (this.$refs.myChatRoom) { // if (this.$refs.myChatRoom) {
// this.$refs.myChatRoom.showDialog(); // this.$refs.myChatRoom.showDialog();
// } // }
}, },
closeDialogChatRoomPeople() { // closeDialogChatRoomPeople() {
this.chatRoomPeopleVisible = false; // this.chatRoomPeopleVisible = false;
}, // },
showPeopleList() { showPeopleList() {
// this.chatRoomPeopleVisible = true;
this.$nextTick(() => { this.$nextTick(() => {
this.$refs.myChatRoomPeople.showDialog(); this.$refs.myChatRoomPeople.showDialog();
}) })
// if (this.$refs.myChatRoomPeople) {
// this.$refs.myChatRoomPeople.showDialog();
// }
}, },
queryChatRoomListFn(params) { queryChatRoomListFn(params) {
getChatRoomList(params).then(res => { getChatRoomList(params).then(res => {
......
...@@ -100,7 +100,7 @@ module.exports = { ...@@ -100,7 +100,7 @@ module.exports = {
} }
}, },
'/websocket/**': { '/websocket/**': {
target: 'ws://192.168.168.106:8081', target: 'ws://192.168.168.213:8081',
ws: true, ws: true,
secure: false, secure: false,
logLevel: 'debug', logLevel: 'debug',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment