whx 4 miesięcy temu
rodzic
commit
48721cbf91
21 zmienionych plików z 348 dodań i 115 usunięć
  1. 5 0
      virgo.wzfrontend/console/package-lock.json
  2. 1 0
      virgo.wzfrontend/console/package.json
  3. 10 1
      virgo.wzfrontend/console/src/layout/components/chat.vue
  4. 218 0
      virgo.wzfrontend/console/src/layout/components/chatBox.vue
  5. 1 1
      virgo.wzfrontend/console/src/layout/work.vue
  6. 1 1
      virgo.wzfrontend/console/src/uitls/chat.js
  7. 1 1
      virgo.wzfrontend/src/main/resources/static/console/index.html
  8. 0 1
      virgo.wzfrontend/src/main/resources/static/console/static/css/1275.3f9acf7e.css
  9. 0 1
      virgo.wzfrontend/src/main/resources/static/console/static/css/3369.3f9acf7e.css
  10. 1 0
      virgo.wzfrontend/src/main/resources/static/console/static/css/4751.7836cbb7.css
  11. 1 0
      virgo.wzfrontend/src/main/resources/static/console/static/css/5601.7836cbb7.css
  12. 1 0
      virgo.wzfrontend/src/main/resources/static/console/static/css/app.9708b3c0.css
  13. 0 1
      virgo.wzfrontend/src/main/resources/static/console/static/css/app.ab4dcab7.css
  14. 0 53
      virgo.wzfrontend/src/main/resources/static/console/static/js/1275.11d1817b.js
  15. 0 53
      virgo.wzfrontend/src/main/resources/static/console/static/js/3369-legacy.e4239068.js
  16. 53 0
      virgo.wzfrontend/src/main/resources/static/console/static/js/4751-legacy.addd0147.js
  17. 53 0
      virgo.wzfrontend/src/main/resources/static/console/static/js/5601.d79a5c45.js
  18. 0 1
      virgo.wzfrontend/src/main/resources/static/console/static/js/app-legacy.34c2e64e.js
  19. 1 0
      virgo.wzfrontend/src/main/resources/static/console/static/js/app-legacy.efdd4b7d.js
  20. 1 0
      virgo.wzfrontend/src/main/resources/static/console/static/js/app.14dc66d5.js
  21. 0 1
      virgo.wzfrontend/src/main/resources/static/console/static/js/app.b8c224d6.js

+ 5 - 0
virgo.wzfrontend/console/package-lock.json

@@ -9507,6 +9507,11 @@
 			"integrity": "sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==",
 			"dev": true
 		},
+		"mescroll.js": {
+			"version": "1.4.2",
+			"resolved": "https://registry.npmmirror.com/mescroll.js/-/mescroll.js-1.4.2.tgz",
+			"integrity": "sha512-tZDucS9DXUrIfTGXTY2L7e4mGLIQ8uMqY2GOaQAGrCHQssUADOIM0kcQlRCA6U6ffFPxXV4D+IbhzOy3zVQ1wA=="
+		},
 		"methods": {
 			"version": "1.1.2",
 			"resolved": "https://registry.npmmirror.com/methods/-/methods-1.1.2.tgz",

+ 1 - 0
virgo.wzfrontend/console/package.json

@@ -17,6 +17,7 @@
 		"jquery": "^3.7.1",
 		"js-md5": "^0.8.3",
 		"luckyexcel": "^1.0.1",
+		"mescroll.js": "^1.4.2",
 		"path-browserify": "^1.0.1",
 		"pinyin-pro": "^3.25.0",
 		"svg-sprite-loader": "^6.0.11",

+ 10 - 1
virgo.wzfrontend/console/src/layout/components/chat.vue

@@ -23,11 +23,15 @@
 				</div>
 			</div>
 		</div>
+		<div class="chat-box">
+			<chat-box :body="nowChat" :key="nowChat.conversationId"></chat-box>
+		</div>
 	</div>
 </template>
 
 <script>
 	import uniDateformat from '@/components/common/uniDateformat'
+	import chatBox from './chatBox.vue';
 	export default {
 		data() {
 			return {
@@ -45,7 +49,8 @@
 			}
 		},
 		components: {
-			uniDateformat
+			uniDateformat,
+			chatBox
 		}
 	}
 </script>
@@ -69,6 +74,10 @@
 			border: none;
 		}
 
