Browse Source

Pull request #9897: REPORT-79096【运营产品化二期】交互问题集合二 REPORT-79341【运营产品化二期】立即使用下载的模板名称目前是开头加了(1),是否可按浏览器规则

Merge in DESIGN/design from ~LINK.ZHAO/design:release/11.0 to release/11.0

* commit 'd0e965a8dcf132f0c7b7fbde40f22188092122fc':
  REPORT-79096【运营产品化二期】交互问题集合二 REPORT-79341【运营产品化二期】立即使用下载的模板名称目前是开头加了(1),是否可按浏览器规则
  REPORT-79096【运营产品化二期】交互问题集合二 REPORT-79341【运营产品化二期】立即使用下载的模板名称目前是开头加了(1),是否可按浏览器规则 1、改ui 2、改文件重名规则
newui
Link.Zhao 2 years ago
parent
commit
3460ccc05a
  1. 13
      designer-base/src/main/java/com/fr/design/utils/LinkStrUtils.java
  2. 16
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/RecommendSearchPane.java
  3. 10
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/TemplateResourceImagePanel.java
  4. 1
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/TemplateResourcePageGridPane.java
  5. 30
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/TemplateResourcePanel.java
  6. 9
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/TemplateResourceDetailPane.java
  7. 40
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/helper/FineMarketClientHelper.java

13
designer-base/src/main/java/com/fr/design/utils/LinkStrUtils.java

