Browse Source

REPORT-78647【运营产品化二期】单模板目前点击立即使用未下载

1、浏览器下载实现不了,改用设计器内部下载
2、下载到工作目录下
feature/x
Link.Zhao 2 years ago
parent
commit
9e7e222f02
  1. 5
      designer-base/src/main/java/com/fr/design/dialog/UIDialog.java
  2. 181
      designer-base/src/main/java/com/fr/design/mainframe/toast/SimpleToast.java
  3. 13
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/action/StartUseAction.java
  4. 170
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/download/FineMarketDownloadManager.java
  5. 19
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/model/TemplateResource.java
  6. 202
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/helper/FineMarketClientHelper.java
  7. 5
      designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/caution.svg
  8. 3
      designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/loading.svg

5
designer-base/src/main/java/com/fr/design/dialog/UIDialog.java

@ -18,6 +18,7 @@ import java.awt.BorderLayout;
import java.awt.Dialog;
import java.awt.FlowLayout;
import java.awt.Frame;
import java.awt.Window;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
@ -44,6 +45,10 @@ public abstract class UIDialog extends JDialog {
super(parent);
}
public UIDialog(Window parent) {
super(parent);
}
public UIDialog(Frame parent, BasicPane pane) {
this(parent, pane, true);

181
designer-base/src/main/java/com/fr/design/mainframe/toast/SimpleToast.java

@ -0,0 +1,181 @@
package com.fr.design.mainframe.toast;
import com.fr.concurrent.NamedThreadFactory;
import com.fr.design.dialog.UIDialog;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.module.ModuleContext;
import javax.swing.BorderFactory;
import javax.swing.Icon;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Point;
import java.awt.Window;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
/**
* toast弹窗
* */
public class SimpleToast extends UIDialog {
private static final int MIN_HEIGHT = 36;
private static final String TOAST_MSG_TIMER = "TOAST_MSG_TIMER";
private static final long DEFAULT_DISAPPEAR_DELAY = 5000;
private static final TimeUnit DEFAULT_TIME_UNIT = TimeUnit.MILLISECONDS;
private ScheduledExecutorService TIMER;
private int hide_height = 0;
private JPanel contentPane;
private boolean show = false;
private Window parent;
private boolean autoDisappear;
public SimpleToast(Window parent, Icon icon, String text, boolean autoDisappear) {
super(parent);
this.parent = parent;
this.autoDisappear = autoDisappear;
JPanel panel = createContentPane(icon, text);
init(panel);
}
private JPanel createContentPane(Icon icon, String text) {
JPanel pane = FRGUIPaneFactory.createBorderLayout_S_Pane();
UILabel iconLabel = new UILabel(icon);
iconLabel.setVerticalAlignment(SwingConstants.TOP);
iconLabel.setBorder(BorderFactory.createEmptyBorder(3, 0, 0, 0));
UILabel textLabel = new UILabel(text);
pane.add(iconLabel, BorderLayout.WEST);
pane.add(textLabel, BorderLayout.CENTER);
pane.setBorder(BorderFactory.createEmptyBorder(8, 15, 8, 15));
return pane;
}
private void init(JPanel panel) {
setFocusable(false);
setAutoRequestFocus(false);
setUndecorated(true);
contentPane = panel;
initComponent();
}
private void initComponent() {
this.getContentPane().setLayout(null);
this.getContentPane().add(contentPane);
Dimension dimension = calculatePreferSize();
hide_height = dimension.height;
setSize(new Dimension(dimension.width, 0));
contentPane.setSize(dimension);
setRelativeLocation(dimension);
if (autoDisappear) {
disappear(contentPane);
}
}
private void setRelativeLocation(Dimension dimension) {
int positionX = parent.getLocationOnScreen().x + (parent.getWidth() - dimension.width) / 2;
int positionY = parent.getLocationOnScreen().y + 10;
this.setLocation(positionX, positionY);
}
private Dimension calculatePreferSize() {
Dimension contentDimension = contentPane.getPreferredSize();
int height = Math.max(MIN_HEIGHT, contentDimension.height);
return new Dimension(contentDimension.width, height);
}
public void display(JPanel outerJPanel) {
show = true;
outerJPanel.setLocation(0, -hide_height);
ScheduledExecutorService TIP_TOOL_TIMER = createToastScheduleExecutorService();
TIP_TOOL_TIMER.scheduleAtFixedRate(new Runnable() {
@Override
public void run() {
Point point = outerJPanel.getLocation();
if (point.y >= 0) {
TIP_TOOL_TIMER.shutdown();
}
int showDistance = 5 + point.y < 0 ? 5 : -point.y;
outerJPanel.setLocation(point.x, point.y + showDistance);
Dimension dimension = SimpleToast.this.getSize();
SimpleToast.this.setSize(new Dimension(dimension.width, dimension.height + showDistance));
}
}, 0, 50, TimeUnit.MILLISECONDS);
}
private void disappear(JPanel outerJPanel, long delay, TimeUnit timeUnit) {
TIMER = createToastScheduleExecutorService();
TIMER.schedule(new DisappearMotion(outerJPanel), delay, timeUnit);
}
/**
* toast消失的动画效果
* */
class DisappearMotion implements Runnable {
JPanel panel;
DisappearMotion(JPanel panel) {
this.panel = panel;
}
@Override
public void run() {
ScheduledExecutorService TIP_TOOL_TIMER = createToastScheduleExecutorService();
TIP_TOOL_TIMER.scheduleAtFixedRate(new Runnable() {
@Override
public void run() {
Point point = panel.getLocation();
if (point.y <= -hide_height) {
TIP_TOOL_TIMER.shutdown();
SimpleToast.this.setVisible(false);
SimpleToast.this.dispose();
SimpleToast.this.show = false;
}
panel.setLocation(point.x, point.y - 5);
Dimension dimension = SimpleToast.this.getSize();
SimpleToast.this.setSize(new Dimension(dimension.width, dimension.height - 5));
}
}, 0, 50, TimeUnit.MILLISECONDS);
}
}
private void disappear(JPanel outerJPanel) {
disappear(outerJPanel, DEFAULT_DISAPPEAR_DELAY, DEFAULT_TIME_UNIT);
}
private ScheduledExecutorService createToastScheduleExecutorService() {
return ModuleContext.getExecutor().newSingleThreadScheduledExecutor(new NamedThreadFactory(TOAST_MSG_TIMER));
}
@Override
public void checkValid() throws Exception {
}
public void setVisible(boolean visible) {
super.setVisible(visible);
if (visible) {
display(contentPane);
}
}
@Override
public void dispose() {
super.dispose();
}
public boolean isShow() {
return show;
}
}

13
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/action/StartUseAction.java

@ -1,8 +1,10 @@
package com.fr.design.mainframe.alphafine.action;
import com.fr.design.mainframe.alphafine.AlphaFineHelper;
import com.fr.design.mainframe.alphafine.download.FineMarketDownloadManager;
import com.fr.design.mainframe.alphafine.model.TemplateResourceDetail;
import com.fr.design.mainframe.alphafine.search.helper.FineMarketClientHelper;
import javax.swing.SwingWorker;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
@ -24,6 +26,13 @@ public class StartUseAction implements ActionListener {
@Override
public void actionPerformed(ActionEvent e) {
FineMarketClientHelper.getInstance().openBrowserAndDownload(resourceDetail.getRoot());
new SwingWorker<Void, Void>() {
@Override
protected Void doInBackground() throws Exception {
FineMarketDownloadManager.getInstance().downloadAndOpenTemplateResource(resourceDetail.getRoot(), AlphaFineHelper.getAlphaFineDialog());
return null;
}
}.execute();
}
}

170
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/download/FineMarketDownloadManager.java

@ -0,0 +1,170 @@
package com.fr.design.mainframe.alphafine.download;
import com.fr.base.svg.IconUtils;
import com.fr.common.util.Strings;
import com.fr.design.DesignerEnvManager;
import com.fr.design.extra.Process;
import com.fr.design.i18n.Toolkit;
import com.fr.design.login.DesignerLoginHelper;
import com.fr.design.login.DesignerLoginSource;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.alphafine.AlphaFineHelper;
import com.fr.design.mainframe.alphafine.model.TemplateResource;
import com.fr.design.mainframe.alphafine.search.helper.FineMarketClientHelper;
import com.fr.design.mainframe.toast.SimpleToast;
import com.fr.file.FileFILE;
import com.fr.log.FineLoggerFactory;
import com.fr.third.jodd.io.ZipUtil;
import com.fr.workspace.WorkContext;
import java.awt.Desktop;
import java.awt.Window;
import java.io.File;
import java.io.IOException;
import java.util.HashMap;
public class FineMarketDownloadManager {
private static final FineMarketDownloadManager INSTANCE = new FineMarketDownloadManager();
public static final FineMarketDownloadManager getInstance() {
return INSTANCE;
}
public static final double PROCESS_SUCCESS = 1d;
public static final double PROCESS_FAILED = -1d;
public static final double OPENING_FILE = 2d;
private static final String OPENING_PLEASE_WAIT = Toolkit.i18nText("Fine-Design_Report_AlphaFine_Template_Resource_Opening");
private static final String DOWNLOAD_FAILED = Toolkit.i18nText("Fine-Design_Report_AlphaFine_Template_Resource_Download_Failed_Check_Network");
private static final String REPORTLETS = "/reportlets";
private HashMap<String, DownloadProcess> processMap = new HashMap<>();
/**
* 下载资源并解压
* */
public void downloadAndOpenTemplateResource(TemplateResource resource, Window parentWindow){
// 验证登录
String token = DesignerEnvManager.getEnvManager().getDesignerLoginRefreshToken();
if (Strings.isEmpty(token)) {
DesignerLoginHelper.showLoginDialog(DesignerLoginSource.NORMAL, new HashMap<>(), AlphaFineHelper.getAlphaFineDialog());
return;
}
downloadAndOpen(resource, parentWindow);
}
private void downloadAndOpen(TemplateResource resource, Window parentWindow) {
// 获取报表录作为下载位置
String workDir = WorkContext.getCurrent().getPath() + REPORTLETS;
File destDir = new File(workDir);
DownloadProcess downloadProcess = new DownloadProcess(parentWindow);
String fileName = null;
try {
fileName = FineMarketClientHelper.getInstance().download(resource, destDir, downloadProcess);
open(fileName, downloadProcess);
} catch (Exception e) {
downloadProcess.process(FineMarketDownloadManager.PROCESS_FAILED);
FineLoggerFactory.getLogger().error(e, e.getMessage());
}
}
void open(String fileName, DownloadProcess process) throws IOException {
process.process(OPENING_FILE);
if (Strings.isEmpty(fileName)) {
return;
}
File fileNeedOpen = new File(fileName);
if (fileName.endsWith(".zip")) {
File[] files = unzip(fileName);
fileNeedOpen = getFirstCptOrFrm(files);
} else if (fileName.endsWith(".rar")) {
// rar直接打开系统文件夹
File parentDir = new File(fileName).getParentFile();
Desktop.getDesktop().open(parentDir);
return;
}
openInDesigner(fileNeedOpen);
}
private File getFirstCptOrFrm(File[] files) {
for (File f : files) {
if (f.getName().endsWith(".cpt") || f.getName().endsWith(".frm")) {
return f;
}
}
return null;
}
File[] unzip(String fileName) throws IOException {
File file = new File(fileName);
File parentDir = file.getParentFile();
ZipUtil.unzip(file, parentDir);
return parentDir.listFiles();
}
void openInDesigner(File file) {
DesignerContext.getDesignerFrame().openTemplate(new FileFILE(file));
}
/**
* 下载流程控制主要控制ui的显示
* */
class DownloadProcess implements Process<Double> {
SimpleToast downloadingToast;
SimpleToast openingToast;
SimpleToast failedToast;
Window parent;
public DownloadProcess(Window parentWindow) {
this.parent = parentWindow;
init();
}
void init() {
showLoadingToast();
}
@Override
public void process(Double aDouble) {
if (aDouble == PROCESS_FAILED) {
downloadFailed();
} else if (aDouble == PROCESS_SUCCESS) {
downloadSuccess();
} else if (aDouble == OPENING_FILE) {
openingFile();
}
}
public void downloadFailed() {
downloadingToast.setVisible(false);
showFailedToast();
}
public void downloadSuccess() {
downloadingToast.setVisible(false);
}
private void openingFile() {
downloadingToast.setVisible(false);
openingToast = new SimpleToast(AlphaFineHelper.getAlphaFineDialog(), IconUtils.readIcon("/com/fr/design/mainframe/alphafine/images/loading.svg"), OPENING_PLEASE_WAIT, true);
openingToast.setVisible(true);
}
private void showLoadingToast() {
downloadingToast = new SimpleToast(AlphaFineHelper.getAlphaFineDialog(), IconUtils.readIcon("/com/fr/design/mainframe/alphafine/images/loading.svg"), OPENING_PLEASE_WAIT, false);
downloadingToast.setVisible(true);
}
private void showFailedToast() {
failedToast = new SimpleToast(AlphaFineHelper.getAlphaFineDialog(), IconUtils.readIcon("/com/fr/design/mainframe/alphafine/images/caution.svg"), DOWNLOAD_FAILED, true);
failedToast.setVisible(true);
}
}
}

19
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/model/TemplateResource.java

@ -1,5 +1,6 @@
package com.fr.design.mainframe.alphafine.model;
import com.fr.common.util.Strings;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.alphafine.search.manager.impl.TemplateResourceSearchManager;
import com.fr.general.IOUtils;
@ -46,6 +47,7 @@ public class TemplateResource {
public static final String IMAGE_URL = "pic";
public static final String DEMO_URL = "demoUrl";
public static final String PKG_SIZE = "pkgsize";
public static final String FILE_NAME = "fileLoca";
private static final String RECOMMEND_SEARCH_IMG_URL = "com/fr/design/mainframe/alphafine/images/more.png";
@ -57,6 +59,7 @@ public class TemplateResource {
private Image image;
private String name;
private String demoUrl;
private String fileName;
private int pkgSize;
private List<String> recommendSearchKey;
@ -74,7 +77,7 @@ public class TemplateResource {
public static TemplateResource createByJson(JSONObject jsonObject) {
TemplateResource templateResource = new TemplateResource().setId(jsonObject.getString(ID)).setUuid(jsonObject.getString(UUID)).setName(jsonObject.getString(NAME))
.setDemoUrl(jsonObject.getString(DEMO_URL)).setPkgSize(jsonObject.getInt(PKG_SIZE));
.setDemoUrl(jsonObject.getString(DEMO_URL)).setPkgSize(jsonObject.getInt(PKG_SIZE)).setFileName(jsonObject.getString(FILE_NAME));
int pkgSize = templateResource.getPkgSize();
if (pkgSize == 0) {
templateResource.type = Type.SINGLE_TEMPLATE;
@ -110,6 +113,20 @@ public class TemplateResource {
}
public String getFileName() {
return fileName;
}
public TemplateResource setFileName(String fileName) {
if (Strings.isEmpty(fileName)) {
this.fileName = getName() + ".zip";
} else {
this.fileName = fileName;
}
return this;
}
public Type getType() {
return type;
}

202
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/helper/FineMarketClientHelper.java

@ -1,18 +1,45 @@
package com.fr.design.mainframe.alphafine.search.helper;
import com.fr.design.DesignerEnvManager;
import com.fr.design.extra.PluginConstants;
import com.fr.design.mainframe.alphafine.download.FineMarketDownloadManager;
import com.fr.design.mainframe.alphafine.model.TemplateResource;
import com.fr.design.utils.BrowseUtils;
import com.fr.ftp.util.Base64;
import com.fr.general.CloudCenter;
import com.fr.general.http.HttpToolbox;
import com.fr.json.JSONArray;
import com.fr.json.JSONObject;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.StableUtils;
import com.fr.third.org.apache.http.HttpEntity;
import com.fr.third.org.apache.http.HttpException;
import com.fr.third.org.apache.http.HttpStatus;
import com.fr.third.org.apache.http.client.config.CookieSpecs;
import com.fr.third.org.apache.http.client.config.RequestConfig;
import com.fr.third.org.apache.http.client.methods.CloseableHttpResponse;
import com.fr.third.org.apache.http.client.methods.HttpUriRequest;
import com.fr.third.org.apache.http.client.methods.RequestBuilder;
import com.fr.third.org.apache.http.impl.client.BasicCookieStore;
import com.fr.third.org.apache.http.impl.client.CloseableHttpClient;
import com.fr.third.org.apache.http.impl.client.HttpClients;
import org.jetbrains.annotations.Nullable;
import javax.crypto.Cipher;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.security.KeyFactory;
import java.security.interfaces.RSAPublicKey;
import java.security.spec.X509EncodedKeySpec;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class FineMarketClientHelper {
private static final FineMarketClientHelper INSTANCE = new FineMarketClientHelper();
@ -20,10 +47,13 @@ public class FineMarketClientHelper {
return INSTANCE;
}
private static final String CERTIFICATE_PUBLIC_KEY = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCtsz62CPSWXZE/IYZRiAuTSZkw\n" +
"1WOwer8+JFktK0uKLAUuQoBr+UjAMFtRA8W7JgKMDwZy/2liEAiXEOSPU/hrdV8D\n" +
"tT541LnGi1X/hXiRwuttPWYN3L2GYm/d5blU+FBNwghBIrdAxXTzYBc6P4KL/oYX\n" +
"nMdTIrkz8tYkG3QoFQIDAQAB";
public static final String FINE_MARKET_TEMPLATE_INFO = CloudCenter.getInstance().acquireUrlByKind("market.template.info");
public static final String FINE_MARKET_TEMPLATE_URL = CloudCenter.getInstance().acquireUrlByKind("market.template.url");
public static final String LOGIN_FINE_CLUB_AND_REDIRECT_SHOP = CloudCenter.getInstance().acquireUrlByKind("af.login.redirect.market");
public static final String FILE_DOWNLOAD = "file/";
public static final String FILE_DOWNLOAD = "file/download/";
public static final String PACKAGE_DOWNLOAD = "package/download/";
public static final String TEMPLATES_PARENT_PACKAGE = "parent/";
public static final String TEMPLATES_TAGS = "filter";
@ -46,44 +76,157 @@ public class FineMarketClientHelper {
* */
public String getResourceDownloadUrl(TemplateResource templateResource) {
if (TemplateResource.Type.SCENARIO_SOLUTION.equals(templateResource.getType())) {
return getPackageDownloadUrl(templateResource.getId());
return getPackageDownloadUrl();
} else {
return getFileDownLoadUrl(templateResource.getId());
return getFileDownLoadUrl();
}
}
public void openBrowserAndDownload(TemplateResource templateResource) {
String url = LOGIN_FINE_CLUB_AND_REDIRECT_SHOP;
if (TemplateResource.Type.SCENARIO_SOLUTION.equals(templateResource.getType())) {
url += getPackageDownloadUrl(templateResource.getId());
private String getPackageDownloadUrl() {
return FINE_MARKET_TEMPLATE_INFO + PACKAGE_DOWNLOAD;
}
private String getFileDownLoadUrl() {
return FINE_MARKET_TEMPLATE_INFO + FILE_DOWNLOAD;
}
public String download(TemplateResource resource, File destDir, com.fr.design.extra.Process<Double> process) throws Exception {
String resourceId = resource.getId();
CloseableHttpResponse fileRes = getFileResponse(resource, resourceId);
if (fileRes.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
File destFile = createDestFile(destDir, resource);
StableUtils.makesureFileExist(destFile);
FileOutputStream writer = new FileOutputStream(destFile.getAbsolutePath());
HttpEntity entity = fileRes.getEntity();
long totalSize = entity.getContentLength();
InputStream content = entity.getContent();
byte[] data = new byte[PluginConstants.BYTES_NUM];
int bytesRead;
int totalBytesRead = 0;
while ((bytesRead = content.read(data)) > 0) {
writer.write(data, 0, bytesRead);
data = new byte[PluginConstants.BYTES_NUM];
totalBytesRead += bytesRead;
process.process(totalBytesRead / (double) totalSize);
}
content.close();
writer.flush();
writer.close();
FineLoggerFactory.getLogger().info("download resource{} success", resourceId);
process.process(FineMarketDownloadManager.PROCESS_SUCCESS);
return destFile.getAbsolutePath();
} else {
url += getFileDownLoadUrl(templateResource.getId());
FineLoggerFactory.getLogger().info("download resource{} failed", resourceId);
process.process(FineMarketDownloadManager.PROCESS_FAILED);
throw new HttpException();
}
BrowseUtils.browser(url);
}
/**
* 暂时没有package的下载接口需要用户在浏览器点击下载
* */
private String getPackageDownloadUrl(String id) {
return getTemplateUrlById(id);
private CloseableHttpResponse getFileResponse(TemplateResource resource, String resourceId) throws Exception {
CloseableHttpResponse fileRes = postDownloadHttpResponse(getResourceDownloadUrl(resource), resourceId);
if (fileRes.getStatusLine().getStatusCode() == HttpStatus.SC_MOVED_TEMPORARILY) {
fileRes = getDownloadHttpResponse(fileRes.getHeaders("Location")[0].getValue());
}
return fileRes;
}
/**
* 打开浏览器下载单一模板
* 在目标路径下destDir创建与资源名称相同的文件夹 (finalDir)
* 将资源下载到 destDir/finalDir
* 如果文件重复则在文件名前加自增id
* */
private String getFileDownLoadUrl(String id) {
return FINE_MARKET_TEMPLATE_INFO + FILE_DOWNLOAD + id;
private File createDestFile(File destDir, TemplateResource resource) {
String fileName = resource.getName();
try {
File finalDir = new File(destDir.getAbsolutePath() + "/" + fileName);
if (!finalDir.exists()) {
finalDir.mkdir();
}
// 获取文件名(含后缀)
fileName = resource.getFileName();
// 处理重复文件名
String fileNameFormat = "(%d)" + fileName;
Pattern pattern = Pattern.compile("\\((\\d)\\)" + fileName);
int cnt = 0;
File[] files = finalDir.listFiles();
for (File f : files) {
Matcher matcher = pattern.matcher(f.getName());
if (matcher.find()) {
cnt = Math.max(cnt, Integer.parseInt(matcher.group(1)));
}
}
cnt++;
fileName = String.format(fileNameFormat, cnt);
File destFile = new File(finalDir.getAbsolutePath() + "/" + fileName);
destFile.createNewFile();
return destFile;
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e, e.getMessage());
}
return null;
}
private static CloseableHttpResponse getDownloadHttpResponse(String url) throws Exception {
//先登录一下。不然可能失败
CloseableHttpClient client = createClient();
HttpUriRequest file = RequestBuilder.get()
.setUri(url)
.build();
return client.execute(file);
}
private static CloseableHttpResponse postDownloadHttpResponse(String url, String id) throws Exception {
return postDownloadHttpResponse(url, id, new HashMap<>());
}
private static CloseableHttpResponse postDownloadHttpResponse(String url, String id, Map<String, String> params) throws Exception {
//先登录一下。不然可能失败
CloseableHttpClient client = createClient();
FineLoggerFactory.getLogger().info("login fr-market");
FineLoggerFactory.getLogger().info("start download resource {}", id);
RequestBuilder builder = RequestBuilder.post()
.setHeader("User-Agent", "Mozilla/5.0")
.setUri(url)
.addParameter("id", encrypt(id))
.addParameter("userId", String.valueOf(DesignerEnvManager.getEnvManager().getDesignerLoginUid()));
/**
* 获取帆软市场模板资源页面链接
* */
public String getFineMarketTemplateUrl() {
return FINE_MARKET_TEMPLATE_URL;
if (params != null) {
Set<String> keys = params.keySet();
for (String key: keys) {
builder.addParameter(key, params.get(key));
}
}
return client.execute(builder.build());
}
private static CloseableHttpClient createClient() {
BasicCookieStore cookieStore = new BasicCookieStore();
return HttpClients.custom()
.setDefaultRequestConfig(RequestConfig.custom()
.setCookieSpec(CookieSpecs.STANDARD).build())
.setDefaultCookieStore(cookieStore)
.build();
}
public @Nullable JSONObject getTemplateInfoById(String id) throws IOException {
@ -175,4 +318,15 @@ public class FineMarketClientHelper {
}
}
private static String encrypt(String str) throws Exception {
//base64编码的公钥
byte[] decoded = Base64.decodeBase64(CERTIFICATE_PUBLIC_KEY);
RSAPublicKey pubKey = (RSAPublicKey) KeyFactory.getInstance("RSA").generatePublic(new X509EncodedKeySpec(decoded));
//RSA加密
Cipher cipher = Cipher.getInstance("RSA");
cipher.init(Cipher.ENCRYPT_MODE, pubKey);
String outStr = Base64.encodeBase64String(cipher.doFinal(str.getBytes(StandardCharsets.UTF_8)));
return outStr;
}
}

5
designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/caution.svg

@ -0,0 +1,5 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M15 8C15 11.8656 11.8656 15 8 15C4.13435 15 1 11.8656 1 8C1 4.13435 4.13435 1 8 1C11.8656 1 15 4.13435 15 8Z" fill="#FBB03B"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M7.43328 10.292C7.27773 10.4476 7.19995 10.6365 7.19995 10.8587C7.19995 11.0809 7.27773 11.2698 7.43328 11.4254C7.58884 11.5809 7.77773 11.6587 7.99995 11.6587C8.22217 11.6587 8.41106 11.5809 8.56662 11.4254C8.72217 11.2698 8.79995 11.0809 8.79995 10.8587C8.79995 10.6365 8.72217 10.4476 8.56662 10.292C8.41106 10.1365 8.22217 10.0587 7.99995 10.0587C7.77773 10.0587 7.58884 10.1365 7.43328 10.292Z" fill="white"/>
<rect x="7.30005" y="4.22144" width="1.4" height="5" rx="0.7" fill="white"/>
</svg>

After

Width:  |  Height:  |  Size: 820 B

3
designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/loading.svg

@ -0,0 +1,3 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M7.99997 0.615356C3.92156 0.615356 0.615356 3.92156 0.615356 7.99997C0.615356 9.00517 0.816197 9.96346 1.17994 10.8369L2.32206 10.3771C2.0155 9.64576 1.84613 8.84265 1.84613 7.99997C1.84613 4.6013 4.6013 1.84613 7.99997 1.84613C8.58656 1.84613 9.15398 1.9282 9.69137 2.08148L8.55836 4.00142H12.6779C12.678 4.00154 12.6781 4.00165 12.6782 4.00176H14.2096C12.8951 1.96429 10.605 0.615356 7.99997 0.615356ZM14.7714 5.04894L13.6568 5.57321C13.9767 6.31781 14.1538 7.1382 14.1538 7.99997C14.1538 11.3986 11.3986 14.1538 7.99997 14.1538C7.43089 14.1538 6.87986 14.0766 6.35677 13.932L7.49691 12L6.62743 12L3.3233 12L1.79146 12C3.10622 14.0364 5.39566 15.3846 7.99997 15.3846C12.0784 15.3846 15.3846 12.0784 15.3846 7.99997C15.3846 6.95082 15.1658 5.95276 14.7714 5.04894Z" fill="#419BF9"/>
</svg>

After

Width:  |  Height:  |  Size: 936 B

Loading…
Cancel
Save