|
@@ -20,6 +20,7 @@ import com.taais.biz.service.impl.CommonAlgorithmConfigServiceImpl;
|
|
import com.taais.biz.service.impl.TargetIdentificationSubtaskServiceImpl;
|
|
import com.taais.biz.service.impl.TargetIdentificationSubtaskServiceImpl;
|
|
import com.taais.biz.service.impl.TargetIdentificationTaskServiceImpl;
|
|
import com.taais.biz.service.impl.TargetIdentificationTaskServiceImpl;
|
|
import com.taais.biz.utils.ZipDirectory;
|
|
import com.taais.biz.utils.ZipDirectory;
|
|
|
|
+import com.taais.common.core.config.TaaisConfig;
|
|
import com.taais.common.core.utils.StringUtils;
|
|
import com.taais.common.core.utils.StringUtils;
|
|
import lombok.RequiredArgsConstructor;
|
|
import lombok.RequiredArgsConstructor;
|
|
import jakarta.servlet.http.HttpServletResponse;
|
|
import jakarta.servlet.http.HttpServletResponse;
|
|
@@ -285,31 +286,70 @@ public class TargetIdentificationSubtaskDetailsController extends BaseController
|
|
private String profile;
|
|
private String profile;
|
|
|
|
|
|
@GetMapping("/openDir")
|
|
@GetMapping("/openDir")
|
|
- public CommonResult<Void> openDir(String directory) throws IOException {
|
|
|
|
- log.error("check dir: {}, {}", directory, profile + "/task" + directory);
|
|
|
|
- //Desktop.getDesktop().open(new File(profile + "/task" + directory));
|
|
|
|
-
|
|
|
|
- String dir = profile + "/task" + directory + "/";
|
|
|
|
- String command = "sudo xdg-open " + dir;
|
|
|
|
- Runtime.getRuntime().exec(command);
|
|
|
|
- log.error("try open: {}", command);
|
|
|
|
-
|
|
|
|
- ProcessBuilder pb = new ProcessBuilder("sudo", "xdg-open", dir);
|
|
|
|
- Process p = pb.start();
|
|
|
|
- // 读取错误流避免进程阻塞
|
|
|
|
- try (BufferedReader errReader = new BufferedReader(new InputStreamReader(p.getErrorStream()))) {
|
|
|
|
- String line;
|
|
|
|
- while ((line = errReader.readLine()) != null) {
|
|
|
|
- log.error("进程错误: {}", line);
|
|
|
|
|
|
+ public CommonResult<Void> openDir(String directory, String type) throws IOException {
|
|
|
|
+ String path = profile + "/task" + directory;
|
|
|
|
+ log.info("check dir: {}", path);
|
|
|
|
+ if("1".equals(type)){
|
|
|
|
+ try {
|
|
|
|
+ Desktop desktop = Desktop.getDesktop();
|
|
|
|
+ File dir = new File(path);
|
|
|
|
+ if (dir.exists()) {
|
|
|
|
+ desktop.open(dir);
|
|
|
|
+ } else {
|
|
|
|
+ System.out.println("文件夹不存在: " + path);
|
|
|
|
+ }
|
|
|
|
+ } catch (IOException e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if("2".equals(type)){
|
|
|
|
+ try {
|
|
|
|
+ // 对于Ubuntu/GNOME桌面环境
|
|
|
|
+ Process process = Runtime.getRuntime().exec(new String[]{"xdg-open", path});
|
|
|
|
+
|
|
|
|
+ // 或者使用nautilus(文件管理器)
|
|
|
|
+ // Process process = Runtime.getRuntime().exec(new String[]{"nautilus", path});
|
|
|
|
+
|
|
|
|
+ int exitCode = process.waitFor();
|
|
|
|
+ if (exitCode != 0) {
|
|
|
|
+ System.out.println("打开文件夹失败,退出码: " + exitCode);
|
|
|
|
+ }
|
|
|
|
+ } catch (IOException | InterruptedException e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if("21".equals(type)){
|
|
|
|
+ try {
|
|
|
|
+
|
|
|
|
+ // 或者使用nautilus(文件管理器)
|
|
|
|
+ Process process = Runtime.getRuntime().exec(new String[]{"nautilus", path});
|
|
|
|
+
|
|
|
|
+ int exitCode = process.waitFor();
|
|
|
|
+ if (exitCode != 0) {
|
|
|
|
+ System.out.println("打开文件夹失败,退出码: " + exitCode);
|
|
|
|
+ }
|
|
|
|
+ } catch (IOException | InterruptedException e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if("3".equals(type)){
|
|
|
|
+ try {
|
|
|
|
+ ProcessBuilder pb = new ProcessBuilder("xdg-open", path);
|
|
|
|
+ // 或者使用: ProcessBuilder pb = new ProcessBuilder("nautilus", path);
|
|
|
|
+ pb.start();
|
|
|
|
+ } catch (IOException e) {
|
|
|
|
+ e.printStackTrace();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- pb = new ProcessBuilder("xdg-open", dir);
|
|
|
|
- p = pb.start();
|
|
|
|
- // 读取错误流避免进程阻塞
|
|
|
|
- try (BufferedReader errReader = new BufferedReader(new InputStreamReader(p.getErrorStream()))) {
|
|
|
|
- String line;
|
|
|
|
- while ((line = errReader.readLine()) != null) {
|
|
|
|
- log.error("进程错误: {}", line);
|
|
|
|
|
|
+ if("4".equals(type)){
|
|
|
|
+ try {
|
|
|
|
+ ProcessBuilder pb = new ProcessBuilder("nautilus", path);
|
|
|
|
+ pb.start();
|
|
|
|
+ } catch (IOException e) {
|
|
|
|
+ e.printStackTrace();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return CommonResult.success();
|
|
return CommonResult.success();
|