+		.chat-box {
+			flex: 1;
+		}
+
 		.message-list {
 			width: 300px;
 			border-right: 1px solid $--color-border;

+ 218 - 0
virgo.wzfrontend/console/src/layout/components/chatBox.vue

@@ -0,0 +1,218 @@
+<template>
+	<div class="chat-box-data">
+		<div class="loading" v-show="loading">
+			会话获取中...
+		</div>
+		<div ref="chatList" class="chat-information">
+			<div v-for="(item,index) in dataList" :key="index">
+				<div class="chat-item" :class="item.from == $store.getters.user.userId ? 'push':'pull' ">
+					<img :src="item.fromUserInfo.avatarUrl" mode="aspectFill" class="avatar"></img>
+					<div class="content-box">
+						<div class="content" v-if="item.type === 'text'">{{item.body.text}}</div>
+						<el-image :src="item.body.thumbnailUrl" :preview-src-list="[item.body.originalUrl]" fit="fill"
+							:class="returnImageClass(item.body)" v-else>
+						</el-image>
+					</div>
+				</div>
+			</div>
+		</div>
+		<div class="chat-send">
+			<el-button type="primary" size="medium">发送</el-button>
+		</div>
+	</div>
+</template>
+
+<script>
+	import MescrollVue from 'mescroll.js/mescroll.vue'
+	export default {
+		props: ['body'],
+		data() {
+			return {
+				dataList: [],
+				nextMessageId: null,
+				hasTopData: true,
+				loading: false
+			}
+		},
+		created() {
+			this.$nextTick(() => {
+				// 设置onscroll事件处理函数
+				this.$refs.chatList.onscroll = this.chatScroll;
+				this.mescrollUpFunc('init');
+			})
+		},
+		methods: {
+			chatScroll() {
+				if (!this.hasTopData) return;
+				let scrollHeight = this.$refs.chatList.scrollTop;
+				if (scrollHeight === 0) this.mescrollUpFunc();
+			},
+			returnImageClass(item) {
+				let w = item.thumbnailWidth,
+					h = item.thumbnailHeight;
+				let str = ''
+				if (w > h) str = 'image-width';
+				if (w == h) str = 'image-width-height';
+				if (w < h) str = 'image-height';
+				return str + ' image-box';
+			},
+			mescrollUpFunc(type) {
+				this.loading = true;
+				this.joinHistoryMsg().then(data => {
+					this.loading = false;
+					if (!this.nextMessageId) this.dataList = [];
+					if (data.length === 0) this.hasTopData = false;
+					this.dataList = data.concat(this.dataList);
+					if (type === 'init') {
+						this.$nextTick(() => {
+							this.$refs.chatList.scrollTo(0, 99999);
+						})
+					}
+				})
+			},
+			joinHistoryMsg() {
+				return new Promise((done, fail) => {
+					this.$chat.getHistoryMessageList(this.nextMessageId, this.body.conversationId, res => {
+						this.nextMessageId = res.data.nextMessageId || 'null';
+						done(!res.data ? [] : res.data.list);
+					}, () => {
+						done([]);
+					});
+				})
+			},
+		},
+		components: {
+			MescrollVue
+		}
+	}
+</script>
+
+<style lang="scss">
+	.chat-box-data {
+		width: 100%;
+		height: 100%;
+		display: flex;
+		flex-direction: column;
+		position: relative;
+
+		.chat-item {
+			display: flex;
+			padding: 10px;
+			align-items: flex-start;
+			align-content: flex-start;
+
+			.avatar {
+				width: 40px;
+				height: 40px;
+				border-radius: 50%;
+				border: #fff solid 1px;
+			}
+
+			.content-box {
+				flex: 1;
+				width: 0;
+				display: flex;
+			}
+
+			.image-box {
+				border-radius: 8px;
+			}
+
+			.image-width {
+				width: 140px;
+				height: 100px;
+			}
+
+			.image-height {
+				width: 100px;
+				height: 140px;
+			}
+
+			.image-width-height {
+				width: 100px;
+				height: 100px;
+			}
+
+			.content {
+				padding: 10px 15px;
+				border-radius: 8px;
+				word-break: break-all;
+				line-height: 21px;
+				position: relative;
+				font-weight: 300;
+			}
+
+			/* 收到的消息 */
+			&.pull {
+				.content-box {
+					margin-right: 50px;
+				}
+
+				.image-box {
+					margin-left: 10px;
+				}
+
+				.content {
+					margin-left: 10px;
+					background-color: $--color-background-hover;
+				}
+			}
+
+			/* 发出的消息 */
+			&.push {
+				/* 主轴为水平方向,起点在右端。使不修改DOM结构,也能改变元素排列顺序 */
+				flex-direction: row-reverse;
+
+				.content-box {
+					flex-direction: row-reverse;
+					margin-left: 50px;
+				}
+
+				.image-box {
+					margin-right: 10px;
+				}
+
+				.content {
+					margin-right: 10px;
+					background-color: $--color-primary;
+					color: #fff;
+					box-shadow: 0px 1px 12px rgba(3, 3, 3, 0.08);
+				}
+			}
+		}
+
+		.chat-information {
+			flex: 1;
+			height: 0;
+			overflow-y: auto;
+			position: relative;
+
+
+		}
+
+		.loading {
+			top: 0;
+			left: 0;
+			width: 100%;
+			text-align: center;
+			position: absolute;
+			background: $--color-primary;
+			height: 30px;
+			color: #fff;
+			line-height: 30px;
+			font-size: 12px;
+		}
+
+		.chat-send {
+			height: 200px;
+			border-top: 1px solid $--color-border;
+			position: relative;
+
+			.el-button {
+				position: absolute;
+				right: 10px;
+				bottom: 10px;
+			}
+		}
+	}
+</style>

+ 1 - 1
virgo.wzfrontend/console/src/layout/work.vue

@@ -30,7 +30,7 @@
 		</div>
 		<el-dialog :close-on-click-modal="false" title="聊天列表" :visible.sync="visible" width="900px"
 			:append-to-body="true">
-			<chat></chat>
+			<chat v-if="visible"></chat>
 		</el-dialog>
 	</div>
 </template>

+ 1 - 1
virgo.wzfrontend/console/src/uitls/chat.js

@@ -57,7 +57,7 @@ const $chat = {
 			 *	1 关键性日志,日志量较少,生产环境时建议使用 
 			 *	2 无日志级别,SDK 将不打印任何日志
 			 */
-			logLevel: 0, // 日志等级, 
+			logLevel: 2, // 日志等级, 
 			reConnectInterval: 3000, // 重连时间间隔
 			reConnectTotal: 99, // 最大重连次数,0不限制一直重连 
 			heartInterval: 35000, //心跳时间间隔(默认30s) 

Plik diff jest za duży
+ 1 - 1
virgo.wzfrontend/src/main/resources/static/console/index.html


Plik diff jest za duży
+ 0 - 1
virgo.wzfrontend/src/main/resources/static/console/static/css/1275.3f9acf7e.css


Plik diff jest za duży
+ 0 - 1
virgo.wzfrontend/src/main/resources/static/console/static/css/3369.3f9acf7e.css


Plik diff jest za duży
+ 1 - 0
virgo.wzfrontend/src/main/resources/static/console/static/css/4751.7836cbb7.css


Plik diff jest za duży
+ 1 - 0
virgo.wzfrontend/src/main/resources/static/console/static/css/5601.7836cbb7.css


Plik diff jest za duży
+ 1 - 0
virgo.wzfrontend/src/main/resources/static/console/static/css/app.9708b3c0.css


Plik diff jest za duży
+ 0 - 1
virgo.wzfrontend/src/main/resources/static/console/static/css/app.ab4dcab7.css


Plik diff jest za duży
+ 0 - 53
virgo.wzfrontend/src/main/resources/static/console/static/js/1275.11d1817b.js


Plik diff jest za duży
+ 0 - 53
virgo.wzfrontend/src/main/resources/static/console/static/js/3369-legacy.e4239068.js


Plik diff jest za duży
+ 53 - 0
virgo.wzfrontend/src/main/resources/static/console/static/js/4751-legacy.addd0147.js


Plik diff jest za duży
+ 53 - 0
virgo.wzfrontend/src/main/resources/static/console/static/js/5601.d79a5c45.js


Plik diff jest za duży
+ 0 - 1
virgo.wzfrontend/src/main/resources/static/console/static/js/app-legacy.34c2e64e.js


Plik diff jest za duży
+ 1 - 0
virgo.wzfrontend/src/main/resources/static/console/static/js/app-legacy.efdd4b7d.js


Plik diff jest za duży
+ 1 - 0
virgo.wzfrontend/src/main/resources/static/console/static/js/app.14dc66d5.js


Plik diff jest za duży
+ 0 - 1
virgo.wzfrontend/src/main/resources/static/console/static/js/app.b8c224d6.js