mirror of
				https://github.com/Mabbs/mabbs.github.io
				synced 2025-11-01 02:02:09 +08:00 
			
		
		
		
	Update file message.js
This commit is contained in:
		| @@ -188,7 +188,21 @@ if(!norunFlag){ | |||||||
| 		if(Array.isArray(text)) text = text[Math.floor(Math.random() * text.length + 1)-1]; | 		if(Array.isArray(text)) text = text[Math.floor(Math.random() * text.length + 1)-1]; | ||||||
| 		//console.log('showMessage', text); | 		//console.log('showMessage', text); | ||||||
| 		$('.message').stop(); | 		$('.message').stop(); | ||||||
| 		$('.message').html(text); | 		if(text instanceof EventSource){ | ||||||
|  | 			var outputContainer = $('.message')[0] | ||||||
|  | 			outputContainer.textContent = ""; | ||||||
|  | 			text.onmessage = (event) => { | ||||||
|  | 				if (event.data == "[DONE]") { | ||||||
|  | 					text.close(); | ||||||
|  | 				  return; | ||||||
|  | 				} else { | ||||||
|  | 				  const data = JSON.parse(event.data); | ||||||
|  | 				  outputContainer.textContent += data.response; | ||||||
|  | 				} | ||||||
|  | 			} | ||||||
|  | 		}else{ | ||||||
|  | 			$('.message').html(text); | ||||||
|  | 		} | ||||||
| 		$('.message').fadeTo(200, 1); | 		$('.message').fadeTo(200, 1); | ||||||
| 		//if (timeout === null) timeout = 5000; | 		//if (timeout === null) timeout = 5000; | ||||||
| 		//hideMessage(timeout); | 		//hideMessage(timeout); | ||||||
| @@ -275,36 +289,38 @@ if(!norunFlag){ | |||||||
| 			}); | 			}); | ||||||
| 			$('#talk_send').on('click',function(){ | 			$('#talk_send').on('click',function(){ | ||||||
| 				var info_ = $('#AIuserText').val(); | 				var info_ = $('#AIuserText').val(); | ||||||
| 				var userid_ = $('#AIuserName').val(); | 				// var userid_ = $('#AIuserName').val(); | ||||||
| 				if(info_ == "" ){ | 				if(info_ == "" ){ | ||||||
| 					showMessage('写点什么吧!',0); | 					showMessage('写点什么吧!',0); | ||||||
| 					return; | 					return; | ||||||
| 				} | 				} | ||||||
| 				if(userid_ == ""){ | 				// if(userid_ == ""){ | ||||||
| 					showMessage('聊之前请告诉我你的名字吧!',0); | 				// 	showMessage('聊之前请告诉我你的名字吧!',0); | ||||||
| 					return; | 				// 	return; | ||||||
| 				} | 				// } | ||||||
| 				showMessage('思考中~', 0); | 				showMessage('思考中~', 0); | ||||||
| 				$.ajax({ | 				const evSource = new EventSource(talkAPI + "?info=" + encodeURIComponent(info_)); | ||||||
| 					type: 'POST', | 				showMessage(evSource); | ||||||
| 					url: talkAPI, | 				// $.ajax({ | ||||||
| 					data: { | 				// 	type: 'POST', | ||||||
| 							"info": info_, | 				// 	url: talkAPI, | ||||||
| 							"userId": userid_ | 				// 	data: { | ||||||
| 					}, | 				// 			"info": info_, | ||||||
| 					success: function(res) { | 				// 			"userId": userid_ | ||||||
| 						if(res.intent.code !== 0){ | 				// 	}, | ||||||
| 							talkValTimer(); | 				// 	success: function(res) { | ||||||
| 							showMessage('似乎有什么错误,请和站长联系!',0); | 				// 		if(res.intent.code !== 0){ | ||||||
| 						}else{ | 				// 			talkValTimer(); | ||||||
| 							talkValTimer(); | 				// 			showMessage('似乎有什么错误,请和站长联系!',0); | ||||||
| 							showMessage(res.results[0].values.text,0); | 				// 		}else{ | ||||||
| 						} | 				// 			talkValTimer(); | ||||||
| 						console.log(res); | 				// 			showMessage(res.results[0].values.text,0); | ||||||
| 						$('#AIuserText').val(""); | 				// 		} | ||||||
| 						sessionStorage.setItem("live2duser", userid_); | 				// 		console.log(res); | ||||||
| 					} | 				// 		$('#AIuserText').val(""); | ||||||
| 				}); | 				// 		sessionStorage.setItem("live2duser", userid_); | ||||||
|  | 				// 	} | ||||||
|  | 				// }); | ||||||
| 			}); | 			}); | ||||||
| 		}else{ | 		}else{ | ||||||
| 			$('#showInfoBtn').hide(); | 			$('#showInfoBtn').hide(); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user