fix(ui): refresh git summary while idle
This commit is contained in:
parent
2f0e269788
commit
f2d7d8f3b1
@ -42,6 +42,7 @@ export async function mounted() {
|
||||
// 立即加载初始数据(并行获取状态,优先同步运行模式)
|
||||
const initialDataPromise = this.loadInitialData();
|
||||
this.refreshProjectGitSummary?.();
|
||||
this.startProjectGitSummaryIdleRefresh?.();
|
||||
this.startConnectionHeartbeat();
|
||||
this.checkTutorialPrompt();
|
||||
if (initialDataPromise && typeof initialDataPromise.then === 'function') {
|
||||
@ -118,6 +119,7 @@ export function beforeUnmount() {
|
||||
this.teardownMobileViewportWatcher();
|
||||
this.subAgentStopPolling();
|
||||
this.backgroundCommandStopPolling();
|
||||
this.stopProjectGitSummaryIdleRefresh?.();
|
||||
this.resourceStopContainerStatsPolling();
|
||||
this.resourceStopProjectStoragePolling();
|
||||
this.resourceStopUsageQuotaPolling();
|
||||
|
||||
@ -154,7 +154,30 @@ function parseSystemNoticeLabel(rawContent: any): string | null {
|
||||
}
|
||||
|
||||
export const uiMethods = {
|
||||
startProjectGitSummaryIdleRefresh() {
|
||||
if (this.projectGitSummaryRefreshTimer) {
|
||||
return;
|
||||
}
|
||||
this.projectGitSummaryRefreshTimer = window.setInterval(() => {
|
||||
if (!this.isConnected) return;
|
||||
if (typeof this.isOutputActive === 'function' && this.isOutputActive()) return;
|
||||
this.refreshProjectGitSummary?.({ idleFallback: true });
|
||||
}, 5000);
|
||||
},
|
||||
|
||||
stopProjectGitSummaryIdleRefresh() {
|
||||
if (!this.projectGitSummaryRefreshTimer) {
|
||||
return;
|
||||
}
|
||||
window.clearInterval(this.projectGitSummaryRefreshTimer);
|
||||
this.projectGitSummaryRefreshTimer = null;
|
||||
},
|
||||
|
||||
async refreshProjectGitSummary() {
|
||||
if (this.projectGitSummaryRefreshing) {
|
||||
return;
|
||||
}
|
||||
this.projectGitSummaryRefreshing = true;
|
||||
try {
|
||||
const resp = await fetch('/api/project/git-summary');
|
||||
const payload = await resp.json().catch(() => ({}));
|
||||
@ -170,6 +193,8 @@ export const uiMethods = {
|
||||
} catch (_) {
|
||||
this.projectGitSummary = null;
|
||||
this.gitChangesDiff = null;
|
||||
} finally {
|
||||
this.projectGitSummaryRefreshing = false;
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@ -37,6 +37,8 @@ export function dataState() {
|
||||
runtimeQueueSyncLockKey: '',
|
||||
runtimeQueueSyncLockUntil: 0,
|
||||
projectGitSummary: null,
|
||||
projectGitSummaryRefreshTimer: null,
|
||||
projectGitSummaryRefreshing: false,
|
||||
gitChangesPanelOpen: false,
|
||||
gitChangesLoading: false,
|
||||
gitChangesError: '',
|
||||
|
||||
Loading…
Reference in New Issue
Block a user