mirror of
https://github.com/router-for-me/Cli-Proxy-API-Management-Center.git
synced 2026-02-18 02:30:51 +08:00
feat(logs): refresh on reconnect and section activation
This commit is contained in:
@@ -215,10 +215,14 @@ export const connectionModule = {
|
||||
this.updateConnectionInfo();
|
||||
|
||||
if (this.events && typeof this.events.emit === 'function') {
|
||||
this.events.emit('connection:status-changed', {
|
||||
isConnected: this.isConnected,
|
||||
apiBase: this.apiBase
|
||||
});
|
||||
const shouldEmit = this.lastConnectionStatusEmitted !== this.isConnected;
|
||||
if (shouldEmit) {
|
||||
this.events.emit('connection:status-changed', {
|
||||
isConnected: this.isConnected,
|
||||
apiBase: this.apiBase
|
||||
});
|
||||
this.lastConnectionStatusEmitted = this.isConnected;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -325,9 +329,6 @@ export const connectionModule = {
|
||||
// 从配置中提取并设置各个设置项(现在传递keyStats)
|
||||
await this.updateSettingsFromConfig(config, keyStats);
|
||||
|
||||
// 认证文件需要单独加载,因为不在配置中
|
||||
await this.loadAuthFiles(keyStats);
|
||||
|
||||
if (this.events && typeof this.events.emit === 'function') {
|
||||
this.events.emit('data:config-loaded', {
|
||||
config,
|
||||
|
||||
@@ -406,5 +406,29 @@ export const logsModule = {
|
||||
}
|
||||
this.showNotification(i18n.t('logs.auto_refresh_disabled'), 'info');
|
||||
}
|
||||
},
|
||||
|
||||
registerLogsListeners() {
|
||||
if (!this.events || typeof this.events.on !== 'function') {
|
||||
return;
|
||||
}
|
||||
this.events.on('connection:status-changed', (event) => {
|
||||
const detail = event?.detail || {};
|
||||
if (detail.isConnected) {
|
||||
// 仅在日志页激活时刷新,避免非日志页面触发请求
|
||||
const logsSection = document.getElementById('logs');
|
||||
if (logsSection && logsSection.classList.contains('active')) {
|
||||
this.refreshLogs(false);
|
||||
}
|
||||
} else {
|
||||
this.latestLogTimestamp = null;
|
||||
}
|
||||
});
|
||||
this.events.on('navigation:section-activated', (event) => {
|
||||
const detail = event?.detail || {};
|
||||
if (detail.sectionId === 'logs' && this.isConnected) {
|
||||
this.refreshLogs(false);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
@@ -15,12 +15,13 @@ export const navigationModule = {
|
||||
section.classList.add('active');
|
||||
}
|
||||
|
||||
if (sectionId === 'logs') {
|
||||
this.refreshLogs(false);
|
||||
} else if (sectionId === 'config-management') {
|
||||
if (sectionId === 'config-management') {
|
||||
this.loadConfigFileEditor();
|
||||
this.refreshConfigEditor();
|
||||
}
|
||||
if (this.events && typeof this.events.emit === 'function') {
|
||||
this.events.emit('navigation:section-activated', { sectionId });
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user