|
@@ -18,6 +18,7 @@ import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
+import java.awt.*;
|
|
|
import java.io.File;
|
|
|
import java.io.IOException;
|
|
|
import java.net.URLEncoder;
|
|
@@ -146,4 +147,26 @@ public class FzssController extends BaseController {
|
|
|
response.setHeader("Content-Disposition", "inline;fileName=" + URLEncoder.encode(downloadName, "UTF-8"));
|
|
|
FileUtils.writeBytes(realFileName, response.getOutputStream());
|
|
|
}
|
|
|
+
|
|
|
+ @GetMapping("/open")
|
|
|
+ public RequestResult openFile(String filePath) throws IOException {
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ File file = new File(filePath);
|
|
|
+
|
|
|
+ try {
|
|
|
+ if (Desktop.isDesktopSupported()) {
|
|
|
+ Desktop.getDesktop().open(file);
|
|
|
+ } else {
|
|
|
+ // 使用Runtime作为备用
|
|
|
+ Runtime.getRuntime().exec(filePath);
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ return RequestResult.error("打开文件失败: " + e.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ return RequestResult.success();
|
|
|
+ }
|
|
|
}
|