fix:path rewriting & model list
This commit is contained in:
@@ -113,12 +113,22 @@ class LogsPage {
|
||||
this.elements.systemControls
|
||||
);
|
||||
Swal.fire({
|
||||
title: '实时系统日志',
|
||||
text: '您即将连接到实时日志流。这会与服务器建立一个持续的连接。',
|
||||
icon: 'info',
|
||||
confirmButtonText: '我明白了,开始连接',
|
||||
width: '20rem',
|
||||
backdrop: `rgba(0,0,0,0.5)`,
|
||||
heightAuto: false,
|
||||
customClass: {
|
||||
popup: `swal2-custom-style ${document.documentElement.classList.contains('dark') ? 'swal2-dark' : ''}`
|
||||
},
|
||||
title: '系统终端日志',
|
||||
text: '您即将连接到实时系统日志流窗口。',
|
||||
showCancelButton: true,
|
||||
confirmButtonText: '确认',
|
||||
cancelButtonText: '取消',
|
||||
reverseButtons: false,
|
||||
confirmButtonColor: 'rgba(31, 102, 255, 0.8)',
|
||||
cancelButtonColor: '#6b7280',
|
||||
focusConfirm: false,
|
||||
focusCancel: false,
|
||||
target: '#main-content-wrapper',
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
|
||||
@@ -9,6 +9,7 @@ export default class SystemLogTerminal {
|
||||
this.shouldAutoScroll = true;
|
||||
this.reconnectAttempts = 0;
|
||||
this.maxReconnectAttempts = 5;
|
||||
this.isConnected = false;
|
||||
|
||||
this.elements = {
|
||||
output: this.container.querySelector('#log-terminal-output'),
|
||||
@@ -16,7 +17,8 @@ export default class SystemLogTerminal {
|
||||
clearBtn: this.controlsContainer.querySelector('[data-action="clear-terminal"]'),
|
||||
pauseBtn: this.controlsContainer.querySelector('[data-action="toggle-pause-terminal"]'),
|
||||
scrollBtn: this.controlsContainer.querySelector('[data-action="toggle-scroll-terminal"]'),
|
||||
disconnectBtn: this.controlsContainer.querySelector('[data-action="disconnect-terminal"]'),
|
||||
connectBtn: this.controlsContainer.querySelector('[data-action="toggle-connect-terminal"]'),
|
||||
settingsBtn: this.controlsContainer.querySelector('[data-action="terminal-settings"]'),
|
||||
};
|
||||
|
||||
this._initEventListeners();
|
||||
@@ -26,7 +28,16 @@ export default class SystemLogTerminal {
|
||||
this.elements.clearBtn.addEventListener('click', () => this.clear());
|
||||
this.elements.pauseBtn.addEventListener('click', () => this.togglePause());
|
||||
this.elements.scrollBtn.addEventListener('click', () => this.toggleAutoScroll());
|
||||
this.elements.disconnectBtn.addEventListener('click', () => this.disconnect());
|
||||
this.elements.connectBtn.addEventListener('click', () => this.toggleConnect());
|
||||
this.elements.settingsBtn.addEventListener('click', () => this.openSettings());
|
||||
}
|
||||
|
||||
toggleConnect() {
|
||||
if (this.isConnected) {
|
||||
this.disconnect();
|
||||
} else {
|
||||
this.connect();
|
||||
}
|
||||
}
|
||||
|
||||
connect() {
|
||||
@@ -43,6 +54,9 @@ export default class SystemLogTerminal {
|
||||
this._appendMessage('info', '✓ 已连接到系统日志流');
|
||||
this._updateStatus('connected', '已连接');
|
||||
this.reconnectAttempts = 0;
|
||||
this.isConnected = true;
|
||||
this.elements.connectBtn.title = '断开';
|
||||
this.elements.connectBtn.querySelector('i').classList.replace('fa-plug', 'fa-minus-circle');
|
||||
};
|
||||
|
||||
this.ws.onmessage = (event) => {
|
||||
@@ -53,7 +67,7 @@ export default class SystemLogTerminal {
|
||||
const levelColors = {
|
||||
'error': 'text-red-500',
|
||||
'warning': 'text-yellow-400',
|
||||
'info': 'text-blue-400',
|
||||
'info': 'text-green-400',
|
||||
'debug': 'text-zinc-400'
|
||||
};
|
||||
const color = levelColors[data.level] || 'text-zinc-200';
|
||||
@@ -73,6 +87,9 @@ export default class SystemLogTerminal {
|
||||
this.ws.onclose = () => {
|
||||
this._appendMessage('error', '✗ 连接已断开');
|
||||
this._updateStatus('disconnected', '未连接');
|
||||
this.isConnected = false;
|
||||
this.elements.connectBtn.title = '连接';
|
||||
this.elements.connectBtn.querySelector('i').classList.replace('fa-minus-circle', 'fa-plug');
|
||||
|
||||
if (this.reconnectAttempts < this.maxReconnectAttempts) {
|
||||
this.reconnectAttempts++;
|
||||
@@ -90,7 +107,10 @@ export default class SystemLogTerminal {
|
||||
this.ws = null;
|
||||
}
|
||||
this.reconnectAttempts = this.maxReconnectAttempts;
|
||||
this.isConnected = false;
|
||||
this._updateStatus('disconnected', '未连接');
|
||||
this.elements.connectBtn.title = '连接';
|
||||
this.elements.connectBtn.querySelector('i').classList.replace('fa-minus-circle', 'fa-plug');
|
||||
}
|
||||
|
||||
clear() {
|
||||
@@ -101,25 +121,24 @@ export default class SystemLogTerminal {
|
||||
|
||||
togglePause() {
|
||||
this.isPaused = !this.isPaused;
|
||||
const span = this.elements.pauseBtn.querySelector('span');
|
||||
const icon = this.elements.pauseBtn.querySelector('i');
|
||||
if (this.isPaused) {
|
||||
span.textContent = '继续';
|
||||
this.elements.pauseBtn.title = '继续';
|
||||
icon.classList.replace('fa-pause', 'fa-play');
|
||||
} else {
|
||||
span.textContent = '暂停';
|
||||
this.elements.pauseBtn.title = '暂停';
|
||||
icon.classList.replace('fa-play', 'fa-pause');
|
||||
}
|
||||
}
|
||||
|
||||
toggleAutoScroll() {
|
||||
this.shouldAutoScroll = !this.shouldAutoScroll;
|
||||
const span = this.elements.scrollBtn.querySelector('span');
|
||||
if (this.shouldAutoScroll) {
|
||||
span.textContent = '自动滚动';
|
||||
} else {
|
||||
span.textContent = '手动滚动';
|
||||
}
|
||||
this.elements.scrollBtn.title = this.shouldAutoScroll ? '自动滚动' : '手动滚动';
|
||||
}
|
||||
|
||||
openSettings() {
|
||||
// 实现设置功能
|
||||
console.log('打开设置');
|
||||
}
|
||||
|
||||
_appendMessage(colorClass, text) {
|
||||
|
||||
Reference in New Issue
Block a user