huangct 8 жил өмнө
parent
commit
de0342d22d

+ 15 - 7
jpress-web-admin/src/main/java/io/jpress/admin/controller/_AttachmentController.java

@@ -143,12 +143,6 @@ public class _AttachmentController extends JBaseCRUDController<Attachment> {
 		String webRoot = PathKit.getWebRootPath();
 		String requestUrlMessage = this.getRequest().getScheme() +"://" + this.getRequest().getServerName() + ":" + this.getRequest().getServerPort();
 		Attachment attachment = AttachmentQuery.me().findById(getParaToBigInteger("sourceId"));
-		int x1 = getParaToInt("x1");
-		int x2 = getParaToInt("x2");
-		int y1 = getParaToInt("y1");
-		int y2 = getParaToInt("y2");
-		int width = x2 - x1;
-		int height = y2 - y1;
 		String srcpath = requestUrlMessage + "/jpress" + attachment.getPath();
 		String type = attachment.getSuffix().substring(1);
 		//新截取的图片名称在原图名称上加上时间戳
@@ -157,10 +151,24 @@ public class _AttachmentController extends JBaseCRUDController<Attachment> {
 		String subpath = requestUrlMessage + "/jpress" + "/attachment/" + time + attachment.getSuffix();
 		/*srcpath.replaceAll("/","-");*/
 		BufferedImage bufferedImage = OperateImage.getIconInfo(srcpath);
+		double widthRate = bufferedImage.getWidth()*(1.0/160);
+		double heightRate = bufferedImage.getHeight()*(1.0/160);
+
+
+		int x1 = (int)(getParaToInt("x1") * widthRate);
+		int x2 = (int)(getParaToInt("x2") * widthRate);
+		int y1 = (int)(getParaToInt("y1") * widthRate);
+		int y2 = (int)(getParaToInt("y2") * widthRate);
+		int width = x2 - x1;
+		int height = y2 - y1;
 		OperateImage o = new OperateImage(x1, y1, width, height);
 		//o.setSrcpath(srcpath);
 		o.setSourceImg(bufferedImage);
-		o.setSubpath("D:\\pictest\\" + time + attachment.getSuffix() );
+		File file = new File("D:\\软文截图");
+		if (!file.exists()) {
+			file.mkdir();
+		}
+		o.setSubpath("D:\\软文截图\\" + time + attachment.getSuffix() );
 		try {
 			File cutImage = o.cut(type);
 			/*Attachment cutImage = new Attachment();

+ 2 - 2
jpress-web-admin/src/main/webapp/WEB-INF/admin/attachment/choose_layer.html

@@ -27,7 +27,7 @@ $(document).ready(function(){
   });
 
     <#if imageSize?? && imageSize=="bigImage">
-        $('.jp-grids-photos').imgAreaSelect({aspectRatio: '470:300', maxWidth: 94, maxHeight: 60, handles: true });
+        $('.jp-grids-photos').imgAreaSelect({aspectRatio: '470:300', handles: true });
         $('.jp-grids-photos').imgAreaSelect({
             onSelectEnd: function (img, selection) {
                 $('input[name="x1"]').val(selection.x1);
@@ -37,7 +37,7 @@ $(document).ready(function(){
             }
         });
     <#elseif imageSize?? && imageSize=="smallImage">
-        $('.jp-grids-photos').imgAreaSelect({aspectRatio: '1:1', maxWidth: 50, maxHeight: 50, handles: true });
+        $('.jp-grids-photos').imgAreaSelect({aspectRatio: '1:1', handles: true });
         $('.jp-grids-photos').imgAreaSelect({
             onSelectEnd: function (img, selection) {
                 $('input[name="x1"]').val(selection.x1);

+ 1 - 1
jpress-web-admin/src/main/webapp/WEB-INF/admin/content/edit.html

@@ -146,7 +146,7 @@ function turnPage(){
 					toastr.error(data.message,'操作失败');
 				}
 				if (data.message != null) {
-					toastr.success(data.message);
+					toastr.info(data.message);
 				}
 
 			},