Skip to content

Commit

Permalink
Merge pull request #129 from rememberber/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
rememberber authored Dec 10, 2024
2 parents 89f25a5 + b2e3450 commit ae9c37d
Show file tree
Hide file tree
Showing 11 changed files with 252 additions and 83 deletions.
3 changes: 3 additions & 0 deletions dau.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"url": "http://so47396bf.hb-bkt.clouddn.com/dau/dau.txt"
}
8 changes: 4 additions & 4 deletions grace.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"title": "",
"image": "",
"url": "",
"tips": ""
"title": "政府补贴享8折",
"image": "http://so47396bf.hb-bkt.clouddn.com/grace/qrCode-2024-12-10-14-18-38.jpg",
"url": "https://u.jd.com/uaThV2H",
"tips": "买家电上京东\n政府补贴享8折"
}
8 changes: 8 additions & 0 deletions src/main/java/com/luoboduner/moo/tool/bean/Dau.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.luoboduner.moo.tool.bean;

import lombok.Data;

@Data
public class Dau {
private String url;
}
5 changes: 5 additions & 0 deletions src/main/java/com/luoboduner/moo/tool/ui/UiConsts.java
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,9 @@ public class UiConsts {
* 贡献者信息url
*/
public static final String CONTRIBUTOR_URL = "https://gitee.com/zhoubochina/MooTool/raw/develop/contributor.json";

/**
* DAU信息url
*/
public static final String DAU_URL = "https://gitee.com/zhoubochina/MooTool/raw/develop/dau.json";
}
154 changes: 93 additions & 61 deletions src/main/java/com/luoboduner/moo/tool/ui/form/AboutForm.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
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.Dau;
import com.luoboduner.moo.tool.bean.Grace;
import com.luoboduner.moo.tool.ui.UiConsts;
import com.luoboduner.moo.tool.ui.listener.AboutListener;
Expand All @@ -30,6 +31,8 @@
import java.net.URISyntaxException;
import java.net.URL;
import java.util.Locale;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
* <pre>
Expand Down Expand Up @@ -109,76 +112,83 @@ public void mouseEntered(MouseEvent e) {

AboutListener.addListeners();

// 更新Grace
try {
String graceInfoContent = HttpUtil.get(UiConsts.GRACE_INFO_URL);
if (graceInfoContent != null) {
Grace grace = JSON.parseObject(graceInfoContent, Grace.class);
if (grace != null) {
if (!Strings.isNullOrEmpty(grace.getImage())) {
URL url = new URL(grace.getImage());
BufferedImage image = ImageIO.read(url);
aboutForm.getGraceLabel().setIcon(new ImageIcon(image));
}
if (!Strings.isNullOrEmpty(grace.getTips())) {
aboutForm.getGraceLabel().setToolTipText(grace.getTips());
}

if (!Strings.isNullOrEmpty(grace.getTitle())) {
aboutForm.getGraceTitleLabel().setText(grace.getTitle());
}

if (!Strings.isNullOrEmpty(grace.getUrl())) {
aboutForm.getGracePanel().addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
super.mouseClicked(e);
Desktop desktop = Desktop.getDesktop();
try {
desktop.browse(new URI(grace.getUrl()));
} catch (IOException | URISyntaxException e1) {
e1.printStackTrace();
}
// 每天执行一次
ScheduledThreadPoolExecutor scheduledThreadPoolExecutor = new ScheduledThreadPoolExecutor(1);
scheduledThreadPoolExecutor.scheduleAtFixedRate(() -> {
try {
String graceInfoContent = HttpUtil.get(UiConsts.GRACE_INFO_URL);
if (graceInfoContent != null) {
Grace grace = JSON.parseObject(graceInfoContent, Grace.class);
if (grace != null) {
if (!Strings.isNullOrEmpty(grace.getImage())) {
URL url = new URL(grace.getImage());
BufferedImage image = ImageIO.read(url);
aboutForm.getGraceLabel().setIcon(new ImageIcon(image));
}

@Override
public void mousePressed(MouseEvent e) {
super.mousePressed(e);
if (!Strings.isNullOrEmpty(grace.getTips())) {
aboutForm.getGraceLabel().setToolTipText(grace.getTips());
}

@Override
public void mouseEntered(MouseEvent e) {
super.mouseEntered(e);
e.getComponent().setCursor(new Cursor(Cursor.HAND_CURSOR));
if (!Strings.isNullOrEmpty(grace.getTitle())) {
aboutForm.getGraceTitleLabel().setText(grace.getTitle());
}
});

aboutForm.getGraceLabel().addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
super.mouseClicked(e);
Desktop desktop = Desktop.getDesktop();
try {
desktop.browse(new URI(grace.getUrl()));
} catch (IOException | URISyntaxException e1) {
e1.printStackTrace();
}
if (!Strings.isNullOrEmpty(grace.getUrl())) {
aboutForm.getGracePanel().addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
super.mouseClicked(e);
Desktop desktop = Desktop.getDesktop();
try {
desktop.browse(new URI(grace.getUrl()));
} 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.getGraceLabel().addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
super.mouseClicked(e);
Desktop desktop = Desktop.getDesktop();
try {
desktop.browse(new URI(grace.getUrl()));
} 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));
}
});
}

@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));
}
});
}
}
} catch (Exception e) {
log.error("获取Grace信息失败", e);
}
}
}, 0, 1, TimeUnit.DAYS);
} catch (Exception e) {
log.error("获取Grace信息失败", e);
}
Expand Down Expand Up @@ -228,6 +238,28 @@ public void mouseEntered(MouseEvent e) {
} catch (Exception e) {
log.error("获取贡献者头像失败", e);
}

