From e46c016d56be07d9bfcbaf36ce95c5b1fdc466b0 Mon Sep 17 00:00:00 2001 From: rememberber Date: Fri, 6 Dec 2024 14:32:14 +0800 Subject: [PATCH] =?UTF-8?q?About=E9=A1=B5=E9=9D=A2=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E8=B4=A1=E7=8C=AE=E8=80=85=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- contributor.json | 14 +++++ .../moo/tool/bean/ContributorInfo.java | 20 +++++++ .../com/luoboduner/moo/tool/ui/UiConsts.java | 4 ++ .../moo/tool/ui/form/AboutForm.form | 22 +++++-- .../moo/tool/ui/form/AboutForm.java | 60 +++++++++++++++++-- .../tool/ui/form/ContributorAvatarForm.form | 30 ++++++++++ .../tool/ui/form/ContributorAvatarForm.java | 44 ++++++++++++++ 7 files changed, 182 insertions(+), 12 deletions(-) create mode 100644 contributor.json create mode 100644 src/main/java/com/luoboduner/moo/tool/bean/ContributorInfo.java create mode 100644 src/main/java/com/luoboduner/moo/tool/ui/form/ContributorAvatarForm.form create mode 100644 src/main/java/com/luoboduner/moo/tool/ui/form/ContributorAvatarForm.java diff --git a/contributor.json b/contributor.json new file mode 100644 index 00000000..321a08c3 --- /dev/null +++ b/contributor.json @@ -0,0 +1,14 @@ +{ + "contributorList": [ + { + "name": "John Doe", + "avatarUrl": "https://avatars.githubusercontent.com/u/17471768?s=64&v=4", + "link": "https://gitee.com/" + }, + { + "name": "Jane Doe", + "avatarUrl": "https://avatars.githubusercontent.com/u/17471768?s=64&v=4", + "link": "https://gitee.com/" + } + ] +} \ No newline at end of file diff --git a/src/main/java/com/luoboduner/moo/tool/bean/ContributorInfo.java b/src/main/java/com/luoboduner/moo/tool/bean/ContributorInfo.java new file mode 100644 index 00000000..7500d496 --- /dev/null +++ b/src/main/java/com/luoboduner/moo/tool/bean/ContributorInfo.java @@ -0,0 +1,20 @@ +package com.luoboduner.moo.tool.bean; + +import lombok.Data; + +import java.util.List; + +@Data +public class ContributorInfo { + private List contributorList; + + @Data + public static class Contributor { + private String name; + + private String avatarUrl; + + private String link; + } + +} diff --git a/src/main/java/com/luoboduner/moo/tool/ui/UiConsts.java b/src/main/java/com/luoboduner/moo/tool/ui/UiConsts.java index dd84e638..95942ff9 100644 --- a/src/main/java/com/luoboduner/moo/tool/ui/UiConsts.java +++ b/src/main/java/com/luoboduner/moo/tool/ui/UiConsts.java @@ -102,4 +102,8 @@ public class UiConsts { */ public static final String GRACE_INFO_URL = "https://gitee.com/zhoubochina/MooTool/raw/develop/grace.json"; + /** + * 贡献者信息url + */ + public static final String CONTRIBUTOR_URL = "https://gitee.com/zhoubochina/MooTool/raw/develop/contributor.json"; } diff --git a/src/main/java/com/luoboduner/moo/tool/ui/form/AboutForm.form b/src/main/java/com/luoboduner/moo/tool/ui/form/AboutForm.form index 27529b34..d91e092e 100644 --- a/src/main/java/com/luoboduner/moo/tool/ui/form/AboutForm.form +++ b/src/main/java/com/luoboduner/moo/tool/ui/form/AboutForm.form @@ -17,7 +17,7 @@ - + @@ -39,7 +39,7 @@ - + @@ -136,7 +136,7 @@ - + @@ -164,7 +164,7 @@ - + @@ -184,7 +184,7 @@ - + @@ -220,7 +220,7 @@ - + @@ -377,6 +377,16 @@ + + + + + + + + + + diff --git a/src/main/java/com/luoboduner/moo/tool/ui/form/AboutForm.java b/src/main/java/com/luoboduner/moo/tool/ui/form/AboutForm.java index cecd50e6..70886de3 100644 --- a/src/main/java/com/luoboduner/moo/tool/ui/form/AboutForm.java +++ b/src/main/java/com/luoboduner/moo/tool/ui/form/AboutForm.java @@ -7,6 +7,7 @@ import com.google.common.base.Strings; import com.intellij.uiDesigner.core.GridConstraints; import com.intellij.uiDesigner.core.GridLayoutManager; import com.intellij.uiDesigner.core.Spacer; +import com.luoboduner.moo.tool.bean.ContributorInfo; import com.luoboduner.moo.tool.bean.Grace; import com.luoboduner.moo.tool.ui.UiConsts; import com.luoboduner.moo.tool.ui.listener.AboutListener; @@ -58,6 +59,7 @@ public class AboutForm { private JPanel gracePanel; private JLabel graceLabel; private JLabel graceTitleLabel; + private JPanel contributorPanel; private static AboutForm aboutForm; @@ -179,6 +181,48 @@ public class AboutForm { } catch (Exception e) { log.error("获取Grace信息失败", e); } + + // 更新贡献者头像 + try { + String contributorAvatarContent = HttpUtil.get(UiConsts.CONTRIBUTOR_URL); + if (contributorAvatarContent != null) { + ContributorInfo contributorInfo = JSON.parseObject(contributorAvatarContent, ContributorInfo.class); + if (contributorInfo != null) { + for (ContributorInfo.Contributor contributor : contributorInfo.getContributorList()) { + JLabel contributorLabel = new JLabel(); + contributorLabel.setToolTipText(contributor.getName()); + contributorLabel.setText(contributor.getName()); + contributorLabel.setIcon(new ImageIcon(new URL(contributor.getAvatarUrl()))); + contributorLabel.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent e) { + super.mouseClicked(e); + Desktop desktop = Desktop.getDesktop(); + try { + desktop.browse(new URI(contributor.getLink())); + } catch (IOException | URISyntaxException e1) { + e1.printStackTrace(); + } + } + + @Override + public void mousePressed(MouseEvent e) { + super.mousePressed(e); + } + + @Override + public void mouseEntered(MouseEvent e) { + super.mouseEntered(e); + e.getComponent().setCursor(new Cursor(Cursor.HAND_CURSOR)); + } + }); + aboutForm.getContributorPanel().add(contributorLabel); + } + } + } + } catch (Exception e) { + log.error("获取贡献者头像失败", e); + } } { @@ -203,7 +247,7 @@ public class AboutForm { aboutPanel.add(scrollPane, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); scrollPane.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(), null, TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, null)); final JPanel panel1 = new JPanel(); - panel1.setLayout(new GridLayoutManager(10, 2, new Insets(40, 80, 0, 0), -1, -1)); + panel1.setLayout(new GridLayoutManager(11, 2, new Insets(40, 80, 0, 0), -1, -1)); scrollPane.setViewportView(panel1); panel1.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(), null, TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, null)); final JLabel label1 = new JLabel(); @@ -213,7 +257,7 @@ public class AboutForm { final Spacer spacer1 = new Spacer(); panel1.add(spacer1, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); final Spacer spacer2 = new Spacer(); - panel1.add(spacer2, new GridConstraints(9, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + panel1.add(spacer2, new GridConstraints(10, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); final JPanel panel2 = new JPanel(); panel2.setLayout(new GridLayoutManager(3, 1, new Insets(5, 3, 20, 0), -1, -1)); panel1.add(panel2, new GridConstraints(1, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); @@ -251,7 +295,7 @@ public class AboutForm { panel3.add(label8, new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); final JPanel panel4 = new JPanel(); panel4.setLayout(new GridLayoutManager(2, 1, new Insets(5, 3, 20, 0), -1, -1)); - panel1.add(panel4, new GridConstraints(5, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + panel1.add(panel4, new GridConstraints(6, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); panel4.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(), "CODE", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, this.$$$getFont$$$(null, Font.BOLD, -1, panel4.getFont()), null)); codeGitHubLabel = new JLabel(); codeGitHubLabel.setText("GitHub:https://github.com/rememberber/MooTool"); @@ -261,14 +305,14 @@ public class AboutForm { panel4.add(codeGiteeLabel, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); final JPanel panel5 = new JPanel(); panel5.setLayout(new GridLayoutManager(1, 1, new Insets(5, 3, 20, 0), -1, -1)); - panel1.add(panel5, new GridConstraints(6, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + panel1.add(panel5, new GridConstraints(7, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); panel5.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(), "HELP TO DO BETTER", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, this.$$$getFont$$$(null, Font.BOLD, -1, panel5.getFont()), null)); issueLabel = new JLabel(); issueLabel.setText("https://github.com/rememberber/MooTool/issues"); panel5.add(issueLabel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); final JPanel panel6 = new JPanel(); panel6.setLayout(new GridLayoutManager(3, 1, new Insets(5, 3, 20, 0), -1, -1)); - panel1.add(panel6, new GridConstraints(7, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + panel1.add(panel6, new GridConstraints(8, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); panel6.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(), "THANKS TO", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, this.$$$getFont$$$(null, Font.BOLD, -1, panel6.getFont()), null)); daculaLabel = new JLabel(); daculaLabel.setText("Darcula"); @@ -281,7 +325,7 @@ public class AboutForm { panel6.add(vsCodeIconsLabel, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); final JPanel panel7 = new JPanel(); panel7.setLayout(new GridLayoutManager(2, 1, new Insets(5, 3, 20, 0), -1, -1)); - panel1.add(panel7, new GridConstraints(8, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + panel1.add(panel7, new GridConstraints(9, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); panel7.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(), "OTHER WORKS", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, this.$$$getFont$$$(null, Font.BOLD, -1, panel7.getFont()), null)); wePushPanel = new JPanel(); wePushPanel.setLayout(new GridLayoutManager(5, 1, new Insets(0, 0, 0, 0), -1, -1)); @@ -340,6 +384,10 @@ public class AboutForm { if (graceTitleLabelFont != null) graceTitleLabel.setFont(graceTitleLabelFont); graceTitleLabel.setText(""); gracePanel.add(graceTitleLabel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + contributorPanel = new JPanel(); + contributorPanel.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5)); + panel1.add(contributorPanel, new GridConstraints(5, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + contributorPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(), "Contributor", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, this.$$$getFont$$$(null, Font.BOLD, -1, contributorPanel.getFont()), null)); } /** diff --git a/src/main/java/com/luoboduner/moo/tool/ui/form/ContributorAvatarForm.form b/src/main/java/com/luoboduner/moo/tool/ui/form/ContributorAvatarForm.form new file mode 100644 index 00000000..7a0223b3 --- /dev/null +++ b/src/main/java/com/luoboduner/moo/tool/ui/form/ContributorAvatarForm.form @@ -0,0 +1,30 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/main/java/com/luoboduner/moo/tool/ui/form/ContributorAvatarForm.java b/src/main/java/com/luoboduner/moo/tool/ui/form/ContributorAvatarForm.java new file mode 100644 index 00000000..fe07e4fe --- /dev/null +++ b/src/main/java/com/luoboduner/moo/tool/ui/form/ContributorAvatarForm.java @@ -0,0 +1,44 @@ +package com.luoboduner.moo.tool.ui.form; + +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; + +import javax.swing.*; +import java.awt.*; + +public class ContributorAvatarForm { + private JPanel mainPanel; + + { +// GUI initializer generated by IntelliJ IDEA GUI Designer +// >>> IMPORTANT!! <<< +// DO NOT EDIT OR ADD ANY CODE HERE! + $$$setupUI$$$(); + } + + /** + * Method generated by IntelliJ IDEA GUI Designer + * >>> IMPORTANT!! <<< + * DO NOT edit this method OR call it in your code! + * + * @noinspection ALL + */ + private void $$$setupUI$$$() { + mainPanel = new JPanel(); + mainPanel.setLayout(new GridLayoutManager(2, 1, new Insets(0, 0, 0, 0), -1, -1)); + final JLabel label1 = new JLabel(); + label1.setHorizontalAlignment(0); + label1.setText("Label"); + mainPanel.add(label1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label2 = new JLabel(); + label2.setText("Label"); + mainPanel.add(label2, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + } + + /** + * @noinspection ALL + */ + public JComponent $$$getRootComponent$$$() { + return mainPanel; + } +}