大段粘贴检测
This commit is contained in:
@@ -1,8 +1,11 @@
|
||||
# myapp/services/backboard_service.py
|
||||
import os
|
||||
from flask import current_app
|
||||
from flask_socketio import emit
|
||||
from backboardManager import Backboard # 你已有的类
|
||||
from ..utils.sudoUtil import sudo_open
|
||||
from ..extension_ase.ase_client import HSAEngineClient
|
||||
from manager import ChatManager
|
||||
|
||||
def _to_wsl_path_if_needed(path: str) -> str:
|
||||
cfg = current_app.config["VSCODE_WEB_PATH"]
|
||||
@@ -44,6 +47,19 @@ def realtime_response(config: dict, realtime_action: dict) -> None:
|
||||
bb.pasted_content = realtime_action.get("content")
|
||||
with open(os.path.join(bb.root_path, bb.active_file_path), "r", encoding="utf-8") as f:
|
||||
bb.active_file_content = f.read()
|
||||
#处理粘贴事件
|
||||
|
||||
# paste_data = {
|
||||
# 'pasted_file_path': file_path,
|
||||
# 'pasted_content': bb.pasted_content,
|
||||
# 'pasted_content_length': len(bb.pasted_content)
|
||||
# }
|
||||
# emit('paste_detected', paste_data)
|
||||
|
||||
#判断一下,如果粘帖内容过多就发送,后期可加入更多条件判断
|
||||
if bb.pasted_content and len(bb.pasted_content) > 300:
|
||||
chatmanager.ase_client.send("pasted_detected_in", {"file_path": file_path, "content": bb.pasted_content})
|
||||
|
||||
|
||||
elif rtype == "fileEdit":
|
||||
file_path = realtime_action.get("filePath")
|
||||
|
||||
Reference in New Issue
Block a user