@ -60,6 +60,19 @@ public class LinkStrUtils {
return style.toString(); return style.toString();
} }
public static String generateStyle(Font font, Color fontColor) {
// 构建相同风格样式
StringBuilder style = new StringBuilder("font-family:" + font.getFamily() + ";");
style.append("font-weight:").append(font.isBold() ? "bold" : "normal").append(";");
style.append("font-size:").append(font.getSize()).append("pt;");
style.append("color:rgb(").append(fontColor.getRed()).append(",").append(fontColor.getGreen()).append(",").append(fontColor.getBlue()).append(");");
return style.toString();
}
public static String generateDefaultStyle() { public static String generateDefaultStyle() {
return generateStyle(LABEL.getBackground(), LABEL.getFont(), LABEL.getForeground()); return generateStyle(LABEL.getBackground(), LABEL.getFont(), LABEL.getForeground());

16
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/RecommendSearchPane.java

@ -27,27 +27,27 @@ public class RecommendSearchPane extends TemplateResourcePanel {
this.setBorder(BorderFactory.createLineBorder(BORDER_WHITE, 1)); this.setBorder(BorderFactory.createLineBorder(BORDER_WHITE, 1));
this.add(getNorthPane(), BorderLayout.NORTH); this.add(getNorthPane(), BorderLayout.NORTH);
this.add(getSouthPane(), BorderLayout.SOUTH); this.add(getCenterPane(), BorderLayout.CENTER);
} }
private void initComponent() { private void initComponent() {
createNorthPane(); createNorthPane();
createSouthPane(); createCenterPane();
} }
private void createSouthPane() { private void createCenterPane() {
setSouthPane(new JPanel(new FlowLayout(FlowLayout.LEFT))); setCenterPane(new JPanel(new FlowLayout(FlowLayout.LEFT)));
JPanel southPane = getSouthPane(); JPanel centerPane = getCenterPane();
southPane.setBackground(Color.WHITE); centerPane.setBackground(Color.WHITE);
JLabel recommend = new JLabel(Toolkit.i18nText("Fine-Design_Report_AlphaFine_Template_Resource_Recommend_For_You")); JLabel recommend = new JLabel(Toolkit.i18nText("Fine-Design_Report_AlphaFine_Template_Resource_Recommend_For_You"));
southPane.add(recommend); centerPane.add(recommend);
List<String> searchKeys = getTemplateResource().getRecommendSearchKey(); List<String> searchKeys = getTemplateResource().getRecommendSearchKey();
for (String key : searchKeys) { for (String key : searchKeys) {
JLabel keyLabel = new SearchKeyLabel(key); JLabel keyLabel = new SearchKeyLabel(key);
southPane.add(keyLabel); centerPane.add(keyLabel);
} }
} }

10
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/TemplateResourceImagePanel.java

@ -2,11 +2,15 @@ package com.fr.design.mainframe.alphafine.component;
import com.fr.base.GraphHelper; import com.fr.base.GraphHelper;
import com.fr.design.mainframe.alphafine.model.TemplateResource; import com.fr.design.mainframe.alphafine.model.TemplateResource;
import com.fr.design.utils.DesignUtils;
import com.fr.general.FRFont;
import com.fr.third.jodd.util.StringUtil; import com.fr.third.jodd.util.StringUtil;
import javax.swing.JPanel; import javax.swing.JPanel;
import java.awt.AlphaComposite;
import java.awt.Color; import java.awt.Color;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.Font;
import java.awt.Graphics; import java.awt.Graphics;
import java.awt.Graphics2D; import java.awt.Graphics2D;
import java.awt.Image; import java.awt.Image;
@ -17,7 +21,9 @@ public class TemplateResourceImagePanel extends JPanel {
private static final int BACKGROUND_HEIGHT = 20; private static final int BACKGROUND_HEIGHT = 20;
private static final Color BACKGROUND_COLOR = new Color(116, 181, 249); private static final Color BACKGROUND_COLOR = new Color(0x419BF9);
private static final Font TAG_FONT = DesignUtils.getDefaultGUIFont().applySize(12);
private static final Color COVER_COLOR = new Color(116, 181, 249, 26); private static final Color COVER_COLOR = new Color(116, 181, 249, 26);
@ -56,10 +62,12 @@ public class TemplateResourceImagePanel extends JPanel {
String tagName = templateResource.getType().getName(); String tagName = templateResource.getType().getName();
if (!StringUtil.isEmpty(tagName)) { if (!StringUtil.isEmpty(tagName)) {
g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, .8f));
g2.setColor(BACKGROUND_COLOR); g2.setColor(BACKGROUND_COLOR);
g2.fillRect(0, getHeight() - BACKGROUND_HEIGHT, getWidth(), BACKGROUND_HEIGHT); g2.fillRect(0, getHeight() - BACKGROUND_HEIGHT, getWidth(), BACKGROUND_HEIGHT);
g2.setColor(Color.WHITE); g2.setColor(Color.WHITE);
int x = (getWidth() - GraphHelper.getWidth(tagName, g2.getFont())) / 2; int x = (getWidth() - GraphHelper.getWidth(tagName, g2.getFont())) / 2;
g2.setFont(TAG_FONT);
g2.drawString(tagName, x, getHeight() - 5); g2.drawString(tagName, x, getHeight() - 5);
} }
g2.setColor(defaultColor); g2.setColor(defaultColor);

1
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/TemplateResourcePageGridPane.java

@ -126,6 +126,7 @@ public class TemplateResourcePageGridPane extends JPanel {
this.add(pageButtonPane, BorderLayout.SOUTH); this.add(pageButtonPane, BorderLayout.SOUTH);
} }
this.setBackground(Color.WHITE); this.setBackground(Color.WHITE);
this.setBorder(BorderFactory.createEmptyBorder());
} }
private void initComponents() { private void initComponents() {

30
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/TemplateResourcePanel.java

@ -4,6 +4,7 @@ import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.alphafine.model.TemplateResource; import com.fr.design.mainframe.alphafine.model.TemplateResource;
import com.fr.design.mainframe.alphafine.preview.TemplateShopPane; import com.fr.design.mainframe.alphafine.preview.TemplateShopPane;
import com.fr.design.utils.BrowseUtils; import com.fr.design.utils.BrowseUtils;
import com.fr.design.utils.DesignUtils;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
@ -12,6 +13,7 @@ import javax.swing.JPanel;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Color; import java.awt.Color;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.Font;
import java.awt.event.MouseAdapter; import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
@ -19,11 +21,13 @@ import java.awt.event.MouseEvent;
public class TemplateResourcePanel extends JPanel { public class TemplateResourcePanel extends JPanel {
private JPanel northPane; private JPanel northPane;
private JPanel southPane; private JPanel centerPane;
private TemplateResource templateResource; private TemplateResource templateResource;
private static final Color PANEL_BORDER_COLOR = new Color(0xe8e8e9); private static final Color PANEL_BORDER_COLOR = new Color(0xe8e8e9);
private static final Color DEMO_LABEL_FOREGROUND = new Color(0x419bf9); private static final Color DEMO_LABEL_FOREGROUND = new Color(0x419bf9);
private static final Font RESOURCE_NAME_FONT = DesignUtils.getDefaultGUIFont().applySize(12);
private static final Color RESOURCE_NAME_COLOR = new Color(0x5c5c5d);
protected TemplateResourcePanel() { protected TemplateResourcePanel() {
@ -35,7 +39,7 @@ public class TemplateResourcePanel extends JPanel {
this.setLayout(new BorderLayout()); this.setLayout(new BorderLayout());
this.setBorder(BorderFactory.createLineBorder(PANEL_BORDER_COLOR, 1)); this.setBorder(BorderFactory.createLineBorder(PANEL_BORDER_COLOR, 1));
this.add(northPane, BorderLayout.NORTH); this.add(northPane, BorderLayout.NORTH);
this.add(southPane, BorderLayout.SOUTH); this.add(centerPane, BorderLayout.CENTER);
addAction(); addAction();
} }
@ -60,8 +64,8 @@ public class TemplateResourcePanel extends JPanel {
public JPanel getNorthPane() { public JPanel getNorthPane() {
return northPane; return northPane;
} }
public JPanel getSouthPane() { public JPanel getCenterPane() {
return southPane; return centerPane;
} }
public TemplateResource getTemplateResource() { public TemplateResource getTemplateResource() {
return templateResource; return templateResource;
@ -71,8 +75,8 @@ public class TemplateResourcePanel extends JPanel {
this.northPane = northPane; this.northPane = northPane;
} }
public void setSouthPane(JPanel southPane) { public void setCenterPane(JPanel centerPane) {
this.southPane = southPane; this.centerPane = centerPane;
} }
public void setTemplateResource(TemplateResource templateResource) { public void setTemplateResource(TemplateResource templateResource) {
@ -81,15 +85,17 @@ public class TemplateResourcePanel extends JPanel {
private void initComponent() { private void initComponent() {
createNorthPane(); createNorthPane();
createSouthPane(); createCenterPane();
} }
protected void createNorthPane() { protected void createNorthPane() {
northPane = new TemplateResourceImagePanel(templateResource); northPane = new TemplateResourceImagePanel(templateResource);
} }
private void createSouthPane() { private void createCenterPane() {
JLabel nameLabel = new JLabel(templateResource.getName()); JLabel nameLabel = new JLabel(templateResource.getName());
nameLabel.setFont(RESOURCE_NAME_FONT);
nameLabel.setForeground(RESOURCE_NAME_COLOR);
nameLabel.setBackground(Color.WHITE); nameLabel.setBackground(Color.WHITE);
nameLabel.setBorder(BorderFactory.createEmptyBorder()); nameLabel.setBorder(BorderFactory.createEmptyBorder());
@ -109,10 +115,10 @@ public class TemplateResourcePanel extends JPanel {
}); });
} }
southPane = new JPanel(new BorderLayout()); centerPane = new JPanel(new BorderLayout());
southPane.setBackground(Color.WHITE); centerPane.setBackground(Color.WHITE);
southPane.add(nameLabel, BorderLayout.WEST); centerPane.add(nameLabel, BorderLayout.WEST);
southPane.add(demoLabel, BorderLayout.EAST); centerPane.add(demoLabel, BorderLayout.EAST);
} }
@Override @Override

9
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/TemplateResourceDetailPane.java

@ -9,6 +9,7 @@ import com.fr.design.mainframe.alphafine.action.StartUseAction;
import com.fr.design.mainframe.alphafine.component.TemplateResourceImagePanel; import com.fr.design.mainframe.alphafine.component.TemplateResourceImagePanel;
import com.fr.design.mainframe.alphafine.model.TemplateResourceDetail; import com.fr.design.mainframe.alphafine.model.TemplateResourceDetail;
import com.fr.design.utils.BrowseUtils; import com.fr.design.utils.BrowseUtils;
import com.fr.design.utils.DesignUtils;
import com.fr.design.utils.LinkStrUtils; import com.fr.design.utils.LinkStrUtils;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
@ -20,6 +21,7 @@ import javax.swing.SwingUtilities;
import java.awt.Color; import java.awt.Color;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.FlowLayout; import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.Graphics; import java.awt.Graphics;
import java.awt.Graphics2D; import java.awt.Graphics2D;
import java.awt.RenderingHints; import java.awt.RenderingHints;
@ -66,8 +68,10 @@ public class TemplateResourceDetailPane extends JPanel {
private static final Color INFO_PANE_FOREGROUND = new Color(0x5b5b5c); private static final Color INFO_PANE_FOREGROUND = new Color(0x5b5b5c);
private static final Color MORE_INFO_LINK = new Color(0x419bf9); private static final Color MORE_INFO_LINK = new Color(0x419bf9);
private static final String HTML_FORMAT = "<html><body style=\"font-size: 12pt\">%s</body></html>"; private static final Font HTML_FONT = DesignUtils.getDefaultGUIFont().applySize(12);
private static final String DETAIL_INFO_HTML_FORMAT = "<html><body style=\"font-size: 12pt\"><h3>" + DETAIL_INFO + "</h3>%s</body></html>"; private static final Color HTML_COLOR = new Color(0x5c5c5d);
private static final String HTML_FORMAT = "<html><style>a {color: #419BF9;text-decoration:none;}</style><body style=\"line-height: 20px;"+ LinkStrUtils.generateStyle(HTML_FONT, HTML_COLOR) +"\">%s</body></html>";
private static final String DETAIL_INFO_HTML_FORMAT = "<html><style>a {color: #419BF9;text-decoration:none;}</style><body style=\"line-height: 20px;" + LinkStrUtils.generateStyle(HTML_FONT, HTML_COLOR) + "\"><p>" + DETAIL_INFO + "</p>%s</body></html>";
private static final String HTML_P_TAG_FORMAT = "<p style=\"margin-top:5pt;\">%s</p>"; private static final String HTML_P_TAG_FORMAT = "<p style=\"margin-top:5pt;\">%s</p>";
@ -208,6 +212,7 @@ public class TemplateResourceDetailPane extends JPanel {
content.setBackground(INFO_PANE_BACKGROUND); content.setBackground(INFO_PANE_BACKGROUND);
content.setForeground(INFO_PANE_FOREGROUND); content.setForeground(INFO_PANE_FOREGROUND);
infoScrollPane = new UIScrollPane(content); infoScrollPane = new UIScrollPane(content);
infoScrollPane.setForeground(INFO_PANE_FOREGROUND);
infoScrollPane.setPreferredSize(new Dimension(SCROLL_PANE_WIDTH, SCROLL_PANE_HEIGHT)); infoScrollPane.setPreferredSize(new Dimension(SCROLL_PANE_WIDTH, SCROLL_PANE_HEIGHT));
infoScrollPane.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); infoScrollPane.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
} }

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

@ -61,6 +61,8 @@ public class FineMarketClientHelper {
public static final String TAGS_ITEMS = "items"; public static final String TAGS_ITEMS = "items";
public static final String TAG_NAME = "name"; public static final String TAG_NAME = "name";
public static final String TAG_ID = "id"; public static final String TAG_ID = "id";
private static final String FILENAME_FORMAT = ".+?(.zip|.rar|.cpt|.frm)";
private static final Pattern FILENAME_PATTERN = Pattern.compile(FILENAME_FORMAT);
// 缓存下所有tag标签 // 缓存下所有tag标签
private Map<String, String> tags; private Map<String, String> tags;
@ -161,17 +163,41 @@ public class FineMarketClientHelper {
finalDir.mkdir(); finalDir.mkdir();
} }
// 获取文件名(含后缀)
fileName = resource.getFileName(); fileName = resource.getFileName();
fileName = rename(fileName, finalDir);
File destFile = new File(StableUtils.pathJoin(FileCommonUtils.getAbsolutePath(finalDir), fileName));
return destFile;
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e, e.getMessage());
}
fileName = UUID.randomUUID() + fileName;
File dest = new File(StableUtils.pathJoin(FileCommonUtils.getAbsolutePath(finalDir), fileName));
return dest;
}
/**
* 处理下文件名比如重复下载需要处理重名的情况
* */
String rename(String fileName, File parentDir) throws Exception {
if (!FILENAME_PATTERN.matcher(fileName).matches()) {
throw new Exception("fileName format error: " + fileName);
}
// 获取文件名(含后缀)
String prefix = fileName.substring(0, fileName.length() - 4); String prefix = fileName.substring(0, fileName.length() - 4);
String suffix = fileName.substring(fileName.length() - 4); String suffix = fileName.substring(fileName.length() - 4);
File file = new File(StableUtils.pathJoin(FileCommonUtils.getAbsolutePath(parentDir), fileName));
// 处理重复文件名 // 处理重复文件名
if (file.exists()) {
String fileNameFormat = prefix + "(%d)" + suffix; String fileNameFormat = prefix + "(%d)" + suffix;
Pattern pattern = Pattern.compile(prefix + "\\((\\d)\\)" + suffix); Pattern pattern = Pattern.compile(prefix + "\\((\\d)\\)" + suffix);
int cnt = 0; int cnt = 0;
File[] files = finalDir.listFiles(); File[] files = parentDir.listFiles();
for (File f : files) { for (File f : files) {
Matcher matcher = pattern.matcher(f.getName()); Matcher matcher = pattern.matcher(f.getName());
if (matcher.find()) { if (matcher.find()) {
@ -180,15 +206,9 @@ public class FineMarketClientHelper {
} }
cnt++; cnt++;
fileName = String.format(fileNameFormat, cnt); fileName = String.format(fileNameFormat, cnt);
File destFile = new File(StableUtils.pathJoin(FileCommonUtils.getAbsolutePath(finalDir), fileName));
return destFile;
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e, e.getMessage());
} }
fileName = UUID.randomUUID() + fileName; return fileName;
File dest = new File(StableUtils.pathJoin(FileCommonUtils.getAbsolutePath(finalDir), fileName));
return dest;
} }
private static CloseableHttpResponse getDownloadHttpResponse(String url) throws Exception { private static CloseableHttpResponse getDownloadHttpResponse(String url) throws Exception {

Loading…
Cancel
Save