Compare commits
41 Commits
dba7914e5d
...
code-serve
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
496c5be90a | ||
|
|
ec6be8233c | ||
|
|
d0331d9361 | ||
|
|
8e79380ba4 | ||
|
|
6acb1db093 | ||
|
|
af0ebda419 | ||
|
|
ac74c28f64 | ||
|
|
41c17fcde1 | ||
|
|
5789974d2e | ||
|
|
221f3faace | ||
|
|
560c590067 | ||
|
|
02cf3c0f78 | ||
|
|
9a7571f832 | ||
|
|
14dd164545 | ||
|
|
ff3d6e5bf9 | ||
|
|
97df0f6407 | ||
|
|
58a25b3e07 | ||
|
|
c4743bcadd | ||
|
|
f9b3cf53da | ||
|
|
fe1784fa20 | ||
|
|
140ece742e | ||
|
|
97cda4031b | ||
|
|
9c3ffce1e2 | ||
|
|
23bfc73bcf | ||
|
|
4a5a34b0aa | ||
|
|
2f48f1b6b4 | ||
|
|
b175407d4b | ||
|
|
ce4a9ac2ca | ||
|
|
be78f480a5 | ||
|
|
f804eac811 | ||
|
|
77cd53c241 | ||
|
|
7300b304e3 | ||
|
|
7aa7bf1690 | ||
|
|
84a4a578a8 | ||
|
|
5df2931fa1 | ||
|
|
99758ce1f8 | ||
|
|
ae91b62332 | ||
|
|
1bf13aacf6 | ||
|
|
9dfa0c9738 | ||
|
|
f330916ee0 | ||
|
|
1d4e625b8b |
165
Html/apps/_docs/前端/helpTip.md
Normal file
165
Html/apps/_docs/前端/helpTip.md
Normal file
@@ -0,0 +1,165 @@
|
|||||||
|
# HelpTip 组件文档
|
||||||
|
|
||||||
|
## 功能介绍
|
||||||
|
|
||||||
|
HelpTip 是一个通用的提示框组件,用于在鼠标悬停时显示提示信息。它具有以下特点:
|
||||||
|
|
||||||
|
- 提示框跟随鼠标移动
|
||||||
|
- 支持多行文本
|
||||||
|
- 自动防出界
|
||||||
|
- 平滑的显示/隐藏动画
|
||||||
|
- 支持在不同页面复用
|
||||||
|
- 代码标准化,易于维护
|
||||||
|
|
||||||
|
## 文件结构
|
||||||
|
|
||||||
|
```
|
||||||
|
/static/
|
||||||
|
├── css/
|
||||||
|
│ └── helpTip.css # 样式文件
|
||||||
|
└── js/
|
||||||
|
└── helpTip.js # 核心功能文件
|
||||||
|
```
|
||||||
|
|
||||||
|
## 使用方法
|
||||||
|
|
||||||
|
### 1. 引入文件
|
||||||
|
|
||||||
|
在需要使用 HelpTip 的 HTML 页面中引入以下文件:
|
||||||
|
|
||||||
|
```html
|
||||||
|
<!-- 样式文件 -->
|
||||||
|
<link rel="stylesheet" href="/static/css/helpTip.css">
|
||||||
|
|
||||||
|
<!-- 功能文件 -->
|
||||||
|
<script src="/static/js/helpTip.js"></script>
|
||||||
|
```
|
||||||
|
|
||||||
|
### 2. 基本用法
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
// 获取需要绑定提示框的元素
|
||||||
|
const element = document.getElementById('target-element');
|
||||||
|
|
||||||
|
// 绑定提示框
|
||||||
|
attachImmediateTooltip(element, '这是一条提示信息');
|
||||||
|
```
|
||||||
|
|
||||||
|
### 3. 支持换行的提示信息
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
attachImmediateTooltip(element, `这是一条\n多行提示信息\n\n支持换行符`);
|
||||||
|
```
|
||||||
|
|
||||||
|
### 4. 与问号图标配合使用
|
||||||
|
|
||||||
|
```html
|
||||||
|
<!-- HTML -->
|
||||||
|
<span>这是一个元素<span class="help-icon">?</span></span>
|
||||||
|
```
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
// JavaScript
|
||||||
|
const helpIcon = document.querySelector('.help-icon');
|
||||||
|
attachImmediateTooltip(helpIcon, '这是一条详细的提示信息');
|
||||||
|
```
|
||||||
|
|
||||||
|
## API 说明
|
||||||
|
|
||||||
|
### attachImmediateTooltip(anchorEl, text)
|
||||||
|
|
||||||
|
绑定提示框到指定元素。
|
||||||
|
|
||||||
|
#### 参数
|
||||||
|
|
||||||
|
- `anchorEl` (HTMLElement): 触发提示框的元素
|
||||||
|
- `text` (string): 提示框显示的文本内容,支持换行符 `\n`
|
||||||
|
|
||||||
|
#### 返回值
|
||||||
|
|
||||||
|
- `Function`: 清理函数,用于移除事件监听器
|
||||||
|
|
||||||
|
## 样式说明
|
||||||
|
|
||||||
|
### 问号图标样式
|
||||||
|
|
||||||
|
| 类名 | 说明 |
|
||||||
|
|------|------|
|
||||||
|
| `.help-icon` | 问号图标基础样式 |
|
||||||
|
| `.help-icon:hover` | 问号图标悬停样式 |
|
||||||
|
|
||||||
|
### 提示框样式
|
||||||
|
|
||||||
|
| 类名 | 说明 |
|
||||||
|
|------|------|
|
||||||
|
| `.tooltip-portal` | 提示框基础样式 |
|
||||||
|
| `.tooltip-portal.show` | 提示框显示状态 |
|
||||||
|
| `.tooltip-portal.fade` | 提示框动画效果 |
|
||||||
|
|
||||||
|
## 示例场景
|
||||||
|
|
||||||
|
### 1. 进度条提示
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
// 为进度条的每个阶段绑定提示框
|
||||||
|
for (let i = 0; i < progressItems.length; i++) {
|
||||||
|
const item = progressItems[i];
|
||||||
|
attachImmediateTooltip(item, `阶段 ${i + 1}: ${item.title}`);
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### 2. 表单字段提示
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
// 为表单字段绑定提示框
|
||||||
|
const formFields = document.querySelectorAll('.form-field');
|
||||||
|
formFields.forEach(field => {
|
||||||
|
const tip = field.getAttribute('data-tip');
|
||||||
|
if (tip) {
|
||||||
|
attachImmediateTooltip(field, tip);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
### 3. 工具栏图标提示
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
// 为工具栏图标绑定提示框
|
||||||
|
const toolbarIcons = document.querySelectorAll('.toolbar-icon');
|
||||||
|
toolbarIcons.forEach(icon => {
|
||||||
|
const title = icon.getAttribute('title');
|
||||||
|
if (title) {
|
||||||
|
attachImmediateTooltip(icon, title);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
## 注意事项
|
||||||
|
|
||||||
|
1. 确保在 DOM 加载完成后再调用 `attachImmediateTooltip` 函数
|
||||||
|
2. 如果元素是动态生成的,需要在元素生成后再绑定提示框
|
||||||
|
3. 提示框会自动添加到 `document.body` 中,不会被父元素的 `overflow` 属性裁切
|
||||||
|
4. 提示框的 `z-index` 为 999999,确保它能覆盖所有元素
|
||||||
|
5. 提示框默认支持多行文本,使用 `white-space: pre-wrap` 样式
|
||||||
|
|
||||||
|
## 浏览器兼容性
|
||||||
|
|
||||||
|
- Chrome/Edge (最新版)
|
||||||
|
- Firefox (最新版)
|
||||||
|
- Safari (最新版)
|
||||||
|
|
||||||
|
## 代码优化建议
|
||||||
|
|
||||||
|
1. 对于大量元素需要绑定提示框的情况,建议使用事件委托
|
||||||
|
2. 如果页面中不再需要使用提示框,可以调用返回的清理函数移除事件监听器
|
||||||
|
3. 提示文本应简洁明了,避免过长
|
||||||
|
|
||||||
|
## 更新日志
|
||||||
|
|
||||||
|
- v1.0.0: 初始版本,实现了基本的提示框功能
|
||||||
|
- v1.0.1: 优化了样式,增加了动画效果
|
||||||
|
- v1.0.2: 支持多行文本,自动防出界
|
||||||
|
|
||||||
|
## 贡献指南
|
||||||
|
|
||||||
|
如果您发现问题或有改进建议,欢迎提出 Issue 或 Pull Request。
|
||||||
@@ -32,8 +32,6 @@ class ASEngineClient:
|
|||||||
|
|
||||||
# ACK相关
|
# ACK相关
|
||||||
self.ack_events: Dict[str, Event] = {} # 存储ack_id和对应的Event对象
|
self.ack_events: Dict[str, Event] = {} # 存储ack_id和对应的Event对象
|
||||||
|
|
||||||
# 注册基础事件处理函数
|
|
||||||
self._register_base_events()
|
self._register_base_events()
|
||||||
|
|
||||||
def _register_base_events(self):
|
def _register_base_events(self):
|
||||||
@@ -74,7 +72,6 @@ class ASEngineClient:
|
|||||||
def on_ack(data):
|
def on_ack(data):
|
||||||
ack_id = data.get('ack_id')
|
ack_id = data.get('ack_id')
|
||||||
if ack_id and ack_id in self.ack_events:
|
if ack_id and ack_id in self.ack_events:
|
||||||
print(f"Received ACK for message: {ack_id}")
|
|
||||||
event = self.ack_events[ack_id]
|
event = self.ack_events[ack_id]
|
||||||
event.set() # 触发事件,通知等待的线程
|
event.set() # 触发事件,通知等待的线程
|
||||||
|
|
||||||
@@ -228,7 +225,7 @@ class ASEngineClient:
|
|||||||
self.sid = None
|
self.sid = None
|
||||||
print("Disconnected from server")
|
print("Disconnected from server")
|
||||||
|
|
||||||
def send_text(self, route: str, text: str, id:str="", wait_for_ack: bool = False, timeout: int = 5) -> bool:
|
def send_text(self, route: str, text: str, id:str="", wait_for_ack: bool = False, timeout: int = 5, return_event: bool = False) -> Any:
|
||||||
"""
|
"""
|
||||||
发送文本消息
|
发送文本消息
|
||||||
:param route: 目标路由
|
:param route: 目标路由
|
||||||
@@ -236,7 +233,8 @@ class ASEngineClient:
|
|||||||
:param id: 发送者ID
|
:param id: 发送者ID
|
||||||
:param wait_for_ack: 是否等待服务器ACK确认
|
:param wait_for_ack: 是否等待服务器ACK确认
|
||||||
:param timeout: 等待ACK的超时时间(秒)
|
:param timeout: 等待ACK的超时时间(秒)
|
||||||
:return: 是否发送成功(若wait_for_ack为True,则返回是否收到ACK)
|
:param return_event: 是否返回事件对象和ack_id而不是等待ACK
|
||||||
|
:return: 如果wait_for_ack为True且return_event为False,返回是否收到ACK;如果return_event为True,返回(event, ack_id);否则返回是否发送成功
|
||||||
"""
|
"""
|
||||||
if not self.connected:
|
if not self.connected:
|
||||||
print("Not connected to server")
|
print("Not connected to server")
|
||||||
@@ -247,20 +245,13 @@ class ASEngineClient:
|
|||||||
try:
|
try:
|
||||||
# 生成唯一ack_id
|
# 生成唯一ack_id
|
||||||
ack_id = f"{id}_{datetime.now().strftime('%Y%m%d%H%M%S%f')}"
|
ack_id = f"{id}_{datetime.now().strftime('%Y%m%d%H%M%S%f')}"
|
||||||
|
|
||||||
# 准备发送数据
|
|
||||||
data = {
|
data = {
|
||||||
'type': 'text',
|
'type': 'text',
|
||||||
'data': text,
|
'data': text,
|
||||||
'id': id,
|
'id': id,
|
||||||
'ack_id': ack_id
|
'ack_id': ack_id
|
||||||
}
|
}
|
||||||
|
|
||||||
# 发送数据
|
|
||||||
self.sio.emit(route, data, namespace=self.namespace)
|
self.sio.emit(route, data, namespace=self.namespace)
|
||||||
print(f"Sent text to route '{route}': {text[:20]}")
|
|
||||||
|
|
||||||
# 如果不需要等待ACK,直接返回True
|
|
||||||
if not wait_for_ack:
|
if not wait_for_ack:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@@ -268,6 +259,10 @@ class ASEngineClient:
|
|||||||
event = Event()
|
event = Event()
|
||||||
self.ack_events[ack_id] = event
|
self.ack_events[ack_id] = event
|
||||||
|
|
||||||
|
# 如果需要返回事件对象,直接返回
|
||||||
|
if return_event:
|
||||||
|
return event, ack_id
|
||||||
|
|
||||||
# 等待ACK或超时
|
# 等待ACK或超时
|
||||||
received_ack = event.wait(timeout=timeout)
|
received_ack = event.wait(timeout=timeout)
|
||||||
|
|
||||||
@@ -316,9 +311,6 @@ class ASEngineClient:
|
|||||||
},
|
},
|
||||||
namespace=self.namespace
|
namespace=self.namespace
|
||||||
)
|
)
|
||||||
|
|
||||||
print(f"Sent voice file to route '{route}'")
|
|
||||||
|
|
||||||
# 如果不需要等待ACK,直接返回True
|
# 如果不需要等待ACK,直接返回True
|
||||||
if not wait_for_ack:
|
if not wait_for_ack:
|
||||||
return True
|
return True
|
||||||
@@ -384,7 +376,6 @@ class ASEngineClient:
|
|||||||
},
|
},
|
||||||
namespace=self.namespace
|
namespace=self.namespace
|
||||||
)
|
)
|
||||||
print(f"Sent image file to route '{route}': {filename}")
|
|
||||||
|
|
||||||
# 如果不需要等待ACK,直接返回True
|
# 如果不需要等待ACK,直接返回True
|
||||||
if not wait_for_ack:
|
if not wait_for_ack:
|
||||||
@@ -428,6 +419,17 @@ class HSAEngineClient(ASEngineClient):
|
|||||||
super().__init__(server_url, namespace, id)
|
super().__init__(server_url, namespace, id)
|
||||||
self.chatmanager = chatmanager
|
self.chatmanager = chatmanager
|
||||||
def loadmarkdown(self, fmd, fmdp, fsp):
|
def loadmarkdown(self, fmd, fmdp, fsp):
|
||||||
self.send_text('markdown-in', fmd, self.id, wait_for_ack=True)
|
event1, ack_id1 = self.send_text('markdown-in', fmd, self.id, wait_for_ack=True, return_event=True)
|
||||||
self.send_text('markdown-prompt-in', fmdp, self.id, wait_for_ack=True)
|
event2, ack_id2 = self.send_text('markdown-prompt-in', fmdp, self.id, wait_for_ack=True, return_event=True)
|
||||||
self.send_text('score-prompt-in', fsp, self.id, wait_for_ack=True)
|
event3, ack_id3 = self.send_text('score-prompt-in', fsp, self.id, wait_for_ack=True, return_event=True)
|
||||||
|
timeout = 5 # 超时时间
|
||||||
|
success1 = event1.wait(timeout=timeout)
|
||||||
|
success2 = event2.wait(timeout=timeout)
|
||||||
|
success3 = event3.wait(timeout=timeout)
|
||||||
|
if ack_id1 in self.ack_events:
|
||||||
|
del self.ack_events[ack_id1]
|
||||||
|
if ack_id2 in self.ack_events:
|
||||||
|
del self.ack_events[ack_id2]
|
||||||
|
if ack_id3 in self.ack_events:
|
||||||
|
del self.ack_events[ack_id3]
|
||||||
|
return success1 and success2 and success3
|
||||||
|
|||||||
@@ -49,7 +49,8 @@ class ChatManager:
|
|||||||
self.chapter_chain = None
|
self.chapter_chain = None
|
||||||
self.function_manager = FunctionManager()
|
self.function_manager = FunctionManager()
|
||||||
self.bb = None
|
self.bb = None
|
||||||
self.chat_historys = None
|
self.chat_historys = []
|
||||||
|
self.scores = []
|
||||||
self.vscode_ws = None
|
self.vscode_ws = None
|
||||||
self._vscode_queue = deque()
|
self._vscode_queue = deque()
|
||||||
self._lock = Semaphore(1)
|
self._lock = Semaphore(1)
|
||||||
@@ -119,6 +120,7 @@ class ChatManager:
|
|||||||
|
|
||||||
|
|
||||||
def next_chapter(self):
|
def next_chapter(self):
|
||||||
|
print(f"now next chapter {self.chapter_chain_now} and len {len(self.chapter_chain)}")
|
||||||
assert self.chapter_chain_now + 1 < len(self.chapter_chain), "chapter_chain_now out of range"
|
assert self.chapter_chain_now + 1 < len(self.chapter_chain), "chapter_chain_now out of range"
|
||||||
self.chapter_chain_now += 1
|
self.chapter_chain_now += 1
|
||||||
self.bb.next_chapter()
|
self.bb.next_chapter()
|
||||||
@@ -129,9 +131,10 @@ class ChatManager:
|
|||||||
self.chapter_chain_now = chapter_index
|
self.chapter_chain_now = chapter_index
|
||||||
self.chapter_chain[chapter_index].Focus()
|
self.chapter_chain[chapter_index].Focus()
|
||||||
|
|
||||||
def load_next_chapter(self):
|
def load_now_chapter(self, load_code = True):
|
||||||
print(f"now load next chapter markdown {self.chapter_chain_now}")
|
print(f"now load now chapter markdown {self.chapter_chain_now}")
|
||||||
self.ase_client.loadmarkdown(self.chapter_chain[self.chapter_chain_now].chapter, self.chapter_chain[self.chapter_chain_now].chapter_prompt, self.chapter_chain[self.chapter_chain_now].score_prompt)
|
self.ase_client.loadmarkdown(self.chapter_chain[self.chapter_chain_now].chapter, self.chapter_chain[self.chapter_chain_now].chapter_prompt, self.chapter_chain[self.chapter_chain_now].score_prompt)
|
||||||
|
if load_code:
|
||||||
self.load_code_in_markdown()
|
self.load_code_in_markdown()
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,28 @@ import requests
|
|||||||
from flask_socketio import Namespace
|
from flask_socketio import Namespace
|
||||||
|
|
||||||
|
|
||||||
|
def clear_user_session(asengine_url, asengine_token, user_id):
|
||||||
|
'''
|
||||||
|
快速清理用户会话的函数
|
||||||
|
'''
|
||||||
|
try:
|
||||||
|
base_url = asengine_url
|
||||||
|
clear_url = f"{base_url}/api/sync/clear_user_session"
|
||||||
|
payload = {
|
||||||
|
'namespace_url': asengine_token, # WebSocket命名空间URL
|
||||||
|
'user_id': user_id, # 用户ID,对应session_info.id
|
||||||
|
'clear_type': 'all' # 清理类型,默认为全部
|
||||||
|
}
|
||||||
|
headers = {
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
}
|
||||||
|
response = requests.post(clear_url, json=payload, headers=headers)
|
||||||
|
response.raise_for_status() # 检查请求是否成功
|
||||||
|
print(f"User session {user_id} cleared successfully. Response: {response.json()}")
|
||||||
|
except Exception as e:
|
||||||
|
print(f"Error clearing user session: {e}")
|
||||||
|
|
||||||
|
|
||||||
def on_connect_to_ase(client, entry, init_data, **kwargs):
|
def on_connect_to_ase(client, entry, init_data, **kwargs):
|
||||||
'''
|
'''
|
||||||
此时刚刚建立好aseclient连接,并向前端发送打开code-server-like指令。
|
此时刚刚建立好aseclient连接,并向前端发送打开code-server-like指令。
|
||||||
@@ -10,24 +32,12 @@ def on_connect_to_ase(client, entry, init_data, **kwargs):
|
|||||||
namespace_entry.emit('open-iframe',"", room=init_data['room'], namespace='/agent')
|
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', "Agents服务已连接, 加载教案中", room=init_data['room'], namespace='/agent')
|
||||||
|
|
||||||
if init_data.get("restart", False):
|
restart = init_data.get("restart", False)
|
||||||
try:
|
if restart: # 重启时,从-1章进入 0章
|
||||||
base_url = namespace_entry.app.config['ASE_ENGINE_URL']
|
ase_client.chatmanager.next_chapter()
|
||||||
clear_url = f"{base_url}/clear_user_session"
|
ase_client.chatmanager.load_now_chapter(load_code=restart)
|
||||||
payload = {
|
print("load_now_chapter with restart:", restart)
|
||||||
'namespace_url': namespace_entry.app.config['ASE_ENGINE_URL_TOKEN'], # WebSocket命名空间URL
|
if restart:
|
||||||
'user_id': init_data['room'], # 用户ID,对应session_info.id
|
|
||||||
'clear_type': 'all' # 清理类型,默认为全部
|
|
||||||
}
|
|
||||||
headers = {
|
|
||||||
'Content-Type': 'application/json'
|
|
||||||
}
|
|
||||||
response = requests.post(clear_url, json=payload, headers=headers)
|
|
||||||
response.raise_for_status() # 检查请求是否成功
|
|
||||||
print(f"Clear user session successful: {response.json()}")
|
|
||||||
except Exception as e:
|
|
||||||
print(f"Error clearing user session: {e}")
|
|
||||||
ase_client.chatmanager.load_next_chapter()
|
|
||||||
ase_client.send_text("chapter-start", "")
|
ase_client.send_text("chapter-start", "")
|
||||||
namespace_entry.emit('message', "教案加载完毕", room=init_data['room'], namespace='/agent')
|
namespace_entry.emit('message', "教案加载完毕", room=init_data['room'], namespace='/agent')
|
||||||
|
|
||||||
@@ -69,5 +79,5 @@ def receive_ase_chapter_score(client_entry, user_and_manager, data, init_data):
|
|||||||
chatmanager.scores[chatmanager.chapter_chain_now - 1] = data.get('data', None)
|
chatmanager.scores[chatmanager.chapter_chain_now - 1] = data.get('data', None)
|
||||||
else: chatmanager.scores.append(data.get('data', None))
|
else: chatmanager.scores.append(data.get('data', None))
|
||||||
user.set_course_progress(chatmanager.chat_historys, chatmanager.scores, chatmanager.course_id, chatmanager.chapter_name, chatmanager.lesson_name)
|
user.set_course_progress(chatmanager.chat_historys, chatmanager.scores, chatmanager.course_id, chatmanager.chapter_name, chatmanager.lesson_name)
|
||||||
chatmanager.load_next_chapter()
|
chatmanager.load_now_chapter()
|
||||||
chatmanager.ase_client.send_text("chapter-start", "")
|
chatmanager.ase_client.send_text("chapter-start", "")
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ def save_learning_progress(chatmanager, user_id: str) -> bool:
|
|||||||
"chat_historys": chatmanager.chat_historys,
|
"chat_historys": chatmanager.chat_historys,
|
||||||
"scores": chatmanager.scores,
|
"scores": chatmanager.scores,
|
||||||
"multiagents_dialogs": his_data,
|
"multiagents_dialogs": his_data,
|
||||||
|
"chapter_chain_length": len(chatmanager.chapter_chain),
|
||||||
"updated_at": datetime.now()
|
"updated_at": datetime.now()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -92,6 +93,7 @@ def get_multiagents_dialog_list(user_id: str) -> List[Dict]:
|
|||||||
|
|
||||||
# 检查响应
|
# 检查响应
|
||||||
if response.status_code == 200:
|
if response.status_code == 200:
|
||||||
|
current_app.logger.info(f"获取MultiAgents对话列表成功: user_id={user_id}, json={response.json()}")
|
||||||
return response.json()
|
return response.json()
|
||||||
else:
|
else:
|
||||||
current_app.logger.error(f"获取MultiAgents对话列表失败: HTTP {response.status_code}")
|
current_app.logger.error(f"获取MultiAgents对话列表失败: HTTP {response.status_code}")
|
||||||
@@ -145,6 +147,7 @@ def load_learning_progress(user_id: str, material_id: str, chapter_name: str, le
|
|||||||
"chat_historys": [],
|
"chat_historys": [],
|
||||||
"scores": [],
|
"scores": [],
|
||||||
"chapter_chain_now": None,
|
"chapter_chain_now": None,
|
||||||
|
"chapter_chain_length": 0,
|
||||||
"updated_at": datetime.now().isoformat()
|
"updated_at": datetime.now().isoformat()
|
||||||
},
|
},
|
||||||
"message": "未找到学习记录,返回默认值"
|
"message": "未找到学习记录,返回默认值"
|
||||||
@@ -163,6 +166,7 @@ def load_learning_progress(user_id: str, material_id: str, chapter_name: str, le
|
|||||||
"chat_historys": [],
|
"chat_historys": [],
|
||||||
"scores": [],
|
"scores": [],
|
||||||
"chapter_chain_now": None,
|
"chapter_chain_now": None,
|
||||||
|
"chapter_chain_length": 0,
|
||||||
"updated_at": datetime.now().isoformat()
|
"updated_at": datetime.now().isoformat()
|
||||||
},
|
},
|
||||||
"message": error_msg
|
"message": error_msg
|
||||||
|
|||||||
@@ -24,7 +24,6 @@ def load_markdown_file(course_id, chapter_name, lesson_name):
|
|||||||
break
|
break
|
||||||
if file_link is None:
|
if file_link is None:
|
||||||
return None
|
return None
|
||||||
print(f"load_markdown_file: {file_link}")
|
|
||||||
return get_text_file(file_link)
|
return get_text_file(file_link)
|
||||||
|
|
||||||
def convert_markdown_to_html(md_file: str) -> str:
|
def convert_markdown_to_html(md_file: str) -> str:
|
||||||
|
|||||||
@@ -23,7 +23,8 @@ from ..services.asectrl_service import (
|
|||||||
receive_ase_process,
|
receive_ase_process,
|
||||||
receive_ase_judge,
|
receive_ase_judge,
|
||||||
receive_ase_next_chapter,
|
receive_ase_next_chapter,
|
||||||
receive_ase_chapter_score
|
receive_ase_chapter_score,
|
||||||
|
clear_user_session
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -62,33 +63,25 @@ class VSCodeNamespace(Namespace):
|
|||||||
|
|
||||||
|
|
||||||
class AgentNamespace(Namespace):
|
class AgentNamespace(Namespace):
|
||||||
def on_login(self, data):
|
def _load_learning_progress(self, chatmanager, user_id, course_id, chapter_name, lesson_name, continue_learn):
|
||||||
self.app = current_app
|
"""加载并恢复用户学习进度
|
||||||
ex = current_app.extensions
|
|
||||||
uuid2username = ex["uuid2username"]
|
|
||||||
backboard_manager = ex["backboard_manager"]
|
|
||||||
data = json.loads(data)
|
|
||||||
user_uuid = data['user_uuid']
|
|
||||||
course_id = data['course_id']
|
|
||||||
lesson_name = data['lesson_name']
|
|
||||||
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}')
|
|
||||||
|
|
||||||
user_uuid2chatmanager = ex["user_uuid2chatmanager"]
|
Args:
|
||||||
user_uuid2ase_client = ex["user_uuid2ase_client"]
|
chatmanager: 聊天管理器实例
|
||||||
if (user_uuid2ase_client.get(user_uuid,None) is not None and user_uuid2ase_client[user_uuid].connected):
|
user_id: 用户ID
|
||||||
user_uuid2ase_client[user_uuid].disconnect()
|
course_id: 课程ID
|
||||||
chatmanager = user_uuid2chatmanager[user_uuid]
|
chapter_name: 章节名称
|
||||||
chatmanager.function_manager.add_function(judge, {'course_id': course_id, 'root_path': f'/home/{user_id}/{course_id}/{chapter_name}/{lesson_name}'})
|
lesson_name: 课时名称
|
||||||
chatmanager.function_manager.add_function(next_chapter, {'user_uuid': user_uuid})
|
continue_learn: 是否继续学习
|
||||||
|
|
||||||
if not chatmanager.restart:# 尝试加载用户学习进度
|
Returns:
|
||||||
progress_result = load_learning_progress(user_id, course_id, chapter_name, lesson_name)
|
int: 需要跳过的章节数
|
||||||
|
"""
|
||||||
need_skip_chapters = 0
|
need_skip_chapters = 0
|
||||||
|
|
||||||
|
if continue_learn: # 尝试加载用户学习进度
|
||||||
|
progress_result = load_learning_progress(user_id, course_id, chapter_name, lesson_name)
|
||||||
|
|
||||||
if progress_result['exists']:
|
if progress_result['exists']:
|
||||||
progress = progress_result['data']
|
progress = progress_result['data']
|
||||||
# 恢复学习进度数据
|
# 恢复学习进度数据
|
||||||
@@ -112,17 +105,51 @@ class AgentNamespace(Namespace):
|
|||||||
chatmanager.chat_historys = progress_result['data']['chat_historys']
|
chatmanager.chat_historys = progress_result['data']['chat_historys']
|
||||||
chatmanager.scores = progress_result['data']['scores']
|
chatmanager.scores = progress_result['data']['scores']
|
||||||
|
|
||||||
|
return need_skip_chapters
|
||||||
|
|
||||||
|
def on_login(self, data):
|
||||||
|
self.app = current_app
|
||||||
|
ex = current_app.extensions
|
||||||
|
uuid2username = ex["uuid2username"]
|
||||||
|
backboard_manager = ex["backboard_manager"]
|
||||||
|
data = json.loads(data)
|
||||||
|
user_uuid = data['user_uuid']
|
||||||
|
course_id = data['course_id']
|
||||||
|
lesson_name = data['lesson_name']
|
||||||
|
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}')
|
||||||
|
|
||||||
|
user_uuid2chatmanager = ex["user_uuid2chatmanager"]
|
||||||
|
user_uuid2ase_client = ex["user_uuid2ase_client"]
|
||||||
|
if (user_uuid2ase_client.get(user_uuid,None) is not None and user_uuid2ase_client[user_uuid].connected):
|
||||||
|
user_uuid2ase_client[user_uuid].disconnect()
|
||||||
|
chatmanager = user_uuid2chatmanager[user_uuid]
|
||||||
|
chatmanager.function_manager.add_function(judge, {'course_id': course_id, 'root_path': f'/home/{user_id}/{course_id}/{chapter_name}/{lesson_name}'})
|
||||||
|
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)
|
||||||
|
|
||||||
fmd,fmdp,fsp = load_full_markdown_file(course_id, chapter_name, lesson_name)
|
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)
|
user_uuid2ase_client[user_uuid] = HSAEngineClient(current_app.config["ASE_ENGINE_URL"], current_app.config["ASE_ENGINE_NAMESPACE"],id=user_id, chatmanager = chatmanager)
|
||||||
chatmanager.init(user_uuid, user_uuid2ase_client[user_uuid], fmd, fmdp, fsp, course_id, chapter_name, lesson_name, max_iter=5, app=current_app, socketio=self)
|
chatmanager.init(user_uuid, user_uuid2ase_client[user_uuid],
|
||||||
backboard_manager.add_backboard(user_uuid, user_id, course_id, lesson_name, root_path=f'/home/{user_id}/{course_id}/{chapter_name}/{lesson_name}')
|
fmd, fmdp, fsp, course_id, chapter_name, lesson_name, max_iter=5, app=current_app, socketio=self)
|
||||||
|
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)
|
chatmanager.bb = backboard_manager.get_backboard(user_uuid)
|
||||||
if not progress:
|
# 如果有保存的进度,需要跳过已经完成的章节、无需清空代码、对话历史恢复
|
||||||
chatmanager.next_chapter()
|
if continue_learn:
|
||||||
|
|
||||||
# 如果有保存的进度,需要跳过已经完成的章节
|
|
||||||
for _ in range(need_skip_chapters):
|
for _ in range(need_skip_chapters):
|
||||||
chatmanager.next_chapter()
|
chatmanager.next_chapter()
|
||||||
|
emit('next_chapter', room=user_uuid, namespace='/agent')
|
||||||
|
# 恢复对话历史到前端 - 使用批量发送消息列表
|
||||||
|
if chatmanager.chat_historys:
|
||||||
|
emit('messages', chatmanager.chat_historys, room=user_uuid, namespace='/agent')
|
||||||
|
|
||||||
self.chatmanager = chatmanager
|
self.chatmanager = chatmanager
|
||||||
self.ase_client = user_uuid2ase_client[user_uuid]
|
self.ase_client = user_uuid2ase_client[user_uuid]
|
||||||
user_uuid2ase_client[user_uuid].register_on_connect_entry(
|
user_uuid2ase_client[user_uuid].register_on_connect_entry(
|
||||||
|
|||||||
6
Html/apps/static/cdnback/css/editor/editor.main.css
Normal file
6
Html/apps/static/cdnback/css/editor/editor.main.css
Normal file
File diff suppressed because one or more lines are too long
218
Html/apps/static/cdnback/css/xterm.css
Normal file
218
Html/apps/static/cdnback/css/xterm.css
Normal file
@@ -0,0 +1,218 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2014 The xterm.js authors. All rights reserved.
|
||||||
|
* Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)
|
||||||
|
* https://github.com/chjj/term.js
|
||||||
|
* @license MIT
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*
|
||||||
|
* Originally forked from (with the author's permission):
|
||||||
|
* Fabrice Bellard's javascript vt100 for jslinux:
|
||||||
|
* http://bellard.org/jslinux/
|
||||||
|
* Copyright (c) 2011 Fabrice Bellard
|
||||||
|
* The original design remains. The terminal itself
|
||||||
|
* has been extended to include xterm CSI codes, among
|
||||||
|
* other features.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default styles for xterm.js
|
||||||
|
*/
|
||||||
|
|
||||||
|
.xterm {
|
||||||
|
cursor: text;
|
||||||
|
position: relative;
|
||||||
|
user-select: none;
|
||||||
|
-ms-user-select: none;
|
||||||
|
-webkit-user-select: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.xterm.focus,
|
||||||
|
.xterm:focus {
|
||||||
|
outline: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.xterm .xterm-helpers {
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
/**
|
||||||
|
* The z-index of the helpers must be higher than the canvases in order for
|
||||||
|
* IMEs to appear on top.
|
||||||
|
*/
|
||||||
|
z-index: 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
.xterm .xterm-helper-textarea {
|
||||||
|
padding: 0;
|
||||||
|
border: 0;
|
||||||
|
margin: 0;
|
||||||
|
/* Move textarea out of the screen to the far left, so that the cursor is not visible */
|
||||||
|
position: absolute;
|
||||||
|
opacity: 0;
|
||||||
|
left: -9999em;
|
||||||
|
top: 0;
|
||||||
|
width: 0;
|
||||||
|
height: 0;
|
||||||
|
z-index: -5;
|
||||||
|
/** Prevent wrapping so the IME appears against the textarea at the correct position */
|
||||||
|
white-space: nowrap;
|
||||||
|
overflow: hidden;
|
||||||
|
resize: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.xterm .composition-view {
|
||||||
|
/* TODO: Composition position got messed up somewhere */
|
||||||
|
background: #000;
|
||||||
|
color: #FFF;
|
||||||
|
display: none;
|
||||||
|
position: absolute;
|
||||||
|
white-space: nowrap;
|
||||||
|
z-index: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.xterm .composition-view.active {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.xterm .xterm-viewport {
|
||||||
|
/* On OS X this is required in order for the scroll bar to appear fully opaque */
|
||||||
|
background-color: #000;
|
||||||
|
overflow-y: scroll;
|
||||||
|
cursor: default;
|
||||||
|
position: absolute;
|
||||||
|
right: 0;
|
||||||
|
left: 0;
|
||||||
|
top: 0;
|
||||||
|
bottom: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.xterm .xterm-screen {
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
.xterm .xterm-screen canvas {
|
||||||
|
position: absolute;
|
||||||
|
left: 0;
|
||||||
|
top: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.xterm .xterm-scroll-area {
|
||||||
|
visibility: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.xterm-char-measure-element {
|
||||||
|
display: inline-block;
|
||||||
|
visibility: hidden;
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
left: -9999em;
|
||||||
|
line-height: normal;
|
||||||
|
}
|
||||||
|
|
||||||
|
.xterm.enable-mouse-events {
|
||||||
|
/* When mouse events are enabled (eg. tmux), revert to the standard pointer cursor */
|
||||||
|
cursor: default;
|
||||||
|
}
|
||||||
|
|
||||||
|
.xterm.xterm-cursor-pointer,
|
||||||
|
.xterm .xterm-cursor-pointer {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.xterm.column-select.focus {
|
||||||
|
/* Column selection mode */
|
||||||
|
cursor: crosshair;
|
||||||
|
}
|
||||||
|
|
||||||
|
.xterm .xterm-accessibility:not(.debug),
|
||||||
|
.xterm .xterm-message {
|
||||||
|
position: absolute;
|
||||||
|
left: 0;
|
||||||
|
top: 0;
|
||||||
|
bottom: 0;
|
||||||
|
right: 0;
|
||||||
|
z-index: 10;
|
||||||
|
color: transparent;
|
||||||
|
pointer-events: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.xterm .xterm-accessibility-tree:not(.debug) *::selection {
|
||||||
|
color: transparent;
|
||||||
|
}
|
||||||
|
|
||||||
|
.xterm .xterm-accessibility-tree {
|
||||||
|
user-select: text;
|
||||||
|
white-space: pre;
|
||||||
|
}
|
||||||
|
|
||||||
|
.xterm .live-region {
|
||||||
|
position: absolute;
|
||||||
|
left: -9999px;
|
||||||
|
width: 1px;
|
||||||
|
height: 1px;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.xterm-dim {
|
||||||
|
/* Dim should not apply to background, so the opacity of the foreground color is applied
|
||||||
|
* explicitly in the generated class and reset to 1 here */
|
||||||
|
opacity: 1 !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.xterm-underline-1 { text-decoration: underline; }
|
||||||
|
.xterm-underline-2 { text-decoration: double underline; }
|
||||||
|
.xterm-underline-3 { text-decoration: wavy underline; }
|
||||||
|
.xterm-underline-4 { text-decoration: dotted underline; }
|
||||||
|
.xterm-underline-5 { text-decoration: dashed underline; }
|
||||||
|
|
||||||
|
.xterm-overline {
|
||||||
|
text-decoration: overline;
|
||||||
|
}
|
||||||
|
|
||||||
|
.xterm-overline.xterm-underline-1 { text-decoration: overline underline; }
|
||||||
|
.xterm-overline.xterm-underline-2 { text-decoration: overline double underline; }
|
||||||
|
.xterm-overline.xterm-underline-3 { text-decoration: overline wavy underline; }
|
||||||
|
.xterm-overline.xterm-underline-4 { text-decoration: overline dotted underline; }
|
||||||
|
.xterm-overline.xterm-underline-5 { text-decoration: overline dashed underline; }
|
||||||
|
|
||||||
|
.xterm-strikethrough {
|
||||||
|
text-decoration: line-through;
|
||||||
|
}
|
||||||
|
|
||||||
|
.xterm-screen .xterm-decoration-container .xterm-decoration {
|
||||||
|
z-index: 6;
|
||||||
|
position: absolute;
|
||||||
|
}
|
||||||
|
|
||||||
|
.xterm-screen .xterm-decoration-container .xterm-decoration.xterm-decoration-top-layer {
|
||||||
|
z-index: 7;
|
||||||
|
}
|
||||||
|
|
||||||
|
.xterm-decoration-overview-ruler {
|
||||||
|
z-index: 8;
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
right: 0;
|
||||||
|
pointer-events: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.xterm-decoration-top {
|
||||||
|
z-index: 2;
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
51
Html/apps/static/cdnback/js/addons/fit/fit.js
Normal file
51
Html/apps/static/cdnback/js/addons/fit/fit.js
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.fit = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
|
||||||
|
"use strict";
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
function proposeGeometry(term) {
|
||||||
|
if (!term.element.parentElement) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
var parentElementStyle = window.getComputedStyle(term.element.parentElement);
|
||||||
|
var parentElementHeight = parseInt(parentElementStyle.getPropertyValue('height'));
|
||||||
|
var parentElementWidth = Math.max(0, parseInt(parentElementStyle.getPropertyValue('width')));
|
||||||
|
var elementStyle = window.getComputedStyle(term.element);
|
||||||
|
var elementPadding = {
|
||||||
|
top: parseInt(elementStyle.getPropertyValue('padding-top')),
|
||||||
|
bottom: parseInt(elementStyle.getPropertyValue('padding-bottom')),
|
||||||
|
right: parseInt(elementStyle.getPropertyValue('padding-right')),
|
||||||
|
left: parseInt(elementStyle.getPropertyValue('padding-left'))
|
||||||
|
};
|
||||||
|
var elementPaddingVer = elementPadding.top + elementPadding.bottom;
|
||||||
|
var elementPaddingHor = elementPadding.right + elementPadding.left;
|
||||||
|
var availableHeight = parentElementHeight - elementPaddingVer;
|
||||||
|
var availableWidth = parentElementWidth - elementPaddingHor - term._core.viewport.scrollBarWidth;
|
||||||
|
var geometry = {
|
||||||
|
cols: Math.floor(availableWidth / term._core.renderer.dimensions.actualCellWidth),
|
||||||
|
rows: Math.floor(availableHeight / term._core.renderer.dimensions.actualCellHeight)
|
||||||
|
};
|
||||||
|
return geometry;
|
||||||
|
}
|
||||||
|
exports.proposeGeometry = proposeGeometry;
|
||||||
|
function fit(term) {
|
||||||
|
var geometry = proposeGeometry(term);
|
||||||
|
if (geometry) {
|
||||||
|
if (term.rows !== geometry.rows || term.cols !== geometry.cols) {
|
||||||
|
term._core.renderer.clear();
|
||||||
|
term.resize(geometry.cols, geometry.rows);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exports.fit = fit;
|
||||||
|
function apply(terminalConstructor) {
|
||||||
|
terminalConstructor.prototype.proposeGeometry = function () {
|
||||||
|
return proposeGeometry(this);
|
||||||
|
};
|
||||||
|
terminalConstructor.prototype.fit = function () {
|
||||||
|
fit(this);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
exports.apply = apply;
|
||||||
|
|
||||||
|
},{}]},{},[1])(1)
|
||||||
|
});
|
||||||
|
//# sourceMappingURL=fit.js.map
|
||||||
27
Html/apps/static/cdnback/js/addons/fullscreen/fullscreen.js
Normal file
27
Html/apps/static/cdnback/js/addons/fullscreen/fullscreen.js
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.fullscreen = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
|
||||||
|
"use strict";
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
function toggleFullScreen(term, fullscreen) {
|
||||||
|
var fn;
|
||||||
|
if (typeof fullscreen === 'undefined') {
|
||||||
|
fn = (term.element.classList.contains('fullscreen')) ? 'remove' : 'add';
|
||||||
|
}
|
||||||
|
else if (!fullscreen) {
|
||||||
|
fn = 'remove';
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
fn = 'add';
|
||||||
|
}
|
||||||
|
term.element.classList[fn]('fullscreen');
|
||||||
|
}
|
||||||
|
exports.toggleFullScreen = toggleFullScreen;
|
||||||
|
function apply(terminalConstructor) {
|
||||||
|
terminalConstructor.prototype.toggleFullScreen = function (fullscreen) {
|
||||||
|
toggleFullScreen(this, fullscreen);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
exports.apply = apply;
|
||||||
|
|
||||||
|
},{}]},{},[1])(1)
|
||||||
|
});
|
||||||
|
//# sourceMappingURL=fullscreen.js.map
|
||||||
126
Html/apps/static/cdnback/js/addons/search/search.js
Normal file
126
Html/apps/static/cdnback/js/addons/search/search.js
Normal file
@@ -0,0 +1,126 @@
|
|||||||
|
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.search = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
|
||||||
|
"use strict";
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
var SearchHelper = (function () {
|
||||||
|
function SearchHelper(_terminal) {
|
||||||
|
this._terminal = _terminal;
|
||||||
|
}
|
||||||
|
SearchHelper.prototype.findNext = function (term) {
|
||||||
|
if (!term || term.length === 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
var result;
|
||||||
|
var startRow = this._terminal._core.buffer.ydisp;
|
||||||
|
if (this._terminal._core.selectionManager.selectionEnd) {
|
||||||
|
startRow = this._terminal._core.selectionManager.selectionEnd[1];
|
||||||
|
}
|
||||||
|
for (var y = startRow + 1; y < this._terminal._core.buffer.ybase + this._terminal.rows; y++) {
|
||||||
|
result = this._findInLine(term, y);
|
||||||
|
if (result) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!result) {
|
||||||
|
for (var y = 0; y < startRow; y++) {
|
||||||
|
result = this._findInLine(term, y);
|
||||||
|
if (result) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return this._selectResult(result);
|
||||||
|
};
|
||||||
|
SearchHelper.prototype.findPrevious = function (term) {
|
||||||
|
if (!term || term.length === 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
var result;
|
||||||
|
var startRow = this._terminal._core.buffer.ydisp;
|
||||||
|
if (this._terminal._core.selectionManager.selectionStart) {
|
||||||
|
startRow = this._terminal._core.selectionManager.selectionStart[1];
|
||||||
|
}
|
||||||
|
for (var y = startRow - 1; y >= 0; y--) {
|
||||||
|
result = this._findInLine(term, y);
|
||||||
|
if (result) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!result) {
|
||||||
|
for (var y = this._terminal._core.buffer.ybase + this._terminal.rows - 1; y > startRow; y--) {
|
||||||
|
result = this._findInLine(term, y);
|
||||||
|
if (result) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return this._selectResult(result);
|
||||||
|
};
|
||||||
|
SearchHelper.prototype._findInLine = function (term, y) {
|
||||||
|
var lowerStringLine = this._terminal._core.buffer.translateBufferLineToString(y, true).toLowerCase();
|
||||||
|
var lowerTerm = term.toLowerCase();
|
||||||
|
var searchIndex = lowerStringLine.indexOf(lowerTerm);
|
||||||
|
if (searchIndex >= 0) {
|
||||||
|
var line = this._terminal._core.buffer.lines.get(y);
|
||||||
|
for (var i = 0; i < searchIndex; i++) {
|
||||||
|
var charData = line[i];
|
||||||
|
var char = charData[1];
|
||||||
|
if (char.length > 1) {
|
||||||
|
searchIndex -= char.length - 1;
|
||||||
|
}
|
||||||
|
var charWidth = charData[2];
|
||||||
|
if (charWidth === 0) {
|
||||||
|
searchIndex++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
term: term,
|
||||||
|
col: searchIndex,
|
||||||
|
row: y
|
||||||
|
};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
SearchHelper.prototype._selectResult = function (result) {
|
||||||
|
if (!result) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
this._terminal._core.selectionManager.setSelection(result.col, result.row, result.term.length);
|
||||||
|
this._terminal.scrollLines(result.row - this._terminal._core.buffer.ydisp);
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
return SearchHelper;
|
||||||
|
}());
|
||||||
|
exports.SearchHelper = SearchHelper;
|
||||||
|
|
||||||
|
},{}],2:[function(require,module,exports){
|
||||||
|
"use strict";
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
var SearchHelper_1 = require("./SearchHelper");
|
||||||
|
function findNext(terminal, term) {
|
||||||
|
var addonTerminal = terminal;
|
||||||
|
if (!addonTerminal.__searchHelper) {
|
||||||
|
addonTerminal.__searchHelper = new SearchHelper_1.SearchHelper(addonTerminal);
|
||||||
|
}
|
||||||
|
return addonTerminal.__searchHelper.findNext(term);
|
||||||
|
}
|
||||||
|
exports.findNext = findNext;
|
||||||
|
function findPrevious(terminal, term) {
|
||||||
|
var addonTerminal = terminal;
|
||||||
|
if (!addonTerminal.__searchHelper) {
|
||||||
|
addonTerminal.__searchHelper = new SearchHelper_1.SearchHelper(addonTerminal);
|
||||||
|
}
|
||||||
|
return addonTerminal.__searchHelper.findPrevious(term);
|
||||||
|
}
|
||||||
|
exports.findPrevious = findPrevious;
|
||||||
|
function apply(terminalConstructor) {
|
||||||
|
terminalConstructor.prototype.findNext = function (term) {
|
||||||
|
return findNext(this, term);
|
||||||
|
};
|
||||||
|
terminalConstructor.prototype.findPrevious = function (term) {
|
||||||
|
return findPrevious(this, term);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
exports.apply = apply;
|
||||||
|
|
||||||
|
},{"./SearchHelper":1}]},{},[2])(2)
|
||||||
|
});
|
||||||
|
//# sourceMappingURL=search.js.map
|
||||||
41
Html/apps/static/cdnback/js/addons/webLinks/webLinks.js
Normal file
41
Html/apps/static/cdnback/js/addons/webLinks/webLinks.js
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.webLinks = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
|
||||||
|
"use strict";
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
var protocolClause = '(https?:\\/\\/)';
|
||||||
|
var domainCharacterSet = '[\\da-z\\.-]+';
|
||||||
|
var negatedDomainCharacterSet = '[^\\da-z\\.-]+';
|
||||||
|
var domainBodyClause = '(' + domainCharacterSet + ')';
|
||||||
|
var tldClause = '([a-z\\.]{2,6})';
|
||||||
|
var ipClause = '((\\d{1,3}\\.){3}\\d{1,3})';
|
||||||
|
var localHostClause = '(localhost)';
|
||||||
|
var portClause = '(:\\d{1,5})';
|
||||||
|
var hostClause = '((' + domainBodyClause + '\\.' + tldClause + ')|' + ipClause + '|' + localHostClause + ')' + portClause + '?';
|
||||||
|
var pathClause = '(\\/[\\/\\w\\.\\-%~]*)*';
|
||||||
|
var queryStringHashFragmentCharacterSet = '[0-9\\w\\[\\]\\(\\)\\/\\?\\!#@$%&\'*+,:;~\\=\\.\\-]*';
|
||||||
|
var queryStringClause = '(\\?' + queryStringHashFragmentCharacterSet + ')?';
|
||||||
|
var hashFragmentClause = '(#' + queryStringHashFragmentCharacterSet + ')?';
|
||||||
|
var negatedPathCharacterSet = '[^\\/\\w\\.\\-%]+';
|
||||||
|
var bodyClause = hostClause + pathClause + queryStringClause + hashFragmentClause;
|
||||||
|
var start = '(?:^|' + negatedDomainCharacterSet + ')(';
|
||||||
|
var end = ')($|' + negatedPathCharacterSet + ')';
|
||||||
|
var strictUrlRegex = new RegExp(start + protocolClause + bodyClause + end);
|
||||||
|
function handleLink(event, uri) {
|
||||||
|
window.open(uri, '_blank');
|
||||||
|
}
|
||||||
|
function webLinksInit(term, handler, options) {
|
||||||
|
if (handler === void 0) { handler = handleLink; }
|
||||||
|
if (options === void 0) { options = {}; }
|
||||||
|
options.matchIndex = 1;
|
||||||
|
term.registerLinkMatcher(strictUrlRegex, handler, options);
|
||||||
|
}
|
||||||
|
exports.webLinksInit = webLinksInit;
|
||||||
|
function apply(terminalConstructor) {
|
||||||
|
terminalConstructor.prototype.webLinksInit = function (handler, options) {
|
||||||
|
webLinksInit(this, handler, options);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
exports.apply = apply;
|
||||||
|
|
||||||
|
},{}]},{},[1])(1)
|
||||||
|
});
|
||||||
|
//# sourceMappingURL=webLinks.js.map
|
||||||
File diff suppressed because one or more lines are too long
1
Html/apps/static/cdnback/js/tex-mml-chtml.js
Normal file
1
Html/apps/static/cdnback/js/tex-mml-chtml.js
Normal file
File diff suppressed because one or more lines are too long
8588
Html/apps/static/cdnback/js/xterm.js
Normal file
8588
Html/apps/static/cdnback/js/xterm.js
Normal file
File diff suppressed because it is too large
Load Diff
@@ -107,12 +107,6 @@
|
|||||||
.btn-group-toggle .btn {
|
.btn-group-toggle .btn {
|
||||||
padding: 5px 10px;
|
padding: 5px 10px;
|
||||||
}
|
}
|
||||||
#leftSidebar, .vscode-web, #rightSidebar {
|
|
||||||
height: 100%;
|
|
||||||
overflow: auto;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* 主容器,使用 grid 布局 */
|
/* 主容器,使用 grid 布局 */
|
||||||
#maxcontainer {
|
#maxcontainer {
|
||||||
display: grid;
|
display: grid;
|
||||||
@@ -122,7 +116,20 @@
|
|||||||
|
|
||||||
/* 各区域基础样式 */
|
/* 各区域基础样式 */
|
||||||
.sidebar {
|
.sidebar {
|
||||||
overflow: auto; /* 确保内容可以滚动 */
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
overflow: hidden; /* 隐藏溢出内容,让内部元素单独滚动 */
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 左侧边栏样式 */
|
||||||
|
#leftSidebar {
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 中间和右侧边栏样式 */
|
||||||
|
.vscode-web, #rightSidebar {
|
||||||
|
height: 100%;
|
||||||
|
overflow: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
.vscode-web {
|
.vscode-web {
|
||||||
@@ -162,55 +169,75 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Markdown内容区域样式 */
|
||||||
|
#markdown-content {
|
||||||
|
flex: 1; /* 占满剩余空间 */
|
||||||
|
overflow-y: auto; /* 只有内容区域可以垂直滚动 */
|
||||||
|
overflow-x: hidden; /* 隐藏水平滚动条 */
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 设置进度条容器样式 */
|
||||||
|
#markdown-content-process {
|
||||||
|
display: flex;
|
||||||
|
align-items: flex-end; /* 让进度条靠底部对齐 */
|
||||||
|
padding: 0 10px 10px 10px; /* 添加底部内边距,调整与底部的距离 */
|
||||||
|
box-sizing: border-box;
|
||||||
|
flex-shrink: 0; /* 防止进度条被压缩 */
|
||||||
|
}
|
||||||
|
|
||||||
/* 设置每个子框的基本样式 */
|
/* 设置每个子框的基本样式 */
|
||||||
.progress-box {
|
.progress-box {
|
||||||
height: 100%; /* 高度为 100%,撑满容器 */
|
width: 100%; /* 宽度为 100%,撑满容器 */
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: row; /* 使子框横向排列 */
|
flex-direction: row; /* 使子框横向排列 */
|
||||||
justify-content: flex-start;
|
justify-content: flex-start;
|
||||||
|
gap: 2px; /* 进度条之间的间距 */
|
||||||
|
margin-bottom: 0; /* 移除底部边距 */
|
||||||
}
|
}
|
||||||
|
|
||||||
.progress-title {
|
.progress-title {
|
||||||
height: 60px;
|
height: 8px; /* 更细的进度条 */
|
||||||
text-align: center;
|
flex: 1; /* 均匀分配宽度 */
|
||||||
line-height: 60px;
|
border-radius: 4px; /* 圆角设计,更扁平化 */
|
||||||
margin-right: 2px;
|
transition: all 0.3s ease; /* 平滑过渡效果 */
|
||||||
border: 1px solid #ddd;
|
|
||||||
transition: background-color 0.3s ease;
|
|
||||||
position: relative;
|
position: relative;
|
||||||
|
cursor: pointer;
|
||||||
/* 新增以下属性实现文字溢出省略 */
|
box-shadow: 0 1px 3px rgba(0,0,0,0.1); /* 轻微阴影,增加层次感 */
|
||||||
white-space: nowrap; /* 防止文字换行 */
|
overflow: visible; /* 允许文字溢出 */
|
||||||
overflow: hidden; /* 隐藏溢出内容 */
|
|
||||||
text-overflow: ellipsis; /* 溢出部分显示为省略号 */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* 颜色方案:已学习为蓝色,当前学习为绿色,未学习为白色 */
|
||||||
|
.blue {
|
||||||
|
background-color: #007bff; /* 蓝色 - 已学习 */
|
||||||
|
}
|
||||||
|
|
||||||
.green {
|
.green {
|
||||||
background-color: green;
|
background-color: #28a745; /* 绿色 - 当前学习 */
|
||||||
color: white;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.white {
|
.white {
|
||||||
background-color: white;
|
background-color: #e9ecef; /* 浅灰色 - 未学习,比纯白色更美观 */
|
||||||
color: black;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.progress-box > .progress-title:last-child {
|
/* 进度条悬停效果 */
|
||||||
margin-bottom: 0; /* 防止最后一个子框出现多余的间距 */
|
.progress-title:hover {
|
||||||
|
transform: translateY(-1px); /* 轻微上浮效果 */
|
||||||
|
box-shadow: 0 2px 5px rgba(0,0,0,0.2); /* 增强阴影 */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 进度条详细信息的样式 */
|
/* 进度条详细信息的样式 */
|
||||||
#progress-detail {
|
#progress-detail {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 0;
|
|
||||||
left: 0;
|
|
||||||
display: none;
|
display: none;
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
background-color: rgba(0, 0, 0, 0.7);
|
background-color: rgba(0, 0, 0, 0.8);
|
||||||
color: white;
|
color: white;
|
||||||
border-radius: 5px;
|
border-radius: 6px;
|
||||||
max-width: 200px;
|
max-width: 200px;
|
||||||
|
font-size: 14px;
|
||||||
|
z-index: 1000;
|
||||||
|
pointer-events: none; /* 防止干扰鼠标事件 */
|
||||||
|
box-shadow: 0 2px 10px rgba(0,0,0,0.3); /* 增强阴影 */
|
||||||
}
|
}
|
||||||
|
|
||||||
.button {
|
.button {
|
||||||
|
|||||||
51
Html/apps/static/css/helpTip.css
Normal file
51
Html/apps/static/css/helpTip.css
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
/* HelpTip 组件样式 */
|
||||||
|
|
||||||
|
/* 问号图标样式 */
|
||||||
|
.help-icon {
|
||||||
|
display: inline-block;
|
||||||
|
margin-left: 8px;
|
||||||
|
color: #888;
|
||||||
|
font-weight: bold;
|
||||||
|
cursor: help;
|
||||||
|
font-size: 14px;
|
||||||
|
line-height: 1;
|
||||||
|
transition: color 0.2s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.help-icon:hover {
|
||||||
|
color: #4CAF50;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 全局提示框样式(挂在 body 下) */
|
||||||
|
.tooltip-portal {
|
||||||
|
position: fixed; /* 不受父级 overflow 影响 */
|
||||||
|
left: 0;
|
||||||
|
top: 0;
|
||||||
|
z-index: 999999; /* 足够高,覆盖所有元素 */
|
||||||
|
display: none;
|
||||||
|
opacity: 0;
|
||||||
|
transition: opacity 0.08s linear;
|
||||||
|
|
||||||
|
background: rgba(0, 0, 0, 0.9);
|
||||||
|
color: #fff;
|
||||||
|
padding: 6px 10px;
|
||||||
|
border-radius: 6px;
|
||||||
|
font-size: 13px;
|
||||||
|
line-height: 1.4;
|
||||||
|
pointer-events: none; /* 鼠标穿透,避免闪烁 */
|
||||||
|
white-space: pre-wrap; /* 支持换行符 */
|
||||||
|
max-width: 300px;
|
||||||
|
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
|
||||||
|
word-wrap: break-word;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 提示框显示状态 */
|
||||||
|
.tooltip-portal.show {
|
||||||
|
display: block;
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 提示框动画效果 */
|
||||||
|
.tooltip-portal.fade {
|
||||||
|
transition: opacity 0.2s ease;
|
||||||
|
}
|
||||||
@@ -1,35 +1,3 @@
|
|||||||
/* 问号图标 */
|
|
||||||
.help-icon {
|
|
||||||
display: inline-block;
|
|
||||||
margin-left: 8px;
|
|
||||||
color: #888;
|
|
||||||
font-weight: bold;
|
|
||||||
cursor: help;
|
|
||||||
}
|
|
||||||
.help-icon:hover { color: #4CAF50; }
|
|
||||||
|
|
||||||
/* Portal Tooltip(挂在 body 下) */
|
|
||||||
.tooltip-portal {
|
|
||||||
position: fixed; /* 不受父级 overflow 影响 */
|
|
||||||
left: 0; top: 0;
|
|
||||||
z-index: 999999; /* 足够高,覆盖侧栏等 */
|
|
||||||
display: none;
|
|
||||||
opacity: 0;
|
|
||||||
transition: opacity .08s linear;
|
|
||||||
|
|
||||||
background: rgba(0,0,0,.9);
|
|
||||||
color: #fff;
|
|
||||||
padding: 6px 10px;
|
|
||||||
border-radius: 6px;
|
|
||||||
font-size: 13px;
|
|
||||||
line-height: 1.4;
|
|
||||||
pointer-events: none; /* 鼠标穿透,避免闪烁 */
|
|
||||||
white-space: nowrap;
|
|
||||||
box-shadow: 0 4px 12px rgba(0,0,0,.25);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
.add-step-btn, .add-phase-btn {
|
.add-step-btn, .add-phase-btn {
|
||||||
background-color: #4CAF50;
|
background-color: #4CAF50;
|
||||||
color: white;
|
color: white;
|
||||||
|
|||||||
@@ -3,13 +3,28 @@
|
|||||||
background: linear-gradient(135deg, var(--primary-blue), var(--accent-blue));
|
background: linear-gradient(135deg, var(--primary-blue), var(--accent-blue));
|
||||||
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
|
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
|
||||||
padding: 0.8rem 1rem;
|
padding: 0.8rem 1rem;
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
flex-wrap: wrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
.navbar .logo h1 {
|
.navbar .logo h1 {
|
||||||
color: rgb(245, 245, 245);
|
color: rgb(245, 245, 245);
|
||||||
|
font-size: 18px;
|
||||||
font-size: 24px;
|
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
|
margin: 0;
|
||||||
|
white-space: nowrap;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
max-width: 300px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.navbar-links {
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
flex: 1;
|
||||||
|
margin: 0 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.navbar-links a {
|
.navbar-links a {
|
||||||
@@ -70,3 +85,40 @@
|
|||||||
.dropdown:hover .dropdown-content {
|
.dropdown:hover .dropdown-content {
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* 响应式设计 */
|
||||||
|
@media (max-width: 768px) {
|
||||||
|
.navbar {
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.navbar-links {
|
||||||
|
margin: 0;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
justify-content: center;
|
||||||
|
gap: 0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.navbar-links a {
|
||||||
|
margin: 0 0.75rem;
|
||||||
|
font-size: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.navbar .logo h1 {
|
||||||
|
font-size: 16px;
|
||||||
|
max-width: 250px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 480px) {
|
||||||
|
.navbar .logo h1 {
|
||||||
|
font-size: 14px;
|
||||||
|
max-width: 200px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.navbar-links a {
|
||||||
|
margin: 0 0.5rem;
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,6 +2,57 @@
|
|||||||
var socket;
|
var socket;
|
||||||
let system_message_idx = 0
|
let system_message_idx = 0
|
||||||
const activeApprovals = {};
|
const activeApprovals = {};
|
||||||
|
let chatManager; // 全局聊天管理器实例
|
||||||
|
|
||||||
|
// 聊天消息管理器 - 更现代的数据结构
|
||||||
|
class ChatMessageManager {
|
||||||
|
constructor() {
|
||||||
|
this.chatbox = document.getElementById('chatbox');
|
||||||
|
this.messageTemplate = {
|
||||||
|
user: `<div class="chat-message user-message"><b>你:</b> {{content}}</div>`,
|
||||||
|
assistant: `<div><b>华实君:</b></div><div class="chat-message server-message"> {{content}}</div>`
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
// 渲染单个消息
|
||||||
|
renderMessage(message) {
|
||||||
|
let html;
|
||||||
|
let content;
|
||||||
|
|
||||||
|
// 处理不同的数据格式
|
||||||
|
if (typeof message === 'string') {
|
||||||
|
// 旧格式:直接字符串
|
||||||
|
content = marked.parse(message);
|
||||||
|
html = this.messageTemplate.assistant.replace('{{content}}', content);
|
||||||
|
} else if (typeof message === 'object' && message !== null) {
|
||||||
|
// 新格式:{role, content} 对象
|
||||||
|
content = marked.parse(message.content);
|
||||||
|
if (message.role === 'user') {
|
||||||
|
html = this.messageTemplate.user.replace('{{content}}', content);
|
||||||
|
} else {
|
||||||
|
html = this.messageTemplate.assistant.replace('{{content}}', content);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (html) {
|
||||||
|
const messageDiv = document.createElement('div');
|
||||||
|
messageDiv.innerHTML = html;
|
||||||
|
this.chatbox.appendChild(messageDiv);
|
||||||
|
this.scrollToBottom();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 渲染多条消息(用于恢复历史)
|
||||||
|
renderMessages(messages) {
|
||||||
|
messages.forEach(message => this.renderMessage(message));
|
||||||
|
}
|
||||||
|
|
||||||
|
// 滚动到底部
|
||||||
|
scrollToBottom() {
|
||||||
|
this.chatbox.scrollTop = this.chatbox.scrollHeight;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 清理过期的批准记录
|
// 清理过期的批准记录
|
||||||
function cleanupExpiredApprovals() {
|
function cleanupExpiredApprovals() {
|
||||||
const now = Date.now();
|
const now = Date.now();
|
||||||
@@ -24,6 +75,10 @@ document.addEventListener('DOMContentLoaded', function () {
|
|||||||
folder: data.folder
|
folder: data.folder
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 初始化聊天消息管理器
|
||||||
|
chatManager = new ChatMessageManager();
|
||||||
|
|
||||||
socket.on('connect', function () {
|
socket.on('connect', function () {
|
||||||
console.log('Connected to server');
|
console.log('Connected to server');
|
||||||
socket.emit('login',JSON.stringify(data));
|
socket.emit('login',JSON.stringify(data));
|
||||||
@@ -38,12 +93,13 @@ document.addEventListener('DOMContentLoaded', function () {
|
|||||||
input.value += data;
|
input.value += data;
|
||||||
});
|
});
|
||||||
socket.on('message', function (data) {
|
socket.on('message', function (data) {
|
||||||
// 显示服务器的回复消息
|
// 显示服务器的回复消息 - 单个消息
|
||||||
const serverMessage = document.createElement('div');
|
chatManager.renderMessage(data);
|
||||||
serverMessage.innerHTML = `<div><b>华实君:</b></div><div class="chat-message server-message"> ${marked.parse(data)}</div>`;
|
});
|
||||||
document.getElementById('chatbox').appendChild(serverMessage);
|
|
||||||
// 滚动到最新消息
|
socket.on('messages', function (data) {
|
||||||
document.getElementById('chatbox').scrollTop = document.getElementById('chatbox').scrollHeight;
|
// 显示服务器发送的消息列表 - 用于恢复对话历史
|
||||||
|
chatManager.renderMessages(data);
|
||||||
});
|
});
|
||||||
socket.on('message-hint', function(data){
|
socket.on('message-hint', function(data){
|
||||||
console.log('get message-hint');
|
console.log('get message-hint');
|
||||||
@@ -90,7 +146,7 @@ document.addEventListener('DOMContentLoaded', function () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const approveButton = document.createElement('button');
|
const approveButton = document.createElement('button');
|
||||||
approveButton.innerHTML = '<i class="fas fa-check-circle-check"></i>';
|
approveButton.innerHTML = '<i class="bi bi-check-circle-fill"></i>';
|
||||||
approveButton.data = element;
|
approveButton.data = element;
|
||||||
approveButton.className = 'approve-button';
|
approveButton.className = 'approve-button';
|
||||||
approveButton.onclick = function (event) {
|
approveButton.onclick = function (event) {
|
||||||
@@ -210,22 +266,14 @@ function sendMessage() {
|
|||||||
const input = document.getElementById('messageInput').value;
|
const input = document.getElementById('messageInput').value;
|
||||||
if (input.trim() === '') return;
|
if (input.trim() === '') return;
|
||||||
|
|
||||||
// 使用 marked.js 解析 markdown
|
|
||||||
const markdownHtml = marked.parse(input);
|
|
||||||
|
|
||||||
// 显示用户发送的消息
|
|
||||||
const userMessage = document.createElement('div');
|
|
||||||
userMessage.innerHTML = `<div class="chat-message user-message"><b>你:</b> ${markdownHtml}</div>`;
|
|
||||||
document.getElementById('chatbox').appendChild(userMessage);
|
|
||||||
|
|
||||||
// 发送消息到服务器
|
// 发送消息到服务器
|
||||||
socket.emit('message', JSON.stringify({ data: input, type: 'text' }));
|
socket.emit('message', JSON.stringify({ data: input, type: 'text' }));
|
||||||
|
|
||||||
|
// 使用聊天管理器显示用户消息
|
||||||
|
chatManager.renderMessage({ role: 'user', content: input });
|
||||||
|
|
||||||
// 清空输入框
|
// 清空输入框
|
||||||
document.getElementById('messageInput').value = '';
|
document.getElementById('messageInput').value = '';
|
||||||
|
|
||||||
// 滚动到最新消息
|
|
||||||
document.getElementById('chatbox').scrollTop = document.getElementById('chatbox').scrollHeight;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -376,14 +424,11 @@ window.addEventListener('beforeunload', () => {
|
|||||||
|
|
||||||
let currentChapterIndex = -1;
|
let currentChapterIndex = -1;
|
||||||
function next_chapter(data) {
|
function next_chapter(data) {
|
||||||
// 获取所有的 h3 元素
|
var container = document.getElementById('markdown-content-container');
|
||||||
var iframe = document.getElementById('markdown-content-iframe');
|
var titles = [];
|
||||||
|
var h3Elements = container.querySelectorAll('h3');
|
||||||
|
console.log("h3Elements next");
|
||||||
|
|
||||||
// 访问 iframe 的文档对象
|
|
||||||
var iframeDocument = iframe.contentDocument || iframe.contentWindow.document;
|
|
||||||
var titles = []
|
|
||||||
var h3Elements = iframeDocument.querySelectorAll('h3');
|
|
||||||
console.log("h3Elements next")
|
|
||||||
if (currentChapterIndex >= h3Elements.length) {
|
if (currentChapterIndex >= h3Elements.length) {
|
||||||
return; // 如果已经到了最后一个章节,则不进行任何操作
|
return; // 如果已经到了最后一个章节,则不进行任何操作
|
||||||
}
|
}
|
||||||
@@ -391,7 +436,7 @@ function next_chapter(data) {
|
|||||||
// 隐藏当前章节及其后的内容
|
// 隐藏当前章节及其后的内容
|
||||||
for (let i = 0; i < h3Elements.length; i++) {
|
for (let i = 0; i < h3Elements.length; i++) {
|
||||||
h3Elements[i].style.display = 'none';
|
h3Elements[i].style.display = 'none';
|
||||||
titles.push(h3Elements[i].innerText)
|
titles.push(h3Elements[i].innerText);
|
||||||
let nextSibling = h3Elements[i].nextElementSibling;
|
let nextSibling = h3Elements[i].nextElementSibling;
|
||||||
while (nextSibling && nextSibling.tagName !== 'H3') {
|
while (nextSibling && nextSibling.tagName !== 'H3') {
|
||||||
nextSibling.style.display = 'none';
|
nextSibling.style.display = 'none';
|
||||||
@@ -421,48 +466,31 @@ function generateProgressBar(N, idx, titles) {
|
|||||||
const progressBox = document.createElement('div');
|
const progressBox = document.createElement('div');
|
||||||
progressBox.className = 'progress-box';
|
progressBox.className = 'progress-box';
|
||||||
|
|
||||||
// 获取详细信息容器
|
|
||||||
const detailBox = document.getElementById('progress-detail');
|
|
||||||
|
|
||||||
// 根据N值动态调整每个进度节点的宽度
|
|
||||||
const nodeWidth = 100 / N; // 每个节点的宽度为 100% / N
|
|
||||||
|
|
||||||
// 根据N值生成子框并设置颜色
|
// 根据N值生成子框并设置颜色
|
||||||
for (let i = 0; i < N; i++) {
|
for (let i = 0; i < N; i++) {
|
||||||
const titleBox = document.createElement('div');
|
const titleBox = document.createElement('div');
|
||||||
titleBox.className = 'progress-title';
|
titleBox.className = 'progress-title';
|
||||||
|
|
||||||
// 设置进度条的颜色
|
// 设置进度条的颜色:已学习为蓝色,当前学习为绿色,未学习为白色
|
||||||
if (i < idx) {
|
if (i < idx) {
|
||||||
titleBox.classList.add('green'); // 已完成部分
|
titleBox.classList.add('blue'); // 已完成部分 - 蓝色
|
||||||
|
} else if (i === idx) {
|
||||||
|
titleBox.classList.add('green'); // 当前正在学习 - 绿色
|
||||||
} else {
|
} else {
|
||||||
titleBox.classList.add('white'); // 未完成部分
|
titleBox.classList.add('white'); // 未完成部分 - 白色
|
||||||
}
|
}
|
||||||
|
|
||||||
// 设置每个子框的标题
|
// 移除进度条上的文字,因为现在进度条很细
|
||||||
titleBox.innerHTML = titles[i] || `Step ${i + 1}`;
|
titleBox.innerHTML = '';
|
||||||
|
|
||||||
// 设置每个进度节点的宽度
|
// 使用attachImmediateTooltip函数,使提示框跟随鼠标移动
|
||||||
titleBox.style.width = `${nodeWidth}%`;
|
const tooltipText = `Step ${i + 1}: ${titles[i] || "No title"}`;
|
||||||
|
attachImmediateTooltip(titleBox, tooltipText);
|
||||||
// 监听鼠标移入事件来显示详情
|
|
||||||
titleBox.addEventListener('mouseenter', function () {
|
|
||||||
detailBox.innerHTML = `Step ${i + 1}: ${titles[i] || "No title"}`;// - Additional details here...`;
|
|
||||||
detailBox.style.display = 'block';
|
|
||||||
// 根据进度条位置显示详情
|
|
||||||
const rect = titleBox.getBoundingClientRect();
|
|
||||||
detailBox.style.top = `${rect.top + window.scrollY - 100}px`; // 微调位置
|
|
||||||
detailBox.style.left = `${rect.left + window.scrollX + rect.width / 2 - detailBox.offsetWidth / 2}px`;
|
|
||||||
});
|
|
||||||
|
|
||||||
// 监听鼠标移出事件来隐藏详情
|
|
||||||
titleBox.addEventListener('mouseleave', function () {
|
|
||||||
detailBox.style.display = 'none';
|
|
||||||
});
|
|
||||||
|
|
||||||
progressBox.appendChild(titleBox);
|
progressBox.appendChild(titleBox);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 将生成的进度条添加到容器中
|
// 将生成的进度条添加到容器中
|
||||||
container.appendChild(progressBox);
|
container.appendChild(progressBox);
|
||||||
|
|
||||||
}
|
}
|
||||||
58
Html/apps/static/js/helpTip.js
Normal file
58
Html/apps/static/js/helpTip.js
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
// helpTip.js - 全局tooltip功能,可在不同页面复用
|
||||||
|
|
||||||
|
// 在页面里复用一个全局 tooltip 节点
|
||||||
|
let __globalTooltip;
|
||||||
|
|
||||||
|
// 确保tooltip节点存在
|
||||||
|
function ensureTooltip() {
|
||||||
|
if (!__globalTooltip) {
|
||||||
|
__globalTooltip = document.createElement('div');
|
||||||
|
__globalTooltip.className = 'tooltip-portal';
|
||||||
|
document.body.appendChild(__globalTooltip);
|
||||||
|
}
|
||||||
|
return __globalTooltip;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 绑定到任意图标:移入→显示;移动→跟随;移出→隐藏
|
||||||
|
function attachImmediateTooltip(anchorEl, text) {
|
||||||
|
const tip = ensureTooltip();
|
||||||
|
let shown = false;
|
||||||
|
|
||||||
|
function show(e) {
|
||||||
|
tip.textContent = text;
|
||||||
|
tip.style.display = 'block';
|
||||||
|
tip.style.opacity = '1';
|
||||||
|
position(e);
|
||||||
|
shown = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function position(e) {
|
||||||
|
// 以鼠标位置为准
|
||||||
|
const padding = 8;
|
||||||
|
const tipRect = tip.getBoundingClientRect();
|
||||||
|
let x = e.clientX + 12;
|
||||||
|
let y = e.clientY - tipRect.height - 12;
|
||||||
|
|
||||||
|
// 简易防出界
|
||||||
|
const vw = window.innerWidth, vh = window.innerHeight;
|
||||||
|
if (x + tipRect.width + padding > vw) x = vw - tipRect.width - padding;
|
||||||
|
if (y < padding) y = e.clientY + 16; // 放到下面
|
||||||
|
|
||||||
|
tip.style.left = `${x}px`;
|
||||||
|
tip.style.top = `${y}px`;
|
||||||
|
}
|
||||||
|
|
||||||
|
function hide() {
|
||||||
|
tip.style.opacity = '0';
|
||||||
|
// 用小延迟避免闪烁
|
||||||
|
setTimeout(() => { if (!shown) return; tip.style.display = 'none'; }, 100);
|
||||||
|
shown = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
anchorEl.addEventListener('mouseenter', show);
|
||||||
|
anchorEl.addEventListener('mousemove', position);
|
||||||
|
anchorEl.addEventListener('mouseleave', hide);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 导出函数,供其他文件使用
|
||||||
|
window.attachImmediateTooltip = attachImmediateTooltip;
|
||||||
@@ -4,60 +4,6 @@ window.addEventListener('load', ()=>{
|
|||||||
editLesson(window.material.material_id, window.chapter.chapter_name, window.lesson.lesson_name);
|
editLesson(window.material.material_id, window.chapter.chapter_name, window.lesson.lesson_name);
|
||||||
});
|
});
|
||||||
|
|
||||||
// 在页面里复用一个全局 tooltip 节点
|
|
||||||
let __globalTooltip;
|
|
||||||
function ensureTooltip() {
|
|
||||||
if (!__globalTooltip) {
|
|
||||||
__globalTooltip = document.createElement('div');
|
|
||||||
__globalTooltip.className = 'tooltip-portal';
|
|
||||||
document.body.appendChild(__globalTooltip);
|
|
||||||
}
|
|
||||||
return __globalTooltip;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 绑定到任意图标:移入→显示;移动→跟随;移出→隐藏
|
|
||||||
function attachImmediateTooltip(anchorEl, text) {
|
|
||||||
const tip = ensureTooltip();
|
|
||||||
let shown = false;
|
|
||||||
|
|
||||||
function show(e) {
|
|
||||||
tip.textContent = text;
|
|
||||||
tip.style.display = 'block';
|
|
||||||
tip.style.opacity = '1';
|
|
||||||
position(e);
|
|
||||||
shown = true;
|
|
||||||
}
|
|
||||||
function position(e) {
|
|
||||||
// 以鼠标位置为准(也可用 anchorEl.getBoundingClientRect())
|
|
||||||
const padding = 8;
|
|
||||||
const tipRect = tip.getBoundingClientRect();
|
|
||||||
let x = e.clientX + 12;
|
|
||||||
let y = e.clientY - tipRect.height - 12;
|
|
||||||
|
|
||||||
// 简易防出界
|
|
||||||
const vw = window.innerWidth, vh = window.innerHeight;
|
|
||||||
if (x + tipRect.width + padding > vw) x = vw - tipRect.width - padding;
|
|
||||||
if (y < padding) y = e.clientY + 16; // 放到下面
|
|
||||||
|
|
||||||
tip.style.left = `${x}px`;
|
|
||||||
tip.style.top = `${y}px`;
|
|
||||||
}
|
|
||||||
function hide() {
|
|
||||||
tip.style.opacity = '0';
|
|
||||||
// 用小延迟避免闪烁
|
|
||||||
setTimeout(() => { if (!shown) return; tip.style.display = 'none'; }, 100);
|
|
||||||
shown = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
anchorEl.addEventListener('mouseenter', show);
|
|
||||||
anchorEl.addEventListener('mousemove', position);
|
|
||||||
anchorEl.addEventListener('mouseleave', hide);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 你的 renderOutline 里调用:
|
|
||||||
// if (outline.theme) addThemeWithHelp(tree, outline.theme);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -196,6 +142,7 @@ function parseHeadings(mdText) {
|
|||||||
help.className = 'help-icon';
|
help.className = 'help-icon';
|
||||||
help.textContent = ' ?';
|
help.textContent = ' ?';
|
||||||
li.appendChild(help);
|
li.appendChild(help);
|
||||||
|
|
||||||
// 新增:铅笔编辑按钮
|
// 新增:铅笔编辑按钮
|
||||||
const editBtn = createEditButton(() => {
|
const editBtn = createEditButton(() => {
|
||||||
openTitleEditor({
|
openTitleEditor({
|
||||||
|
|||||||
116
Html/apps/static/js/render-desktop-markdown.js
Normal file
116
Html/apps/static/js/render-desktop-markdown.js
Normal file
@@ -0,0 +1,116 @@
|
|||||||
|
// 动态加载 Markdown 文件
|
||||||
|
function loadMarkdown(course_id, chapter_name, lesson_name) {
|
||||||
|
fetch(`/${course_id}-${chapter_name}-${lesson_name}-markdown`)
|
||||||
|
.then(response => response.json())
|
||||||
|
.then(data => {
|
||||||
|
if (data.markdown_content) {
|
||||||
|
// 使用 marked 解析 Markdown 内容
|
||||||
|
const html = marked.parse(data.markdown_content);
|
||||||
|
|
||||||
|
// 创建包含 MathJax 支持的 HTML 结构
|
||||||
|
const markdownContainer = document.createElement('div');
|
||||||
|
markdownContainer.id = 'markdown-content-container';
|
||||||
|
markdownContainer.innerHTML = html;
|
||||||
|
|
||||||
|
// 处理代码块,实现缩略显示
|
||||||
|
const codeBlocks = markdownContainer.querySelectorAll('pre code');
|
||||||
|
codeBlocks.forEach(codeBlock => {
|
||||||
|
const preBlock = codeBlock.parentElement;
|
||||||
|
|
||||||
|
// 保存原始代码内容
|
||||||
|
const originalContent = preBlock.innerHTML;
|
||||||
|
|
||||||
|
// 创建缩略提示元素
|
||||||
|
const codeHint = document.createElement('div');
|
||||||
|
codeHint.className = 'code-hint';
|
||||||
|
codeHint.innerHTML = '<div style="padding: 10px; background-color: #f5f5f5; border: 1px solid #ddd; border-radius: 4px; color: #666; font-size: 14px; text-align: center;">💡 代码已放置在代码区中,点击展开查看</div>';
|
||||||
|
|
||||||
|
// 创建展开/折叠按钮
|
||||||
|
const toggleButton = document.createElement('button');
|
||||||
|
toggleButton.className = 'toggle-code';
|
||||||
|
toggleButton.innerHTML = '展开代码';
|
||||||
|
toggleButton.style.cssText = 'margin: 5px; padding: 5px 10px; background-color: #007bff; color: white; border: none; border-radius: 3px; cursor: pointer; font-size: 12px;';
|
||||||
|
|
||||||
|
// 添加到提示元素中
|
||||||
|
codeHint.appendChild(toggleButton);
|
||||||
|
|
||||||
|
// 替换原始代码块为提示
|
||||||
|
preBlock.innerHTML = '';
|
||||||
|
preBlock.appendChild(codeHint);
|
||||||
|
|
||||||
|
// 保存原始代码,用于切换
|
||||||
|
preBlock.dataset.originalContent = originalContent;
|
||||||
|
preBlock.dataset.isExpanded = 'false';
|
||||||
|
|
||||||
|
// 添加切换事件
|
||||||
|
toggleButton.addEventListener('click', () => {
|
||||||
|
if (preBlock.dataset.isExpanded === 'false') {
|
||||||
|
// 展开代码
|
||||||
|
preBlock.innerHTML = preBlock.dataset.originalContent;
|
||||||
|
toggleButton.innerHTML = '折叠代码';
|
||||||
|
preBlock.appendChild(toggleButton);
|
||||||
|
preBlock.dataset.isExpanded = 'true';
|
||||||
|
// 如果MathJax已加载,重新排版
|
||||||
|
if (typeof MathJax !== 'undefined') {
|
||||||
|
MathJax.typesetPromise([preBlock]);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 折叠代码
|
||||||
|
preBlock.innerHTML = '';
|
||||||
|
preBlock.appendChild(codeHint.cloneNode(true));
|
||||||
|
preBlock.appendChild(toggleButton.cloneNode(true));
|
||||||
|
preBlock.dataset.isExpanded = 'false';
|
||||||
|
// 重新添加事件监听
|
||||||
|
const newToggleButton = preBlock.querySelector('.toggle-code');
|
||||||
|
newToggleButton.addEventListener('click', arguments.callee);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// 清空内容容器并添加渲染后的内容
|
||||||
|
const contentElement = document.getElementById('markdown-content');
|
||||||
|
contentElement.innerHTML = '';
|
||||||
|
contentElement.appendChild(markdownContainer);
|
||||||
|
|
||||||
|
// 配置并加载 MathJax
|
||||||
|
if (typeof MathJax === 'undefined') {
|
||||||
|
// 动态加载 MathJax
|
||||||
|
const script = document.createElement('script');
|
||||||
|
script.src = '/static/cdnback/js/tex-mml-chtml.js';
|
||||||
|
script.async = true;
|
||||||
|
script.onload = function() {
|
||||||
|
MathJax.config = {
|
||||||
|
tex: {
|
||||||
|
inlineMath: [['$', '$'], ['\\(', '\\)']]
|
||||||
|
},
|
||||||
|
svg: {
|
||||||
|
fontCache: 'global'
|
||||||
|
}
|
||||||
|
};
|
||||||
|
MathJax.typesetPromise([markdownContainer]);
|
||||||
|
// 初始化课程进度
|
||||||
|
next_chapter();
|
||||||
|
};
|
||||||
|
document.head.appendChild(script);
|
||||||
|
} else {
|
||||||
|
// MathJax 已加载,直接排版
|
||||||
|
MathJax.typesetPromise([markdownContainer]);
|
||||||
|
// 初始化课程进度
|
||||||
|
next_chapter();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
console.error('Markdown file not found');
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.error('Error loading markdown:', error);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// 文档加载完成后初始化
|
||||||
|
document.addEventListener('DOMContentLoaded', function() {
|
||||||
|
// 从全局变量获取课程信息
|
||||||
|
if (window.appData) {
|
||||||
|
loadMarkdown(window.appData.course_id, window.appData.chapter_name, window.appData.lesson_name);
|
||||||
|
}
|
||||||
|
});
|
||||||
@@ -8,6 +8,7 @@
|
|||||||
</style>
|
</style>
|
||||||
<link rel="stylesheet" href="/static/css/desktop.css">
|
<link rel="stylesheet" href="/static/css/desktop.css">
|
||||||
<link rel="stylesheet" href="/static/css/chatbox_approve_icon.css">
|
<link rel="stylesheet" href="/static/css/chatbox_approve_icon.css">
|
||||||
|
<link rel="stylesheet" href="/static/css/helpTip.css">
|
||||||
<script>
|
<script>
|
||||||
document.cookie = "vscode-tkn=44edc269-6f88-46ab-9790-dc253f66ac36; path=/; SameSite=None; Secure";
|
document.cookie = "vscode-tkn=44edc269-6f88-46ab-9790-dc253f66ac36; path=/; SameSite=None; Secure";
|
||||||
</script>
|
</script>
|
||||||
@@ -140,9 +141,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<script src="/static/js/process_show_floating_window.js"></script>
|
<script src="/static/js/process_show_floating_window.js"></script>
|
||||||
|
<script src="/static/js/helpTip.js"></script>
|
||||||
|
|
||||||
|
|
||||||
<script src="/static/js/chatbox.js"></script>
|
<script src="/static/js/chatbox.js"></script>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
@@ -193,7 +192,6 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 使用 fetch 发送请求到 Flask 服务器,获取 session 信息
|
// 使用 fetch 发送请求到 Flask 服务器,获取 session 信息
|
||||||
fetch('/get_session', {
|
fetch('/get_session', {
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
@@ -230,31 +228,6 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// 动态加载 Markdown 文件
|
|
||||||
function loadMarkdown(course_id, chapter_name, lesson_name) {
|
|
||||||
fetch(`/${course_id}-${chapter_name}-${lesson_name}-markdown`)
|
|
||||||
.then(response => response.json())
|
|
||||||
.then(data => {
|
|
||||||
if (data.html_url) {
|
|
||||||
document.getElementById('markdown-content').innerHTML = `<iframe id="markdown-content-iframe" src="${data.html_url}"style="width: 100%;height: 100%;"></iframe>`;
|
|
||||||
document.getElementById('markdown-content-iframe').addEventListener('load', function() {
|
|
||||||
// 在这里执行你想要的操作
|
|
||||||
console.log('Iframe has finished loading');
|
|
||||||
next_chapter();
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
console.error('Markdown file not found');
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.catch(error => {
|
|
||||||
console.error('Error loading markdown:', error);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
document.addEventListener('DOMContentLoaded', function() {
|
|
||||||
loadMarkdown('{{course_id}}','{{chapter_name}}','{{lesson_name}}');
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
// 侧边工具栏切换
|
// 侧边工具栏切换
|
||||||
const sidebarTools = document.getElementById('sidebarTools');
|
const sidebarTools = document.getElementById('sidebarTools');
|
||||||
const toggleButton = document.getElementById('toggleButton');
|
const toggleButton = document.getElementById('toggleButton');
|
||||||
@@ -270,5 +243,7 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
<!-- 引入 Markdown 渲染脚本 -->
|
||||||
|
<script src="/static/js/render-desktop-markdown.js"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -61,6 +61,15 @@
|
|||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="confirm-container">
|
<div class="confirm-container">
|
||||||
|
{% if is_course_finished %}
|
||||||
|
<h1>重新学习确认</h1>
|
||||||
|
<p>您已经完成了该课程的学习,是否要重新开始学习?</p>
|
||||||
|
<div class="btn-group">
|
||||||
|
<a href="{{ url_for('vscode.desktop', user_uuid=user_uuid, course_id=course_id, chapter_name=chapter_name, lesson_name=lesson_name, load_history='false') }}" class="btn btn-primary">
|
||||||
|
重新开始学习
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
{% else %}
|
||||||
<h1>加载历史数据确认</h1>
|
<h1>加载历史数据确认</h1>
|
||||||
<p>您即将进入学习环境,是否需要加载您之前的对话历史记录和学习进度数据?</p>
|
<p>您即将进入学习环境,是否需要加载您之前的对话历史记录和学习进度数据?</p>
|
||||||
<div class="btn-group">
|
<div class="btn-group">
|
||||||
@@ -71,6 +80,7 @@
|
|||||||
否,重新开始
|
否,重新开始
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
@@ -8,6 +8,7 @@
|
|||||||
<link rel="stylesheet" href="/static/css/teacherboard.css">
|
<link rel="stylesheet" href="/static/css/teacherboard.css">
|
||||||
<link rel="stylesheet" href="/static/css/dashboard.css">
|
<link rel="stylesheet" href="/static/css/dashboard.css">
|
||||||
<link rel="stylesheet" href="/static/css/lesson.css">
|
<link rel="stylesheet" href="/static/css/lesson.css">
|
||||||
|
<link rel="stylesheet" href="/static/css/helpTip.css">
|
||||||
<link rel="stylesheet" href="/static/css/teacher_course_setting.css">
|
<link rel="stylesheet" href="/static/css/teacher_course_setting.css">
|
||||||
<link rel="stylesheet" href="/static/css/lesson_setting.css">
|
<link rel="stylesheet" href="/static/css/lesson_setting.css">
|
||||||
<link rel="stylesheet" href="/static/css/modelinput.css">
|
<link rel="stylesheet" href="/static/css/modelinput.css">
|
||||||
@@ -100,6 +101,7 @@
|
|||||||
<script src="/static/js/teacherboard.js"></script>
|
<script src="/static/js/teacherboard.js"></script>
|
||||||
<script src="/static/js/teacher_course_setting.js"></script>
|
<script src="/static/js/teacher_course_setting.js"></script>
|
||||||
<script src="/static/js/lesson_markdown.js"></script>
|
<script src="/static/js/lesson_markdown.js"></script>
|
||||||
|
<script src="/static/js/helpTip.js"></script>
|
||||||
<script src="/static/js/lesson.js"></script>
|
<script src="/static/js/lesson.js"></script>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
<link rel="stylesheet" href="/static/css/navbar.css">
|
|
||||||
|
|
||||||
<link rel="stylesheet" href="/static/cdnback/all.min.css">
|
<link rel="stylesheet" href="/static/cdnback/all.min.css">
|
||||||
<link rel="stylesheet" href="/static/css/dashboard.css">
|
<link rel="stylesheet" href="/static/css/dashboard.css">
|
||||||
|
<link rel="stylesheet" href="/static/css/navbar.css">
|
||||||
<header class="navbar">
|
<header class="navbar">
|
||||||
<div class="logo">
|
<div class="logo">
|
||||||
<h1>华实学伴:教学练评一体的虚拟助教</h1>
|
<h1>华实学伴:教学练评一体的虚拟助教</h1>
|
||||||
|
|||||||
@@ -14,17 +14,8 @@ bp = Blueprint("markdown", __name__)
|
|||||||
def convert_md(course_id, chapter_name, lesson_name):
|
def convert_md(course_id, chapter_name, lesson_name):
|
||||||
print(f"convert_md: {course_id}, {chapter_name}, {lesson_name}")
|
print(f"convert_md: {course_id}, {chapter_name}, {lesson_name}")
|
||||||
md_file = load_markdown_file(course_id, chapter_name, lesson_name)
|
md_file = load_markdown_file(course_id, chapter_name, lesson_name)
|
||||||
# 配置Markdown解析器,启用数学公式支持
|
# 直接返回Markdown源文件内容,不进行服务器端渲染
|
||||||
md = MarkdownIt()
|
return jsonify({"markdown_content": md_file})
|
||||||
md.use(texmath.texmath_plugin) # 添加数学公式插件
|
|
||||||
# 转换markdown为html(包含公式标记)
|
|
||||||
html = md.render(md_file)
|
|
||||||
# 包装样式时添加MathJax支持,用于在浏览器中渲染公式
|
|
||||||
html_with_styles = wrap_with_styles(html)
|
|
||||||
# 保存HTML文件到static
|
|
||||||
html_output_path = os.path.join(current_app.config["STATIC_DIR"], f"{course_id}-{chapter_name}-{lesson_name}.html")
|
|
||||||
save_html(html_with_styles, html_output_path)
|
|
||||||
return jsonify({"html_url": f"/static/{course_id}-{chapter_name}-{lesson_name}.html"})
|
|
||||||
|
|
||||||
# 提供静态文件访问
|
# 提供静态文件访问
|
||||||
@bp.route("/static/<path:filename>")
|
@bp.route("/static/<path:filename>")
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ from ..services.backboard_service import realtime_response
|
|||||||
from ..extension_ase.ase_client.manager import ChatManager
|
from ..extension_ase.ase_client.manager import ChatManager
|
||||||
import subprocess
|
import subprocess
|
||||||
from ..auth.decorators import require_role
|
from ..auth.decorators import require_role
|
||||||
|
from ..services.course_service import load_learning_progress
|
||||||
|
|
||||||
bp = Blueprint("vscode", __name__)
|
bp = Blueprint("vscode", __name__)
|
||||||
|
|
||||||
@@ -19,11 +20,14 @@ def desktop(user_uuid, course_id, chapter_name, lesson_name):
|
|||||||
return redirect(url_for("auth.login"))
|
return redirect(url_for("auth.login"))
|
||||||
|
|
||||||
# 检查是否有 load_history 参数
|
# 检查是否有 load_history 参数
|
||||||
load_history = request.args.get('load_history')
|
load_history_str = request.args.get('load_history')
|
||||||
if load_history is None:
|
if load_history_str is None:
|
||||||
# 如果没有参数,跳转到确认页面
|
# 如果没有参数,跳转到确认页面
|
||||||
return redirect(url_for("vscode.desktop_nouser", course_id=course_id, chapter_name=chapter_name, lesson_name=lesson_name))
|
return redirect(url_for("vscode.desktop_nouser", course_id=course_id, chapter_name=chapter_name, lesson_name=lesson_name))
|
||||||
|
|
||||||
|
# 将字符串转换为布尔值
|
||||||
|
load_history = load_history_str.lower() == 'true'
|
||||||
|
|
||||||
# 全局映射
|
# 全局映射
|
||||||
user_id = uuid2username[user_uuid]
|
user_id = uuid2username[user_uuid]
|
||||||
userid_recorder[f"{user_id}&{course_id}"] = session["user_uuid"]
|
userid_recorder[f"{user_id}&{course_id}"] = session["user_uuid"]
|
||||||
@@ -66,7 +70,6 @@ def desktop(user_uuid, course_id, chapter_name, lesson_name):
|
|||||||
|
|
||||||
|
|
||||||
chatmanager = ChatManager(restart=not load_history)
|
chatmanager = ChatManager(restart=not load_history)
|
||||||
print(f"now user uuid {user_uuid}")
|
|
||||||
current_app.extensions["user_uuid2chatmanager"][user_uuid] = chatmanager
|
current_app.extensions["user_uuid2chatmanager"][user_uuid] = chatmanager
|
||||||
code_server_port = 10000 + int(uuid.uuid4().int % 10000)
|
code_server_port = 10000 + int(uuid.uuid4().int % 10000)
|
||||||
# chatmanager.start_code_server(user_uuid, user_id, path_dir, code_server_port)
|
# chatmanager.start_code_server(user_uuid, user_id, path_dir, code_server_port)
|
||||||
@@ -147,13 +150,33 @@ def desktop(user_uuid, course_id, chapter_name, lesson_name):
|
|||||||
def desktop_nouser(course_id, chapter_name, lesson_name):
|
def desktop_nouser(course_id, chapter_name, lesson_name):
|
||||||
if "user_uuid" not in session:
|
if "user_uuid" not in session:
|
||||||
return redirect(url_for("auth.login")) # 如果你有 auth 蓝图
|
return redirect(url_for("auth.login")) # 如果你有 auth 蓝图
|
||||||
|
|
||||||
user_uuid = session["user_uuid"]
|
user_uuid = session["user_uuid"]
|
||||||
|
uuid2username = current_app.extensions["uuid2username"]
|
||||||
|
user_id = uuid2username[user_uuid]
|
||||||
|
|
||||||
|
# 检查是否有学习记录
|
||||||
|
progress_result = load_learning_progress(user_id, course_id, chapter_name, lesson_name)
|
||||||
|
|
||||||
|
if not progress_result["exists"]:
|
||||||
|
# 没有学习记录,直接跳转到学习页面,不显示确认加载历史的页面
|
||||||
|
return redirect(url_for("vscode.desktop", user_uuid=user_uuid, course_id=course_id, chapter_name=chapter_name, lesson_name=lesson_name, load_history="false"))
|
||||||
|
|
||||||
|
# 获取学习记录数据
|
||||||
|
progress_data = progress_result["data"]
|
||||||
|
chapter_chain_now = progress_data.get("chapter_chain_now", -1)
|
||||||
|
chapter_chain_length = progress_data.get("chapter_chain_length", 0)
|
||||||
|
|
||||||
|
# 检查是否已经学完所有章节
|
||||||
|
is_course_finished = chapter_chain_now >= chapter_chain_length - 1
|
||||||
|
|
||||||
return render_template(
|
return render_template(
|
||||||
"confirm_load_history.html",
|
"confirm_load_history.html",
|
||||||
user_uuid=user_uuid,
|
user_uuid=user_uuid,
|
||||||
course_id=course_id,
|
course_id=course_id,
|
||||||
chapter_name=chapter_name,
|
chapter_name=chapter_name,
|
||||||
lesson_name=lesson_name
|
lesson_name=lesson_name,
|
||||||
|
is_course_finished=is_course_finished
|
||||||
)
|
)
|
||||||
|
|
||||||
@bp.route("/vscode_data", methods=["POST"])
|
@bp.route("/vscode_data", methods=["POST"])
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ def read_and_forward_pty_output(fd=None, pid=None, room_id=None,namespace=None):
|
|||||||
"""
|
"""
|
||||||
max_read_bytes = 1024 * 20
|
max_read_bytes = 1024 * 20
|
||||||
timeout=0.1
|
timeout=0.1
|
||||||
|
try:
|
||||||
while True:
|
while True:
|
||||||
socketio.sleep(timeout)
|
socketio.sleep(timeout)
|
||||||
timeout=min(timeout*2, 0.4)
|
timeout=min(timeout*2, 0.4)
|
||||||
@@ -48,8 +49,21 @@ def read_and_forward_pty_output(fd=None, pid=None, room_id=None,namespace=None):
|
|||||||
try:
|
try:
|
||||||
child_process = psutil.Process(pid)
|
child_process = psutil.Process(pid)
|
||||||
except psutil.NoSuchProcess as err:
|
except psutil.NoSuchProcess as err:
|
||||||
|
# Process already terminated, clean up any zombie
|
||||||
|
try:
|
||||||
|
os.waitpid(pid, os.WNOHANG)
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
return
|
return
|
||||||
if child_process.status() not in ('running', 'sleeping'):
|
if child_process.status() not in ('running', 'sleeping'):
|
||||||
|
# Process is terminated or in other state, clean up
|
||||||
|
try:
|
||||||
|
child_process.wait(timeout=1)
|
||||||
|
except Exception:
|
||||||
|
try:
|
||||||
|
os.waitpid(pid, os.WNOHANG)
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
return
|
return
|
||||||
if fd:
|
if fd:
|
||||||
timeout_sec = 0
|
timeout_sec = 0
|
||||||
@@ -68,6 +82,13 @@ def read_and_forward_pty_output(fd=None, pid=None, room_id=None,namespace=None):
|
|||||||
# the key for different visitor to get different terminal (instead of mixing up)
|
# 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!
|
# is to let the background task push pty response to each one's own (default) ROOM!
|
||||||
namespace.emit("pty_output", {"output": output}, room=room_id)
|
namespace.emit("pty_output", {"output": output}, room=room_id)
|
||||||
|
finally:
|
||||||
|
# Clean up file descriptor if it's open
|
||||||
|
if fd:
|
||||||
|
try:
|
||||||
|
os.close(fd)
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
|
||||||
class VSCLikeNameSpace(Namespace):
|
class VSCLikeNameSpace(Namespace):
|
||||||
def on_connect(self):
|
def on_connect(self):
|
||||||
@@ -156,15 +177,40 @@ class VSCLikeNameSpace(Namespace):
|
|||||||
set_winsize(fd, data["rows"], data["cols"])
|
set_winsize(fd, data["rows"], data["cols"])
|
||||||
|
|
||||||
def on_disconnect(self):
|
def on_disconnect(self):
|
||||||
|
child_pid = session.get('terminal_config', {}).get('child_pid')
|
||||||
|
if child_pid:
|
||||||
try:
|
try:
|
||||||
child_process = psutil.Process(session.get('terminal_config', {}).get('child_pid'))
|
child_process = psutil.Process(child_pid)
|
||||||
except psutil.NoSuchProcess as err:
|
|
||||||
disconnect()
|
|
||||||
session['terminal_config'] = TERM_INIT_CONFIG
|
|
||||||
return
|
|
||||||
if child_process.status() in ('running', 'sleeping'):
|
if child_process.status() in ('running', 'sleeping'):
|
||||||
# if visitor just close the browser tab then left alone the pty here
|
# if visitor just close the browser tab then left alone the pty here
|
||||||
# it should be terminated by the parent process after
|
# it should be terminated by the parent process after
|
||||||
child_process.terminate()
|
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
|
||||||
|
child_process.kill()
|
||||||
|
try:
|
||||||
|
child_process.wait(timeout=1)
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
except Exception as err:
|
||||||
|
current_app.logger.error(f'Error terminating process: {err}')
|
||||||
|
finally:
|
||||||
|
# Close the file descriptor if it's open
|
||||||
|
fd = session.get('terminal_config', {}).get('fd')
|
||||||
|
if fd:
|
||||||
|
try:
|
||||||
|
os.close(fd)
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
# Reset session config
|
||||||
|
session['terminal_config'] = TERM_INIT_CONFIG
|
||||||
current_app.logger.debug('Client disconnected')
|
current_app.logger.debug('Client disconnected')
|
||||||
@@ -4,17 +4,17 @@
|
|||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title>Cloud IDE</title>
|
<title>Cloud IDE</title>
|
||||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/monaco-editor/0.34.0/min/vs/editor/editor.main.css">
|
<link rel="stylesheet" href="static/cdnback/css/editor/editor.main.css">
|
||||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/4.5.1/socket.io.min.js"></script>
|
<script src="static/cdnback/socket.io.min.js"></script>
|
||||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css">
|
<link rel="stylesheet" href="static/cdnback/all.min.css">
|
||||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/xterm/5.5.0/xterm.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="https://cdnjs.cloudflare.com/ajax/libs/xterm/5.5.0/xterm.js"></script> -->
|
||||||
<script src="https://unpkg.com/xterm@3.6.0/dist/xterm.js"></script>
|
<script src="static/cdnback/js/xterm.js"></script>
|
||||||
<script src="https://unpkg.com/xterm@3.6.0/dist/addons/fit/fit.js"></script>
|
<script src="static/cdnback/js/addons/fit/fit.js"></script>
|
||||||
<script src="https://unpkg.com/xterm@3.6.0/dist/addons/webLinks/webLinks.js"></script>
|
<script src="static/cdnback/js/addons/webLinks/webLinks.js"></script>
|
||||||
<script src="https://unpkg.com/xterm@3.6.0/dist/addons/fullscreen/fullscreen.js"></script>
|
<script src="static/cdnback/js/addons/fullscreen/fullscreen.js"></script>
|
||||||
<script src="https://unpkg.com/xterm@3.6.0/dist/addons/search/search.js"></script>
|
<script src="static/cdnback/js/addons/search/search.js"></script>
|
||||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css">
|
<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/index.css">
|
||||||
<link rel="stylesheet" href="/vsc-like/static/css/notification.css">
|
<link rel="stylesheet" href="/vsc-like/static/css/notification.css">
|
||||||
@@ -61,7 +61,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div id="notificationsContainer"></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/code-like-extension.js"></script>
|
||||||
<script src="/vsc-like/static/js/file.js"></script>
|
<script src="/vsc-like/static/js/file.js"></script>
|
||||||
<script src="/vsc-like/static/js/terminal.js"></script>
|
<script src="/vsc-like/static/js/terminal.js"></script>
|
||||||
|
|||||||
BIN
profile_stats
Normal file
BIN
profile_stats
Normal file
Binary file not shown.
BIN
profile_stats_extract
Normal file
BIN
profile_stats_extract
Normal file
Binary file not shown.
Reference in New Issue
Block a user