}
const data = await res.json();
currentTask.model = (data.task && data.task.model) || '';
- term.writeln('\\x1b[33m⏳ 切换模型为 "' + (currentTask.model || '默认·最新GLM') + '",正在重启会话...\\x1b[0m');
+ term.writeln('\x1b[33m⏳ 切换模型为 "' + (currentTask.model || '默认·最新GLM') + '",正在重启会话...\x1b[0m');
// 重启以应用新模型(resume 同样会采用新 --model)
killCurrent();
if (term) term.clear();
const m = Math.floor(sec / 60), s = sec % 60;
term.writeln('');
if (msg.running) {
- term.writeln('\\x1b[36m🔗 已重新连接 · 任务运行中 · 已运行 ' + m + '分' + s + '秒\\x1b[0m');
+ term.writeln('\x1b[36m🔗 已重新连接 · 任务运行中 · 已运行 ' + m + '分' + s + '秒\x1b[0m');
} else {
- term.writeln('\\x1b[33mⓘ 任务已结束(退出码 ' + (msg.exit_code == null ? '?' : msg.exit_code) + ')\\x1b[0m');
+ term.writeln('\x1b[33mⓘ 任务已结束(退出码 ' + (msg.exit_code == null ? '?' : msg.exit_code) + ')\x1b[0m');
}
- if (msg.current_task) term.writeln('\\x1b[90m当前/最近任务:' + msg.current_task + '\\x1b[0m');
+ if (msg.current_task) term.writeln('\x1b[90m当前/最近任务:' + msg.current_task + '\x1b[0m');
if (msg.replay) {
- term.writeln('\\x1b[90m──── 以下为断开期间 / 上次的输出 ────\\x1b[0m');
+ term.writeln('\x1b[90m──── 以下为断开期间 / 上次的输出 ────\x1b[0m');
term.write(msg.replay);
}
try { term.focus(); } catch (e) {}
if (!authToken || !TASK_ID) return;
const proto = location.protocol === 'https:' ? 'wss:' : 'ws:';
const url = proto + '//' + location.host + '/ws?token=' + encodeURIComponent(authToken) + '&task=' + encodeURIComponent(TASK_ID);
- term.writeln('\\x1b[33m⏳ 正在连接任务 [' + (currentTask ? currentTask.name : TASK_ID) + ']...\\x1b[0m');
+ term.writeln('\x1b[33m⏳ 正在连接任务 [' + (currentTask ? currentTask.name : TASK_ID) + ']...\x1b[0m');
setConnected(false);
ws = new WebSocket(url);
ws.binaryType = 'arraybuffer';
- ws.onopen = () => { setConnected(true); term.writeln('\\x1b[32m✓ 连接成功\\x1b[0m'); };
+ ws.onopen = () => { setConnected(true); term.writeln('\x1b[32m✓ 连接成功\x1b[0m'); };
ws.onmessage = (event) => {
try {
const msg = JSON.parse(event.data);
if (msg.type === 'output' && msg.data) term.write(msg.data);
else if (msg.type === 'pid') pid = msg.pid;
else if (msg.type === 'reattach') { pid = msg.pid || pid; renderReattach(msg); }
- else if (msg.type === 'error') { term.writeln('\\x1b[31m✗ ' + msg.data + '\\x1b[0m'); }
- else if (msg.type === 'exit') { term.writeln('\\x1b[33m⚠ 进程已退出 (code: ' + msg.code + ')\\x1b[0m'); setConnected(false); }
+ else if (msg.type === 'error') { term.writeln('\x1b[31m✗ ' + msg.data + '\x1b[0m'); }
+ else if (msg.type === 'exit') { term.writeln('\x1b[33m⚠ 进程已退出 (code: ' + msg.code + ')\x1b[0m'); setConnected(false); }
} catch(e) { term.write(event.data); }
};
- ws.onclose = () => { setConnected(false); term.writeln('\\x1b[31m✗ 连接已断开\\x1b[0m'); };
- ws.onerror = () => { setConnected(false); term.writeln('\\x1b[31m✗ 连接错误\\x1b[0m'); };
+ ws.onclose = () => { setConnected(false); term.writeln('\x1b[31m✗ 连接已断开\x1b[0m'); };
+ ws.onerror = () => { setConnected(false); term.writeln('\x1b[31m✗ 连接错误\x1b[0m'); };
}
function killCurrent() {
document.getElementById('btn-restart').onclick = () => {
killCurrent();
if (term) term.clear();
- term.writeln('\\x1b[33m⏳ 重启会话中...\\x1b[0m');
+ term.writeln('\x1b[33m⏳ 重启会话中...\x1b[0m');
connectWS();
};
document.getElementById('btn-list').onclick = () => { window.open('/', 'cb_picker'); };