From 58dc0727a11481c127fc6111b73fa309b03505b5 Mon Sep 17 00:00:00 2001
From: Junjie <DELL@qq.com>
Date: 星期四, 11 十二月 2025 18:54:36 +0800
Subject: [PATCH] #AI
---
src/main/webapp/static/js/ai/diagnose.js | 43 +++++++++++++++++++++++++++++++++++++++++++
1 files changed, 43 insertions(+), 0 deletions(-)
diff --git a/src/main/webapp/static/js/ai/diagnose.js b/src/main/webapp/static/js/ai/diagnose.js
new file mode 100644
index 0000000..0b23ae0
--- /dev/null
+++ b/src/main/webapp/static/js/ai/diagnose.js
@@ -0,0 +1,43 @@
+var sse;
+
+function startDiagnosis() {
+ if (sse) {
+ sse.close();
+ }
+ $('#ai-output').text('');
+ $('#start-btn').attr('disabled', true);
+ $('#stop-btn').attr('disabled', false);
+
+ var url = baseUrl + '/ai/diagnose/runAiStream';
+ sse = new EventSource(url);
+
+ sse.onmessage = function (e) {
+ var curr = $('#ai-output').text();
+ $('#ai-output').text(curr + e.data);
+ };
+
+ sse.onerror = function () {
+ $('#start-btn').attr('disabled', false);
+ $('#stop-btn').attr('disabled', true);
+ if (sse) {
+ sse.close();
+ }
+ layer.msg('杩炴帴宸插叧闂垨鍙戠敓閿欒');
+ };
+}
+
+function stopDiagnosis() {
+ if (sse) {
+ sse.close();
+ sse = null;
+ }
+ $('#start-btn').attr('disabled', false);
+ $('#stop-btn').attr('disabled', true);
+}
+
+$(function () {
+ $('#stop-btn').attr('disabled', true);
+ $('#start-btn').on('click', startDiagnosis);
+ $('#stop-btn').on('click', stopDiagnosis);
+ $('#clear-btn').on('click', function () { $('#ai-output').text(''); });
+});
--
Gitblit v1.9.1