mirror of
https://github.com/Gmaker689/ai-diff-preview.git
synced 2026-09-30 09:01:52 +08:00
71 lines
1.9 KiB
TypeScript
71 lines
1.9 KiB
TypeScript
|
|
/**
|
||
|
|
* 状态栏管理器 - 显示 Diff 状态信息
|
||
|
|
*/
|
||
|
|
|
||
|
|
import * as vscode from 'vscode';
|
||
|
|
import { Snapshot } from '../models/types';
|
||
|
|
import { STATUS_BAR_PRIORITY } from '../models/constants';
|
||
|
|
|
||
|
|
export class StatusBarManager {
|
||
|
|
private statusBarItem: vscode.StatusBarItem;
|
||
|
|
private chunkCountItem: vscode.StatusBarItem;
|
||
|
|
|
||
|
|
constructor() {
|
||
|
|
this.statusBarItem = vscode.window.createStatusBarItem(
|
||
|
|
vscode.StatusBarAlignment.Left,
|
||
|
|
STATUS_BAR_PRIORITY.DIFF_STATUS
|
||
|
|
);
|
||
|
|
|
||
|
|
this.chunkCountItem = vscode.window.createStatusBarItem(
|
||
|
|
vscode.StatusBarAlignment.Left,
|
||
|
|
STATUS_BAR_PRIORITY.CHUNK_COUNT
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 更新状态栏
|
||
|
|
*/
|
||
|
|
update(snapshot: Snapshot): void {
|
||
|
|
const pendingChunks = snapshot.chunks.filter(c => c.status === 'pending');
|
||
|
|
const conflictChunks = snapshot.chunks.filter(c => c.status === 'conflict');
|
||
|
|
|
||
|
|
// 更新主状态
|
||
|
|
this.statusBarItem.text = '$(diff) AI Diff';
|
||
|
|
this.statusBarItem.tooltip = 'AI Diff Preview 活跃';
|
||
|
|
this.statusBarItem.show();
|
||
|
|
|
||
|
|
// 更新变更块数量
|
||
|
|
if (pendingChunks.length > 0 || conflictChunks.length > 0) {
|
||
|
|
this.chunkCountItem.text = `$(edit) ${pendingChunks.length} 个变更`;
|
||
|
|
if (conflictChunks.length > 0) {
|
||
|
|
this.chunkCountItem.text += ` (${conflictChunks.length} 个冲突)`;
|
||
|
|
this.chunkCountItem.backgroundColor = new vscode.ThemeColor(
|
||
|
|
'statusBarItem.warningBackground'
|
||
|
|
);
|
||
|
|
} else {
|
||
|
|
this.chunkCountItem.backgroundColor = undefined;
|
||
|
|
}
|
||
|
|
this.chunkCountItem.tooltip = '点击查看变更详情';
|
||
|
|
this.chunkCountItem.show();
|
||
|
|
} else {
|
||
|
|
this.chunkCountItem.hide();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 清除状态栏
|
||
|
|
*/
|
||
|
|
clear(): void {
|
||
|
|
this.statusBarItem.hide();
|
||
|
|
this.chunkCountItem.hide();
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 释放资源
|
||
|
|
*/
|
||
|
|
dispose(): void {
|
||
|
|
this.statusBarItem.dispose();
|
||
|
|
this.chunkCountItem.dispose();
|
||
|
|
}
|
||
|
|
}
|