vscode plugin ws ok
This commit is contained in:
12
Html/app.py
12
Html/app.py
@@ -14,8 +14,8 @@ sys.path.insert(0, current_dir)
|
||||
from AlgoriAgent.projects.algoriAgent.agent_manager import AgentManager
|
||||
|
||||
app = Flask(__name__)
|
||||
socketio = SocketIO(app, cors_allowed_origins="*",ping_timeout=60, ping_interval=5)
|
||||
# socketio = SocketIO(app, cors_allowed_origins="http://localhost:9888") # 设置跨域支持
|
||||
# socketio = SocketIO(app, cors_allowed_origins="*",ping_timeout=60, ping_interval=5)
|
||||
socketio = SocketIO(app, cors_allowed_origins="http://localhost:9888") # 设置跨域支持
|
||||
import logging
|
||||
app.secret_key = 'cakebaker'
|
||||
app.logger.setLevel(logging.DEBUG)
|
||||
@@ -35,6 +35,7 @@ uuid2user_id = {}
|
||||
user_id2uuid = {}
|
||||
|
||||
|
||||
|
||||
# 定义命名空间:用于和 VSCode 插件交流
|
||||
class VSCodeNamespace(Namespace):
|
||||
def on_login(self,data):
|
||||
@@ -97,9 +98,10 @@ agent_manager = AgentManager()
|
||||
|
||||
|
||||
class AgentNamespace(Namespace):
|
||||
def on_connect(self):
|
||||
user = request.args.get('username')
|
||||
folder_name = request.args.get('folder')
|
||||
def on_login(self, data):
|
||||
data = json.loads(data)
|
||||
user = data['username']
|
||||
folder_name = data['folder']
|
||||
user_uuid = user_id2uuid[user]
|
||||
session['user_id'] = user_uuid
|
||||
print(f'User connected with session user_id: {user_uuid}')
|
||||
|
||||
@@ -44,23 +44,6 @@ chineseRadio.addEventListener('change', function() {
|
||||
if (chineseRadio.checked) language = 'zn';
|
||||
});
|
||||
|
||||
function sendMessage() {
|
||||
const input = document.getElementById('messageInput').value;
|
||||
if (input.trim() === '') return;
|
||||
|
||||
// 创建一个新的消息元素
|
||||
const newMessage = document.createElement('div');
|
||||
newMessage.classList.add('chat-message');
|
||||
newMessage.innerHTML = `<b>${language === 'en' ? 'You:' : '你:'}</b> ${input}`;
|
||||
chatbox.appendChild(newMessage);
|
||||
|
||||
// 清空输入框
|
||||
document.getElementById('messageInput').value = '';
|
||||
|
||||
// 滚动到最新消息
|
||||
chatbox.scrollTop = chatbox.scrollHeight;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 发送消息
|
||||
|
||||
Reference in New Issue
Block a user