Browse Source

REPORT-79096【运营产品化二期】交互问题集合二

REPORT-79341【运营产品化二期】立即使用下载的模板名称目前是开头加了(1),是否可按浏览器规则
1、改ui
2、改文件重名规则
release/11.0
Link.Zhao 2 years ago
parent
commit
5cdc79bbbf
  1. 16
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/RecommendSearchPane.java
  2. 8
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/TemplateResourceImagePanel.java
  3. 1
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/TemplateResourcePageGridPane.java
  4. 29
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/TemplateResourcePanel.java
  5. 5
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/TemplateResourceDetailPane.java
  6. 39
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/helper/FineMarketClientHelper.java

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);
} }
} }

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

@ -5,8 +5,10 @@ import com.fr.design.mainframe.alphafine.model.TemplateResource;
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 +19,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 = new Font("PingFang SC", Font.PLAIN, 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 +60,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() {

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

@ -12,6 +12,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 +20,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 = new Font("PingFang SC", Font.PLAIN, 12);
private static final Color RESOURCE_NAME_COLOR = new Color(0x5c5c5d);
protected TemplateResourcePanel() { protected TemplateResourcePanel() {
@ -35,7 +38,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 +63,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 +74,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 +84,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 +114,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

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

@ -66,8 +66,8 @@ 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 String HTML_FORMAT = "<html><style>a {color: #419BF9;text-decoration:none;}</style><body style=\"font-family: 'PingFang SC';font-style: normal;font-weight: 400;font-size: 12pt;line-height: 20px; color: #5c5c5d;\">%s</body></html>";
private static final String DETAIL_INFO_HTML_FORMAT = "<html><body style=\"font-size: 12pt\"><h3>" + DETAIL_INFO + "</h3>%s</body></html>"; private static final String DETAIL_INFO_HTML_FORMAT = "<html><style>a {color: #419BF9;text-decoration:none;}</style><body style=\"font-family: 'PingFang SC';font-style: normal;font-weight: 400;font-size: 12pt;line-height: 20px; color: #5c5c5d;\"><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 +208,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));
} }

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

@ -161,17 +161,36 @@ public class FineMarketClientHelper {
finalDir.mkdir(); finalDir.mkdir();
} }
// 获取文件名(含后缀)
fileName = resource.getFileName(); fileName = resource.getFileName();
String prefix = fileName.substring(0, fileName.length() - 4); fileName = rename(fileName, finalDir);
String suffix = fileName.substring(fileName.length() - 4);
// 处理重复文件名 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) {
// 获取文件名(含后缀)
String prefix = fileName.substring(0, 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 +199,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