feat: v2 Vue3 frontend + multiple optimizations
- New Vue 3 + Vite frontend at /v2/ (OLED dark theme, Fira Sans/Code) - Date selector: support day/week/month range (backend unchanged) - SSE auto-reconnect (up to 3 retries) - Visibility polling pause (dashboard pauses when tab hidden) - Friendly Chinese HTTP error messages - Cancel task with confirmation in Dashboard - Split AiWorkflowService (1700->845 lines): - AiApiService: AI API calls + streaming - ExcelExportService: POI Excel generation - Dockerfile: 3-stage build (Node frontend -> Maven -> JRE) - WebApplication.java: System.out -> Logger - .gitignore: v2 build output, backup dirs Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -17,19 +17,27 @@ class AiWorkflowServiceTest {
|
||||
@TempDir
|
||||
Path tempDir;
|
||||
|
||||
private AiApiService buildAiApiService(SettingsService settingsService) {
|
||||
return new AiApiService(settingsService);
|
||||
}
|
||||
|
||||
private ExcelExportService buildExcelExportService() {
|
||||
return new ExcelExportService();
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldResolveDeepSeekProviderByDefault() {
|
||||
final OutputFileService outputFileService = buildOutputFileService();
|
||||
final SettingsService settingsService = buildSettingsService(outputFileService);
|
||||
final AiApiService aiApiService = buildAiApiService(settingsService);
|
||||
final AiWorkflowService service = new AiWorkflowService(
|
||||
buildOutputFileService(),
|
||||
new SettingsService(
|
||||
buildOutputFileService(),
|
||||
new SettingsPersistenceService(),
|
||||
new SvnPresetService()
|
||||
),
|
||||
new AiInputValidator()
|
||||
outputFileService,
|
||||
new AiInputValidator(),
|
||||
aiApiService,
|
||||
buildExcelExportService()
|
||||
);
|
||||
|
||||
final AiWorkflowService.AiProviderContext context = service.resolveProviderContext(null);
|
||||
final AiApiService.AiProviderContext context = aiApiService.resolveProviderContext(null);
|
||||
|
||||
Assertions.assertEquals(SettingsService.PROVIDER_DEEPSEEK, context.getProvider());
|
||||
Assertions.assertEquals("deepseek-chat", context.getStageOneModel());
|
||||
@@ -39,11 +47,7 @@ class AiWorkflowServiceTest {
|
||||
@Test
|
||||
void shouldResolveOpenAiCompatibleModelsAndUrl() {
|
||||
final OutputFileService outputFileService = buildOutputFileService();
|
||||
final SettingsService settingsService = new SettingsService(
|
||||
outputFileService,
|
||||
new SettingsPersistenceService(),
|
||||
new SvnPresetService()
|
||||
);
|
||||
final SettingsService settingsService = buildSettingsService(outputFileService);
|
||||
settingsService.updateSettings(
|
||||
null,
|
||||
SettingsService.PROVIDER_OPENAI_COMPATIBLE,
|
||||
@@ -56,9 +60,12 @@ class AiWorkflowServiceTest {
|
||||
null,
|
||||
null
|
||||
);
|
||||
final AiWorkflowService service = new AiWorkflowService(outputFileService, settingsService, new AiInputValidator());
|
||||
final AiApiService aiApiService = buildAiApiService(settingsService);
|
||||
final AiWorkflowService service = new AiWorkflowService(
|
||||
outputFileService, new AiInputValidator(), aiApiService, buildExcelExportService()
|
||||
);
|
||||
|
||||
final AiWorkflowService.AiProviderContext context = service.resolveProviderContext(null);
|
||||
final AiApiService.AiProviderContext context = aiApiService.resolveProviderContext(null);
|
||||
|
||||
Assertions.assertEquals(SettingsService.PROVIDER_OPENAI_COMPATIBLE, context.getProvider());
|
||||
Assertions.assertEquals("http://127.0.0.1:5001/v1/chat/completions", context.getApiUrl());
|
||||
@@ -68,15 +75,14 @@ class AiWorkflowServiceTest {
|
||||
|
||||
@Test
|
||||
void shouldFailFastWhenOpenAiCompatibleBaseUrlMissing() {
|
||||
final AiWorkflowService service = new AiWorkflowService(
|
||||
buildOutputFileService(),
|
||||
new StubSettingsService(buildOutputFileService(), " ", "sk-openai-test"),
|
||||
new AiInputValidator()
|
||||
final OutputFileService outputFileService = buildOutputFileService();
|
||||
final AiApiService aiApiService = buildAiApiService(
|
||||
new StubSettingsService(outputFileService, " ", "sk-openai-test")
|
||||
);
|
||||
|
||||
final IllegalStateException error = Assertions.assertThrows(
|
||||
IllegalStateException.class,
|
||||
() -> service.resolveProviderContext(null)
|
||||
() -> aiApiService.resolveProviderContext(null)
|
||||
);
|
||||
|
||||
Assertions.assertTrue(error.getMessage().contains("OpenAI兼容 Base URL"));
|
||||
@@ -85,11 +91,7 @@ class AiWorkflowServiceTest {
|
||||
@Test
|
||||
void shouldParseCompatibleStreamWhenOnlyContentIsReturned() throws Exception {
|
||||
final OutputFileService outputFileService = buildOutputFileService();
|
||||
final SettingsService settingsService = new SettingsService(
|
||||
outputFileService,
|
||||
new SettingsPersistenceService(),
|
||||
new SvnPresetService()
|
||||
);
|
||||
final SettingsService settingsService = buildSettingsService(outputFileService);
|
||||
settingsService.updateSettings(
|
||||
null,
|
||||
SettingsService.PROVIDER_OPENAI_COMPATIBLE,
|
||||
@@ -102,8 +104,8 @@ class AiWorkflowServiceTest {
|
||||
null,
|
||||
null
|
||||
);
|
||||
final AiWorkflowService service = new AiWorkflowService(outputFileService, settingsService, new AiInputValidator());
|
||||
final AiWorkflowService.AiProviderContext providerContext = service.resolveProviderContext(null);
|
||||
final AiApiService aiApiService = buildAiApiService(settingsService);
|
||||
final AiApiService.AiProviderContext providerContext = aiApiService.resolveProviderContext(null);
|
||||
final TaskContext taskContext = new TaskContext(buildTaskInfo(), null, null);
|
||||
final Buffer buffer = new Buffer()
|
||||
.writeUtf8("data: {\"choices\":[{\"delta\":{\"content\":\"{\\\"items\\\":[\"}}]}\n")
|
||||
@@ -111,7 +113,7 @@ class AiWorkflowServiceTest {
|
||||
.writeUtf8("data: {\"choices\":[{\"delta\":{\"content\":\"]}\"},\"finish_reason\":\"stop\"}]}\n")
|
||||
.writeUtf8("data: [DONE]\n");
|
||||
|
||||
final AiWorkflowService.AiStreamResult result = service.readStreamingResponse(
|
||||
final AiApiService.AiStreamResult result = aiApiService.readStreamingResponse(
|
||||
buffer,
|
||||
taskContext,
|
||||
providerContext,
|
||||
@@ -138,12 +140,30 @@ class AiWorkflowServiceTest {
|
||||
return taskInfo;
|
||||
}
|
||||
|
||||
private SettingsService buildSettingsService(OutputFileService outputFileService) {
|
||||
final RepositoryConfigService repositoryConfigService = buildRepositoryConfigService(outputFileService);
|
||||
final SvnPresetService svnPresetService = new SvnPresetService(repositoryConfigService);
|
||||
svnPresetService.init();
|
||||
return new SettingsService(outputFileService, new SettingsPersistenceService(), svnPresetService, repositoryConfigService);
|
||||
}
|
||||
|
||||
private RepositoryConfigService buildRepositoryConfigService(OutputFileService outputFileService) {
|
||||
final RepositoryConfigService repositoryConfigService = new RepositoryConfigService(outputFileService);
|
||||
repositoryConfigService.init();
|
||||
return repositoryConfigService;
|
||||
}
|
||||
|
||||
private static final class StubSettingsService extends SettingsService {
|
||||
private final String openaiBaseUrl;
|
||||
private final String openaiApiKey;
|
||||
|
||||
private StubSettingsService(OutputFileService outputFileService, String openaiBaseUrl, String openaiApiKey) {
|
||||
super(outputFileService, new SettingsPersistenceService(), new SvnPresetService());
|
||||
super(
|
||||
outputFileService,
|
||||
new SettingsPersistenceService(),
|
||||
new SvnPresetService(new RepositoryConfigService(outputFileService)),
|
||||
new RepositoryConfigService(outputFileService)
|
||||
);
|
||||
this.openaiBaseUrl = openaiBaseUrl;
|
||||
this.openaiApiKey = openaiApiKey;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user