sudo cat\tee

This commit is contained in:
CakeCN
2025-09-14 17:13:00 +08:00
parent 18c28edd4f
commit 49badd72db
3 changed files with 38 additions and 4 deletions

View File

@@ -2,6 +2,7 @@
import os
from flask import current_app
from backboardManager import Backboard # 你已有的类
from ..utils.sudoUtil import sudo_open
def _to_wsl_path_if_needed(path: str) -> str:
cfg = current_app.config["VSCODE_WEB_PATH"]
@@ -32,7 +33,7 @@ def realtime_response(config: dict, realtime_action: dict) -> None:
elif rtype == "activeFile":
file_path = realtime_action.get("filePath")
assert isinstance(file_path, str)
with open(file_path, "r", encoding="utf-8") as f:
with sudo_open(file_path, "r", encoding="utf-8") as f:
bb.active_file_content = f.read()
bb.active_file_path = file_path
@@ -42,14 +43,14 @@ def realtime_response(config: dict, realtime_action: dict) -> None:
bb.pasted_file_path = file_path
bb.pasted_content = realtime_action.get("content")
bb.active_file_path = file_path
with open(file_path, "r", encoding="utf-8") as f:
with sudo_open(file_path, "r", encoding="utf-8") as f:
bb.active_file_content = f.read()
elif rtype == "fileEdit":
file_path = realtime_action.get("filePath")
assert isinstance(file_path, str)
bb.active_file_path = file_path
with open(file_path, "r", encoding="utf-8") as f:
with sudo_open(file_path, "r", encoding="utf-8") as f:
bb.active_file_content = f.read()