From 6b3f2f46f58a2fb0360f0569f72e3200025da2b8 Mon Sep 17 00:00:00 2001 From: hades Date: Mon, 25 Apr 2022 15:40:44 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-67417=20=E8=BF=90=E8=90=A5=E4=BA=A7?= =?UTF-8?q?=E5=93=81v1.0=20=E8=A1=A5=E5=85=85=E4=B8=80=E4=BA=9B=E5=86=85?= =?UTF-8?q?=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../alphafine/AlphaFineConstants.java | 2 ++ .../alphafine/component/AlphaFineFrame.java | 30 +++++++++++-------- .../preview/HelpDocumentNoResultPane.java | 19 ++++++------ .../preview/NoResultWithLinkPane.java | 30 ++++++++++++++++++- 4 files changed, 59 insertions(+), 22 deletions(-) diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/AlphaFineConstants.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/AlphaFineConstants.java index 6afce21e4..08ed7ef51 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/AlphaFineConstants.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/AlphaFineConstants.java @@ -140,6 +140,8 @@ public class AlphaFineConstants { public static final String ALPHA_CID = CloudCenter.getInstance().acquireUrlByKind("af.cid"); + public static final String ALPHA_HELP_RECOMMEND = CloudCenter.getInstance().acquireUrlByKind("af.recommend"); + public static final String JAVASCRIPT_PREFIX = "javascript:SendJava"; public static final String CHINESE_CHARACTERS = "[\\u4e00-\\u9fa5]"; diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineFrame.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineFrame.java index 2911ef68f..52ddd614c 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineFrame.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineFrame.java @@ -30,6 +30,10 @@ import com.fr.design.mainframe.alphafine.search.manager.impl.ProductNewsSearchMa import com.fr.design.mainframe.alphafine.search.manager.impl.SegmentationManager; import com.fr.design.utils.DesignUtils; import com.fr.general.ComparatorUtils; +import com.fr.json.JSON; +import com.fr.json.JSONArray; +import com.fr.json.JSONFactory; +import com.fr.json.JSONObject; import com.fr.stable.StringUtils; import java.awt.BorderLayout; import java.awt.CardLayout; @@ -319,11 +323,7 @@ public class AlphaFineFrame extends JFrame { readLabel.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { - List productNewsList = ProductNewsSearchManager.getInstance().getCachedProductNewsList(); - Set readSet = DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().getReadSet(); - for (ProductNews productNews : productNewsList) { - readSet.add(productNews.getId()); - } + fireOneClickRead(); showPane.repaint(); } }); @@ -403,15 +403,21 @@ public class AlphaFineFrame extends JFrame { return showPane; } - // todo 暂无 先做测试 + private void fireOneClickRead() { + List productNewsList = ProductNewsSearchManager.getInstance().getCachedProductNewsList(); + Set readSet = DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().getReadSet(); + for (ProductNews productNews : productNewsList) { + readSet.add(productNews.getId()); + } + } + private Map generateMap() { + JSONArray jsonArray = JSONFactory.createJSON(JSON.ARRAY, AlphaFineConstants.ALPHA_HELP_RECOMMEND); Map linkMap = new LinkedHashMap<>(); - linkMap.put("test", "https://www.baidu.com"); - linkMap.put("test1", "https://www.baidu.com"); - linkMap.put("test2", "https://www.baidu.com"); - linkMap.put("test3", "https://www.baidu.com"); - linkMap.put("test4", "https://www.baidu.com"); - linkMap.put("test5", "https://www.baidu.com"); + for (int i = 0, len = jsonArray.size(); i < len; i++) { + JSONObject json = jsonArray.getJSONObject(i); + linkMap.put(json.getString("name"), json.getString("link")); + } return linkMap; } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/HelpDocumentNoResultPane.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/HelpDocumentNoResultPane.java index 4a2ede608..d88da9637 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/HelpDocumentNoResultPane.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/HelpDocumentNoResultPane.java @@ -3,17 +3,14 @@ package com.fr.design.mainframe.alphafine.preview; import com.fr.design.constants.UIConstants; import com.fr.design.gui.ilable.UILabel; import com.fr.design.i18n.Toolkit; +import com.fr.design.utils.BrowseUtils; import com.fr.design.utils.DesignUtils; -import com.fr.log.FineLoggerFactory; import java.awt.BorderLayout; import java.awt.Color; -import java.awt.Desktop; import java.awt.Dimension; import java.awt.GridLayout; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; -import java.io.IOException; -import java.net.URI; import java.util.Map; import javax.swing.BorderFactory; import javax.swing.Icon; @@ -69,11 +66,7 @@ public class HelpDocumentNoResultPane extends JPanel { listLabel.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { - try { - Desktop.getDesktop().browse(URI.create(link)); - } catch (IOException exception) { - FineLoggerFactory.getLogger().error(exception.getMessage(), exception); - } + responseClick(link); } }); @@ -90,5 +83,13 @@ public class HelpDocumentNoResultPane extends JPanel { return listPane; } + /** + * 方便记录埋点 + * + * @param link + */ + private void responseClick(String link) { + BrowseUtils.browser(link); + } } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/NoResultWithLinkPane.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/NoResultWithLinkPane.java index 1f61342c4..3dc4a44b2 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/NoResultWithLinkPane.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/NoResultWithLinkPane.java @@ -2,11 +2,14 @@ package com.fr.design.mainframe.alphafine.preview; import com.fr.design.dialog.link.MessageWithLink; import com.fr.design.mainframe.alphafine.AlphaFineConstants; +import com.fr.design.utils.BrowseUtils; import com.fr.design.utils.DesignUtils; import java.awt.Color; import java.awt.Component; import javax.swing.BorderFactory; import javax.swing.Icon; +import javax.swing.event.HyperlinkEvent; +import javax.swing.event.HyperlinkListener; /** * 带跳转链接的无结果面板 @@ -28,8 +31,33 @@ public class NoResultWithLinkPane extends NoResultPane { protected Component generateDescription(String title) { String[] para1 = title.split(TAG_A_START); String[] para2 = para1[1].split(TAG_A_END); - MessageWithLink messageWithLink = new MessageWithLink(para1[0], para2[0], AlphaFineConstants.ALPHA_GO_TO_FORUM, para2[1], Color.WHITE, DesignUtils.getDefaultGUIFont().applySize(14), AlphaFineConstants.MEDIUM_GRAY); + + MessageWithLink messageWithLink = new MessageWithLink(para1[0], para2[0], AlphaFineConstants.ALPHA_GO_TO_FORUM, para2[1], Color.WHITE, DesignUtils.getDefaultGUIFont().applySize(14), AlphaFineConstants.MEDIUM_GRAY) { + @Override + protected void initListener(String link) { + + addHyperlinkListener(new HyperlinkListener() { + @Override + public void hyperlinkUpdate(HyperlinkEvent e) { + if (e.getEventType().equals(HyperlinkEvent.EventType.ACTIVATED)) { + jumpToForum(link); + } + } + }); + } + }; messageWithLink.setBorder(BorderFactory.createEmptyBorder(0, AlphaFineConstants.LEFT_WIDTH - 30, 135, 0)); return messageWithLink; } + + + /** + * 方便记录埋点 + * + * @param link + */ + private void jumpToForum(String link) { + BrowseUtils.browser(link); + } + }