// DAU
try {
// 每天执行一次
ScheduledThreadPoolExecutor scheduledThreadPoolExecutor = new ScheduledThreadPoolExecutor(1);
scheduledThreadPoolExecutor.scheduleAtFixedRate(() -> {
try {
String dauContent = HttpUtil.get(UiConsts.DAU_URL);
if (dauContent != null) {
Dau dau = JSON.parseObject(dauContent, Dau.class);
if (dau != null) {
String dauUrl = dau.getUrl();
log.info("dau:" + HttpUtil.get(dauUrl));
}
}
} catch (Exception e) {
log.error("获取DAU失败", e);
}
}, 0, 1, TimeUnit.DAYS);
} catch (Exception e) {
log.error("获取DAU失败", e);
}
}

{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@
</grid>
<scrollpane id="41496" binding="scrollPane">
<constraints>
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="7" hsize-policy="7" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="7" hsize-policy="7" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
Expand All @@ -295,7 +295,7 @@
</scrollpane>
<grid id="df7e6" binding="imageControlPanel" layout-manager="BorderLayout" hgap="0" vgap="0">
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="etched"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ public static void initListTable() {
final Spacer spacer5 = new Spacer();
panel7.add(spacer5, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false));
scrollPane = new JScrollPane();
panel3.add(scrollPane, new GridConstraints(2, 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));
panel3.add(scrollPane, new GridConstraints(1, 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));
showImagePanel = new JPanel();
showImagePanel.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1));
scrollPane.setViewportView(showImagePanel);
Expand All @@ -316,7 +316,7 @@ public static void initListTable() {
showImagePanel.add(showImageLabel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
imageControlPanel = new JPanel();
imageControlPanel.setLayout(new BorderLayout(0, 0));
panel3.add(imageControlPanel, new GridConstraints(1, 0, 1, 1, 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));
panel3.add(imageControlPanel, new GridConstraints(2, 0, 1, 1, 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));
imageControlPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), null, TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, null));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<grid id="27dc6" binding="quickNotePanel" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="10" left="10" bottom="10" right="10"/>
<constraints>
<xy x="20" y="20" width="1231" height="1004"/>
<xy x="20" y="20" width="1231" height="1144"/>
</constraints>
<properties>
<minimumSize width="400" height="300"/>
Expand Down Expand Up @@ -306,7 +306,7 @@
</properties>
<border type="none"/>
<children>
<grid id="c2eeb" layout-manager="GridLayoutManager" row-count="32" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<grid id="c2eeb" layout-manager="GridLayoutManager" row-count="37" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="10" left="10" bottom="10" right="10"/>
<constraints/>
<properties>
Expand All @@ -333,7 +333,7 @@
</component>
<vspacer id="c9ff8">
<constraints>
<grid row="31" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
<grid row="36" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
</constraints>
</vspacer>
<component id="ed115" class="javax.swing.JCheckBox" binding="clearTabTCheckBox">
Expand Down Expand Up @@ -434,7 +434,7 @@
</component>
<component id="5c20" class="javax.swing.JButton" binding="startQuickReplaceButton">
<constraints>
<grid row="30" column="0" row-span="1" col-span="1" vsize-policy="1" hsize-policy="1" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
<grid row="35" column="0" row-span="1" col-span="1" vsize-policy="1" hsize-policy="1" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="开始"/>
Expand Down Expand Up @@ -572,6 +572,44 @@
<text value="&quot;,&quot; -&gt; 换行"/>
</properties>
</component>
<component id="4305f" class="javax.swing.JSeparator">
<constraints>
<grid row="30" column="0" row-span="1" col-span="1" vsize-policy="1" hsize-policy="1" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
</component>
<component id="40890" class="javax.swing.JCheckBox" binding="reverseByRowCheckBox">
<constraints>
<grid row="31" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="按行倒序"/>
</properties>
</component>
<component id="bbb9e" class="javax.swing.JCheckBox" binding="sortFromAToZByRowCheckBox">
<constraints>
<grid row="32" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="按行A-&gt;Z排序"/>
</properties>
</component>
<component id="2ec58" class="javax.swing.JCheckBox" binding="sortFromZToAByRowCheckBox">
<constraints>
<grid row="33" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="按行Z-&gt;A排序"/>
</properties>
</component>
<component id="70da1" class="javax.swing.JCheckBox" binding="sortByPinyinCheckBox">
<constraints>
<grid row="34" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="按拼音排序"/>
</properties>
</component>
</children>
</grid>
</children>
Expand Down
Loading

0 comments on commit ae9c37d

Please sign in to comment.