Compare commits
58 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
36bbedd3cf | ||
|
|
0e3703b1f4 | ||
|
|
52696707dd | ||
|
|
0a812e496f | ||
|
|
de1ba08d7e | ||
|
|
3f14cbd6c1 | ||
|
|
c51565199c | ||
|
|
8d29a26d7d | ||
|
|
decf24020a | ||
|
|
3dc219adc2 | ||
|
|
40d1341685 | ||
|
|
0d606fb171 | ||
|
|
e1f32ec980 | ||
|
|
ad8d7d069c | ||
|
|
687b316db6 | ||
|
|
60248d5c51 | ||
|
|
befec5543c | ||
|
|
af24c51a2f | ||
|
|
fa91696aae | ||
|
|
e698c50a4b | ||
|
|
75795dd853 | ||
|
|
5b8180b48e | ||
|
|
09103abf38 | ||
|
|
6ecd0c6735 | ||
|
|
a07eee1ffc | ||
|
|
848b235ddc | ||
|
|
7f469803df | ||
|
|
4dd2667785 | ||
|
|
f8e0b461ba | ||
|
|
607c6dfbab | ||
|
|
73275cffad | ||
|
|
ee20e8b85b | ||
|
|
b806da10c4 | ||
|
|
f818d84208 | ||
|
|
9231c14013 | ||
|
|
8aa567cdf2 | ||
|
|
a3b3018de7 | ||
|
|
761095d61d | ||
| 643c16fdf7 | |||
| 5082436289 | |||
| 7193b9a000 | |||
| 042f6ee99e | |||
|
|
8fd88b0088 | ||
|
|
319b111485 | ||
|
|
f060a17f6a | ||
|
|
ecdc2e320f | ||
|
|
aa9f39ca18 | ||
|
|
f444e86136 | ||
|
|
22d9fb39f1 | ||
|
|
cb435ecade | ||
|
|
c8942cedac | ||
|
|
1f6e75f006 | ||
|
|
5438dc99ba | ||
|
|
f65b5bf32a | ||
|
|
da93289799 | ||
|
|
1554c85616 | ||
|
|
70410d2c4b | ||
|
|
496c5be90a |
@@ -39,9 +39,12 @@ class ASEngineClient:
|
||||
# 连接事件
|
||||
@self.sio.on('connect', namespace=self.namespace)
|
||||
def on_connect():
|
||||
print("---------------ASEngineClient on_connect----------------")
|
||||
self.sid = self.sio.sid
|
||||
print(f"Connected to server with sid: {self.sid}")
|
||||
|
||||
self.connected = True
|
||||
self.sid = self.sio.get_sid(namespace=self.namespace)
|
||||
print(f"Connected to server. SID: {self.sid}")
|
||||
self.sio.emit('join', {'id': self.id}, namespace=self.namespace)
|
||||
if self._on_connect_callback is not None:
|
||||
self._on_connect_callback(
|
||||
self,
|
||||
|
||||
@@ -35,7 +35,6 @@ class ChatManager:
|
||||
_lock = threading.RLock()
|
||||
def __init__(self, restart=False):
|
||||
self.restart = restart
|
||||
self.chapter_chain_now = -1
|
||||
self.ase_client = None
|
||||
self.app = None
|
||||
self.socketio = None
|
||||
@@ -70,6 +69,9 @@ class ChatManager:
|
||||
self.chapter_chain = load_chapters(raw_markdown, raw_markdown_prompts, raw_score_prompts)
|
||||
self.bb = None
|
||||
self.chat_historys = []
|
||||
self.chapter_chain_now = 0
|
||||
self.scores = []
|
||||
|
||||
|
||||
|
||||
def send_to_vscode(self, event: str, data: dict, room: str = None, namespace: str = '/vscode'):
|
||||
|
||||
@@ -14,7 +14,7 @@ from typing import Optional
|
||||
mongo = PyMongo()
|
||||
|
||||
|
||||
socketio = SocketIO(cors_allowed_origins="*",max_payload_size=52428800, async_mode="eventlet") # 不直接传 app
|
||||
socketio = SocketIO(cors_allowed_origins="*",max_payload_size=52428800, async_mode="eventlet",always_connect=False) # 不直接传 app
|
||||
cors = CORS()
|
||||
# ===== 你的全局对象 =====
|
||||
# Backboard
|
||||
@@ -38,7 +38,7 @@ def init_extensions(app):
|
||||
cors_allowed_origins='*',#app.config["VSCODE_WEB_URL"],
|
||||
ping_timeout=app.config["SOCKETIO_PING_TIMEOUT"],
|
||||
ping_interval=app.config["SOCKETIO_PING_INTERVAL"],
|
||||
max_payload_size=50000000, async_mode="eventlet"
|
||||
max_payload_size=50000000, async_mode="eventlet",always_connect=False
|
||||
)
|
||||
cors.init_app(
|
||||
app,
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import requests
|
||||
from flask_socketio import Namespace
|
||||
|
||||
|
||||
def clear_user_session(asengine_url, asengine_token, user_id):
|
||||
'''
|
||||
@@ -28,15 +26,23 @@ def on_connect_to_ase(client, entry, init_data, **kwargs):
|
||||
'''
|
||||
此时刚刚建立好aseclient连接,并向前端发送打开code-server-like指令。
|
||||
'''
|
||||
namespace_entry, ase_client = entry
|
||||
namespace_entry, ase_client, logger = entry
|
||||
logger.info(f"on_connect_to_ase with init_data: {init_data}")
|
||||
namespace_entry.emit('open-iframe',"", room=init_data['room'], namespace='/agent')
|
||||
namespace_entry.emit('message', "Agents服务已连接, 加载教案中", room=init_data['room'], namespace='/agent')
|
||||
namespace_entry.emit('message', f'{init_data}', room=init_data['room'], namespace='/agent')
|
||||
|
||||
|
||||
restart = init_data.get("restart", False)
|
||||
if restart: # 重启时,从-1章进入 0章
|
||||
ase_client.chatmanager.next_chapter()
|
||||
# 不再需要手动next_chapter,因为已经在on_login中根据mongo进度恢复了正确的章节
|
||||
# if restart: # 重启时,从-1章进入 0章
|
||||
# ase_client.chatmanager.next_chapter()
|
||||
|
||||
# 根据restart决定是否重新加载代码
|
||||
ase_client.chatmanager.load_now_chapter(load_code=restart)
|
||||
print("load_now_chapter with restart:", restart)
|
||||
|
||||
# 只有当需要restart时才发送chapter-start
|
||||
if restart:
|
||||
ase_client.send_text("chapter-start", "")
|
||||
namespace_entry.emit('message', "教案加载完毕", room=init_data['room'], namespace='/agent')
|
||||
|
||||
@@ -93,7 +93,6 @@ def get_multiagents_dialog_list(user_id: str) -> List[Dict]:
|
||||
|
||||
# 检查响应
|
||||
if response.status_code == 200:
|
||||
current_app.logger.info(f"获取MultiAgents对话列表成功: user_id={user_id}, json={response.json()}")
|
||||
return response.json()
|
||||
else:
|
||||
current_app.logger.error(f"获取MultiAgents对话列表失败: HTTP {response.status_code}")
|
||||
|
||||
@@ -63,6 +63,12 @@ class VSCodeNamespace(Namespace):
|
||||
|
||||
|
||||
class AgentNamespace(Namespace):
|
||||
def __init__(self, namespace):
|
||||
super().__init__(namespace)
|
||||
# 使用字典存储每个用户的chatmanager和ase_client,避免多用户冲突
|
||||
self.user_chatmanagers = {}
|
||||
self.user_ase_clients = {}
|
||||
|
||||
def _load_learning_progress(self, chatmanager, user_id, course_id, chapter_name, lesson_name, continue_learn):
|
||||
"""加载并恢复用户学习进度
|
||||
|
||||
@@ -72,22 +78,18 @@ class AgentNamespace(Namespace):
|
||||
course_id: 课程ID
|
||||
chapter_name: 章节名称
|
||||
lesson_name: 课时名称
|
||||
continue_learn: 是否继续学习
|
||||
continue_learn: 是否继续学习(现在总是为True,保持兼容性)
|
||||
|
||||
Returns:
|
||||
int: 需要跳过的章节数
|
||||
"""
|
||||
need_skip_chapters = 0
|
||||
|
||||
if continue_learn: # 尝试加载用户学习进度
|
||||
# 总是从mongo加载学习进度
|
||||
progress_result = load_learning_progress(user_id, course_id, chapter_name, lesson_name)
|
||||
|
||||
if progress_result['exists']:
|
||||
progress = progress_result['data']
|
||||
# 恢复学习进度数据
|
||||
if 'scores' in progress:
|
||||
# 根据scores的数量确定需要跳过的章节数
|
||||
need_skip_chapters = len(progress['scores'])
|
||||
chatmanager.scores = progress['scores']
|
||||
|
||||
# 恢复聊天历史
|
||||
@@ -100,10 +102,15 @@ class AgentNamespace(Namespace):
|
||||
if 'chapter_chain_now' in progress:
|
||||
chatmanager.chapter_chain_now = progress['chapter_chain_now']
|
||||
upload_learning_progress_to_cloud(progress)
|
||||
|
||||
# 计算需要跳过的章节数:从初始的-1到当前的chapter_chain_now
|
||||
need_skip_chapters = chatmanager.chapter_chain_now
|
||||
else:
|
||||
# 使用默认值,确保有完整的结构
|
||||
chatmanager.chat_historys = progress_result['data']['chat_historys']
|
||||
chatmanager.scores = progress_result['data']['scores']
|
||||
chatmanager.chapter_chain_now = 0
|
||||
need_skip_chapters = 0
|
||||
|
||||
return need_skip_chapters
|
||||
|
||||
@@ -119,8 +126,8 @@ class AgentNamespace(Namespace):
|
||||
chapter_name = data['chapter_name']
|
||||
user_id = uuid2username[user_uuid]
|
||||
session['user_uuid'] = user_uuid
|
||||
join_room(user_uuid, namespace='/agent') # 将该用户加入以user_id为名的room
|
||||
print(f'User connected with session user_uuid: {user_uuid}')
|
||||
join_room(user_uuid)
|
||||
|
||||
user_uuid2chatmanager = ex["user_uuid2chatmanager"]
|
||||
user_uuid2ase_client = ex["user_uuid2ase_client"]
|
||||
@@ -131,8 +138,9 @@ class AgentNamespace(Namespace):
|
||||
chatmanager.function_manager.add_function(next_chapter, {'user_uuid': user_uuid})
|
||||
|
||||
clear_user_session(current_app.config["ASE_ENGINE_URL"], current_app.config["ASE_ENGINE_URL_TOKEN"], user_id)
|
||||
continue_learn = not chatmanager.restart
|
||||
need_skip_chapters = self._load_learning_progress(chatmanager, user_id, course_id, chapter_name, lesson_name, continue_learn)
|
||||
|
||||
# 总是从mongo加载进度,不管restart状态
|
||||
need_skip_chapters = self._load_learning_progress(chatmanager, user_id, course_id, chapter_name, lesson_name, True)
|
||||
|
||||
fmd,fmdp,fsp = load_full_markdown_file(course_id, chapter_name, lesson_name)
|
||||
user_uuid2ase_client[user_uuid] = HSAEngineClient(current_app.config["ASE_ENGINE_URL"], current_app.config["ASE_ENGINE_NAMESPACE"],id=user_id, chatmanager = chatmanager)
|
||||
@@ -141,8 +149,8 @@ class AgentNamespace(Namespace):
|
||||
backboard_manager.add_backboard(user_uuid, user_id, course_id,
|
||||
lesson_name, root_path=f'/home/{user_id}/{course_id}/{chapter_name}/{lesson_name}')
|
||||
chatmanager.bb = backboard_manager.get_backboard(user_uuid)
|
||||
# 如果有保存的进度,需要跳过已经完成的章节、无需清空代码、对话历史恢复
|
||||
if continue_learn:
|
||||
|
||||
# 总是根据进度跳过章节,恢复对话历史
|
||||
for _ in range(need_skip_chapters):
|
||||
chatmanager.next_chapter()
|
||||
emit('next_chapter', room=user_uuid, namespace='/agent')
|
||||
@@ -150,18 +158,24 @@ class AgentNamespace(Namespace):
|
||||
if chatmanager.chat_historys:
|
||||
emit('messages', chatmanager.chat_historys, room=user_uuid, namespace='/agent')
|
||||
|
||||
self.chatmanager = chatmanager
|
||||
self.ase_client = user_uuid2ase_client[user_uuid]
|
||||
# 存储每个用户的chatmanager和ase_client到字典中,使用用户UUID作为键
|
||||
self.user_chatmanagers[user_uuid] = chatmanager
|
||||
self.user_ase_clients[user_uuid] = user_uuid2ase_client[user_uuid]
|
||||
|
||||
# 将restart设置为False,避免后续重复处理
|
||||
restart = chatmanager.restart
|
||||
chatmanager.restart = False
|
||||
|
||||
user_uuid2ase_client[user_uuid].register_on_connect_entry(
|
||||
callback=on_connect_to_ase,
|
||||
entry=(self, user_uuid2ase_client[user_uuid]),
|
||||
init_data={'room':user_uuid, 'restart':chatmanager.restart}
|
||||
entry=(self, user_uuid2ase_client[user_uuid], current_app.logger),
|
||||
init_data={'room':user_uuid, 'restart':restart}
|
||||
)
|
||||
user_uuid2ase_client[user_uuid].register_route_with_entry(
|
||||
route='dialog',
|
||||
callback=receive_ase_dialog,
|
||||
entry=self,
|
||||
init_data={'room': user_uuid}
|
||||
init_data={'room':user_uuid}
|
||||
)
|
||||
user_uuid2ase_client[user_uuid].register_route_with_entry(
|
||||
route='dialog-hint',
|
||||
@@ -179,13 +193,13 @@ class AgentNamespace(Namespace):
|
||||
route='judge',
|
||||
callback=receive_ase_judge,
|
||||
entry=self,
|
||||
init_data={'room': user_uuid}
|
||||
init_data={'room':user_uuid}
|
||||
)
|
||||
user_uuid2ase_client[user_uuid].register_route_with_entry(
|
||||
route='next_chapter',
|
||||
callback=receive_ase_next_chapter,
|
||||
entry=self,
|
||||
init_data={'room': user_uuid}
|
||||
init_data={'room':user_uuid}
|
||||
)
|
||||
user_uuid2ase_client[user_uuid].register_route_with_entry(
|
||||
route='chapter_score',
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -66,31 +66,29 @@ function cleanupExpiredApprovals() {
|
||||
// 定时清理过期记录
|
||||
setInterval(cleanupExpiredApprovals, 3000); // 每3秒检查一次
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
data = window.appData;
|
||||
user_data = window.appData;
|
||||
const host = window.location.host;
|
||||
console.log(`Connecting to WebSocket server at wss://${host}/agent`);
|
||||
socket = io(`wss://${host}/agent`, {
|
||||
query: {
|
||||
user_uuid: data.user_uuid,
|
||||
folder: data.folder
|
||||
user_uuid: user_data.user_uuid,
|
||||
folder: user_data.folder
|
||||
}
|
||||
});
|
||||
|
||||
// 初始化聊天消息管理器
|
||||
chatManager = new ChatMessageManager();
|
||||
|
||||
socket.on('connect', function () {
|
||||
console.log('Connected to server');
|
||||
socket.emit('login',JSON.stringify(data));
|
||||
console.log('Connected to WebSocket server'+socket.id+"with user"+JSON.stringify(user_data));
|
||||
socket.emit('login',JSON.stringify(user_data));
|
||||
});
|
||||
socket.on('open-iframe', function(data) {
|
||||
OpenIframe();
|
||||
socket.on('open-iframe', function() {
|
||||
OpenIframe(user_data);
|
||||
});
|
||||
// 监听来自服务器的消息
|
||||
socket.on('voiceMessage', function (data) {
|
||||
console.log(data);
|
||||
const input = document.getElementById('messageInput');
|
||||
input.value += data;
|
||||
input.value = data;
|
||||
});
|
||||
socket.on('message', function (data) {
|
||||
// 显示服务器的回复消息 - 单个消息
|
||||
|
||||
@@ -1,41 +1,53 @@
|
||||
function show_books(courses_data, user_selected_courses){
|
||||
function show_books(courses_data, user_selected_courses) {
|
||||
console.log(courses_data)
|
||||
console.log(user_selected_courses)
|
||||
}
|
||||
function show_course_details(course_id){
|
||||
function show_course_details(course_id) {
|
||||
window.location.href = '/course/' + course_id
|
||||
}
|
||||
|
||||
function on_click_select_course(event){
|
||||
function on_click_select_course(event) {
|
||||
event.stopPropagation(); // 阻止事件冒泡
|
||||
const courseId = event.currentTarget.getAttribute('data-course-id');
|
||||
if (event.currentTarget.classList.contains("selected-button")) {alert('课程已选择'); return;}
|
||||
const button = event.currentTarget;
|
||||
const courseId = button.getAttribute('data-course-id');
|
||||
if (!courseId) { alert('缺少课程ID'); return; }
|
||||
if (button.classList.contains("selected-button")) { alert('课程已选择'); return; }
|
||||
if (button.disabled) { return; }
|
||||
button.disabled = true;
|
||||
fetch(`/select_course`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'X-CSRFToken': '{{ csrf_token() }}' // 如果使用 CSRF 保护
|
||||
},
|
||||
body: JSON.stringify({ course_id: courseId })
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if (data.success) {
|
||||
// 更新按钮样式或显示消息
|
||||
this.classList.remove('select-button');
|
||||
this.classList.add('selected-button');
|
||||
this.textContent = '已选择';
|
||||
alert('选择课程成功');
|
||||
} else {
|
||||
alert('选择课程失败');
|
||||
.then(async (response) => {
|
||||
let data = null;
|
||||
try {
|
||||
data = await response.json();
|
||||
} catch (_) {
|
||||
}
|
||||
if (!response.ok) {
|
||||
throw new Error(data?.message || `请求失败(${response.status})`);
|
||||
}
|
||||
return data;
|
||||
})
|
||||
.then((data) => {
|
||||
if (!data?.success) {
|
||||
throw new Error(data?.message || '选择课程失败');
|
||||
}
|
||||
button.classList.remove('select-button');
|
||||
button.classList.add('selected-button');
|
||||
button.textContent = '已选课';
|
||||
alert('选择课程成功');
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('Error:', error);
|
||||
alert('选择课程失败');
|
||||
alert(error?.message || '选择课程失败');
|
||||
button.disabled = false;
|
||||
});
|
||||
}
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
|
||||
});
|
||||
@@ -1,4 +1,4 @@
|
||||
window.addEventListener('load', ()=>{
|
||||
window.addEventListener('load', () => {
|
||||
console.log(window.material);
|
||||
console.log(window.lesson);
|
||||
editLesson(window.material.material_id, window.chapter.chapter_name, window.lesson.lesson_name);
|
||||
@@ -12,58 +12,58 @@ function parseHeadings(mdText) {
|
||||
|
||||
const lines = mdText.split('\n');
|
||||
const tokens = [];
|
||||
for (let i=0;i<lines.length;i++) {
|
||||
for (let i = 0; i < lines.length; i++) {
|
||||
const m = lines[i].match(/^(#{1,3})\s+(.*)$/);
|
||||
if (m) tokens.push({ level: m[1].length, text: m[2].trim(), line: i });
|
||||
}
|
||||
// 确定每个heading的区间(到下一个同级或上级前一行)
|
||||
for (let i=0;i<tokens.length;i++) {
|
||||
let j = i+1;
|
||||
while (j<tokens.length && tokens[j].level > tokens[i].level) j++;
|
||||
for (let i = 0; i < tokens.length; i++) {
|
||||
let j = i + 1;
|
||||
while (j < tokens.length && tokens[j].level > tokens[i].level) j++;
|
||||
// 找到第一个 >= 当前level 的 heading 或到文末
|
||||
let k = i+1;
|
||||
while (k<tokens.length && tokens[k].level > tokens[i].level) k++;
|
||||
const nextSameOrHigher = k<tokens.length ? tokens[k].line : lines.length;
|
||||
let k = i + 1;
|
||||
while (k < tokens.length && tokens[k].level > tokens[i].level) k++;
|
||||
const nextSameOrHigher = k < tokens.length ? tokens[k].line : lines.length;
|
||||
tokens[i].start = tokens[i].line;
|
||||
tokens[i].end = nextSameOrHigher - 1;
|
||||
}
|
||||
return { lines, tokens };
|
||||
}
|
||||
}
|
||||
|
||||
// 从解析结果中抽取一个 heading 段落文本
|
||||
function sliceSection(parsed, headingText, level) {
|
||||
const t = parsed.tokens.find(x => x.level===level && x.text===headingText);
|
||||
// 从解析结果中抽取一个 heading 段落文本
|
||||
function sliceSection(parsed, headingText, level) {
|
||||
const t = parsed.tokens.find(x => x.level === level && x.text === headingText);
|
||||
if (!t) return '';
|
||||
return parsed.lines.slice(t.start, t.end+1).join('\n');
|
||||
}
|
||||
return parsed.lines.slice(t.start, t.end + 1).join('\n');
|
||||
}
|
||||
|
||||
// 根据三个 md,构造统一大纲树(一级唯一“主题”,其下多个阶段##,其下多个步骤###)
|
||||
function buildUnifiedOutline(parsedLesson, parsedPrompt, parsedScore) {
|
||||
// 根据三个 md,构造统一大纲树(一级唯一“主题”,其下多个阶段##,其下多个步骤###)
|
||||
function buildUnifiedOutline(parsedLesson, parsedPrompt, parsedScore) {
|
||||
// 取 lesson 的结构为主(也可做三者交集/并集策略,这里简单以 lesson 为基准)
|
||||
const root1 = parsedLesson.tokens.find(t => t.level===1);
|
||||
const phases = parsedLesson.tokens.filter(t => t.level===2);
|
||||
const root1 = parsedLesson.tokens.find(t => t.level === 1);
|
||||
const phases = parsedLesson.tokens.filter(t => t.level === 2);
|
||||
const stepsByPhase = {};
|
||||
phases.forEach(ph => {
|
||||
stepsByPhase[ph.text] = parsedLesson.tokens.filter(t => t.level===3 && t.start>ph.start && t.end<=ph.end)
|
||||
stepsByPhase[ph.text] = parsedLesson.tokens.filter(t => t.level === 3 && t.start > ph.start && t.end <= ph.end)
|
||||
.map(s => s.text);
|
||||
});
|
||||
return { theme: root1 ? root1.text : '主题', phases, stepsByPhase };
|
||||
}
|
||||
}
|
||||
|
||||
let CURRENT = {
|
||||
let CURRENT = {
|
||||
material_id: null, chapter_name: null, lesson_name: null,
|
||||
links: { lesson:'', prompt:'', score:'' },
|
||||
raw: { lesson:'', prompt:'', score:'' },
|
||||
parsed:{ lesson:null, prompt:null, score:null },
|
||||
active:{ phase:null, step:null, lessontxt:null, prompt:null, score:null },
|
||||
outline:null
|
||||
};
|
||||
function bustCache(url) {
|
||||
links: { lesson: '', prompt: '', score: '' },
|
||||
raw: { lesson: '', prompt: '', score: '' },
|
||||
parsed: { lesson: null, prompt: null, score: null },
|
||||
active: { phase: null, step: null, lessontxt: null, prompt: null, score: null },
|
||||
outline: null
|
||||
};
|
||||
function bustCache(url) {
|
||||
const sep = url.includes("?") ? "&" : "?";
|
||||
return url + sep + "_ts=" + Date.now();
|
||||
}
|
||||
// 入口:从你的列表调用
|
||||
async function editLesson(material_id, chapter_name, lesson_name) {
|
||||
}
|
||||
// 入口:从你的列表调用
|
||||
async function editLesson(material_id, chapter_name, lesson_name) {
|
||||
|
||||
CURRENT.material_id = material_id;
|
||||
CURRENT.chapter_name = chapter_name;
|
||||
@@ -84,7 +84,7 @@ function parseHeadings(mdText) {
|
||||
detailsContent.innerHTML = `<h4>描述</h4><p>${meta.description || meta.material_description || '暂无描述'}</p>`;
|
||||
const chapterList = document.getElementById('chapter-list');
|
||||
chapterList.innerHTML = '';
|
||||
(meta.chapters||[]).forEach(ch=>{
|
||||
(meta.chapters || []).forEach(ch => {
|
||||
const li = document.createElement('li');
|
||||
li.textContent = ch.chapter_name;
|
||||
chapterList.appendChild(li);
|
||||
@@ -125,10 +125,10 @@ function parseHeadings(mdText) {
|
||||
document.getElementById('editor-prompt').value = CURRENT.raw.prompt;
|
||||
document.getElementById('editor-score').value = CURRENT.raw.score;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ===== 在渲染一级标题时调用 =====
|
||||
function addThemeWithHelp(tree, themeText) {
|
||||
// ===== 在渲染一级标题时调用 =====
|
||||
function addThemeWithHelp(tree, themeText) {
|
||||
const li = document.createElement('li');
|
||||
li.className = 'lvl1';
|
||||
|
||||
@@ -175,9 +175,9 @@ function parseHeadings(mdText) {
|
||||
);
|
||||
|
||||
tree.appendChild(li);
|
||||
}
|
||||
}
|
||||
|
||||
function renderOutline(outline) {
|
||||
function renderOutline(outline) {
|
||||
const tree = document.getElementById('outline-tree');
|
||||
tree.innerHTML = ''; // 清空大纲内容
|
||||
|
||||
@@ -220,7 +220,7 @@ function parseHeadings(mdText) {
|
||||
if (window.confirm(confirmMsg)) {
|
||||
saveUpdatedStep()
|
||||
}
|
||||
}else{
|
||||
} else {
|
||||
// 已存在新标题:保持原文不变
|
||||
alert("新标题已存在")
|
||||
}
|
||||
@@ -339,21 +339,21 @@ function addStepToPhase(phaseText) {
|
||||
renderOutline(CURRENT.outline);
|
||||
loadStepToEditors(phaseText, stepName);
|
||||
highlightActive(phaseText, stepName);
|
||||
}
|
||||
function highlightActive(phase, step) {
|
||||
document.querySelectorAll('#outline-tree li').forEach(li=>li.classList.remove('active'));
|
||||
}
|
||||
function highlightActive(phase, step) {
|
||||
document.querySelectorAll('#outline-tree li').forEach(li => li.classList.remove('active'));
|
||||
const target = Array.from(document.querySelectorAll('#outline-tree li.lvl3'))
|
||||
.find(li => li.dataset.phase===phase && li.dataset.step===step);
|
||||
.find(li => li.dataset.phase === phase && li.dataset.step === step);
|
||||
if (target) target.classList.add('active');
|
||||
CURRENT.active.phase=phase
|
||||
CURRENT.active.step=step
|
||||
}
|
||||
/**
|
||||
* 在 mdText 中,将 `### stepName` 插入到 `## phaseText` 阶段的末尾。
|
||||
* 若 phase 不存在,则创建 `## phaseText` 再插入。
|
||||
* skeleton 为插入文本模板(含### 标题本身及正文)。
|
||||
*/
|
||||
function insertStepIntoMarkdown(mdText, phaseText, stepName, skeleton, { allowDuplicate = false } = {}) {
|
||||
CURRENT.active.phase = phase
|
||||
CURRENT.active.step = step
|
||||
}
|
||||
/**
|
||||
* 在 mdText 中,将 `### stepName` 插入到 `## phaseText` 阶段的末尾。
|
||||
* 若 phase 不存在,则创建 `## phaseText` 再插入。
|
||||
* skeleton 为插入文本模板(含### 标题本身及正文)。
|
||||
*/
|
||||
function insertStepIntoMarkdown(mdText, phaseText, stepName, skeleton, { allowDuplicate = false } = {}) {
|
||||
const parsed = parseHeadings(mdText);
|
||||
const { lines, tokens } = parsed;
|
||||
// 找到目标阶段(##)
|
||||
@@ -419,35 +419,35 @@ function addStepToPhase(phaseText) {
|
||||
.concat(insertChunk)
|
||||
.concat(lines.slice(insertPos));
|
||||
return newLines.join('\n');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const outlineAside = document.querySelector('.outline');
|
||||
const outlineTree = document.getElementById('outline-tree');
|
||||
const btnDeleteMode = document.getElementById('toggle-outline-delete');
|
||||
const outlineAside = document.querySelector('.outline');
|
||||
const outlineTree = document.getElementById('outline-tree');
|
||||
const btnDeleteMode = document.getElementById('toggle-outline-delete');
|
||||
|
||||
// 切换删除模式
|
||||
function setDeleteMode(enabled) {
|
||||
// 切换删除模式
|
||||
function setDeleteMode(enabled) {
|
||||
btnDeleteMode.setAttribute('aria-pressed', String(enabled));
|
||||
outlineAside.classList.toggle('delete-mode', enabled);
|
||||
}
|
||||
}
|
||||
|
||||
// 点击按钮:进入/退出删除模式
|
||||
btnDeleteMode.addEventListener('click', (e) => {
|
||||
// 点击按钮:进入/退出删除模式
|
||||
btnDeleteMode.addEventListener('click', (e) => {
|
||||
e.preventDefault();
|
||||
const enabled = btnDeleteMode.getAttribute('aria-pressed') !== 'true';
|
||||
setDeleteMode(enabled);
|
||||
});
|
||||
});
|
||||
|
||||
// 工具:判断是否是 lvl2 / lvl3 节点(允许点到它的内部子元素)
|
||||
function findDeletableNode(el) {
|
||||
// 工具:判断是否是 lvl2 / lvl3 节点(允许点到它的内部子元素)
|
||||
function findDeletableNode(el) {
|
||||
if (!el) return null;
|
||||
if (el.classList?.contains('lvl2') || el.classList?.contains('lvl3')) return el;
|
||||
return el.closest?.('.lvl2, .lvl3') || null;
|
||||
}
|
||||
}
|
||||
|
||||
// 事件代理:删除模式下,点击二/三级标题进行删除确认
|
||||
outlineTree.addEventListener('click', (e) => {
|
||||
// 事件代理:删除模式下,点击二/三级标题进行删除确认
|
||||
outlineTree.addEventListener('click', (e) => {
|
||||
if (btnDeleteMode.getAttribute('aria-pressed') !== 'true') return; // 非删除模式,忽略
|
||||
const targetNode = findDeletableNode(e.target);
|
||||
if (!targetNode) return;
|
||||
@@ -472,7 +472,7 @@ function addStepToPhase(phaseText) {
|
||||
// 可选:如果你需要同步删除到正文内容(CURRENT.raw.xxx),可以在这里调用你的同步逻辑
|
||||
// 例:把正文中第一处行首 "## 标题" 或 "### 标题" 删除(仅示例,按你项目规则调整):
|
||||
deleteSectionInRaw(level, text);
|
||||
});
|
||||
});
|
||||
/**
|
||||
* 删除指定 level(2/3) 与 title 的小节:
|
||||
* 从 "^## title$" 或 "^### title$" 那一行开始,
|
||||
@@ -512,8 +512,8 @@ function deleteSectionInRaw(level, title) {
|
||||
|
||||
|
||||
|
||||
// 解析Markdown并定位章节/步骤
|
||||
function parseHeadings(mdText) {
|
||||
// 解析Markdown并定位章节/步骤
|
||||
function parseHeadings(mdText) {
|
||||
const lines = mdText.split('\n');
|
||||
const tokens = [];
|
||||
for (let i = 0; i < lines.length; i++) {
|
||||
@@ -531,19 +531,27 @@ function deleteSectionInRaw(level, title) {
|
||||
tokens[i].end = nextSameOrHigher - 1;
|
||||
}
|
||||
return { lines, tokens };
|
||||
}
|
||||
}
|
||||
|
||||
// 从解析结果中抽取一个 heading 段落文本
|
||||
function sliceSection(parsed, headingText, level) {
|
||||
// 从解析结果中抽取一个 heading 段落文本
|
||||
function sliceSection(parsed, headingText, level) {
|
||||
const t = parsed.tokens.find(x => x.level === level && x.text === headingText);
|
||||
if (!t) return '';
|
||||
return parsed.lines.slice(t.start, t.end + 1).join('\n');
|
||||
}
|
||||
function buildOriginSaveUrl() {
|
||||
return `/api/materials/save/${encodeURIComponent(CURRENT.material_id)}/${encodeURIComponent(CURRENT.chapter_name)}/${encodeURIComponent(CURRENT.lesson_name)}`;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
// 加载某个步骤到编辑器
|
||||
function buildOriginSaveUrl() {
|
||||
const mid = typeof CURRENT.material_id === 'string' && CURRENT.material_id
|
||||
|| (window.material && window.material.material_id) || '';
|
||||
const ch = typeof CURRENT.chapter_name === 'string' && CURRENT.chapter_name
|
||||
|| (window.chapter && window.chapter.chapter_name) || '';
|
||||
const ln = typeof CURRENT.lesson_name === 'string' && CURRENT.lesson_name
|
||||
|| (window.lesson && window.lesson.lesson_name) || '';
|
||||
return `/api/materials/save/${encodeURIComponent(mid)}/${encodeURIComponent(ch)}/${encodeURIComponent(ln)}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* 把三份文档(lesson/prompt/score)的 "CDN 外链 + 原文内容" 一次性提交给源站。
|
||||
* @param {Object} payload 形如:
|
||||
* {
|
||||
@@ -552,7 +560,7 @@ function deleteSectionInRaw(level, title) {
|
||||
* score: { cdn_link, content }
|
||||
* }
|
||||
*/
|
||||
async function saveToOrigin(payload) {
|
||||
async function saveToOrigin(payload) {
|
||||
const res = await fetch(buildOriginSaveUrl(), {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
@@ -565,11 +573,11 @@ function deleteSectionInRaw(level, title) {
|
||||
credentials: 'include' // 若需要带 cookie/会话,保留;不需要可移除
|
||||
});
|
||||
if (!res.ok) {
|
||||
const text = await res.text().catch(()=>'');
|
||||
const text = await res.text().catch(() => '');
|
||||
throw new Error(`保存失败(${res.status}): ${text}`);
|
||||
}
|
||||
return res.json().catch(()=> ({}));
|
||||
}
|
||||
return res.json().catch(() => ({}));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -642,8 +650,8 @@ function sanitizeHeadingsBeyondFirst(text = "") {
|
||||
|
||||
|
||||
|
||||
// 保存某个步骤的更新
|
||||
async function saveUpdatedStep() {
|
||||
// 保存某个步骤的更新
|
||||
async function saveUpdatedStep() {
|
||||
const lEditor = document.getElementById('editor-lesson');
|
||||
const pEditor = document.getElementById('editor-prompt');
|
||||
const sEditor = document.getElementById('editor-score');
|
||||
@@ -651,7 +659,7 @@ function sanitizeHeadingsBeyondFirst(text = "") {
|
||||
|
||||
if (!check.ok) {
|
||||
alert("保存被阻止:" + check.report);
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
|
||||
// 获取原始的文档内容
|
||||
@@ -707,10 +715,10 @@ function sanitizeHeadingsBeyondFirst(text = "") {
|
||||
btn.innerText = ClearModifiedStat(btn.innerText)
|
||||
btn = document.getElementById("tab-btn-score");
|
||||
btn.innerText = ClearModifiedStat(btn.innerText)
|
||||
}
|
||||
}
|
||||
|
||||
// 更新对应步骤的内容
|
||||
function updateMarkdownContent(parsed, phaseText, stepText, newContent) {
|
||||
// 更新对应步骤的内容
|
||||
function updateMarkdownContent(parsed, phaseText, stepText, newContent) {
|
||||
const phaseIndex = parsed.tokens.findIndex(token => token.level === 2 && token.text === phaseText);
|
||||
if (phaseIndex === -1) return parsed.lines.join('\n'); // 找不到阶段
|
||||
|
||||
@@ -730,14 +738,14 @@ function sanitizeHeadingsBeyondFirst(text = "") {
|
||||
lines.splice(startLine, endLine - startLine + 1, newContent); // 用新内容替换
|
||||
|
||||
return lines.join('\n'); // 返回更新后的完整内容
|
||||
}
|
||||
}
|
||||
|
||||
// 获取所有 textarea
|
||||
function AddModifiedStat(str){
|
||||
function AddModifiedStat(str) {
|
||||
return str.charAt(str.length - 1) !== '*' ? str + '*' : str;
|
||||
}
|
||||
function ClearModifiedStat(str){
|
||||
return str.charAt(str.length - 1) !== '*' ? str:str.slice(0, str.length-1);
|
||||
function ClearModifiedStat(str) {
|
||||
return str.charAt(str.length - 1) !== '*' ? str : str.slice(0, str.length - 1);
|
||||
}
|
||||
function ValidTextareaNoBlankHead(textarea) {
|
||||
let lines = textarea.value.split("\n");
|
||||
@@ -753,25 +761,25 @@ const PREFIX = "### ";
|
||||
// 记录每个 textarea 最新的“标题内容”(不含前缀)
|
||||
const lastTitleMap = new Map();
|
||||
|
||||
// 防止循环触发
|
||||
let isProgrammaticUpdate = false;
|
||||
function getFirstLine(text) {
|
||||
// 防止循环触发
|
||||
let isProgrammaticUpdate = false;
|
||||
function getFirstLine(text) {
|
||||
const idx = text.indexOf("\n");
|
||||
return idx === -1 ? text : text.slice(0, idx);
|
||||
}
|
||||
function setFirstLine(text, newFirstLine) {
|
||||
}
|
||||
function setFirstLine(text, newFirstLine) {
|
||||
const idx = text.indexOf("\n");
|
||||
return idx === -1 ? newFirstLine : newFirstLine + text.slice(idx);
|
||||
}
|
||||
// 工具:规范化首行 -> 始终以 '### ' 开头,并返回 { line, title }
|
||||
function normalizeFirstLine(line) {
|
||||
}
|
||||
// 工具:规范化首行 -> 始终以 '### ' 开头,并返回 { line, title }
|
||||
function normalizeFirstLine(line) {
|
||||
// 去掉前导的 # 和空格,保留后面的标题内容
|
||||
const title = line.replace(/^#+\s*/,''); // 如果用户没写#,也直接当作标题
|
||||
const title = line.replace(/^#+\s*/, ''); // 如果用户没写#,也直接当作标题
|
||||
const normalized = PREFIX + title;
|
||||
return { line: normalized, title };
|
||||
}
|
||||
// 初始化 lastTitleMap(把当前值规范化一次)
|
||||
editorsDoc.forEach(ed => {
|
||||
}
|
||||
// 初始化 lastTitleMap(把当前值规范化一次)
|
||||
editorsDoc.forEach(ed => {
|
||||
const rawFirst = getFirstLine(ed.value || "");
|
||||
const { line, title } = normalizeFirstLine(rawFirst);
|
||||
if (line !== rawFirst) {
|
||||
@@ -780,9 +788,9 @@ const lastTitleMap = new Map();
|
||||
isProgrammaticUpdate = false;
|
||||
}
|
||||
lastTitleMap.set(ed, title);
|
||||
});
|
||||
// 同步到其他两个 textarea 的首行
|
||||
function syncOthers(sourceEditor, newTitle) {
|
||||
});
|
||||
// 同步到其他两个 textarea 的首行
|
||||
function syncOthers(sourceEditor, newTitle) {
|
||||
isProgrammaticUpdate = true;
|
||||
try {
|
||||
editorsDoc.forEach(ed => {
|
||||
@@ -798,7 +806,7 @@ const lastTitleMap = new Map();
|
||||
} finally {
|
||||
isProgrammaticUpdate = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ==== 前置:你的三编辑器实例与 id 映射(按你实际为准)====
|
||||
const ID_LESSON = 'editor-lesson';
|
||||
@@ -1018,12 +1026,12 @@ function loadStepToEditors(phaseText, stepText) {
|
||||
editors['editor-prompt'].value(pText);
|
||||
editors['editor-score'].value(sText);
|
||||
|
||||
CURRENT.active={ //保存打开时的三个文本
|
||||
phase:phaseText,
|
||||
step:stepText,
|
||||
lesson:lText,
|
||||
prompt:pText,
|
||||
score:sText
|
||||
CURRENT.active = { //保存打开时的三个文本
|
||||
phase: phaseText,
|
||||
step: stepText,
|
||||
lesson: lText,
|
||||
prompt: pText,
|
||||
score: sText
|
||||
}
|
||||
let btn = document.getElementById("tab-btn-lesson");
|
||||
btn.innerText = ClearModifiedStat(btn.innerText)
|
||||
@@ -1045,9 +1053,9 @@ document.addEventListener('click', (e) => {
|
||||
|
||||
// 广播 tab 变更(告诉别人当前激活的 tab id / 以及要用哪个 editorId)
|
||||
const editorIdMap = {
|
||||
'tab-lesson' : 'editor-lesson',
|
||||
'tab-prompt' : 'editor-prompt',
|
||||
'tab-score' : 'editor-score',
|
||||
'tab-lesson': 'editor-lesson',
|
||||
'tab-prompt': 'editor-prompt',
|
||||
'tab-score': 'editor-score',
|
||||
};
|
||||
const activeBtnId = e.target.id; // 如 'tab-btn-lesson'
|
||||
const editorId =
|
||||
@@ -1061,8 +1069,8 @@ document.addEventListener('click', (e) => {
|
||||
}
|
||||
});
|
||||
|
||||
// 保存全部:将三个编辑器中的文本保存回相应的 markdown 文件
|
||||
document.getElementById('save-all-btn')?.addEventListener('click', async () => {
|
||||
// 保存全部:将三个编辑器中的文本保存回相应的 markdown 文件
|
||||
document.getElementById('save-all-btn')?.addEventListener('click', async () => {
|
||||
|
||||
try {
|
||||
// 将各自的步骤更新保存回文件
|
||||
@@ -1070,10 +1078,10 @@ document.addEventListener('click', (e) => {
|
||||
} catch (err) {
|
||||
console.error('保存错误:', err);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
const STEP_TEMPLATES = {
|
||||
const STEP_TEMPLATES = {
|
||||
lesson: `在这里编写本步骤的课程内容...`,
|
||||
prompt: `#### 指令
|
||||
请严格遵循本步骤的教学目标,输出所需内容。
|
||||
@@ -1093,8 +1101,8 @@ document.addEventListener('click', (e) => {
|
||||
#### 打分
|
||||
请输出 JSON:
|
||||
{"score": 0-100, "reasons": ["...","..."]}`
|
||||
};
|
||||
const PHASE_TEMPLATES = {
|
||||
};
|
||||
const PHASE_TEMPLATES = {
|
||||
lesson: `### 新步骤
|
||||
本阶段描述:请在此补充阶段说明。
|
||||
|
||||
@@ -1112,7 +1120,7 @@ document.addEventListener('click', (e) => {
|
||||
- 维度A:...
|
||||
- 维度B:...
|
||||
`
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -1174,7 +1182,7 @@ function buildGlobalStepIndex(lines, tokens) {
|
||||
const phases = tokens.filter(t => t.level === 2);
|
||||
for (let i = 0; i < phases.length; i++) {
|
||||
const ph = phases[i];
|
||||
const phNextStart = (i + 1 < phases.length) ? phases[i+1].start : lines.length;
|
||||
const phNextStart = (i + 1 < phases.length) ? phases[i + 1].start : lines.length;
|
||||
// 该阶段内的所有 ###:
|
||||
const steps = tokens.filter(t => t.level === 3 && t.start > ph.start && t.start < phNextStart);
|
||||
for (const st of steps) {
|
||||
@@ -1186,7 +1194,7 @@ function buildGlobalStepIndex(lines, tokens) {
|
||||
}
|
||||
|
||||
|
||||
// ===== 选择器与小工具 =====
|
||||
// ===== 选择器与小工具 =====
|
||||
const treeEl = document.getElementById('outline-tree');
|
||||
const toggleOutlineBtn = document.getElementById('toggle-outline-reorder');
|
||||
|
||||
|
||||
@@ -208,7 +208,7 @@
|
||||
console.error('Error fetching session:', error);
|
||||
});
|
||||
let lastiframe = null;
|
||||
function OpenIframe(){
|
||||
function OpenIframe(data){
|
||||
// 等待1s再加载
|
||||
setTimeout(() => {
|
||||
// 在成功获取 session 后创建并插入 iframe
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>华实学伴 - 专业的在线学习平台</title>
|
||||
<script src="/static/cdnback/jquery.min.js"></script>
|
||||
<link href="/static/cdnback/bootstrap.min.css" rel="stylesheet">
|
||||
<link rel="stylesheet" href="/static/cdnback/all.min.css">
|
||||
<link rel="stylesheet" href="/static/css/dashboard.css">
|
||||
|
||||
@@ -187,7 +187,7 @@
|
||||
|
||||
|
||||
let lastIframe = null;
|
||||
function OpenIframe(){
|
||||
function OpenIframe(data){
|
||||
// 在成功获取 session 后创建并插入 iframe
|
||||
const iframe = document.createElement('iframe');
|
||||
const div=document.getElementById('vscodeWeb')
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>课程选择主页</title>
|
||||
@@ -12,6 +13,7 @@
|
||||
<script src="/static/cdnback/js/bootstrap.bundle.min.js"></script>
|
||||
<link rel="stylesheet" href="/static/css/index.css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
{% include 'navbar.html' %}
|
||||
|
||||
@@ -51,8 +53,7 @@
|
||||
|
||||
<div class="col-md-6 col-lg-4">
|
||||
<div class="course-card card h-100" onclick="openCourseProgress('{{course._id}}')">
|
||||
<img src="{{course.image_url}}"
|
||||
class="course-img" alt="课程封面">
|
||||
<img src="{{course.image_url}}" class="course-img" alt="课程封面">
|
||||
<div class="card-body d-flex flex-column">
|
||||
<span class="course-category">算法设计</span>
|
||||
<h5 class="course-title">{{course.name}}</h5>
|
||||
@@ -62,11 +63,15 @@
|
||||
<span class="course-rating"><i class="fas fa-star"></i> 4.7</span>
|
||||
</div>
|
||||
<div class="mt-auto d-grid gap-2 d-md-flex">
|
||||
<button class="btn btn-view flex-fill" onclick="btn_view(event,'{{course._id}}')"><i class="far fa-eye me-1"></i> 课程</button>
|
||||
<button class="btn btn-view flex-fill" onclick="btn_view(event,'{{course._id}}')"><i
|
||||
class="far fa-eye me-1"></i> 课程</button>
|
||||
{% if course._id in selected_courses %}
|
||||
<button class="btn btn-process flex-fill selected-button" data-course-id="{{course._id}}">已选课</button>
|
||||
<button class="btn btn-process flex-fill selected-button"
|
||||
data-course-id="{{course._id}}">已选课</button>
|
||||
{% else %}
|
||||
<button class="btn btn-process flex-fill select-button" onclick="on_click_select_course(event)" data-course-id="{{course._id}}">选择课程</button>
|
||||
<button class="btn btn-process flex-fill select-button"
|
||||
onclick="on_click_select_course(event)"
|
||||
data-course-id="{{course._id}}">选择课程</button>
|
||||
{% endif %}
|
||||
|
||||
</div>
|
||||
@@ -88,5 +93,6 @@
|
||||
}
|
||||
</script>
|
||||
<script src="/static/js/index.js"></script>
|
||||
</html>
|
||||
<script src="/static/js/dashboard.js"></script>
|
||||
|
||||
</html>
|
||||
@@ -69,45 +69,28 @@ def desktop(user_uuid, course_id, chapter_name, lesson_name):
|
||||
|
||||
|
||||
|
||||
chatmanager = ChatManager(restart=not load_history)
|
||||
restart = not load_history
|
||||
chatmanager = ChatManager(restart=restart)
|
||||
current_app.extensions["user_uuid2chatmanager"][user_uuid] = chatmanager
|
||||
|
||||
# 如果restart为True,删除mongo中的学习进度
|
||||
if restart:
|
||||
try:
|
||||
mongo = current_app.extensions["mongo"]
|
||||
mongo.db.learning_progress.delete_one({
|
||||
"user_id": user_id,
|
||||
"material_id": course_id,
|
||||
"chapter_name": chapter_name,
|
||||
"lesson_name": lesson_name
|
||||
})
|
||||
current_app.logger.info(f"删除学习进度成功: user_id={user_id}, course_id={course_id}, chapter={chapter_name}, lesson={lesson_name}")
|
||||
except Exception as e:
|
||||
current_app.logger.error(f"删除学习进度失败: {str(e)}")
|
||||
code_server_port = 10000 + int(uuid.uuid4().int % 10000)
|
||||
# chatmanager.start_code_server(user_uuid, user_id, path_dir, code_server_port)
|
||||
|
||||
|
||||
|
||||
caddy_conf = f"""
|
||||
handle_path /vsc{user_id}/* {{
|
||||
reverse_proxy localhost:{code_server_port}
|
||||
}}
|
||||
"""
|
||||
caddy_config_path = "/etc/caddy/Caddyfile"
|
||||
with open(caddy_config_path, "r") as f:
|
||||
lines = f.readlines()
|
||||
pattern = re.compile(
|
||||
r'handle_path\s+/vsc' + re.escape(user_id) + r'/\* {.*?reverse_proxy.*?}',
|
||||
re.DOTALL
|
||||
)
|
||||
for i in range(len(lines)):
|
||||
if (lines[i].strip()==''): lines[i]=''
|
||||
content = "".join(lines)
|
||||
if pattern.search(content):
|
||||
new_content = pattern.sub('', content)
|
||||
lines = new_content.splitlines(keepends=True)
|
||||
if len(lines) >= 2:
|
||||
insert_position = len(lines) - 2
|
||||
else:
|
||||
insert_position = len(lines)
|
||||
if caddy_conf[-1] not in ['\n', '\r']:
|
||||
caddy_conf += '\n'
|
||||
lines.insert(insert_position, caddy_conf)
|
||||
with open(caddy_config_path, "w") as f:
|
||||
f.writelines(lines)
|
||||
|
||||
try:
|
||||
subprocess.run(["sudo", "caddy", "reload", "--config", "/etc/caddy/Caddyfile"])
|
||||
except subprocess.CalledProcessError as e:
|
||||
print(f"Error reload caddy {e}")
|
||||
|
||||
cfg = current_app.config["VSCODE_WEB_PATH"]
|
||||
path_for_vscode = path_dir
|
||||
|
||||
@@ -5,7 +5,7 @@ api_key = sk-aMpnWklN2IbsK44d1kNpy6YOP9bk1pdPJjFeEmbb0a5ytEFf
|
||||
model=gpt-4.1-nano
|
||||
|
||||
[VSCODE_WEB]
|
||||
url = https://hsamooc.cn
|
||||
url = https://hsamooc.com
|
||||
[CODE_LIKE]
|
||||
url = /vsc-like
|
||||
#http://asengine.net:8282
|
||||
@@ -27,6 +27,6 @@ bucket = hsamooc-cdn-1374354408
|
||||
region = ap-guangzhou
|
||||
|
||||
[ASE_ENGINE]
|
||||
url = https://test.asengine.net
|
||||
namespace = /socket.io/7100eebf7a909e1ee3f4e06766f512f0358ecb6ac51d5434c17d31dd70890dc1
|
||||
url_token = 7100eebf7a909e1ee3f4e06766f512f0358ecb6ac51d5434c17d31dd70890dc1
|
||||
url = https://asengine.net
|
||||
namespace = /socket.io/afe58a9e4c03e10fae6fae5985e8adde23a49635
|
||||
url_token = afe58a9e4c03e10fae6fae5985e8adde23a49635
|
||||
|
||||
1
Html/db/data/user/_10235101560.json
Normal file
1
Html/db/data/user/_10235101560.json
Normal file
@@ -0,0 +1 @@
|
||||
{"username": "_10235101560"}
|
||||
1
Html/db/data/user/shanks.json
Normal file
1
Html/db/data/user/shanks.json
Normal file
@@ -0,0 +1 @@
|
||||
{"username": "shanks"}
|
||||
1
Html/db/data/user/ts88.json
Normal file
1
Html/db/data/user/ts88.json
Normal file
@@ -0,0 +1 @@
|
||||
{"username": "ts88"}
|
||||
1
Html/db/data/user/xuans.json
Normal file
1
Html/db/data/user/xuans.json
Normal file
@@ -0,0 +1 @@
|
||||
{"username": "xuans"}
|
||||
1
Html/db/data/user/xuans_.json
Normal file
1
Html/db/data/user/xuans_.json
Normal file
@@ -0,0 +1 @@
|
||||
{"username": "xuans_"}
|
||||
@@ -1,5 +1,209 @@
|
||||
import eventlet
|
||||
eventlet.monkey_patch() # 进行猴子补丁操作
|
||||
import logging
|
||||
|
||||
# 配置 eventlet 日志,抑制 IOClosed 等错误日志
|
||||
logging.getLogger('eventlet.hubs').setLevel(logging.CRITICAL)
|
||||
logging.getLogger('eventlet.greenio').setLevel(logging.CRITICAL)
|
||||
|
||||
# 进行猴子补丁操作
|
||||
eventlet.monkey_patch()
|
||||
|
||||
# 配置 eventlet 以更优雅地处理错误,避免疯狂报错
|
||||
try:
|
||||
import eventlet
|
||||
import traceback
|
||||
|
||||
# 1. 首先,禁用 eventlet 的调试日志,减少输出
|
||||
import logging
|
||||
logging.getLogger('eventlet').setLevel(logging.CRITICAL)
|
||||
logging.getLogger('socketio').setLevel(logging.CRITICAL)
|
||||
logging.getLogger('werkzeug').setLevel(logging.CRITICAL)
|
||||
|
||||
# 2. 配置 eventlet 相关设置(移除了不存在的debug属性)
|
||||
|
||||
# 3. 避免重复打印相同错误的机制
|
||||
seen_errors = set()
|
||||
max_error_logs = 5 # 每个错误最多打印5次
|
||||
error_counts = {}
|
||||
|
||||
def is_duplicate_error(e):
|
||||
"""检查是否为重复错误"""
|
||||
error_key = f"{type(e).__name__}: {e}"
|
||||
if error_key in seen_errors:
|
||||
error_counts[error_key] = error_counts.get(error_key, 0) + 1
|
||||
if error_counts[error_key] > max_error_logs:
|
||||
return True
|
||||
else:
|
||||
seen_errors.add(error_key)
|
||||
error_counts[error_key] = 1
|
||||
return False
|
||||
|
||||
# 4. 只修改关键的 greenio 方法,确保在致命错误时彻底关闭连接
|
||||
# 增强 socketio 错误处理,确保不会因为单个连接错误而宕机
|
||||
try:
|
||||
from flask_socketio import SocketIO
|
||||
# 获取当前 socketio 实例并配置错误处理
|
||||
import sys
|
||||
original_excepthook = sys.excepthook
|
||||
|
||||
def custom_excepthook(exc_type, exc_value, exc_traceback):
|
||||
"""全局异常钩子,捕获所有未处理的异常"""
|
||||
if exc_type.__name__ in ['OSError', 'IOError'] and 'Bad file descriptor' in str(exc_value):
|
||||
# 处理 Bad file descriptor 错误,不导致服务器宕机
|
||||
if not is_duplicate_error(exc_value):
|
||||
print(f"[Global Error Handler] {exc_type.__name__}: {exc_value}")
|
||||
print("[Traceback]")
|
||||
traceback.print_exception(exc_type, exc_value, exc_traceback)
|
||||
# 不调用原始的 excepthook,防止服务器宕机
|
||||
return
|
||||
# 其他异常调用原始的 excepthook
|
||||
original_excepthook(exc_type, exc_value, exc_traceback)
|
||||
|
||||
# 设置全局异常钩子
|
||||
sys.excepthook = custom_excepthook
|
||||
except Exception as e:
|
||||
# 如果修改失败,忽略错误
|
||||
print(f"[Global Excepthook Patch Error] {e}")
|
||||
from eventlet import greenio
|
||||
|
||||
# 保存并替换原始的 greenio 方法
|
||||
if hasattr(greenio.base.GreenSocket, '_recv_loop'):
|
||||
original_recv_loop = greenio.base.GreenSocket._recv_loop
|
||||
|
||||
def custom_recv_loop(self, recv_func, recv_args, *args, **kwargs):
|
||||
try:
|
||||
return original_recv_loop(self, recv_func, recv_args, *args, **kwargs)
|
||||
except Exception as e:
|
||||
if not is_duplicate_error(e):
|
||||
print(f"[Eventlet IO Error] _recv_loop: {type(e).__name__}: {e}")
|
||||
print("[Traceback]")
|
||||
traceback.print_exc()
|
||||
# 彻底关闭连接,不再继续处理
|
||||
try:
|
||||
self.close()
|
||||
except Exception:
|
||||
pass
|
||||
return b''
|
||||
|
||||
greenio.base.GreenSocket._recv_loop = custom_recv_loop
|
||||
|
||||
if hasattr(greenio.base.GreenSocket, 'recv_into'):
|
||||
original_recv_into = greenio.base.GreenSocket.recv_into
|
||||
|
||||
def custom_recv_into(self, buffer, nbytes=0, flags=0):
|
||||
try:
|
||||
return original_recv_into(self, buffer, nbytes, flags)
|
||||
except Exception as e:
|
||||
if not is_duplicate_error(e):
|
||||
print(f"[Eventlet IO Error] recv_into: {type(e).__name__}: {e}")
|
||||
print("[Traceback]")
|
||||
traceback.print_exc()
|
||||
# 彻底关闭连接,不再继续处理
|
||||
try:
|
||||
self.close()
|
||||
except Exception:
|
||||
pass
|
||||
return 0
|
||||
|
||||
greenio.base.GreenSocket.recv_into = custom_recv_into
|
||||
|
||||
if hasattr(greenio.base.GreenSocket, '_send_loop'):
|
||||
original_send_loop = greenio.base.GreenSocket._send_loop
|
||||
|
||||
def custom_send_loop(self, send_func, data, *args, **kwargs):
|
||||
try:
|
||||
return original_send_loop(self, send_func, data, *args, **kwargs)
|
||||
except Exception as e:
|
||||
if not is_duplicate_error(e):
|
||||
print(f"[Eventlet IO Error] _send_loop: {type(e).__name__}: {e}")
|
||||
print("[Traceback]")
|
||||
traceback.print_exc()
|
||||
# 彻底关闭连接,不再继续处理
|
||||
try:
|
||||
self.close()
|
||||
except Exception:
|
||||
pass
|
||||
return 0
|
||||
|
||||
greenio.base.GreenSocket._send_loop = custom_send_loop
|
||||
|
||||
if hasattr(greenio.base.GreenSocket, 'send'):
|
||||
original_send = greenio.base.GreenSocket.send
|
||||
|
||||
def custom_send(self, data, flags=0):
|
||||
try:
|
||||
return original_send(self, data, flags)
|
||||
except Exception as e:
|
||||
if not is_duplicate_error(e):
|
||||
print(f"[Eventlet IO Error] send: {type(e).__name__}: {e}")
|
||||
print("[Traceback]")
|
||||
traceback.print_exc()
|
||||
# 彻底关闭连接,不再继续处理
|
||||
try:
|
||||
self.close()
|
||||
except Exception:
|
||||
pass
|
||||
return 0
|
||||
|
||||
greenio.base.GreenSocket.send = custom_send
|
||||
|
||||
# 5. 处理 WSGI 中的错误,确保彻底清理
|
||||
try:
|
||||
import eventlet.wsgi
|
||||
|
||||
if hasattr(eventlet.wsgi.HttpProtocol, 'handle_one_request'):
|
||||
original_wsgi_handle_one_request = eventlet.wsgi.HttpProtocol.handle_one_request
|
||||
|
||||
def custom_wsgi_handle_one_request(self):
|
||||
try:
|
||||
return original_wsgi_handle_one_request(self)
|
||||
except Exception as e:
|
||||
if not is_duplicate_error(e):
|
||||
print(f"[Eventlet WSGI Request Error] {type(e).__name__}: {e}")
|
||||
print("[Traceback]")
|
||||
traceback.print_exc()
|
||||
# 彻底清理连接,不再继续
|
||||
try:
|
||||
self.rfile.close()
|
||||
self.wfile.close()
|
||||
self.finish()
|
||||
except Exception:
|
||||
pass
|
||||
return
|
||||
|
||||
eventlet.wsgi.HttpProtocol.handle_one_request = custom_wsgi_handle_one_request
|
||||
|
||||
if hasattr(eventlet.wsgi.HttpProtocol, 'handle_one_response'):
|
||||
original_wsgi_handle_one_response = eventlet.wsgi.HttpProtocol.handle_one_response
|
||||
|
||||
def custom_wsgi_handle_one_response(self):
|
||||
try:
|
||||
return original_wsgi_handle_one_response(self)
|
||||
except Exception as e:
|
||||
if not is_duplicate_error(e):
|
||||
print(f"[Eventlet WSGI Response Error] {type(e).__name__}: {e}")
|
||||
print("[Traceback]")
|
||||
traceback.print_exc()
|
||||
# 彻底清理连接,不再继续
|
||||
try:
|
||||
self.rfile.close()
|
||||
self.wfile.close()
|
||||
self.finish()
|
||||
except Exception:
|
||||
pass
|
||||
return
|
||||
|
||||
eventlet.wsgi.HttpProtocol.handle_one_response = custom_wsgi_handle_one_response
|
||||
except Exception as e:
|
||||
# 如果修改失败,忽略错误
|
||||
print(f"[WSGI Patch Error] {e}")
|
||||
|
||||
print("[Eventlet Error Handling] Configured to handle errors gracefully, avoiding duplicate logs")
|
||||
except Exception as e:
|
||||
# 如果修改失败,打印错误但继续运行
|
||||
print(f"[Eventlet Patch Initialization Error] {e}")
|
||||
traceback.print_exc()
|
||||
|
||||
from flask import Flask
|
||||
from .views.routes import main_bp
|
||||
from .views.file import file_bp
|
||||
|
||||
@@ -13,4 +13,5 @@ class Config:
|
||||
|
||||
# 自定义其他全局配置
|
||||
ROOT_WORKSPACE_PATH = GLOBAL_CONFIG['Global']['ROOT_WORKSPACE_PATH']
|
||||
DEBUG = GLOBAL_CONFIG['Global'].getboolean('DEBUG', False)
|
||||
|
||||
|
||||
@@ -3,12 +3,12 @@ from flask_socketio import SocketIO
|
||||
from .config import Config
|
||||
# 初始化扩展
|
||||
cors = CORS()
|
||||
socketio = SocketIO(path='vsc-like-ws',cors_allowed_origins="*",max_payload_size=5242880, async_mode="eventlet") # 不直接传 app
|
||||
socketio = SocketIO(path='vsc-like-ws',cors_allowed_origins="*",max_payload_size=5242880, async_mode="eventlet",always_connect=False) # 不直接传 app
|
||||
|
||||
session_paths = {}
|
||||
def init_extensions(app):
|
||||
cors.init_app(app, resources={r"/*": {"origins": "*"}}, supports_credentials=True)
|
||||
socketio.init_app(app, cors_allowed_origins="*", max_payload_size=5242880, async_mode="eventlet")
|
||||
socketio.init_app(app, cors_allowed_origins="*", max_payload_size=5242880, async_mode="eventlet",always_connect=False)
|
||||
app.extensions["session_paths"] = session_paths
|
||||
|
||||
def register_namespaces(app):
|
||||
|
||||
@@ -29,53 +29,122 @@ terminal_bp = Blueprint('terminal', __name__, url_prefix='/vsc-like')
|
||||
|
||||
|
||||
def set_winsize(fd, row, col, xpix=0, ypix=0):
|
||||
try:
|
||||
winsize = struct.pack("HHHH", row, col, xpix, ypix)
|
||||
fcntl.ioctl(fd, termios.TIOCSWINSZ, winsize)
|
||||
except (OSError, IOError):
|
||||
# File descriptor closed or invalid, do nothing
|
||||
pass
|
||||
|
||||
|
||||
def read_and_forward_pty_output(fd=None, pid=None, room_id=None,namespace=None):
|
||||
def read_and_forward_pty_output(fd=None, pid=None, room_id=None, namespace=None):
|
||||
"""
|
||||
read data on pty master from the pty slave, and emit to the web terminal visitor
|
||||
"""
|
||||
max_read_bytes = 1024 * 20
|
||||
timeout=0.1
|
||||
# 初始超时时间设置为较短值,确保响应迅速
|
||||
timeout = 0.05
|
||||
# 最大超时时间,避免太频繁的检查
|
||||
max_timeout = 0.5
|
||||
# 成功读取数据后的重置超时时间
|
||||
reset_timeout = 0.05
|
||||
|
||||
try:
|
||||
while True:
|
||||
# 等待一段时间,减少CPU占用
|
||||
socketio.sleep(timeout)
|
||||
timeout=min(timeout*2, 0.4)
|
||||
# using flask default web server, or uwsgi production web server
|
||||
# when the child process is terminated, it will not disappear from linux process list
|
||||
# and keep staying as a zombie process until the parent exits.
|
||||
|
||||
# 使用指数退避算法调整超时时间,但不超过最大值
|
||||
timeout = min(timeout * 1.5, max_timeout)
|
||||
|
||||
# 检查子进程状态
|
||||
try:
|
||||
child_process = psutil.Process(pid)
|
||||
except psutil.NoSuchProcess as err:
|
||||
return
|
||||
if child_process.status() not in ('running', 'sleeping'):
|
||||
return
|
||||
if fd:
|
||||
timeout_sec = 0
|
||||
(data_ready, _, _) = select.select([fd], [], [], timeout_sec)
|
||||
if data_ready:
|
||||
# output = os.read(fd, max_read_bytes).decode('ascii')
|
||||
timeout=0.1
|
||||
except psutil.NoSuchProcess:
|
||||
# 进程已终止,清理僵尸进程
|
||||
try:
|
||||
os.waitpid(pid, os.WNOHANG)
|
||||
except Exception:
|
||||
pass
|
||||
return
|
||||
|
||||
# 检查进程状态,如果不是运行或睡眠状态,则退出
|
||||
if child_process.status() not in ('running', 'sleeping'):
|
||||
try:
|
||||
# 等待进程终止
|
||||
child_process.wait(timeout=1)
|
||||
except Exception:
|
||||
try:
|
||||
os.waitpid(pid, os.WNOHANG)
|
||||
except Exception:
|
||||
pass
|
||||
return
|
||||
|
||||
# 如果文件描述符有效,尝试读取数据
|
||||
if fd:
|
||||
try:
|
||||
# 使用非阻塞select检查是否有数据可读
|
||||
(data_ready, _, _) = select.select([fd], [], [], 0)
|
||||
if data_ready:
|
||||
# 有数据可读,重置超时时间
|
||||
timeout = reset_timeout
|
||||
try:
|
||||
# 读取数据
|
||||
output = os.read(fd, max_read_bytes).decode()
|
||||
except Exception as err:
|
||||
output = """
|
||||
except (OSError, IOError, EOFError):
|
||||
# 文件描述符已关闭或其他IO错误,优雅退出
|
||||
return
|
||||
except UnicodeDecodeError as err:
|
||||
# 处理编码错误
|
||||
output = f"""
|
||||
***AQUI WEB TERM ERR***
|
||||
{}
|
||||
Unicode decode error: {err}
|
||||
***********************
|
||||
""".format(err)
|
||||
# the key for different visitor to get different terminal (instead of mixing up)
|
||||
# is to let the background task push pty response to each one's own (default) ROOM!
|
||||
"""
|
||||
|
||||
# 发送数据到客户端
|
||||
try:
|
||||
namespace.emit("pty_output", {"output": output}, room=room_id)
|
||||
except Exception:
|
||||
# 如果发送失败,客户端可能已断开连接,退出
|
||||
return
|
||||
except (OSError, IOError):
|
||||
# 文件描述符无效,优雅退出
|
||||
return
|
||||
except Exception as e:
|
||||
# 捕获任何其他未预期的异常,防止服务器崩溃
|
||||
current_app.logger.error(f"Unexpected error in read_and_forward_pty_output: {e}")
|
||||
finally:
|
||||
# 清理文件描述符
|
||||
if fd:
|
||||
try:
|
||||
os.close(fd)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
class VSCLikeNameSpace(Namespace):
|
||||
def on_connect(self):
|
||||
"""new client connected"""
|
||||
if session.get('terminal_config', {}).get('child_pid', None):
|
||||
print(session['terminal_config']['child_pid'])
|
||||
# already started child process, don't start another
|
||||
# 确保terminal_config存在于session中
|
||||
if 'terminal_config' not in session:
|
||||
session['terminal_config'] = TERM_INIT_CONFIG.copy()
|
||||
session.modified = True
|
||||
|
||||
terminal_config = session['terminal_config']
|
||||
|
||||
# 检查是否已经有运行中的子进程
|
||||
if terminal_config.get('child_pid'):
|
||||
try:
|
||||
# 验证进程是否真的存在
|
||||
child_process = psutil.Process(terminal_config['child_pid'])
|
||||
if child_process.status() in ('running', 'sleeping'):
|
||||
current_app.logger.debug("Already running child process: {}".format(terminal_config['child_pid']))
|
||||
return
|
||||
except psutil.NoSuchProcess:
|
||||
# 进程不存在,清理配置
|
||||
terminal_config.pop('child_pid', None)
|
||||
terminal_config.pop('fd', None)
|
||||
session.modified = True
|
||||
|
||||
# create child process attached to a pty we can read from and write to
|
||||
(child_pid, fd) = pty.fork()
|
||||
@@ -84,87 +153,210 @@ class VSCLikeNameSpace(Namespace):
|
||||
# this is the child process fork.
|
||||
# anything printed here will show up in the pty, including the output
|
||||
# of this subprocess
|
||||
# subprocess.run('bash')
|
||||
term_type = session.get('terminal_config').get('term_type')
|
||||
try:
|
||||
# 获取终端配置
|
||||
terminal_config = session.get('terminal_config', {})
|
||||
term_type = terminal_config.get('term_type')
|
||||
|
||||
if not term_type:
|
||||
print("Terminal type not specified, exit")
|
||||
os._exit(1)
|
||||
|
||||
path = TERM_INIT_CONFIG.get('client_path', {}).get(term_type, None)
|
||||
if not path:
|
||||
print("Can't locate {} binary, exit".format(term_type))
|
||||
disconnect()
|
||||
if not path or not os.path.exists(path):
|
||||
print("Can't locate {} binary at {}, exit".format(term_type, path))
|
||||
os._exit(1)
|
||||
|
||||
# 获取连接参数
|
||||
username = terminal_config.get('username')
|
||||
domain = terminal_config.get('domain', TERM_INIT_CONFIG['domain'])
|
||||
port = terminal_config.get('port')
|
||||
|
||||
if not username or not domain:
|
||||
print("Missing required connection parameters, exit")
|
||||
os._exit(1)
|
||||
|
||||
if term_type == 'telnet':
|
||||
# switch to the right location of your telnet binary (example comes from OSX which got telnet from brew)
|
||||
# or you can also make work like auto-detection, or manually but configurable
|
||||
os.execl(path, 'telnet', '-l', session['terminal_config']['username'],
|
||||
session['terminal_config']['domain'], '{}'.format(session['terminal_config']['port']))
|
||||
# 使用telnet连接
|
||||
if not port:
|
||||
print("Port not specified for telnet, exit")
|
||||
os._exit(1)
|
||||
os.execl(path, 'telnet', '-l', username, domain, str(port))
|
||||
elif term_type == 'ssh':
|
||||
os.execl(path,'ssh', '-p','22',
|
||||
#'{}'.format(session['terminal_config']['port']),
|
||||
'{}@{}'.format(session['terminal_config']['username'], session['terminal_config']['domain']))
|
||||
|
||||
|
||||
# 使用ssh连接
|
||||
ssh_port = port if port else 22 # 默认端口22
|
||||
os.execl(path, 'ssh', '-p', str(ssh_port), '{}@{}'.format(username, domain))
|
||||
else:
|
||||
current_app.logger.debug("wrong term type {}".format(term_type))
|
||||
disconnect()
|
||||
session['terminal_config'] = TERM_INIT_CONFIG
|
||||
print("Wrong term type {}, exit".format(term_type))
|
||||
os._exit(1)
|
||||
except Exception as e:
|
||||
print("Error in child process: {}", str(e))
|
||||
os._exit(1)
|
||||
else:
|
||||
session['terminal_config']['fd'] = fd
|
||||
session['terminal_config']['child_pid'] = child_pid
|
||||
session['terminal_config']['room_id'] = rooms()[0]
|
||||
# 更新会话配置
|
||||
terminal_config['fd'] = fd
|
||||
terminal_config['child_pid'] = child_pid
|
||||
terminal_config['room_id'] = rooms()[0]
|
||||
session.modified = True
|
||||
|
||||
# 设置初始窗口大小
|
||||
set_winsize(fd, 50, 50)
|
||||
|
||||
# 记录日志
|
||||
current_app.logger.debug("child pid = {}".format(child_pid))
|
||||
current_app.logger.debug("rooms of this session = {}".format(rooms()))
|
||||
socketio.start_background_task(read_and_forward_pty_output, fd, child_pid, rooms()[0],self)
|
||||
|
||||
# 启动后台任务读取pty输出
|
||||
socketio.start_background_task(read_and_forward_pty_output, fd, child_pid, rooms()[0], self)
|
||||
current_app.logger.debug("background task running")
|
||||
# print(session)
|
||||
|
||||
def on_pty_input(self, data):
|
||||
"""write to the child pty, which now is the ssh process from this machine to the 'domain' configured
|
||||
"""
|
||||
print(f"get data {data}")
|
||||
# 输入验证
|
||||
if not isinstance(data, dict):
|
||||
current_app.logger.error("Invalid input format: expected dictionary")
|
||||
return
|
||||
|
||||
input_data = data.get("input")
|
||||
if not isinstance(input_data, str):
|
||||
current_app.logger.error("Invalid input data: expected string")
|
||||
return
|
||||
|
||||
# 限制输入长度,防止缓冲区溢出
|
||||
if len(input_data) > 1024:
|
||||
input_data = input_data[:1024]
|
||||
current_app.logger.warning("Input truncated due to length")
|
||||
|
||||
try:
|
||||
child_process = psutil.Process(session.get('terminal_config').get('child_pid'))
|
||||
except psutil.NoSuchProcess as err:
|
||||
disconnect()
|
||||
session['terminal_config'] = TERM_INIT_CONFIG
|
||||
terminal_config = session.get('terminal_config', {})
|
||||
child_pid = terminal_config.get('child_pid')
|
||||
if not child_pid:
|
||||
current_app.logger.error("No child process found")
|
||||
return
|
||||
|
||||
child_process = psutil.Process(child_pid)
|
||||
if child_process.status() not in ('running', 'sleeping'):
|
||||
disconnect()
|
||||
session['terminal_config'] = TERM_INIT_CONFIG
|
||||
current_app.logger.debug("Child process not running, cleaning up")
|
||||
terminal_config.pop('child_pid', None)
|
||||
terminal_config.pop('fd', None)
|
||||
session.modified = True
|
||||
return
|
||||
# print(session)
|
||||
# print(data, 'from input')
|
||||
fd = session.get('terminal_config').get('fd')
|
||||
|
||||
fd = terminal_config.get('fd')
|
||||
if fd:
|
||||
# print("writing to ptd: %s" % data["input"])
|
||||
# os.write(fd, data["input"].encode('ascii'))
|
||||
os.write(fd, data["input"].encode())
|
||||
try:
|
||||
os.write(fd, input_data.encode())
|
||||
except (OSError, IOError) as e:
|
||||
# File descriptor closed or invalid, clean up
|
||||
current_app.logger.debug(f"Error writing to file descriptor: {e}")
|
||||
terminal_config.pop('child_pid', None)
|
||||
terminal_config.pop('fd', None)
|
||||
session.modified = True
|
||||
except psutil.NoSuchProcess:
|
||||
# Process no longer exists, clean up
|
||||
terminal_config = session.get('terminal_config', {})
|
||||
terminal_config.pop('child_pid', None)
|
||||
terminal_config.pop('fd', None)
|
||||
session.modified = True
|
||||
except Exception as e:
|
||||
current_app.logger.error(f"Error in pty_input handling: {e}")
|
||||
|
||||
|
||||
def on_resize(self, data):
|
||||
# 输入验证
|
||||
if not isinstance(data, dict):
|
||||
current_app.logger.error("Invalid resize data format: expected dictionary")
|
||||
return
|
||||
|
||||
rows = data.get("rows")
|
||||
cols = data.get("cols")
|
||||
|
||||
# 验证行和列的值是否为正整数
|
||||
if not (isinstance(rows, int) and isinstance(cols, int)):
|
||||
current_app.logger.error("Invalid resize dimensions: expected integers")
|
||||
return
|
||||
|
||||
# 限制窗口大小范围,防止异常值
|
||||
if rows <= 0 or rows > 1000 or cols <= 0 or cols > 1000:
|
||||
current_app.logger.error(f"Invalid resize dimensions: {rows}x{cols} (out of range)")
|
||||
return
|
||||
|
||||
try:
|
||||
child_process = psutil.Process(session.get('terminal_config').get('child_pid'))
|
||||
except psutil.NoSuchProcess as err:
|
||||
disconnect()
|
||||
session['terminal_config'] = TERM_INIT_CONFIG
|
||||
terminal_config = session.get('terminal_config', {})
|
||||
child_pid = terminal_config.get('child_pid')
|
||||
if not child_pid:
|
||||
current_app.logger.error("No child process found for resize")
|
||||
return
|
||||
|
||||
# 检查子进程是否存在且运行中
|
||||
child_process = psutil.Process(child_pid)
|
||||
if child_process.status() not in ('running', 'sleeping'):
|
||||
disconnect()
|
||||
session['terminal_config'] = TERM_INIT_CONFIG
|
||||
current_app.logger.debug("Child process not running, cleaning up resize")
|
||||
terminal_config.pop('child_pid', None)
|
||||
terminal_config.pop('fd', None)
|
||||
session.modified = True
|
||||
return
|
||||
fd = session.get('terminal_config').get('fd')
|
||||
|
||||
fd = terminal_config.get('fd')
|
||||
if fd:
|
||||
set_winsize(fd, data["rows"], data["cols"])
|
||||
# 检查文件描述符是否有效
|
||||
try:
|
||||
os.fstat(fd)
|
||||
set_winsize(fd, rows, cols)
|
||||
except (OSError, IOError) as e:
|
||||
# 文件描述符无效,清理资源
|
||||
current_app.logger.debug(f"Error resizing terminal: {e}")
|
||||
terminal_config.pop('child_pid', None)
|
||||
terminal_config.pop('fd', None)
|
||||
session.modified = True
|
||||
except psutil.NoSuchProcess:
|
||||
# 进程不存在,清理资源
|
||||
terminal_config = session.get('terminal_config', {})
|
||||
terminal_config.pop('child_pid', None)
|
||||
terminal_config.pop('fd', None)
|
||||
session.modified = True
|
||||
except Exception as e:
|
||||
current_app.logger.error(f"Error in resize handling: {e}")
|
||||
|
||||
def on_disconnect(self):
|
||||
terminal_config = session.get('terminal_config', {})
|
||||
child_pid = terminal_config.get('child_pid')
|
||||
fd = terminal_config.get('fd')
|
||||
|
||||
# 先关闭文件描述符,避免其他操作尝试使用无效的文件描述符
|
||||
if fd:
|
||||
try:
|
||||
child_process = psutil.Process(session.get('terminal_config', {}).get('child_pid'))
|
||||
except psutil.NoSuchProcess as err:
|
||||
disconnect()
|
||||
session['terminal_config'] = TERM_INIT_CONFIG
|
||||
return
|
||||
os.close(fd)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
if child_pid:
|
||||
try:
|
||||
child_process = psutil.Process(child_pid)
|
||||
if child_process.status() in ('running', 'sleeping'):
|
||||
# if visitor just close the browser tab then left alone the pty here
|
||||
# it should be terminated by the parent process after
|
||||
child_process.terminate()
|
||||
current_app.logger.debug('user left the pty alone, terminated')
|
||||
# Wait for the process to terminate and collect its exit status
|
||||
child_process.wait(timeout=2)
|
||||
current_app.logger.debug('user left the pty alone, terminated and waited')
|
||||
except psutil.NoSuchProcess as err:
|
||||
# Process already terminated, try to wait anyway to clean up any zombie
|
||||
try:
|
||||
os.waitpid(child_pid, os.WNOHANG)
|
||||
except Exception:
|
||||
pass
|
||||
except psutil.TimeoutExpired:
|
||||
# If process didn't terminate in time, kill it forcefully
|
||||
try:
|
||||
child_process.kill()
|
||||
child_process.wait(timeout=1)
|
||||
except Exception:
|
||||
pass
|
||||
except Exception as err:
|
||||
current_app.logger.error(f'Error terminating process: {err}')
|
||||
|
||||
# Reset session config
|
||||
session['terminal_config'] = TERM_INIT_CONFIG
|
||||
current_app.logger.debug('Client disconnected')
|
||||
@@ -1,5 +1,5 @@
|
||||
import os
|
||||
import subprocess
|
||||
from eventlet.green import subprocess
|
||||
from flask import Blueprint, request, jsonify, current_app, render_template, session
|
||||
from ..services.file_service import get_file_tree, load_config
|
||||
|
||||
@@ -42,32 +42,34 @@ def vsc_like(user_uuid, user_id, course_id, chapter_name, lesson_name, port):
|
||||
subprocess.run(["sudo", "chown", "-R", user_id, user_root]) # 设置目录权限为新用户
|
||||
|
||||
except subprocess.CalledProcessError as e:
|
||||
print(f"Error creating user {user_id}: {e}")
|
||||
# 用户可能已经存在,这是正常情况,继续执行
|
||||
print(f"Useradd command returned non-zero exit status, this is expected if user already exists: {e}")
|
||||
try:
|
||||
# 使用 sudo 执行 mkdir 命令来创建目录
|
||||
subprocess.run(["sudo", "-u", user_id, "mkdir", "-p", path], check=True)
|
||||
subprocess.run(["sudo", "-u", user_id, "mkdir", "-p", f'{user_root}/.ssh'], check=True)
|
||||
subprocess.run(["sudo", "-u", user_id, "mkdir", "-p", path], check=current_app.config['DEBUG'])
|
||||
subprocess.run(["sudo", "-u", user_id, "mkdir", "-p", f'{user_root}/.ssh'], check=current_app.config['DEBUG'])
|
||||
flask_pub_key = "/home/flask/.ssh/id_ed25519.pub"
|
||||
subprocess.run(["sudo", "cp", flask_pub_key, f"{user_root}/.ssh/authorized_keys"], check=True)
|
||||
subprocess.run(["sudo", "chmod", "700", f"{user_root}/.ssh"], check=True)
|
||||
subprocess.run(["sudo", "chmod", "600", f"{user_root}/.ssh/authorized_keys"], check=True)
|
||||
subprocess.run(["sudo", "cp", flask_pub_key, f"{user_root}/.ssh/authorized_keys"], check=current_app.config['DEBUG'])
|
||||
subprocess.run(["sudo", "chmod", "700", f"{user_root}/.ssh"], check=current_app.config['DEBUG'])
|
||||
subprocess.run(["sudo", "chmod", "600", f"{user_root}/.ssh/authorized_keys"], check=current_app.config['DEBUG'])
|
||||
print(f"Directory {path} created successfully for user {user_id}")
|
||||
except subprocess.CalledProcessError as e:
|
||||
print(f"Error creating directory {path} details {str(e)}")
|
||||
try:#使用sudo创建shared_group
|
||||
subprocess.run(["sudo", "groupadd", f"shared_group_{user_id}"], check=True)
|
||||
subprocess.run(["sudo", "groupadd", f"shared_group_{user_id}"], check=current_app.config['DEBUG'])
|
||||
except subprocess.CalledProcessError as e:
|
||||
print(f"Error creating shared_group: {e}")
|
||||
# 组可能已经存在,这是正常情况,继续执行
|
||||
print(f"Groupadd command returned non-zero exit status, this is expected if group already exists: {e}")
|
||||
try:#使用sudo将user_id加入shared_group
|
||||
subprocess.run(["sudo", "usermod", "-a", "-G", f"shared_group_{user_id}", user_id], check=True)
|
||||
subprocess.run(["sudo", "usermod", "-a", "-G", f"shared_group_{user_id}", user_id], check=current_app.config['DEBUG'])
|
||||
# 自己也加入
|
||||
subprocess.run(["sudo", "usermod", "-a", "-G", f"shared_group_{user_id}", 'flask'], check=True)
|
||||
subprocess.run(["sudo", "usermod", "-a", "-G", f"shared_group_{user_id}", 'flask'], check=current_app.config['DEBUG'])
|
||||
except subprocess.CalledProcessError as e:
|
||||
print(f"Error adding user {user_id} to shared_group: {e}")
|
||||
try:
|
||||
subprocess.run(["sudo", "chown", "-R", f"flask:shared_group_{user_id}", path], check=True)
|
||||
subprocess.run(["sudo", "chmod", "-R", "755", user_root], check=True)
|
||||
subprocess.run(["sudo", "chmod", "-R", "775", path], check=True)
|
||||
subprocess.run(["sudo", "chown", "-R", f"flask:shared_group_{user_id}", path], check=current_app.config['DEBUG'])
|
||||
subprocess.run(["sudo", "chmod", "-R", "755", user_root], check=current_app.config['DEBUG'])
|
||||
subprocess.run(["sudo", "chmod", "-R", "775", path], check=current_app.config['DEBUG'])
|
||||
except subprocess.CalledProcessError as e:
|
||||
print(f"Error changing directory {path} to shared_group_{user_id}: {e}")
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
[Global]
|
||||
SECRET_KEY = cakebaker
|
||||
ROOT_WORKSPACE_PATH = /home
|
||||
DEBUG = False
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
from app import create_app
|
||||
from app.extensions import socketio
|
||||
import logging
|
||||
|
||||
# 配置日志,减少eventlet的调试日志
|
||||
logging.getLogger('eventlet').setLevel(logging.ERROR)
|
||||
logging.getLogger('socketio').setLevel(logging.ERROR)
|
||||
logging.getLogger('werkzeug').setLevel(logging.ERROR)
|
||||
|
||||
app = create_app()
|
||||
|
||||
if __name__ == '__main__':
|
||||
@@ -9,4 +16,5 @@ if __name__ == '__main__':
|
||||
port=5200,
|
||||
debug=False, # 开发期打开
|
||||
allow_unsafe_werkzeug=True, # 避免 dev server 的安全限制提示
|
||||
log_output=False # 禁用详细输出
|
||||
)
|
||||
|
||||
@@ -4,17 +4,17 @@
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Cloud IDE</title>
|
||||
<link rel="stylesheet" href="static/cdnback/css/editor/editor.main.css">
|
||||
<script src="static/cdnback/socket.io.min.js"></script>
|
||||
<link rel="stylesheet" href="static/cdnback/all.min.css">
|
||||
<link rel="stylesheet" href="static/cdnback/css/xterm.css" />
|
||||
<link rel="stylesheet" href="/static/cdnback/css/editor/editor.main.css">
|
||||
<script src="/static/cdnback/socket.io.min.js"></script>
|
||||
<link rel="stylesheet" href="/static/cdnback/all.min.css">
|
||||
<link rel="stylesheet" href="/static/cdnback/css/xterm.css" />
|
||||
<!-- <script src="https://cdnjs.cloudflare.com/ajax/libs/xterm/5.5.0/xterm.js"></script> -->
|
||||
<script src="static/cdnback/js/xterm.js"></script>
|
||||
<script src="static/cdnback/js/addons/fit/fit.js"></script>
|
||||
<script src="static/cdnback/js/addons/webLinks/webLinks.js"></script>
|
||||
<script src="static/cdnback/js/addons/fullscreen/fullscreen.js"></script>
|
||||
<script src="static/cdnback/js/addons/search/search.js"></script>
|
||||
<link rel="stylesheet" href="static/cdnback/all.min.css">
|
||||
<script src="/static/cdnback/js/xterm.js"></script>
|
||||
<script src="/static/cdnback/js/addons/fit/fit.js"></script>
|
||||
<script src="/static/cdnback/js/addons/webLinks/webLinks.js"></script>
|
||||
<script src="/static/cdnback/js/addons/fullscreen/fullscreen.js"></script>
|
||||
<script src="/static/cdnback/js/addons/search/search.js"></script>
|
||||
<link rel="stylesheet" href="/static/cdnback/all.min.css">
|
||||
|
||||
<link rel="stylesheet" href="/vsc-like/static/css/index.css">
|
||||
<link rel="stylesheet" href="/vsc-like/static/css/notification.css">
|
||||
@@ -61,7 +61,7 @@
|
||||
</div>
|
||||
<div id="notificationsContainer"></div>
|
||||
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/monaco-editor/0.34.0/min/vs/loader.js"></script>
|
||||
<script src="/static/cdnback/js/monaco-editor/0.34.0/min/vs/loader.js"></script>
|
||||
<script src="/vsc-like/static/js/code-like-extension.js"></script>
|
||||
<script src="/vsc-like/static/js/file.js"></script>
|
||||
<script src="/vsc-like/static/js/terminal.js"></script>
|
||||
@@ -161,7 +161,7 @@
|
||||
// saveFile
|
||||
if (saveTimeout) clearTimeout(saveTimeout);
|
||||
saveTimeout = setTimeout(() => {
|
||||
postSaveFile(selectedItem.path+'/'+selectedItem.name, editor.getValue());
|
||||
postSaveFile(filePath, editor.getValue());
|
||||
}, 5000); // 5000ms = 5秒
|
||||
});
|
||||
|
||||
|
||||
69
et --hard HEAD@{1}
Normal file
69
et --hard HEAD@{1}
Normal file
@@ -0,0 +1,69 @@
|
||||
[33m68493d6a[m[33m ([m[1;36mHEAD[m[33m -> [m[1;32mmain[m[33m, [m[1;31morigin/main[m[33m)[m HEAD@{0}: pull origin main: Fast-forward
|
||||
[33m0852e121[m HEAD@{1}: reset: moving to HEAD
|
||||
[33m0852e121[m HEAD@{2}: commit: cdn fix more
|
||||
[33m7dc4714a[m HEAD@{3}: commit: index style
|
||||
[33m9dc81b14[m[33m ([m[1;31morigin/feature/paste_detecte_new[m[33m, [m[1;32mfeature/paste_detecte_new[m[33m)[m HEAD@{4}: merge feature/paste_detecte_new: Fast-forward
|
||||
[33m7862647b[m HEAD@{5}: checkout: moving from feature/paste_detecte_new to main
|
||||
[33m9dc81b14[m[33m ([m[1;31morigin/feature/paste_detecte_new[m[33m, [m[1;32mfeature/paste_detecte_new[m[33m)[m HEAD@{6}: commit (merge): Merge branch 'main' into feature/paste_detecte_new
|
||||
[33m0cf1896b[m HEAD@{7}: checkout: moving from main to feature/paste_detecte_new
|
||||
[33m7862647b[m HEAD@{8}: commit: style fix
|
||||
[33m6b9c8e9e[m HEAD@{9}: commit: cdn change to local and use markdown and style change
|
||||
[33m33844786[m HEAD@{10}: commit: use markdown to edit
|
||||
[33mce88ae64[m HEAD@{11}: commit: use queue to allow send vscode_ws when it is none
|
||||
[33m6c38e906[m HEAD@{12}: pull: Fast-forward
|
||||
[33m9759c93a[m HEAD@{13}: commit: fix funciton response
|
||||
[33mecf19f49[m HEAD@{14}: commit: fix function double promlem
|
||||
[33mf5d50772[m HEAD@{15}: commit: function call can be expire
|
||||
[33m4a390adb[m HEAD@{16}: commit: fix style bug
|
||||
[33m960d1f1d[m HEAD@{17}: commit: style fix
|
||||
[33mc73ea447[m HEAD@{18}: commit: fix index
|
||||
[33m33bf569f[m HEAD@{19}: commit: fix nextchapter bug
|
||||
[33mb921bda4[m HEAD@{20}: commit: auto get domain
|
||||
[33m9921848d[m HEAD@{21}: commit: remove prefix of http url
|
||||
[33m4d81aef8[m HEAD@{22}: commit (merge): Merge branch 'feature/paste_deteced'
|
||||
[33m8fe5ee16[m HEAD@{23}: checkout: moving from feature/paste_deteced to main
|
||||
[33m9ce212e9[m[33m ([m[1;31morigin/feature/paste_deteced[m[33m, [m[1;32mfeature/paste_deteced[m[33m)[m HEAD@{24}: checkout: moving from main to feature/paste_deteced
|
||||
[33m8fe5ee16[m HEAD@{25}: commit (merge): 准备合并main
|
||||
[33m908d5915[m HEAD@{26}: checkout: moving from syt to main
|
||||
[33m57d8ac32[m[33m ([m[1;31morigin/syt[m[33m, [m[1;32msyt[m[33m)[m HEAD@{27}: checkout: moving from main to syt
|
||||
[33m908d5915[m HEAD@{28}: commit: ready
|
||||
[33m02b12791[m HEAD@{29}: checkout: moving from syt to main
|
||||
[33m57d8ac32[m[33m ([m[1;31morigin/syt[m[33m, [m[1;32msyt[m[33m)[m HEAD@{30}: checkout: moving from main to syt
|
||||
[33m02b12791[m HEAD@{31}: pull: Fast-forward
|
||||
[33m7d861e34[m[33m ([m[1;31morigin/zrz[m[33m)[m HEAD@{32}: checkout: moving from syt to main
|
||||
[33m57d8ac32[m[33m ([m[1;31morigin/syt[m[33m, [m[1;32msyt[m[33m)[m HEAD@{33}: commit: first
|
||||
[33m0196f37e[m HEAD@{34}: pull: Merge made by the 'ort' strategy.
|
||||
[33m57eb1197[m HEAD@{35}: commit: ok
|
||||
[33m382f2006[m HEAD@{36}: checkout: moving from main to syt
|
||||
[33m7d861e34[m[33m ([m[1;31morigin/zrz[m[33m)[m HEAD@{37}: commit (merge): Merge branch 'main' of https://gitee.com/CakeCN/code-agent
|
||||
[33m5f8f6c94[m HEAD@{38}: commit: many ok
|
||||
[33me24aa12e[m HEAD@{39}: commit: ready to process
|
||||
[33m6766ca85[m HEAD@{40}: commit (merge): Merge branch 'feature/voice_send'
|
||||
[33m3c9c7553[m HEAD@{41}: checkout: moving from feature/voice_send to main
|
||||
[33m58a95e9f[m[33m ([m[1;31morigin/feature/voice_send[m[33m, [m[1;32mfeature/voice_send[m[33m)[m HEAD@{42}: commit: ready merge to main
|
||||
[33m79125ffc[m HEAD@{43}: commit: change .cn to .com
|
||||
[33m2f9bc7df[m HEAD@{44}: checkout: moving from main to feature/voice_send
|
||||
[33m3c9c7553[m HEAD@{45}: reset: moving to HEAD
|
||||
[33m3c9c7553[m HEAD@{46}: checkout: moving from feature/voice_send to main
|
||||
[33m2f9bc7df[m HEAD@{47}: pull: Fast-forward
|
||||
[33m504c5cae[m[33m ([m[1;32m0v[m[33m)[m HEAD@{48}: checkout: moving from main to feature/voice_send
|
||||
[33m3c9c7553[m HEAD@{49}: commit: cn/com allow all
|
||||
[33m7122c3be[m HEAD@{50}: commit (merge): fix url
|
||||
[33me07c41fb[m HEAD@{51}: commit: fix code-server reboot problem(close debug)
|
||||
[33m821e20c9[m HEAD@{52}: commit: clear double iframe more safe
|
||||
[33m053584a7[m HEAD@{53}: checkout: moving from feature/voice_send to main
|
||||
[33m504c5cae[m[33m ([m[1;32m0v[m[33m)[m HEAD@{54}: checkout: moving from main to feature/voice_send
|
||||
[33m053584a7[m HEAD@{55}: commit: clear iframe double
|
||||
[33m10481b0b[m HEAD@{56}: commit: fix permisson bug
|
||||
[33mdc0eeaa9[m HEAD@{57}: commit: add hint
|
||||
[33ma24df620[m HEAD@{58}: commit: fix some bug
|
||||
[33m3ad36c29[m HEAD@{59}: commit: 25/09/24 10:00~11:30 停机维护
|
||||
[33m07cf2363[m HEAD@{60}: commit: fix many bug
|
||||
[33m6aac4200[m HEAD@{61}: commit: try hello message
|
||||
[33m271672c9[m HEAD@{62}: commit: check to code-server-like
|
||||
[33m252c426c[m HEAD@{63}: pull: Merge made by the 'ort' strategy.
|
||||
[33m588fc3b6[m HEAD@{64}: commit: ready to code-like
|
||||
[33mb1f832a2[m[33m ([m[1;31morigin/code-like-autosave[m[33m, [m[1;32mcode-like-autosave[m[33m)[m HEAD@{65}: merge code-like-autosave: Fast-forward
|
||||
[33m24f191d5[m HEAD@{66}: checkout: moving from code-like-autosave to main
|
||||
[33mb1f832a2[m[33m ([m[1;31morigin/code-like-autosave[m[33m, [m[1;32mcode-like-autosave[m[33m)[m HEAD@{67}: checkout: moving from main to code-like-autosave
|
||||
[33m24f191d5[m HEAD@{68}: clone: from https://gitee.com/CakeCN/code-agent.git
|
||||
Reference in New Issue
Block a user