提交UI自动化插件

This commit is contained in:
张家训
2026-07-03 16:50:26 +08:00
parent bd605c47c7
commit 3883323f93
6 changed files with 0 additions and 3203 deletions
@@ -1,97 +0,0 @@
package com.example.workutils.biz.apitrimmer;
import com.example.workutils.biz.apitrimmer.service.ApiTrimmerService;
import com.example.workutils.system.config.WorkUtilsProperties;
import com.example.workutils.system.plugin.Plugin;
import com.example.workutils.system.plugin.PluginDescriptor;
import com.example.workutils.system.plugin.VisualPluginFactory;
import com.example.workutils.system.support.JfxBootstrap;
import javafx.scene.Parent;
import javafx.scene.layout.Pane;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import java.util.Scanner;
import java.util.concurrent.CountDownLatch;
/**
* API Trim 插件:精简 API JAR 包,移除冗余实现类与传递依赖。
*/
@Slf4j
@Component
@RequiredArgsConstructor
public class ApiTrimmerPlugin implements Plugin {
private static final PluginDescriptor DESCRIPTOR = PluginDescriptor.builder()
.id("api-trim")
.name("API Trim")
.version("1.0.0")
.description("精简API模块JAR包,移除冗余实现类与传递依赖")
.order(65)
.icon("✂️")
.build();
private static final String[] MENU_OPTIONS = {
"1. UI可视化操作(选择JAR → 分析 → 精简)",
"0. 返回上级菜单"
};
private final ApiTrimmerService service;
private final WorkUtilsProperties properties;
@Override public PluginDescriptor getDescriptor() { return DESCRIPTOR; }
@Override public String[] getMenuOptions() { return MENU_OPTIONS; }
@Override
public VisualPluginFactory getVisualFactory() {
return new VisualPluginFactory() {
private ApiTrimmerWindow window;
private Parent embeddedRoot;
private CountDownLatch latch;
@Override
public Parent getEmbeddedPane() {
if (embeddedRoot != null) return embeddedRoot;
latch = new CountDownLatch(1);
window = new ApiTrimmerWindow(service, properties, latch);
embeddedRoot = window.getContentPane();
window.getStage().getScene().setRoot(new Pane());
return embeddedRoot;
}
@Override
public void open(Runnable onClosed) {
if (window == null) {
latch = new CountDownLatch(1);
window = new ApiTrimmerWindow(service, properties, latch);
}
if (embeddedRoot != null && window.getStage().getScene().getRoot() != embeddedRoot) {
window.getStage().getScene().setRoot(embeddedRoot);
}
window.show();
new Thread(() -> {
try { latch.await(); } catch (InterruptedException ignored) {}
onClosed.run();
}, "apitrim-close").start();
}
};
}
@Override
public void handleChoice(int choice, Scanner scanner) throws Exception {
if (choice == 1) {
System.out.println("正在打开 API Trim 窗口...");
JfxBootstrap.await();
if (JfxBootstrap.isFailed()) {
System.err.println("JavaFX 初始化失败");
return;
}
CountDownLatch closeLatch = new CountDownLatch(1);
javafx.application.Platform.runLater(() ->
new ApiTrimmerWindow(service, properties, closeLatch).show());
closeLatch.await();
System.out.println("API Trim 窗口已关闭");
}
}
}
File diff suppressed because it is too large Load Diff
@@ -1,5 +0,0 @@
# API Trim 自动勾选目录名配置(每行一个关键词,忽略大小写,匹配即勾选)
# 修改后保存,点击「刷新目录」即可生效
lombok
ttf
class50