diff --git a/assets/linux/WePush.png b/assets/linux/WePush.png new file mode 100644 index 000000000..95e911a39 Binary files /dev/null and b/assets/linux/WePush.png differ diff --git a/assets/mac/WePush.icns b/assets/mac/WePush.icns new file mode 100644 index 000000000..5a369256d Binary files /dev/null and b/assets/mac/WePush.icns differ diff --git a/assets/windows/WePush.ico b/assets/windows/WePush.ico new file mode 100644 index 000000000..e02dd461d Binary files /dev/null and b/assets/windows/WePush.ico differ diff --git a/pom.xml b/pom.xml index 09cb8ecf0..4aa8e6999 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.fangxuele.tool WePush - 1.0 + 4.5.0 jar WePush @@ -20,9 +20,9 @@ 1.8 1.2.3 - 4.0.0 - 4.0.0 - 4.0.0 + 4.1.0 + 4.1.0 + 4.1.0 5.1.1 5.4.4 5.2 @@ -36,8 +36,8 @@ 1.0.6 1.2.7 2.2 - 1.18.20 - 3.5.7 + 1.18.22 + 3.5.6 3.36.0.1 4.13.1 4.1.4 @@ -47,7 +47,7 @@ 1.1.0 0.10.134 7.3.0 - 1.2 + 2.0-rc1 @@ -221,18 +221,6 @@ - - com.darcula - darcula-lnf - 1.0 - - - - com.beautyeye - beautyeye-lnf - 1.0 - - net.sourceforge.cpdetector @@ -285,11 +273,11 @@ httpasyncclient ${httpasyncclient.version} - - com.zaxxer - HikariCP - ${HikariCP.version} - + + + + + org.quartz-scheduler quartz @@ -391,6 +379,10 @@ hbase-client org.apache.hbase + + bcprov-jdk15on + org.bouncycastle + @@ -410,50 +402,69 @@ - - org.apache.maven.plugins - maven-compiler-plugin - 3.8.1 - - 1.8 - 1.8 - UTF-8 - - - org.apache.maven.plugins - maven-javadoc-plugin - 3.1.0 - - - - org.apache.maven.plugins - maven-jar-plugin - 3.1.2 + io.github.fvarrui + javapackager + 1.6.2 - - - true - lib/ - com.fangxuele.tool.push.App - - + true + com.fangxuele.tool.push.App + true - - - org.apache.maven.plugins - maven-dependency-plugin - 3.1.1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - copy-dependencies + bundling-for-mac package - copy-dependencies + package - ${project.build.directory}/lib + mac + true + + @@ -464,36 +475,6 @@ maven-install-plugin 2.5.2 - - install-beautyeye - clean - - lib/beautyeye_lnf.jar - com.beautyeye - beautyeye-lnf - 1.0 - jar - true - - - install-file - - - - install-darcula - clean - - lib/darcula.jar - com.darcula - darcula-lnf - 1.0 - jar - true - - - install-file - - install-taobao-sdk-auto clean diff --git a/src/main/java/com/fangxuele/tool/push/App.java b/src/main/java/com/fangxuele/tool/push/App.java index 0ec0a54a2..5434250a2 100644 --- a/src/main/java/com/fangxuele/tool/push/App.java +++ b/src/main/java/com/fangxuele/tool/push/App.java @@ -1,12 +1,14 @@ package com.fangxuele.tool.push; import com.fangxuele.tool.push.ui.Init; +import com.fangxuele.tool.push.ui.UiConsts; import com.fangxuele.tool.push.ui.form.LoadingForm; import com.fangxuele.tool.push.ui.form.MainWindow; import com.fangxuele.tool.push.ui.frame.MainFrame; import com.fangxuele.tool.push.util.ConfigUtil; import com.fangxuele.tool.push.util.MybatisUtil; import com.fangxuele.tool.push.util.UpgradeUtil; +import com.formdev.flatlaf.util.SystemInfo; import lombok.extern.slf4j.Slf4j; import org.apache.ibatis.session.SqlSession; @@ -34,6 +36,15 @@ public class App { public static TrayIcon trayIcon; public static void main(String[] args) { + if (SystemInfo.isMacOS) { +// java -Xdock:name="WePush" -Xdock:icon=WePush.jpg ... (whatever else you normally specify here) +// java -Xms64m -Xmx256m -Dapple.awt.application.name="WePush" -Dcom.apple.mrj.application.apple.menu.about.name="WePush" -cp "./lib/*" com.luoboduner.moo.tool.App + System.setProperty("apple.laf.useScreenMenuBar", "true"); + System.setProperty("apple.awt.application.name", UiConsts.APP_NAME); + System.setProperty("com.apple.mrj.application.apple.menu.about.name", UiConsts.APP_NAME); + System.setProperty("apple.awt.application.appearance", "system"); + } + Init.initTheme(); mainFrame = new MainFrame(); mainFrame.init(); diff --git a/src/main/java/com/fangxuele/tool/push/dao/TMsgMpSubscribeMapper.java b/src/main/java/com/fangxuele/tool/push/dao/TMsgMpSubscribeMapper.java new file mode 100644 index 000000000..2c558c184 --- /dev/null +++ b/src/main/java/com/fangxuele/tool/push/dao/TMsgMpSubscribeMapper.java @@ -0,0 +1,28 @@ +package com.fangxuele.tool.push.dao; + +import com.fangxuele.tool.push.domain.TMsgMpSubscribe; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +public interface TMsgMpSubscribeMapper { + int deleteByPrimaryKey(Integer id); + + int insert(TMsgMpSubscribe record); + + int insertSelective(TMsgMpSubscribe record); + + TMsgMpSubscribe selectByPrimaryKey(Integer id); + + int updateByPrimaryKeySelective(TMsgMpSubscribe record); + + int updateByPrimaryKey(TMsgMpSubscribe record); + + List selectByMsgTypeAndWxAccountId(@Param("msgType") int msgType, @Param("wxAccountId") Integer wxAccountId); + + int deleteByMsgTypeAndName(int msgType, String msgName); + + List selectByMsgTypeAndMsgName(@Param("msgType") int msgType, @Param("msgName") String msgName); + + int updateByMsgTypeAndMsgName(TMsgMpSubscribe tMsgMpSubscribe); +} \ No newline at end of file diff --git a/src/main/java/com/fangxuele/tool/push/domain/TMsgMpSubscribe.java b/src/main/java/com/fangxuele/tool/push/domain/TMsgMpSubscribe.java new file mode 100644 index 000000000..e302bf86d --- /dev/null +++ b/src/main/java/com/fangxuele/tool/push/domain/TMsgMpSubscribe.java @@ -0,0 +1,117 @@ +package com.fangxuele.tool.push.domain; + +import java.io.Serializable; + +public class TMsgMpSubscribe implements Serializable { + private Integer id; + + private Integer msgType; + + private String msgName; + + private String templateId; + + private String url; + + private String maAppid; + + private String maPagePath; + + private String previewUser; + + private Integer wxAccountId; + + private String createTime; + + private String modifiedTime; + + private static final long serialVersionUID = 1L; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public Integer getMsgType() { + return msgType; + } + + public void setMsgType(Integer msgType) { + this.msgType = msgType; + } + + public String getMsgName() { + return msgName; + } + + public void setMsgName(String msgName) { + this.msgName = msgName == null ? null : msgName.trim(); + } + + public String getTemplateId() { + return templateId; + } + + public void setTemplateId(String templateId) { + this.templateId = templateId == null ? null : templateId.trim(); + } + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url == null ? null : url.trim(); + } + + public String getMaAppid() { + return maAppid; + } + + public void setMaAppid(String maAppid) { + this.maAppid = maAppid == null ? null : maAppid.trim(); + } + + public String getMaPagePath() { + return maPagePath; + } + + public void setMaPagePath(String maPagePath) { + this.maPagePath = maPagePath == null ? null : maPagePath.trim(); + } + + public String getPreviewUser() { + return previewUser; + } + + public void setPreviewUser(String previewUser) { + this.previewUser = previewUser == null ? null : previewUser.trim(); + } + + public Integer getWxAccountId() { + return wxAccountId; + } + + public void setWxAccountId(Integer wxAccountId) { + this.wxAccountId = wxAccountId; + } + + public String getCreateTime() { + return createTime; + } + + public void setCreateTime(String createTime) { + this.createTime = createTime == null ? null : createTime.trim(); + } + + public String getModifiedTime() { + return modifiedTime; + } + + public void setModifiedTime(String modifiedTime) { + this.modifiedTime = modifiedTime == null ? null : modifiedTime.trim(); + } +} \ No newline at end of file diff --git a/src/main/java/com/fangxuele/tool/push/logic/MessageTypeEnum.java b/src/main/java/com/fangxuele/tool/push/logic/MessageTypeEnum.java index 0c2444513..4695f262d 100644 --- a/src/main/java/com/fangxuele/tool/push/logic/MessageTypeEnum.java +++ b/src/main/java/com/fangxuele/tool/push/logic/MessageTypeEnum.java @@ -28,7 +28,8 @@ public enum MessageTypeEnum { BD_YUN(15, "百度云短信"), QI_NIU_YUN(16, "七牛云短信"), WX_UNIFORM_MESSAGE(17, "小程序-统一服务消息"), - MA_SUBSCRIBE(18, "小程序-订阅消息"); + MA_SUBSCRIBE(18, "小程序-订阅消息"), + MP_SUBSCRIBE(19, "公众号-订阅通知"); private int code; @@ -51,6 +52,7 @@ public enum MessageTypeEnum { public static final int QI_NIU_YUN_CODE = 16; public static final int WX_UNIFORM_MESSAGE_CODE = 17; public static final int MA_SUBSCRIBE_CODE = 18; + public static final int MP_SUBSCRIBE_CODE = 19; MessageTypeEnum(int code, String name) { this.code = code; @@ -111,9 +113,30 @@ public static String getName(int code) { case 18: name = MA_SUBSCRIBE.name; break; + case 19: + name = MP_SUBSCRIBE.name; + break; default: name = ""; } return name; } + + public static boolean isWxMpType(int msgType) { + return msgType == MessageTypeEnum.KEFU_CODE + || msgType == MessageTypeEnum.KEFU_PRIORITY_CODE + || msgType == MessageTypeEnum.MP_TEMPLATE_CODE + || msgType == MessageTypeEnum.MP_SUBSCRIBE_CODE; + } + + public static boolean isWxMaType(int msgType) { + return msgType == MessageTypeEnum.MA_TEMPLATE_CODE + || msgType == MessageTypeEnum.MA_SUBSCRIBE_CODE + || msgType == MessageTypeEnum.WX_UNIFORM_MESSAGE_CODE; + } + + public static boolean isWxMaOrMpType(int msgType) { + return isWxMaType(msgType) + || isWxMpType(msgType); + } } diff --git a/src/main/java/com/fangxuele/tool/push/logic/PushControl.java b/src/main/java/com/fangxuele/tool/push/logic/PushControl.java index 11643e4b3..52fb4488d 100644 --- a/src/main/java/com/fangxuele/tool/push/logic/PushControl.java +++ b/src/main/java/com/fangxuele/tool/push/logic/PushControl.java @@ -144,6 +144,7 @@ public static boolean configCheck() { int msgType = App.config.getMsgType(); switch (msgType) { case MessageTypeEnum.MP_TEMPLATE_CODE: + case MessageTypeEnum.MP_SUBSCRIBE_CODE: case MessageTypeEnum.KEFU_CODE: case MessageTypeEnum.KEFU_PRIORITY_CODE: case MessageTypeEnum.WX_UNIFORM_MESSAGE_CODE: { diff --git a/src/main/java/com/fangxuele/tool/push/logic/msgmaker/MsgMakerFactory.java b/src/main/java/com/fangxuele/tool/push/logic/msgmaker/MsgMakerFactory.java index 3a06042b4..89a7b3b2b 100644 --- a/src/main/java/com/fangxuele/tool/push/logic/msgmaker/MsgMakerFactory.java +++ b/src/main/java/com/fangxuele/tool/push/logic/msgmaker/MsgMakerFactory.java @@ -63,6 +63,9 @@ public static IMsgMaker getMsgMaker() { case MessageTypeEnum.QI_NIU_YUN_CODE: iMsgMaker = new QiNiuYunMsgMaker(); break; + case MessageTypeEnum.MP_SUBSCRIBE_CODE: + iMsgMaker = new WxMpSubscribeMsgMaker(); + break; default: } return iMsgMaker; diff --git a/src/main/java/com/fangxuele/tool/push/logic/msgmaker/WxMaSubscribeMsgMaker.java b/src/main/java/com/fangxuele/tool/push/logic/msgmaker/WxMaSubscribeMsgMaker.java index 4c1b2c491..c28f0fa1e 100644 --- a/src/main/java/com/fangxuele/tool/push/logic/msgmaker/WxMaSubscribeMsgMaker.java +++ b/src/main/java/com/fangxuele/tool/push/logic/msgmaker/WxMaSubscribeMsgMaker.java @@ -67,9 +67,9 @@ public WxMaSubscribeMessage makeMsg(String[] msgData) { String templateUrlEvaluated = TemplateUtil.evaluate(templateUrl, velocityContext); wxMaSubscribeMessage.setPage(templateUrlEvaluated); - WxMaSubscribeMessage.Data wxMaSubscribeData; + WxMaSubscribeMessage.MsgData wxMaSubscribeData; for (TemplateData templateData : templateDataList) { - wxMaSubscribeData = new WxMaSubscribeMessage.Data(); + wxMaSubscribeData = new WxMaSubscribeMessage.MsgData(); wxMaSubscribeData.setName(templateData.getName()); wxMaSubscribeData.setValue(TemplateUtil.evaluate(templateData.getValue(), velocityContext)); wxMaSubscribeMessage.addData(wxMaSubscribeData); diff --git a/src/main/java/com/fangxuele/tool/push/logic/msgmaker/WxMpSubscribeMsgMaker.java b/src/main/java/com/fangxuele/tool/push/logic/msgmaker/WxMpSubscribeMsgMaker.java new file mode 100644 index 000000000..40325fe1d --- /dev/null +++ b/src/main/java/com/fangxuele/tool/push/logic/msgmaker/WxMpSubscribeMsgMaker.java @@ -0,0 +1,94 @@ +package com.fangxuele.tool.push.logic.msgmaker; + +import com.fangxuele.tool.push.bean.TemplateData; +import com.fangxuele.tool.push.ui.form.msg.MpSubscribeMsgForm; +import com.fangxuele.tool.push.util.TemplateUtil; +import me.chanjar.weixin.mp.bean.subscribe.WxMpSubscribeMessage; +import org.apache.commons.compress.utils.Lists; +import org.apache.velocity.VelocityContext; + +import javax.swing.table.DefaultTableModel; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + *
+ * 公众号订阅通知加工器
+ * 
+ * + * @author Zhou Bo + * @since 2021/3/23. + */ +public class WxMpSubscribeMsgMaker extends BaseMsgMaker implements IMsgMaker { + + public static String templateId; + + private static String templateUrl; + + private static String miniAppId; + + private static String miniAppPagePath; + + public static List templateDataList; + + /** + * 准备(界面字段等) + */ + @Override + public void prepare() { + templateId = MpSubscribeMsgForm.getInstance().getMsgTemplateIdTextField().getText().trim(); + templateUrl = MpSubscribeMsgForm.getInstance().getMsgTemplateUrlTextField().getText().trim(); + miniAppId = MpSubscribeMsgForm.getInstance().getMsgTemplateMiniAppidTextField().getText().trim(); + miniAppPagePath = MpSubscribeMsgForm.getInstance().getMsgTemplateMiniPagePathTextField().getText().trim(); + + if (MpSubscribeMsgForm.getInstance().getTemplateMsgDataTable().getModel().getRowCount() == 0) { + MpSubscribeMsgForm.initTemplateDataTable(); + } + + DefaultTableModel tableModel = (DefaultTableModel) MpSubscribeMsgForm.getInstance().getTemplateMsgDataTable().getModel(); + int rowCount = tableModel.getRowCount(); + TemplateData templateData; + templateDataList = Lists.newArrayList(); + for (int i = 0; i < rowCount; i++) { + String name = ((String) tableModel.getValueAt(i, 0)).trim(); + String value = ((String) tableModel.getValueAt(i, 1)).trim(); + String color = ((String) tableModel.getValueAt(i, 2)).trim(); + templateData = new TemplateData(); + templateData.setName(name); + templateData.setValue(value); + templateData.setColor(color); + templateDataList.add(templateData); + } + + } + + /** + * 组织订阅通知-公众号 + * + * @param msgData 消息数据 + * @return WxMpSubscribeMessage + */ + @Override + public WxMpSubscribeMessage makeMsg(String[] msgData) { + // 拼模板 + WxMpSubscribeMessage wxMessageTemplate = new WxMpSubscribeMessage(); + wxMessageTemplate.setTemplateId(templateId); + + VelocityContext velocityContext = getVelocityContext(msgData); + String templateUrlEvaluated = TemplateUtil.evaluate(templateUrl, velocityContext); + wxMessageTemplate.setPage(templateUrlEvaluated); + String miniAppPagePathEvaluated = TemplateUtil.evaluate(miniAppPagePath, velocityContext); + WxMpSubscribeMessage.MiniProgram miniProgram = new WxMpSubscribeMessage.MiniProgram(miniAppId, miniAppPagePathEvaluated, false); + wxMessageTemplate.setMiniProgram(miniProgram); + + Map dataMap = new HashMap<>(10); + for (TemplateData templateData : templateDataList) { + dataMap.put(templateData.getName(), TemplateUtil.evaluate(templateData.getValue(), velocityContext)); + } + + wxMessageTemplate.setDataMap(dataMap); + + return wxMessageTemplate; + } +} diff --git a/src/main/java/com/fangxuele/tool/push/logic/msgsender/MsgSenderFactory.java b/src/main/java/com/fangxuele/tool/push/logic/msgsender/MsgSenderFactory.java index a1543753f..383d79c81 100644 --- a/src/main/java/com/fangxuele/tool/push/logic/msgsender/MsgSenderFactory.java +++ b/src/main/java/com/fangxuele/tool/push/logic/msgsender/MsgSenderFactory.java @@ -69,6 +69,9 @@ public static IMsgSender getMsgSender() { case MessageTypeEnum.QI_NIU_YUN_CODE: iMsgSender = new QiNiuYunMsgSender(); break; + case MessageTypeEnum.MP_SUBSCRIBE_CODE: + iMsgSender = new WxMpSubscribeMsgSender(); + break; default: break; } diff --git a/src/main/java/com/fangxuele/tool/push/logic/msgsender/WxMpSubscribeMsgSender.java b/src/main/java/com/fangxuele/tool/push/logic/msgsender/WxMpSubscribeMsgSender.java new file mode 100644 index 000000000..ad67b170b --- /dev/null +++ b/src/main/java/com/fangxuele/tool/push/logic/msgsender/WxMpSubscribeMsgSender.java @@ -0,0 +1,57 @@ +package com.fangxuele.tool.push.logic.msgsender; + +import com.fangxuele.tool.push.logic.PushControl; +import com.fangxuele.tool.push.logic.msgmaker.WxMpSubscribeMsgMaker; +import lombok.extern.slf4j.Slf4j; +import me.chanjar.weixin.mp.api.WxMpService; +import me.chanjar.weixin.mp.bean.subscribe.WxMpSubscribeMessage; +import org.apache.commons.lang3.exception.ExceptionUtils; + +/** + *
+ * 微信公众号订阅通知发送器
+ * 
+ * + * @author RememBerBer + * @since 2021/3/23. + */ +@Slf4j +public class WxMpSubscribeMsgSender implements IMsgSender { + public volatile static WxMpService wxMpService; + private WxMpSubscribeMsgMaker wxMpSubscribeMsgMaker; + + public WxMpSubscribeMsgSender() { + wxMpSubscribeMsgMaker = new WxMpSubscribeMsgMaker(); + wxMpService = WxMpTemplateMsgSender.getWxMpService(); + } + + @Override + public SendResult send(String[] msgData) { + SendResult sendResult = new SendResult(); + + try { + String openId = msgData[0]; + WxMpSubscribeMessage wxMessageTemplate = wxMpSubscribeMsgMaker.makeMsg(msgData); + wxMessageTemplate.setToUser(openId); + if (PushControl.dryRun) { + sendResult.setSuccess(true); + return sendResult; + } else { + wxMpService.getSubscribeMsgService().send(wxMessageTemplate); + } + } catch (Exception e) { + sendResult.setSuccess(false); + sendResult.setInfo(e.getMessage()); + log.error(ExceptionUtils.getStackTrace(e)); + return sendResult; + } + + sendResult.setSuccess(true); + return sendResult; + } + + @Override + public SendResult asyncSend(String[] msgData) { + return null; + } +} diff --git a/src/main/java/com/fangxuele/tool/push/logic/msgsender/WxUniformMsgSender.java b/src/main/java/com/fangxuele/tool/push/logic/msgsender/WxUniformMsgSender.java index 5f180c4bd..2c8396edf 100644 --- a/src/main/java/com/fangxuele/tool/push/logic/msgsender/WxUniformMsgSender.java +++ b/src/main/java/com/fangxuele/tool/push/logic/msgsender/WxUniformMsgSender.java @@ -58,9 +58,9 @@ public SendResult send(String[] msgData) { wxMaUniformMessage.setMiniProgram(miniProgram); List wxMaTemplateDataList = Lists.newArrayList(); - List data = wxMaSubscribeMessage.getData(); + List data = wxMaSubscribeMessage.getData(); WxMaTemplateData wxMaTemplateData; - for (WxMaSubscribeMessage.Data datum : data) { + for (WxMaSubscribeMessage.MsgData datum : data) { wxMaTemplateData = new WxMaTemplateData(); wxMaTemplateData.setName(datum.getName()); wxMaTemplateData.setValue(datum.getValue()); diff --git a/src/main/java/com/fangxuele/tool/push/ui/Init.java b/src/main/java/com/fangxuele/tool/push/ui/Init.java index bd8096b83..06ab0e71a 100644 --- a/src/main/java/com/fangxuele/tool/push/ui/Init.java +++ b/src/main/java/com/fangxuele/tool/push/ui/Init.java @@ -5,19 +5,7 @@ import cn.hutool.log.LogFactory; import com.fangxuele.tool.push.App; import com.fangxuele.tool.push.ui.dialog.FontSizeAdjustDialog; -import com.fangxuele.tool.push.ui.form.AboutForm; -import com.fangxuele.tool.push.ui.form.BoostForm; -import com.fangxuele.tool.push.ui.form.HelpForm; -import com.fangxuele.tool.push.ui.form.InfinityForm; -import com.fangxuele.tool.push.ui.form.MainWindow; -import com.fangxuele.tool.push.ui.form.MemberForm; -import com.fangxuele.tool.push.ui.form.MessageEditForm; -import com.fangxuele.tool.push.ui.form.MessageManageForm; -import com.fangxuele.tool.push.ui.form.MessageTypeForm; -import com.fangxuele.tool.push.ui.form.PushForm; -import com.fangxuele.tool.push.ui.form.PushHisForm; -import com.fangxuele.tool.push.ui.form.ScheduleForm; -import com.fangxuele.tool.push.ui.form.SettingForm; +import com.fangxuele.tool.push.ui.form.*; import com.fangxuele.tool.push.ui.listener.AboutListener; import com.fangxuele.tool.push.util.SystemUtil; import com.fangxuele.tool.push.util.UIUtil; @@ -26,7 +14,6 @@ import com.formdev.flatlaf.IntelliJTheme; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.exception.ExceptionUtils; -import org.jb2011.lnf.beautyeye.BeautyEyeLNFHelper; import javax.swing.*; import javax.swing.plaf.FontUIResource; @@ -115,21 +102,13 @@ public static void initTheme() { return; } + UIManager.put("TitlePane.unifiedBackground", true); + try { switch (App.config.getTheme()) { - case "BeautyEye": - BeautyEyeLNFHelper.launchBeautyEyeLNF(); - UIManager.put("RootPane.setupButtonVisible", false); - break; case "系统默认": UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); break; - case "weblaf": - case "Darcula": - JFrame.setDefaultLookAndFeelDecorated(false); - JDialog.setDefaultLookAndFeelDecorated(false); - UIManager.setLookAndFeel("com.bulenkov.darcula.DarculaLaf"); - break; case "Flat Light": if (SystemUtil.isJBR()) { JFrame.setDefaultLookAndFeelDecorated(true); @@ -157,6 +136,23 @@ public static void initTheme() { JDialog.setDefaultLookAndFeelDecorated(true); } UIManager.setLookAndFeel("com.formdev.flatlaf.FlatDarculaLaf"); +// UIManager.put( "TitlePane.unifiedBackground", true ); +/** + If you don't like/want it, you can disable it with: + UIManager.put( "TitlePane.useWindowDecorations", false ); + + It is also possible to disable only the embedded menu bar (and keep the dark title pane) with: + UIManager.put( "TitlePane.menuBarEmbedded", false ); + + It is also possible to disable this on command line with following VM options: + -Dflatlaf.useWindowDecorations=false + -Dflatlaf.menuBarEmbedded=false + + If you have following code in your app, you can remove it (no longer necessary): + // enable window decorations + JFrame.setDefaultLookAndFeelDecorated( true ); + JDialog.setDefaultLookAndFeelDecorated( true ); + **/ break; case "Dark purple": if (SystemUtil.isJBR()) { @@ -183,6 +179,10 @@ public static void initTheme() { "/theme/Light.theme.json")); break; + case "BeautyEye": + case "weblaf": + case "Darcula": + case "Darcula(推荐)": default: if (SystemUtil.isJBR()) { JFrame.setDefaultLookAndFeelDecorated(true); diff --git a/src/main/java/com/fangxuele/tool/push/ui/UiConsts.java b/src/main/java/com/fangxuele/tool/push/ui/UiConsts.java index 26049602f..9c822cd29 100644 --- a/src/main/java/com/fangxuele/tool/push/ui/UiConsts.java +++ b/src/main/java/com/fangxuele/tool/push/ui/UiConsts.java @@ -16,7 +16,7 @@ public class UiConsts { * 软件名称,版本 */ public final static String APP_NAME = "WePush"; - public final static String APP_VERSION = "v_4.4.0_210221"; + public final static String APP_VERSION = "v_4.5.0_220107"; /** * Logo-1024*1024 diff --git a/src/main/java/com/fangxuele/tool/push/ui/form/MemberForm.form b/src/main/java/com/fangxuele/tool/push/ui/form/MemberForm.form index 619b0b286..1d40c5ea2 100644 --- a/src/main/java/com/fangxuele/tool/push/ui/form/MemberForm.form +++ b/src/main/java/com/fangxuele/tool/push/ui/form/MemberForm.form @@ -287,7 +287,7 @@ - + @@ -307,7 +307,7 @@ - + @@ -345,6 +345,16 @@ + + + + + + + + + + diff --git a/src/main/java/com/fangxuele/tool/push/ui/form/MemberForm.java b/src/main/java/com/fangxuele/tool/push/ui/form/MemberForm.java index ddd652b0a..d4611d18a 100644 --- a/src/main/java/com/fangxuele/tool/push/ui/form/MemberForm.java +++ b/src/main/java/com/fangxuele/tool/push/ui/form/MemberForm.java @@ -82,6 +82,7 @@ public class MemberForm { private JButton dingDeptsImportButton; private JComboBox dingDeptsComboBox; private JButton dingDeptsRefreshButton; + private JButton memberImportTagExceptButton; private static MemberForm memberForm; @@ -269,7 +270,7 @@ public static void clearMember() { importFromSqlTextArea = new JTextArea(); memberTabCenterPanel.add(importFromSqlTextArea, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_WANT_GROW, null, new Dimension(40, 50), null, 0, false)); importFromWeixinPanel = new JPanel(); - importFromWeixinPanel.setLayout(new GridLayoutManager(4, 3, new Insets(0, 15, 0, 5), -1, -1)); + importFromWeixinPanel.setLayout(new GridLayoutManager(5, 3, new Insets(0, 15, 0, 5), -1, -1)); importWayPanel.add(importFromWeixinPanel, new GridConstraints(3, 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)); importFromWeixinPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "通过微信公众平台导入", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, this.$$$getFont$$$(null, Font.BOLD, -1, importFromWeixinPanel.getFont()), null)); memberImportTagComboBox = new JComboBox(); @@ -281,7 +282,7 @@ public static void clearMember() { if (memberImportAllButtonFont != null) memberImportAllButton.setFont(memberImportAllButtonFont); memberImportAllButton.setIcon(new ImageIcon(getClass().getResource("/icon/import_dark.png"))); memberImportAllButton.setText("导入所有关注公众号的用户"); - importFromWeixinPanel.add(memberImportAllButton, new GridConstraints(3, 0, 1, 3, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + importFromWeixinPanel.add(memberImportAllButton, new GridConstraints(4, 0, 1, 3, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); memberImportTagFreshButton = new JButton(); Font memberImportTagFreshButtonFont = this.$$$getFont$$$(null, Font.PLAIN, -1, memberImportTagFreshButton.getFont()); if (memberImportTagFreshButtonFont != null) memberImportTagFreshButton.setFont(memberImportTagFreshButtonFont); @@ -301,6 +302,13 @@ public static void clearMember() { memberImportTagRetainButton.setIcon(new ImageIcon(getClass().getResource("/icon/import_dark.png"))); memberImportTagRetainButton.setText("导入选择的标签分组-取交集"); importFromWeixinPanel.add(memberImportTagRetainButton, new GridConstraints(2, 0, 1, 3, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + memberImportTagExceptButton = new JButton(); + Font memberImportTagExceptButtonFont = this.$$$getFont$$$(null, Font.PLAIN, -1, memberImportTagExceptButton.getFont()); + if (memberImportTagExceptButtonFont != null) + memberImportTagExceptButton.setFont(memberImportTagExceptButtonFont); + memberImportTagExceptButton.setIcon(new ImageIcon(getClass().getResource("/icon/remove_dark.png"))); + memberImportTagExceptButton.setText("排除选择的标签分组"); + importFromWeixinPanel.add(memberImportTagExceptButton, new GridConstraints(3, 0, 1, 3, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); final JLabel label2 = new JLabel(); label2.setText("标签分组"); importFromWeixinPanel.add(label2, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); diff --git a/src/main/java/com/fangxuele/tool/push/ui/form/MessageEditForm.java b/src/main/java/com/fangxuele/tool/push/ui/form/MessageEditForm.java index 93263e7e6..2275ac60f 100644 --- a/src/main/java/com/fangxuele/tool/push/ui/form/MessageEditForm.java +++ b/src/main/java/com/fangxuele/tool/push/ui/form/MessageEditForm.java @@ -1,21 +1,7 @@ package com.fangxuele.tool.push.ui.form; import com.fangxuele.tool.push.logic.MessageTypeEnum; -import com.fangxuele.tool.push.ui.form.msg.AliYunMsgForm; -import com.fangxuele.tool.push.ui.form.msg.BdYunMsgForm; -import com.fangxuele.tool.push.ui.form.msg.DingMsgForm; -import com.fangxuele.tool.push.ui.form.msg.HttpMsgForm; -import com.fangxuele.tool.push.ui.form.msg.HwYunMsgForm; -import com.fangxuele.tool.push.ui.form.msg.KefuMsgForm; -import com.fangxuele.tool.push.ui.form.msg.MaSubscribeMsgForm; -import com.fangxuele.tool.push.ui.form.msg.MailMsgForm; -import com.fangxuele.tool.push.ui.form.msg.MpTemplateMsgForm; -import com.fangxuele.tool.push.ui.form.msg.MsgFormFactory; -import com.fangxuele.tool.push.ui.form.msg.QiNiuYunMsgForm; -import com.fangxuele.tool.push.ui.form.msg.TxYunMsgForm; -import com.fangxuele.tool.push.ui.form.msg.UpYunMsgForm; -import com.fangxuele.tool.push.ui.form.msg.WxCpMsgForm; -import com.fangxuele.tool.push.ui.form.msg.YunpianMsgForm; +import com.fangxuele.tool.push.ui.form.msg.*; import com.fangxuele.tool.push.util.UndoUtil; import com.intellij.uiDesigner.core.GridConstraints; import com.intellij.uiDesigner.core.GridLayoutManager; @@ -90,6 +76,9 @@ public static void switchMsgType(int msgType) { case MessageTypeEnum.MP_TEMPLATE_CODE: messageEditForm.getMsgEditorPanel().add(MpTemplateMsgForm.getInstance().getTemplateMsgPanel(), gridConstraintsRow0); break; + case MessageTypeEnum.MP_SUBSCRIBE_CODE: + messageEditForm.getMsgEditorPanel().add(MpSubscribeMsgForm.getInstance().getTemplateMsgPanel(), gridConstraintsRow0); + break; case MessageTypeEnum.MA_TEMPLATE_CODE: case MessageTypeEnum.MA_SUBSCRIBE_CODE: messageEditForm.getMsgEditorPanel().add(MaSubscribeMsgForm.getInstance().getTemplateMsgPanel(), gridConstraintsRow0); diff --git a/src/main/java/com/fangxuele/tool/push/ui/form/MessageManageForm.java b/src/main/java/com/fangxuele/tool/push/ui/form/MessageManageForm.java index f0e4af8ad..0e39ff839 100644 --- a/src/main/java/com/fangxuele/tool/push/ui/form/MessageManageForm.java +++ b/src/main/java/com/fangxuele/tool/push/ui/form/MessageManageForm.java @@ -1,30 +1,8 @@ package com.fangxuele.tool.push.ui.form; import com.fangxuele.tool.push.App; -import com.fangxuele.tool.push.dao.TMsgDingMapper; -import com.fangxuele.tool.push.dao.TMsgHttpMapper; -import com.fangxuele.tool.push.dao.TMsgKefuMapper; -import com.fangxuele.tool.push.dao.TMsgKefuPriorityMapper; -import com.fangxuele.tool.push.dao.TMsgMaSubscribeMapper; -import com.fangxuele.tool.push.dao.TMsgMaTemplateMapper; -import com.fangxuele.tool.push.dao.TMsgMailMapper; -import com.fangxuele.tool.push.dao.TMsgMpTemplateMapper; -import com.fangxuele.tool.push.dao.TMsgSmsMapper; -import com.fangxuele.tool.push.dao.TMsgWxCpMapper; -import com.fangxuele.tool.push.dao.TMsgWxUniformMapper; -import com.fangxuele.tool.push.dao.TWxAccountMapper; -import com.fangxuele.tool.push.domain.TMsgDing; -import com.fangxuele.tool.push.domain.TMsgHttp; -import com.fangxuele.tool.push.domain.TMsgKefu; -import com.fangxuele.tool.push.domain.TMsgKefuPriority; -import com.fangxuele.tool.push.domain.TMsgMaSubscribe; -import com.fangxuele.tool.push.domain.TMsgMaTemplate; -import com.fangxuele.tool.push.domain.TMsgMail; -import com.fangxuele.tool.push.domain.TMsgMpTemplate; -import com.fangxuele.tool.push.domain.TMsgSms; -import com.fangxuele.tool.push.domain.TMsgWxCp; -import com.fangxuele.tool.push.domain.TMsgWxUniform; -import com.fangxuele.tool.push.domain.TWxAccount; +import com.fangxuele.tool.push.dao.*; +import com.fangxuele.tool.push.domain.*; import com.fangxuele.tool.push.logic.MessageTypeEnum; import com.fangxuele.tool.push.ui.UiConsts; import com.fangxuele.tool.push.util.JTableUtil; @@ -65,6 +43,7 @@ public class MessageManageForm { private static TMsgMaTemplateMapper msgMaTemplateMapper = MybatisUtil.getSqlSession().getMapper(TMsgMaTemplateMapper.class); private static TMsgMaSubscribeMapper msgMaSubscribeMapper = MybatisUtil.getSqlSession().getMapper(TMsgMaSubscribeMapper.class); private static TMsgMpTemplateMapper msgMpTemplateMapper = MybatisUtil.getSqlSession().getMapper(TMsgMpTemplateMapper.class); + private static TMsgMpSubscribeMapper msgMpSubscribeMapper = MybatisUtil.getSqlSession().getMapper(TMsgMpSubscribeMapper.class); private static TMsgSmsMapper msgSmsMapper = MybatisUtil.getSqlSession().getMapper(TMsgSmsMapper.class); private static TMsgMailMapper msgMailMapper = MybatisUtil.getSqlSession().getMapper(TMsgMailMapper.class); private static TMsgWxCpMapper msgWxCpMapper = MybatisUtil.getSqlSession().getMapper(TMsgWxCpMapper.class); @@ -157,6 +136,14 @@ public static void initMessageList() { model.addRow(data); } break; + case MessageTypeEnum.MP_SUBSCRIBE_CODE: + List tMsgMpSubscribeList = msgMpSubscribeMapper.selectByMsgTypeAndWxAccountId(msgType, wxAccountId); + for (TMsgMpSubscribe tMsgMpSubscribe : tMsgMpSubscribeList) { + data = new Object[1]; + data[0] = tMsgMpSubscribe.getMsgName(); + model.addRow(data); + } + break; case MessageTypeEnum.EMAIL_CODE: List tMsgMailList = msgMailMapper.selectByMsgType(msgType); for (TMsgMail tMsgMail : tMsgMailList) { @@ -210,6 +197,7 @@ public static void initSwitchMultiAccount() { switch (msgType) { case MessageTypeEnum.MP_TEMPLATE_CODE: + case MessageTypeEnum.MP_SUBSCRIBE_CODE: case MessageTypeEnum.KEFU_CODE: case MessageTypeEnum.KEFU_PRIORITY_CODE: // 多账号切换-公众号 diff --git a/src/main/java/com/fangxuele/tool/push/ui/form/MessageTypeForm.form b/src/main/java/com/fangxuele/tool/push/ui/form/MessageTypeForm.form index 0a61b8c9e..edd8953b1 100644 --- a/src/main/java/com/fangxuele/tool/push/ui/form/MessageTypeForm.form +++ b/src/main/java/com/fangxuele/tool/push/ui/form/MessageTypeForm.form @@ -19,7 +19,7 @@ - + @@ -36,10 +36,19 @@ - + + + + + + + + + + @@ -47,7 +56,7 @@ - + @@ -55,7 +64,7 @@ - + @@ -63,7 +72,7 @@ - + @@ -72,7 +81,7 @@ - + @@ -80,7 +89,7 @@ - + @@ -88,7 +97,7 @@ - + @@ -96,7 +105,7 @@ - + @@ -105,7 +114,7 @@ - + @@ -114,7 +123,7 @@ - + @@ -123,7 +132,7 @@ - + @@ -132,7 +141,7 @@ - + @@ -141,7 +150,7 @@ - + @@ -150,7 +159,7 @@ - + @@ -159,7 +168,7 @@ - + @@ -182,7 +191,7 @@ - + @@ -191,7 +200,7 @@ - + @@ -200,7 +209,7 @@ - + @@ -209,7 +218,7 @@ - + @@ -218,7 +227,7 @@ - + @@ -227,7 +236,7 @@ - + diff --git a/src/main/java/com/fangxuele/tool/push/ui/form/MessageTypeForm.java b/src/main/java/com/fangxuele/tool/push/ui/form/MessageTypeForm.java index b2b01ec59..d6c7ec89a 100644 --- a/src/main/java/com/fangxuele/tool/push/ui/form/MessageTypeForm.java +++ b/src/main/java/com/fangxuele/tool/push/ui/form/MessageTypeForm.java @@ -46,6 +46,7 @@ public class MessageTypeForm { private JRadioButton bdYunRadioButton; private JRadioButton wxUniformMessageRadioButton; private JRadioButton maSubscribeRadioButton; + private JRadioButton mpSubscribeRadioButton; private static MessageTypeForm messageTypeForm; @@ -75,6 +76,9 @@ public static void init() { case MessageTypeEnum.MP_TEMPLATE_CODE: messageTypeForm.getMpTemplateRadioButton().setSelected(true); break; + case MessageTypeEnum.MP_SUBSCRIBE_CODE: + messageTypeForm.getMpSubscribeRadioButton().setSelected(true); + break; case MessageTypeEnum.MA_TEMPLATE_CODE: messageTypeForm.getMaTemplateRadioButton().setSelected(true); break; @@ -139,8 +143,7 @@ public static void init() { } private static void initMessageManageFormLayOut(int msgType) { - if (msgType == MessageTypeEnum.KEFU_CODE || msgType == MessageTypeEnum.KEFU_PRIORITY_CODE || msgType == MessageTypeEnum.MP_TEMPLATE_CODE - || msgType == MessageTypeEnum.MA_TEMPLATE_CODE || msgType == MessageTypeEnum.MA_SUBSCRIBE_CODE || msgType == MessageTypeEnum.WX_UNIFORM_MESSAGE_CODE) { + if (MessageTypeEnum.isWxMaOrMpType(msgType)) { MessageManageForm.getInstance().getAccountSwitchPanel().setVisible(true); } else { MessageManageForm.getInstance().getAccountSwitchPanel().setVisible(false); @@ -166,9 +169,7 @@ private static void initMemberFormLayOut(int msgType) { } MemberForm.getInstance().getMemberTabDownPanel().setVisible(true); MemberForm.getInstance().getMemberTabCenterPanel().setVisible(true); - if (msgType == MessageTypeEnum.MP_TEMPLATE_CODE || msgType == MessageTypeEnum.MA_TEMPLATE_CODE - || msgType == MessageTypeEnum.KEFU_CODE || msgType == MessageTypeEnum.KEFU_PRIORITY_CODE - || msgType == MessageTypeEnum.WX_UNIFORM_MESSAGE_CODE || msgType == MessageTypeEnum.MA_SUBSCRIBE_CODE) { + if (MessageTypeEnum.isWxMaOrMpType(msgType)) { MemberForm.getInstance().getImportFromWeixinPanel().setVisible(true); MemberForm.getInstance().getImportOptionPanel().setVisible(true); } @@ -227,68 +228,72 @@ public static void clearAllSelected() { messageTypeScrollPane.setAutoscrolls(true); messageTypePanel.add(messageTypeScrollPane, 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)); msgTypeListPanel = new JPanel(); - msgTypeListPanel.setLayout(new GridLayoutManager(22, 3, new Insets(20, 20, 0, 0), -1, -1)); + msgTypeListPanel.setLayout(new GridLayoutManager(23, 3, new Insets(20, 20, 0, 0), -1, -1)); msgTypeListPanel.setAutoscrolls(true); messageTypeScrollPane.setViewportView(msgTypeListPanel); mpTemplateRadioButton = new JRadioButton(); mpTemplateRadioButton.setEnabled(true); mpTemplateRadioButton.setText("公众号-模板消息"); msgTypeListPanel.add(mpTemplateRadioButton, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + mpSubscribeRadioButton = new JRadioButton(); + mpSubscribeRadioButton.setEnabled(true); + mpSubscribeRadioButton.setText("公众号-订阅通知"); + msgTypeListPanel.add(mpSubscribeRadioButton, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); maTemplateRadioButton = new JRadioButton(); maTemplateRadioButton.setEnabled(false); maTemplateRadioButton.setText("小程序-模板消息"); - msgTypeListPanel.add(maTemplateRadioButton, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + msgTypeListPanel.add(maTemplateRadioButton, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); maSubscribeRadioButton = new JRadioButton(); maSubscribeRadioButton.setText("小程序-订阅消息"); - msgTypeListPanel.add(maSubscribeRadioButton, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + msgTypeListPanel.add(maSubscribeRadioButton, new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); kefuRadioButton = new JRadioButton(); kefuRadioButton.setText("公众号-客服消息"); - msgTypeListPanel.add(kefuRadioButton, new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + msgTypeListPanel.add(kefuRadioButton, new GridConstraints(5, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); kefuPriorityRadioButton = new JRadioButton(); kefuPriorityRadioButton.setText("公众号-客服消息优先"); kefuPriorityRadioButton.setToolTipText("优先尝试发送客服消息,如果失败则发送模板消息"); - msgTypeListPanel.add(kefuPriorityRadioButton, new GridConstraints(5, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + msgTypeListPanel.add(kefuPriorityRadioButton, new GridConstraints(6, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); aliYunRadioButton = new JRadioButton(); aliYunRadioButton.setText("阿里云短信"); - msgTypeListPanel.add(aliYunRadioButton, new GridConstraints(9, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + msgTypeListPanel.add(aliYunRadioButton, new GridConstraints(10, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); txYunRadioButton = new JRadioButton(); txYunRadioButton.setText("腾讯云短信"); - msgTypeListPanel.add(txYunRadioButton, new GridConstraints(10, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + msgTypeListPanel.add(txYunRadioButton, new GridConstraints(11, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); yunPianRadioButton = new JRadioButton(); yunPianRadioButton.setText("云片网短信"); - msgTypeListPanel.add(yunPianRadioButton, new GridConstraints(13, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + msgTypeListPanel.add(yunPianRadioButton, new GridConstraints(14, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); 网易云信短信RadioButton = new JRadioButton(); 网易云信短信RadioButton.setEnabled(false); 网易云信短信RadioButton.setText("网易云信短信"); - msgTypeListPanel.add(网易云信短信RadioButton, new GridConstraints(17, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + msgTypeListPanel.add(网易云信短信RadioButton, new GridConstraints(18, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); 榛子云短信RadioButton = new JRadioButton(); 榛子云短信RadioButton.setEnabled(false); 榛子云短信RadioButton.setText("榛子云短信"); - msgTypeListPanel.add(榛子云短信RadioButton, new GridConstraints(18, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + msgTypeListPanel.add(榛子云短信RadioButton, new GridConstraints(19, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); luosimao短信RadioButton = new JRadioButton(); luosimao短信RadioButton.setEnabled(false); luosimao短信RadioButton.setText("Luosimao短信"); - msgTypeListPanel.add(luosimao短信RadioButton, new GridConstraints(19, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + msgTypeListPanel.add(luosimao短信RadioButton, new GridConstraints(20, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); 极光短信RadioButton = new JRadioButton(); 极光短信RadioButton.setEnabled(false); 极光短信RadioButton.setText("极光短信"); - msgTypeListPanel.add(极光短信RadioButton, new GridConstraints(20, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + msgTypeListPanel.add(极光短信RadioButton, new GridConstraints(21, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); 极光推送RadioButton = new JRadioButton(); 极光推送RadioButton.setEnabled(false); 极光推送RadioButton.setText("极光推送"); - msgTypeListPanel.add(极光推送RadioButton, new GridConstraints(21, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + msgTypeListPanel.add(极光推送RadioButton, new GridConstraints(22, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); kefuPriorityTipsLabel = new JLabel(); kefuPriorityTipsLabel.setIcon(new ImageIcon(getClass().getResource("/icon/helpButton.png"))); kefuPriorityTipsLabel.setText(""); - msgTypeListPanel.add(kefuPriorityTipsLabel, new GridConstraints(5, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + msgTypeListPanel.add(kefuPriorityTipsLabel, new GridConstraints(6, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); eMailRadioButton = new JRadioButton(); eMailRadioButton.setEnabled(true); eMailRadioButton.setText("E-Mail(BETA)"); - msgTypeListPanel.add(eMailRadioButton, new GridConstraints(16, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + msgTypeListPanel.add(eMailRadioButton, new GridConstraints(17, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); wxCpRadioButton = new JRadioButton(); wxCpRadioButton.setEnabled(true); wxCpRadioButton.setText("企业号/企业微信"); - msgTypeListPanel.add(wxCpRadioButton, new GridConstraints(7, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + msgTypeListPanel.add(wxCpRadioButton, new GridConstraints(8, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); httpRadioButton = new JRadioButton(); httpRadioButton.setEnabled(true); httpRadioButton.setText("HTTP请求"); @@ -298,26 +303,26 @@ public static void clearAllSelected() { dingRadioButton = new JRadioButton(); dingRadioButton.setEnabled(true); dingRadioButton.setText("钉钉"); - msgTypeListPanel.add(dingRadioButton, new GridConstraints(8, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + msgTypeListPanel.add(dingRadioButton, new GridConstraints(9, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); hwYunRadioButton = new JRadioButton(); hwYunRadioButton.setEnabled(true); hwYunRadioButton.setText("华为云短信(BETA)"); - msgTypeListPanel.add(hwYunRadioButton, new GridConstraints(11, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + msgTypeListPanel.add(hwYunRadioButton, new GridConstraints(12, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); bdYunRadioButton = new JRadioButton(); bdYunRadioButton.setEnabled(true); bdYunRadioButton.setText("百度云短信(BETA)"); - msgTypeListPanel.add(bdYunRadioButton, new GridConstraints(12, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + msgTypeListPanel.add(bdYunRadioButton, new GridConstraints(13, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); upYunRadioButton = new JRadioButton(); upYunRadioButton.setEnabled(true); upYunRadioButton.setText("又拍云短信(BETA)"); - msgTypeListPanel.add(upYunRadioButton, new GridConstraints(14, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + msgTypeListPanel.add(upYunRadioButton, new GridConstraints(15, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); qiniuRadioButton = new JRadioButton(); qiniuRadioButton.setEnabled(true); qiniuRadioButton.setText("七牛云短信(BETA)"); - msgTypeListPanel.add(qiniuRadioButton, new GridConstraints(15, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + msgTypeListPanel.add(qiniuRadioButton, new GridConstraints(16, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); wxUniformMessageRadioButton = new JRadioButton(); wxUniformMessageRadioButton.setText("小程序-统一服务消息(BETA)"); - msgTypeListPanel.add(wxUniformMessageRadioButton, new GridConstraints(6, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + msgTypeListPanel.add(wxUniformMessageRadioButton, new GridConstraints(7, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); final JPanel panel1 = new JPanel(); panel1.setLayout(new GridLayoutManager(2, 1, new Insets(8, 8, 8, 0), -1, -1)); messageTypePanel.add(panel1, 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)); diff --git a/src/main/java/com/fangxuele/tool/push/ui/form/ScheduleForm.java b/src/main/java/com/fangxuele/tool/push/ui/form/ScheduleForm.java index 9a85c04ca..1ed8dec27 100644 --- a/src/main/java/com/fangxuele/tool/push/ui/form/ScheduleForm.java +++ b/src/main/java/com/fangxuele/tool/push/ui/form/ScheduleForm.java @@ -90,9 +90,7 @@ public static void fillReimportComboBox() { scheduleForm.getReimportComboBox().addItem("通过SQL导入"); scheduleForm.getReimportComboBox().addItem("通过文件导入"); int msgType = App.config.getMsgType(); - if (msgType == MessageTypeEnum.MP_TEMPLATE_CODE || msgType == MessageTypeEnum.MA_TEMPLATE_CODE - || msgType == MessageTypeEnum.KEFU_CODE || msgType == MessageTypeEnum.KEFU_PRIORITY_CODE - || msgType == MessageTypeEnum.WX_UNIFORM_MESSAGE_CODE || msgType == MessageTypeEnum.MA_SUBSCRIBE_CODE) { + if (MessageTypeEnum.isWxMaOrMpType(msgType)) { scheduleForm.getReimportComboBox().addItem("导入所有关注公众号的用户"); scheduleForm.getReimportComboBox().addItem("导入选择的标签分组"); scheduleForm.getReimportComboBox().addItem("导入选择的标签分组-取并集"); diff --git a/src/main/java/com/fangxuele/tool/push/ui/form/SettingForm.form b/src/main/java/com/fangxuele/tool/push/ui/form/SettingForm.form index 5cc5d6377..8b448acc1 100644 --- a/src/main/java/com/fangxuele/tool/push/ui/form/SettingForm.form +++ b/src/main/java/com/fangxuele/tool/push/ui/form/SettingForm.form @@ -46,7 +46,7 @@ - + @@ -72,10 +72,18 @@ - + + + + + + + + + @@ -83,7 +91,7 @@ - + diff --git a/src/main/java/com/fangxuele/tool/push/ui/form/SettingForm.java b/src/main/java/com/fangxuele/tool/push/ui/form/SettingForm.java index 95a423d6c..5a5d0aaf9 100644 --- a/src/main/java/com/fangxuele/tool/push/ui/form/SettingForm.java +++ b/src/main/java/com/fangxuele/tool/push/ui/form/SettingForm.java @@ -130,6 +130,7 @@ public class SettingForm { private JTextField maxThreadsTextField; private JButton maxThreadsSaveButton; private JCheckBox defaultMaxWindowCheckBox; + private JCheckBox closeToTrayCheckBox; private static SettingForm settingForm; private static TWxAccountMapper wxAccountMapper = MybatisUtil.getSqlSession().getMapper(TWxAccountMapper.class); @@ -157,6 +158,7 @@ public static void init() { // 常规 settingForm.getAutoCheckUpdateCheckBox().setSelected(App.config.isAutoCheckUpdate()); settingForm.getUseTrayCheckBox().setSelected(App.config.isUseTray()); + settingForm.getCloseToTrayCheckBox().setSelected(App.config.isCloseToTray()); settingForm.getDefaultMaxWindowCheckBox().setSelected(App.config.isDefaultMaxWindow()); settingForm.getMaxThreadsTextField().setText(String.valueOf(App.config.getMaxThreads())); @@ -391,7 +393,7 @@ public static void toggleMpOutSideAccessTokenPanel() { panel3.setLayout(new GridLayoutManager(17, 1, new Insets(40, 60, 0, 330), -1, -1)); panel2.add(panel3, new GridConstraints(0, 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, new Dimension(600, -1), null, 0, false)); final JPanel panel4 = new JPanel(); - panel4.setLayout(new GridLayoutManager(4, 1, new Insets(15, 15, 10, 0), -1, -1)); + panel4.setLayout(new GridLayoutManager(5, 1, new Insets(15, 15, 10, 0), -1, -1)); panel3.add(panel4, new GridConstraints(0, 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)); panel4.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(), "常规", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, this.$$$getFont$$$(null, Font.BOLD, -1, panel4.getFont()), null)); autoCheckUpdateCheckBox = new JCheckBox(); @@ -400,12 +402,15 @@ public static void toggleMpOutSideAccessTokenPanel() { useTrayCheckBox = new JCheckBox(); useTrayCheckBox.setText("显示系统托盘图标"); panel4.add(useTrayCheckBox, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + closeToTrayCheckBox = new JCheckBox(); + closeToTrayCheckBox.setText("关闭窗口时最小化到系统托盘"); + panel4.add(closeToTrayCheckBox, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); defaultMaxWindowCheckBox = new JCheckBox(); defaultMaxWindowCheckBox.setText("默认最大化窗口"); - panel4.add(defaultMaxWindowCheckBox, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + panel4.add(defaultMaxWindowCheckBox, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); final JPanel panel5 = new JPanel(); panel5.setLayout(new GridLayoutManager(1, 4, new Insets(0, 0, 0, 0), -1, -1)); - panel4.add(panel5, new GridConstraints(3, 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)); + panel4.add(panel5, new GridConstraints(4, 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)); final JLabel label1 = new JLabel(); label1.setText("最大线程数"); panel5.add(label1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); diff --git a/src/main/java/com/fangxuele/tool/push/ui/form/msg/MpSubscribeMsgForm.form b/src/main/java/com/fangxuele/tool/push/ui/form/msg/MpSubscribeMsgForm.form new file mode 100644 index 000000000..7a885ead0 --- /dev/null +++ b/src/main/java/com/fangxuele/tool/push/ui/form/msg/MpSubscribeMsgForm.form @@ -0,0 +1,235 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/com/fangxuele/tool/push/ui/form/msg/MpSubscribeMsgForm.java b/src/main/java/com/fangxuele/tool/push/ui/form/msg/MpSubscribeMsgForm.java new file mode 100644 index 000000000..e62f2f699 --- /dev/null +++ b/src/main/java/com/fangxuele/tool/push/ui/form/msg/MpSubscribeMsgForm.java @@ -0,0 +1,578 @@ +package com.fangxuele.tool.push.ui.form.msg; + +import com.fangxuele.tool.push.App; +import com.fangxuele.tool.push.dao.TMsgMpSubscribeMapper; +import com.fangxuele.tool.push.dao.TTemplateDataMapper; +import com.fangxuele.tool.push.domain.TMsgMpSubscribe; +import com.fangxuele.tool.push.domain.TTemplateData; +import com.fangxuele.tool.push.logic.MessageTypeEnum; +import com.fangxuele.tool.push.logic.msgsender.WxMpTemplateMsgSender; +import com.fangxuele.tool.push.ui.component.TableInCellButtonColumn; +import com.fangxuele.tool.push.ui.form.MainWindow; +import com.fangxuele.tool.push.ui.form.MessageEditForm; +import com.fangxuele.tool.push.util.MybatisUtil; +import com.fangxuele.tool.push.util.SqliteUtil; +import com.fangxuele.tool.push.util.UIUtil; +import com.google.common.collect.Maps; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import lombok.Getter; +import lombok.extern.slf4j.Slf4j; +import me.chanjar.weixin.common.bean.subscribemsg.TemplateInfo; +import org.apache.commons.compress.utils.Lists; +import org.apache.commons.lang3.StringUtils; + +import javax.swing.*; +import javax.swing.border.TitledBorder; +import javax.swing.plaf.FontUIResource; +import javax.swing.table.DefaultTableCellRenderer; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.TableColumnModel; +import javax.swing.text.StyleContext; +import java.awt.*; +import java.awt.event.ItemEvent; +import java.util.List; +import java.util.*; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + *
+ * MpSubscribeMsgForm
+ * 
+ * + * @author Zhou Bo + * @since 2021/3/23. + */ +@Getter +@Slf4j +public class MpSubscribeMsgForm implements IMsgForm { + private JPanel templateMsgPanel; + private JLabel templateIdLabel; + private JTextField msgTemplateIdTextField; + private JLabel templateUrlLabel; + private JTextField msgTemplateUrlTextField; + private JPanel templateMsgDataPanel; + private JLabel templateMiniProgramAppidLabel; + private JTextField msgTemplateMiniAppidTextField; + private JLabel templateMiniProgramPagePathLabel; + private JTextField msgTemplateMiniPagePathTextField; + private JLabel templateMsgNameLabel; + private JTextField templateDataNameTextField; + private JLabel templateMsgValueLabel; + private JTextField templateDataValueTextField; + private JLabel templateMsgColorLabel; + private JTextField templateDataColorTextField; + private JButton templateMsgDataAddButton; + private JTable templateMsgDataTable; + private JComboBox templateListComboBox; + private JButton refreshTemplateListButton; + private JButton autoFillButton; + private JTextArea templateContentTextArea; + + private static MpSubscribeMsgForm mpSubscribeMsgForm; + + private static TMsgMpSubscribeMapper tMsgMpSubscribeMapper = MybatisUtil.getSqlSession().getMapper(TMsgMpSubscribeMapper.class); + + private static TTemplateDataMapper templateDataMapper = MybatisUtil.getSqlSession().getMapper(TTemplateDataMapper.class); + + /** + * 账号模板列表 + */ + public static List templateList; + + /** + * 模板账号map,key:templateId + */ + public static Map templateMap; + + /** + * (左侧列表中)所选消息对应的模板ID + */ + public static String selectedMsgTemplateId; + + /** + * 是否需要监听模板列表ComboBox + */ + public static boolean needListenTemplateListComboBox = false; + + private static final Pattern BRACE_PATTERN = Pattern.compile("\\{([^{}]+)\\}"); + + public MpSubscribeMsgForm() { + // 模板数据-添加 按钮事件 + templateMsgDataAddButton.addActionListener(e -> { + String[] data = new String[3]; + data[0] = getInstance().getTemplateDataNameTextField().getText(); + data[1] = getInstance().getTemplateDataValueTextField().getText(); + data[2] = getInstance().getTemplateDataColorTextField().getText(); + + if (getInstance().getTemplateMsgDataTable().getModel().getRowCount() == 0) { + initTemplateDataTable(); + } + + DefaultTableModel tableModel = (DefaultTableModel) getInstance().getTemplateMsgDataTable() + .getModel(); + int rowCount = tableModel.getRowCount(); + + Set keySet = new HashSet<>(); + String keyData; + for (int i = 0; i < rowCount; i++) { + keyData = (String) tableModel.getValueAt(i, 0); + keySet.add(keyData); + } + + if (StringUtils.isEmpty(data[0]) || StringUtils.isEmpty(data[1])) { + JOptionPane.showMessageDialog(MessageEditForm.getInstance().getMsgEditorPanel(), "Name或value不能为空!", "提示", + JOptionPane.INFORMATION_MESSAGE); + } else if (keySet.contains(data[0])) { + JOptionPane.showMessageDialog(MessageEditForm.getInstance().getMsgEditorPanel(), "Name不能重复!", "提示", + JOptionPane.INFORMATION_MESSAGE); + } else { + if (StringUtils.isEmpty(data[2])) { + data[2] = "#000000"; + } else if (!data[2].startsWith("#")) { + data[2] = "#" + data[2]; + } + tableModel.addRow(data); + } + }); + templateListComboBox.addItemListener(e -> { + if (needListenTemplateListComboBox && e.getStateChange() == ItemEvent.SELECTED) { + clearAllFieldExceptTemplateListAndContent(); + fillWxTemplateContentToField(); + } + }); + autoFillButton.addActionListener(e -> autoFillTemplateDataTable()); + refreshTemplateListButton.addActionListener(e -> { + initTemplateList(); + initTemplateDataTable(); + }); + } + + @Override + public void init(String msgName) { + MpSubscribeMsgForm mpTemplateMsgForm = getInstance(); + if (UIUtil.isDarkLaf()) { + Color bgColor = new Color(43, 43, 43); + mpTemplateMsgForm.getTemplateContentTextArea().setBackground(bgColor); + Color foreColor = new Color(187, 187, 187); + mpTemplateMsgForm.getTemplateContentTextArea().setForeground(foreColor); + } + + clearAllField(); + + Integer msgId = 0; + List tMsgMpSubscribeList = tMsgMpSubscribeMapper.selectByMsgTypeAndMsgName(MessageTypeEnum.MP_SUBSCRIBE_CODE, msgName); + if (tMsgMpSubscribeList.size() > 0) { + TMsgMpSubscribe tMsgMpSubscribe = tMsgMpSubscribeList.get(0); + msgId = tMsgMpSubscribe.getId(); + selectedMsgTemplateId = tMsgMpSubscribe.getTemplateId(); + initTemplateList(); + + mpTemplateMsgForm.getMsgTemplateIdTextField().setText(tMsgMpSubscribe.getTemplateId()); + mpTemplateMsgForm.getMsgTemplateUrlTextField().setText(tMsgMpSubscribe.getUrl()); + mpTemplateMsgForm.getMsgTemplateMiniAppidTextField().setText(tMsgMpSubscribe.getMaAppid()); + mpTemplateMsgForm.getMsgTemplateMiniPagePathTextField().setText(tMsgMpSubscribe.getMaPagePath()); + + MessageEditForm messageEditForm = MessageEditForm.getInstance(); + messageEditForm.getMsgNameField().setText(tMsgMpSubscribe.getMsgName()); + messageEditForm.getPreviewUserField().setText(tMsgMpSubscribe.getPreviewUser()); + } else { + initTemplateList(); + } + + initTemplateDataTable(); + fillTemplateDataTable(msgId); + } + + @Override + public void save(String msgName) { + int msgId = 0; + boolean existSameMsg = false; + + List tMsgMpSubscribeList = tMsgMpSubscribeMapper.selectByMsgTypeAndMsgName(MessageTypeEnum.MP_SUBSCRIBE_CODE, msgName); + if (tMsgMpSubscribeList.size() > 0) { + existSameMsg = true; + msgId = tMsgMpSubscribeList.get(0).getId(); + } + + int isCover = JOptionPane.NO_OPTION; + if (existSameMsg) { + // 如果存在,是否覆盖 + isCover = JOptionPane.showConfirmDialog(MainWindow.getInstance().getMessagePanel(), "已经存在同名的历史消息,\n是否覆盖?", "确认", + JOptionPane.YES_NO_OPTION); + } + + if (!existSameMsg || isCover == JOptionPane.YES_OPTION) { + String templateId = getInstance().getMsgTemplateIdTextField().getText(); + String templateUrl = getInstance().getMsgTemplateUrlTextField().getText(); + String templateMiniAppid = getInstance().getMsgTemplateMiniAppidTextField().getText(); + String templateMiniPagePath = getInstance().getMsgTemplateMiniPagePathTextField().getText(); + + String now = SqliteUtil.nowDateForSqlite(); + + TMsgMpSubscribe tMsgMpSubscribe = new TMsgMpSubscribe(); + tMsgMpSubscribe.setMsgType(MessageTypeEnum.MP_SUBSCRIBE_CODE); + tMsgMpSubscribe.setMsgName(msgName); + tMsgMpSubscribe.setTemplateId(templateId); + tMsgMpSubscribe.setUrl(templateUrl); + tMsgMpSubscribe.setMaAppid(templateMiniAppid); + tMsgMpSubscribe.setMaPagePath(templateMiniPagePath); + tMsgMpSubscribe.setCreateTime(now); + tMsgMpSubscribe.setModifiedTime(now); + + MessageEditForm messageEditForm = MessageEditForm.getInstance(); + tMsgMpSubscribe.setPreviewUser(messageEditForm.getPreviewUserField().getText()); + tMsgMpSubscribe.setWxAccountId(App.config.getWxAccountId()); + + if (existSameMsg) { + tMsgMpSubscribeMapper.updateByMsgTypeAndMsgName(tMsgMpSubscribe); + } else { + tMsgMpSubscribeMapper.insertSelective(tMsgMpSubscribe); + msgId = tMsgMpSubscribe.getId(); + } + + // 保存模板数据 + + // 如果是覆盖保存,则先清空之前的模板数据 + if (existSameMsg) { + templateDataMapper.deleteByMsgTypeAndMsgId(MessageTypeEnum.MP_SUBSCRIBE_CODE, msgId); + } + + // 如果table为空,则初始化 + if (getInstance().getTemplateMsgDataTable().getModel().getRowCount() == 0) { + initTemplateDataTable(); + } + + // 逐行读取 + DefaultTableModel tableModel = (DefaultTableModel) getInstance().getTemplateMsgDataTable() + .getModel(); + int rowCount = tableModel.getRowCount(); + for (int i = 0; i < rowCount; i++) { + String name = (String) tableModel.getValueAt(i, 0); + String value = (String) tableModel.getValueAt(i, 1); + String color = ((String) tableModel.getValueAt(i, 2)).trim(); + + TTemplateData tTemplateData = new TTemplateData(); + tTemplateData.setMsgType(MessageTypeEnum.MP_SUBSCRIBE_CODE); + tTemplateData.setMsgId(msgId); + tTemplateData.setName(name); + tTemplateData.setValue(value); + tTemplateData.setColor(color); + tTemplateData.setCreateTime(now); + tTemplateData.setModifiedTime(now); + + templateDataMapper.insert(tTemplateData); + } + + JOptionPane.showMessageDialog(MainWindow.getInstance().getMessagePanel(), "保存成功!", "成功", + JOptionPane.INFORMATION_MESSAGE); + } + } + + public static MpSubscribeMsgForm getInstance() { + if (mpSubscribeMsgForm == null) { + mpSubscribeMsgForm = new MpSubscribeMsgForm(); + } + return mpSubscribeMsgForm; + } + + /** + * 填充模板参数表Table(从数据库读取) + * + * @param msgId + */ + public static void fillTemplateDataTable(Integer msgId) { + // 模板消息Data表 + List templateDataList = templateDataMapper.selectByMsgTypeAndMsgId(MessageTypeEnum.MP_SUBSCRIBE_CODE, msgId); + String[] headerNames = {"Name", "Value", "Color", "操作"}; + Object[][] cellData = new String[templateDataList.size()][headerNames.length]; + for (int i = 0; i < templateDataList.size(); i++) { + TTemplateData tTemplateData = templateDataList.get(i); + cellData[i][0] = tTemplateData.getName(); + cellData[i][1] = tTemplateData.getValue(); + cellData[i][2] = tTemplateData.getColor(); + } + DefaultTableModel model = new DefaultTableModel(cellData, headerNames); + getInstance().getTemplateMsgDataTable().setModel(model); + TableColumnModel tableColumnModel = getInstance().getTemplateMsgDataTable().getColumnModel(); + tableColumnModel.getColumn(headerNames.length - 1). + setCellRenderer(new TableInCellButtonColumn(getInstance().getTemplateMsgDataTable(), headerNames.length - 1)); + tableColumnModel.getColumn(headerNames.length - 1). + setCellEditor(new TableInCellButtonColumn(getInstance().getTemplateMsgDataTable(), headerNames.length - 1)); + + // 设置列宽 + tableColumnModel.getColumn(3).setPreferredWidth(getInstance().getTemplateMsgDataAddButton().getWidth()); + tableColumnModel.getColumn(3).setMaxWidth(getInstance().getTemplateMsgDataAddButton().getWidth()); + } + + /** + * 初始化模板列表ComboBox + */ + public static void initTemplateList() { + needListenTemplateListComboBox = false; + try { + templateMap = Maps.newHashMap(); + templateList = WxMpTemplateMsgSender.getWxMpService().getSubscribeMsgService().getTemplateList(); + getInstance().getTemplateListComboBox().removeAllItems(); + int selectedIndex = 0; + for (int i = 0; i < templateList.size(); i++) { + TemplateInfo templateInfo = templateList.get(i); + getInstance().getTemplateListComboBox().addItem(templateInfo.getTitle()); + templateMap.put(templateInfo.getPriTmplId(), templateInfo); + if (templateInfo.getPriTmplId().equals(selectedMsgTemplateId)) { + selectedIndex = i; + } + } + + if (getInstance().getTemplateListComboBox().getItemCount() > 0) { + getInstance().getTemplateListComboBox().setSelectedIndex(selectedIndex); + fillWxTemplateContentToField(); + } + + } catch (Exception e) { + log.error(e.toString()); + } + needListenTemplateListComboBox = true; + } + + /** + * 根据模板内容获取模板中的参数list + * + * @param templateContent 模板内容 + * @return params 模板中的参数 + */ + public static List getTemplateParams(String templateContent) { + List params = Lists.newArrayList(); + Matcher matcher = BRACE_PATTERN.matcher(templateContent); + while (matcher.find()) { + params.add(matcher.group(1).replace(".DATA", "")); + } + return params; + } + + /** + * 根据模板id填充模板列表中对应的WxTemplate内容到表单 + */ + public static void fillWxTemplateContentToField() { + TemplateInfo templateInfo = templateList.get(getInstance().getTemplateListComboBox().getSelectedIndex()); + if (templateInfo != null) { + StringBuilder stringBuilder = new StringBuilder(); + stringBuilder.append("-----------模板ID-----------\n").append(templateInfo.getPriTmplId()).append("\n"); + stringBuilder.append("\n----------模板标题----------\n").append(templateInfo.getTitle()).append("\n"); + int type = templateInfo.getType(); + String templateType = "未知"; + if (type == 2) { + templateType = "一次性订阅"; + } else if (type == 3) { + templateType = "长期订阅"; + } + stringBuilder.append("\n----------模板类型----------\n").append(templateType).append("\n"); + stringBuilder.append("\n----------模板内容----------\n").append(templateInfo.getContent()).append("\n"); + stringBuilder.append("\n----------模板示例----------\n").append(templateInfo.getExample()); + getInstance().getTemplateContentTextArea().setText(stringBuilder.toString()); + getInstance().getMsgTemplateIdTextField().setText(templateInfo.getPriTmplId()); + } + } + + /** + * 自动填充模板数据Table + */ + private static void autoFillTemplateDataTable() { + if (templateList != null) { + TemplateInfo templateInfo = templateList.get(getInstance().getTemplateListComboBox().getSelectedIndex()); + if (templateInfo != null) { + initTemplateDataTable(); + DefaultTableModel tableModel = (DefaultTableModel) getInstance().getTemplateMsgDataTable() + .getModel(); + List params = getTemplateParams(templateInfo.getContent()); + for (int i = 0; i < params.size(); i++) { + String param = params.get(i); + String[] data = new String[3]; + data[0] = param; + data[1] = "示例值" + (i + 1); + data[2] = "#000000"; + tableModel.addRow(data); + } + } + } + } + + /** + * 初始化模板消息数据table + */ + public static void initTemplateDataTable() { + JTable msgDataTable = getInstance().getTemplateMsgDataTable(); + String[] headerNames = {"Name", "Value", "Color", "操作"}; + DefaultTableModel model = new DefaultTableModel(null, headerNames); + msgDataTable.setModel(model); + msgDataTable.updateUI(); + DefaultTableCellRenderer hr = (DefaultTableCellRenderer) msgDataTable.getTableHeader().getDefaultRenderer(); + // 表头列名居左 + hr.setHorizontalAlignment(DefaultTableCellRenderer.LEFT); + + TableColumnModel tableColumnModel = msgDataTable.getColumnModel(); + tableColumnModel.getColumn(headerNames.length - 1). + setCellRenderer(new TableInCellButtonColumn(msgDataTable, headerNames.length - 1)); + tableColumnModel.getColumn(headerNames.length - 1). + setCellEditor(new TableInCellButtonColumn(msgDataTable, headerNames.length - 1)); + + // 设置列宽 + tableColumnModel.getColumn(3).setPreferredWidth(getInstance().getTemplateMsgDataAddButton().getWidth()); + tableColumnModel.getColumn(3).setMaxWidth(getInstance().getTemplateMsgDataAddButton().getWidth()); + } + + /** + * 清空所有界面字段 + */ + public static void clearAllField() { + clearAllFieldExceptTemplateListAndContent(); + getInstance().getTemplateListComboBox().removeAllItems(); + getInstance().getTemplateContentTextArea().setText(""); + } + + /** + * 清空所有界面字段 + */ + public static void clearAllFieldExceptTemplateListAndContent() { + getInstance().getMsgTemplateIdTextField().setText(""); + getInstance().getMsgTemplateUrlTextField().setText(""); + getInstance().getMsgTemplateMiniAppidTextField().setText(""); + getInstance().getMsgTemplateMiniPagePathTextField().setText(""); + getInstance().getTemplateDataNameTextField().setText(""); + getInstance().getTemplateDataValueTextField().setText(""); + getInstance().getTemplateDataColorTextField().setText(""); + selectedMsgTemplateId = null; + initTemplateDataTable(); + } + + { +// 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$$$() { + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + templateMsgPanel = new JPanel(); + templateMsgPanel.setLayout(new GridLayoutManager(2, 1, new Insets(10, 15, 0, 0), -1, -1)); + panel1.add(templateMsgPanel, 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)); + templateMsgPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(), "公众号-订阅通知编辑", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, this.$$$getFont$$$(null, Font.BOLD, -1, templateMsgPanel.getFont()), null)); + templateMsgDataPanel = new JPanel(); + templateMsgDataPanel.setLayout(new GridLayoutManager(3, 4, new Insets(10, 0, 0, 0), -1, -1)); + templateMsgPanel.add(templateMsgDataPanel, 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_WANT_GROW, null, null, null, 0, false)); + templateMsgDataPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "模板变量(可使用\"${ENTER}\"作为换行符)", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, this.$$$getFont$$$(null, Font.BOLD, -1, templateMsgDataPanel.getFont()), null)); + templateDataNameTextField = new JTextField(); + templateDataNameTextField.setToolTipText("当消息类型是模板消息时的示例:first或者keyword1或者remark之类的"); + templateMsgDataPanel.add(templateDataNameTextField, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + templateDataValueTextField = new JTextField(); + templateMsgDataPanel.add(templateDataValueTextField, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + templateDataColorTextField = new JTextField(); + templateDataColorTextField.setToolTipText("示例值:FF0000"); + templateMsgDataPanel.add(templateDataColorTextField, new GridConstraints(1, 2, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + templateMsgDataAddButton = new JButton(); + templateMsgDataAddButton.setIcon(new ImageIcon(getClass().getResource("/icon/add.png"))); + templateMsgDataAddButton.setText(""); + templateMsgDataPanel.add(templateMsgDataAddButton, new GridConstraints(1, 3, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + templateMsgDataTable = new JTable(); + templateMsgDataTable.setAutoCreateColumnsFromModel(true); + templateMsgDataTable.setAutoCreateRowSorter(true); + templateMsgDataTable.setGridColor(new Color(-12236470)); + templateMsgDataTable.setRowHeight(36); + templateMsgDataPanel.add(templateMsgDataTable, new GridConstraints(2, 0, 1, 4, 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)); + templateMsgNameLabel = new JLabel(); + templateMsgNameLabel.setText("name"); + templateMsgNameLabel.setToolTipText("当消息类型是模板消息时的示例:first或者keyword1或者remark之类的"); + templateMsgDataPanel.add(templateMsgNameLabel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + templateMsgValueLabel = new JLabel(); + templateMsgValueLabel.setText("value"); + templateMsgDataPanel.add(templateMsgValueLabel, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + templateMsgColorLabel = new JLabel(); + templateMsgColorLabel.setText("color"); + templateMsgColorLabel.setToolTipText("示例值:FF0000"); + templateMsgDataPanel.add(templateMsgColorLabel, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + autoFillButton = new JButton(); + autoFillButton.setText("自动填充"); + templateMsgDataPanel.add(autoFillButton, new GridConstraints(0, 3, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JPanel panel2 = new JPanel(); + panel2.setLayout(new GridLayoutManager(6, 3, new Insets(0, 0, 5, 0), -1, -1)); + templateMsgPanel.add(panel2, new GridConstraints(0, 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)); + templateIdLabel = new JLabel(); + templateIdLabel.setText("模板ID *"); + panel2.add(templateIdLabel, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + msgTemplateIdTextField = new JTextField(); + panel2.add(msgTemplateIdTextField, new GridConstraints(2, 1, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); + templateUrlLabel = new JLabel(); + templateUrlLabel.setText("跳转URL"); + panel2.add(templateUrlLabel, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + msgTemplateUrlTextField = new JTextField(); + panel2.add(msgTemplateUrlTextField, new GridConstraints(3, 1, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); + templateMiniProgramAppidLabel = new JLabel(); + templateMiniProgramAppidLabel.setText("小程序appid"); + templateMiniProgramAppidLabel.setToolTipText("非必填"); + panel2.add(templateMiniProgramAppidLabel, new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + msgTemplateMiniAppidTextField = new JTextField(); + msgTemplateMiniAppidTextField.setText(""); + msgTemplateMiniAppidTextField.setToolTipText("非必填"); + panel2.add(msgTemplateMiniAppidTextField, new GridConstraints(4, 1, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); + templateMiniProgramPagePathLabel = new JLabel(); + templateMiniProgramPagePathLabel.setText("小程序页面路径"); + templateMiniProgramPagePathLabel.setToolTipText("非必填"); + panel2.add(templateMiniProgramPagePathLabel, new GridConstraints(5, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + msgTemplateMiniPagePathTextField = new JTextField(); + msgTemplateMiniPagePathTextField.setText(""); + msgTemplateMiniPagePathTextField.setToolTipText("非必填"); + panel2.add(msgTemplateMiniPagePathTextField, new GridConstraints(5, 1, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); + final JLabel label1 = new JLabel(); + label1.setText("选择模板"); + panel2.add(label1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + templateListComboBox = new JComboBox(); + panel2.add(templateListComboBox, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + refreshTemplateListButton = new JButton(); + refreshTemplateListButton.setIcon(new ImageIcon(getClass().getResource("/icon/refresh.png"))); + refreshTemplateListButton.setText("刷新"); + panel2.add(refreshTemplateListButton, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, 1, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + templateContentTextArea = new JTextArea(); + templateContentTextArea.setEditable(false); + panel2.add(templateContentTextArea, new GridConstraints(1, 0, 1, 3, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_WANT_GROW, null, new Dimension(150, 50), null, 0, false)); + templateMsgNameLabel.setLabelFor(templateDataNameTextField); + templateMsgValueLabel.setLabelFor(templateDataValueTextField); + templateMsgColorLabel.setLabelFor(templateDataColorTextField); + templateIdLabel.setLabelFor(msgTemplateIdTextField); + templateUrlLabel.setLabelFor(msgTemplateUrlTextField); + templateMiniProgramAppidLabel.setLabelFor(msgTemplateMiniAppidTextField); + templateMiniProgramPagePathLabel.setLabelFor(msgTemplateMiniPagePathTextField); + } + + /** + * @noinspection ALL + */ + private Font $$$getFont$$$(String fontName, int style, int size, Font currentFont) { + if (currentFont == null) return null; + String resultName; + if (fontName == null) { + resultName = currentFont.getName(); + } else { + Font testFont = new Font(fontName, Font.PLAIN, 10); + if (testFont.canDisplay('a') && testFont.canDisplay('1')) { + resultName = fontName; + } else { + resultName = currentFont.getName(); + } + } + Font font = new Font(resultName, style >= 0 ? style : currentFont.getStyle(), size >= 0 ? size : currentFont.getSize()); + boolean isMac = System.getProperty("os.name", "").toLowerCase(Locale.ENGLISH).startsWith("mac"); + Font fontWithFallback = isMac ? new Font(font.getFamily(), font.getStyle(), font.getSize()) : new StyleContext().getFont(font.getFamily(), font.getStyle(), font.getSize()); + return fontWithFallback instanceof FontUIResource ? fontWithFallback : new FontUIResource(fontWithFallback); + } + +} diff --git a/src/main/java/com/fangxuele/tool/push/ui/form/msg/MsgFormFactory.java b/src/main/java/com/fangxuele/tool/push/ui/form/msg/MsgFormFactory.java index d84ad8e36..80044d76b 100644 --- a/src/main/java/com/fangxuele/tool/push/ui/form/msg/MsgFormFactory.java +++ b/src/main/java/com/fangxuele/tool/push/ui/form/msg/MsgFormFactory.java @@ -71,6 +71,9 @@ public static IMsgForm getMsgForm() { case MessageTypeEnum.BD_YUN_CODE: iMsgForm = BdYunMsgForm.getInstance(); break; + case MessageTypeEnum.MP_SUBSCRIBE_CODE: + iMsgForm = MpSubscribeMsgForm.getInstance(); + break; case MessageTypeEnum.HTTP_CODE: default: iMsgForm = HttpMsgForm.getInstance(); diff --git a/src/main/java/com/fangxuele/tool/push/ui/frame/MainFrame.java b/src/main/java/com/fangxuele/tool/push/ui/frame/MainFrame.java index 47043fca3..ec9ae5dce 100644 --- a/src/main/java/com/fangxuele/tool/push/ui/frame/MainFrame.java +++ b/src/main/java/com/fangxuele/tool/push/ui/frame/MainFrame.java @@ -1,24 +1,9 @@ package com.fangxuele.tool.push.ui.frame; import cn.hutool.core.thread.ThreadUtil; -import com.apple.eawt.Application; import com.fangxuele.tool.push.ui.UiConsts; -import com.fangxuele.tool.push.ui.listener.AboutListener; -import com.fangxuele.tool.push.ui.listener.BoostListener; -import com.fangxuele.tool.push.ui.listener.FrameListener; -import com.fangxuele.tool.push.ui.listener.HelpListener; -import com.fangxuele.tool.push.ui.listener.InfinityListener; -import com.fangxuele.tool.push.ui.listener.MemberListener; -import com.fangxuele.tool.push.ui.listener.MessageEditListener; -import com.fangxuele.tool.push.ui.listener.MessageManageListener; -import com.fangxuele.tool.push.ui.listener.MessageTypeListener; -import com.fangxuele.tool.push.ui.listener.PushHisListener; -import com.fangxuele.tool.push.ui.listener.PushListener; -import com.fangxuele.tool.push.ui.listener.ScheduleListener; -import com.fangxuele.tool.push.ui.listener.SettingListener; -import com.fangxuele.tool.push.ui.listener.TabListener; +import com.fangxuele.tool.push.ui.listener.*; import com.fangxuele.tool.push.util.ComponentUtil; -import com.fangxuele.tool.push.util.SystemUtil; import org.apache.commons.compress.utils.Lists; import javax.swing.*; @@ -52,14 +37,14 @@ public void init() { images.add(UiConsts.IMAGE_LOGO_16); this.setIconImages(images); // Mac系统Dock图标 - if (SystemUtil.isMacOs()) { - Application application = Application.getApplication(); - application.setDockIconImage(UiConsts.IMAGE_LOGO_1024); - if (!SystemUtil.isMacM1()) { - application.setEnabledAboutMenu(false); - application.setEnabledPreferencesMenu(false); - } - } +// if (SystemUtil.isMacOs()) { +// Application application = Application.getApplication(); +// application.setDockIconImage(UiConsts.IMAGE_LOGO_1024); +// if (!SystemUtil.isMacM1()) { +// application.setEnabledAboutMenu(false); +// application.setEnabledPreferencesMenu(false); +// } +// } ComponentUtil.setPreferSizeAndLocateToCenter(this, 0.8, 0.88); } diff --git a/src/main/java/com/fangxuele/tool/push/ui/listener/FrameListener.java b/src/main/java/com/fangxuele/tool/push/ui/listener/FrameListener.java index 6e203e1dc..b82ffc6a3 100644 --- a/src/main/java/com/fangxuele/tool/push/ui/listener/FrameListener.java +++ b/src/main/java/com/fangxuele/tool/push/ui/listener/FrameListener.java @@ -52,9 +52,11 @@ public void windowClosing(WindowEvent e) { "有推送任务正在进行!\n\n为避免数据丢失,请先停止!\n\n", "Sorry~", JOptionPane.WARNING_MESSAGE); } else { - App.sqlSession.close(); mainFrame.dispose(); - mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + if (!App.config.isCloseToTray()) { + App.sqlSession.close(); + mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + } } } diff --git a/src/main/java/com/fangxuele/tool/push/ui/listener/MemberListener.java b/src/main/java/com/fangxuele/tool/push/ui/listener/MemberListener.java index 8320acce1..c7dc83aa8 100644 --- a/src/main/java/com/fangxuele/tool/push/ui/listener/MemberListener.java +++ b/src/main/java/com/fangxuele/tool/push/ui/listener/MemberListener.java @@ -35,11 +35,7 @@ import com.fangxuele.tool.push.ui.form.MemberForm; import com.fangxuele.tool.push.ui.form.msg.DingMsgForm; import com.fangxuele.tool.push.ui.form.msg.WxCpMsgForm; -import com.fangxuele.tool.push.util.ConsoleUtil; -import com.fangxuele.tool.push.util.FileCharSetUtil; -import com.fangxuele.tool.push.util.HikariUtil; -import com.fangxuele.tool.push.util.JTableUtil; -import com.fangxuele.tool.push.util.MybatisUtil; +import com.fangxuele.tool.push.util.*; import com.google.common.collect.Maps; import com.opencsv.CSVReader; import com.opencsv.CSVWriter; @@ -65,21 +61,10 @@ import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; import java.awt.event.KeyListener; -import java.io.BufferedReader; -import java.io.DataInputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileWriter; -import java.io.IOException; -import java.io.InputStreamReader; +import java.io.*; import java.sql.Connection; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; import java.util.List; -import java.util.Map; -import java.util.Set; +import java.util.*; import java.util.stream.Collectors; /** @@ -247,6 +232,33 @@ public void keyReleased(KeyEvent evt) { } })); + // 公众号-排除选择的标签分组用户按钮事件 + memberForm.getMemberImportTagExceptButton().addActionListener(e -> ThreadUtil.execute(() -> { + try { + if (memberForm.getMemberImportTagComboBox().getSelectedItem() != null + && StringUtils.isNotEmpty(memberForm.getMemberImportTagComboBox().getSelectedItem().toString())) { + + long selectedTagId = userTagMap.get(memberForm.getMemberImportTagComboBox().getSelectedItem()); + removeMpUserListByTag(selectedTagId); + renderMemberListTable(); + JOptionPane.showMessageDialog(memberPanel, "导入完成!", "完成", + JOptionPane.INFORMATION_MESSAGE); + } else { + JOptionPane.showMessageDialog(memberPanel, "请先选择需要导入的标签!", "提示", + JOptionPane.INFORMATION_MESSAGE); + } + } catch (WxErrorException e1) { + JOptionPane.showMessageDialog(memberPanel, "导入失败!\n\n" + e1.getMessage(), "失败", + JOptionPane.ERROR_MESSAGE); + logger.error(e1); + e1.printStackTrace(); + } finally { + progressBar.setIndeterminate(false); + progressBar.setValue(progressBar.getMaximum()); + progressBar.setVisible(false); + } + })); + // 公众号-清空本地缓存按钮事件 memberForm.getClearDbCacheButton().addActionListener(e -> { int count = tWxMpUserMapper.deleteAll(); @@ -863,7 +875,6 @@ public static void getMpUserList() throws WxErrorException { * 按标签拉取公众平台用户列表 * * @param tagId - * @param retain 是否取交集 * @throws WxErrorException */ public static void getMpUserListByTag(Long tagId) throws WxErrorException { @@ -989,6 +1000,61 @@ public static void getMpUserListByTag(Long tagId, boolean retain) throws WxError } + /** + * 排除所选标签 + * + * @param tagId + * @throws WxErrorException + */ + private static void removeMpUserListByTag(long tagId) throws WxErrorException { + JProgressBar progressBar = MemberForm.getInstance().getMemberTabImportProgressBar(); + JLabel memberCountLabel = MemberForm.getInstance().getMemberTabCountLabel(); + + progressBar.setVisible(true); + progressBar.setIndeterminate(true); + + WxMpService wxMpService = WxMpTemplateMsgSender.getWxMpService(); + if (wxMpService.getWxMpConfigStorage() == null) { + return; + } + + WxTagListUser wxTagListUser = wxMpService.getUserTagService().tagListUser(tagId, ""); + + ConsoleUtil.consoleWithLog("拉取的OPENID个数:" + wxTagListUser.getCount()); + + if (wxTagListUser.getCount() == 0) { + return; + } + + List openIds = wxTagListUser.getData().getOpenidList(); + + tagUserSet = PushData.allUser.stream().map(e -> e[0]).collect(Collectors.toSet()); + openIds.forEach(tagUserSet::remove); + + while (StringUtils.isNotEmpty(wxTagListUser.getNextOpenid())) { + wxTagListUser = wxMpService.getUserTagService().tagListUser(tagId, wxTagListUser.getNextOpenid()); + + ConsoleUtil.consoleWithLog("拉取的OPENID个数:" + wxTagListUser.getCount()); + + if (wxTagListUser.getCount() == 0) { + break; + } + openIds = wxTagListUser.getData().getOpenidList(); + + openIds.forEach(tagUserSet::remove); + } + + PushData.allUser = Collections.synchronizedList(new ArrayList<>()); + for (String openId : tagUserSet) { + PushData.allUser.add(new String[]{openId}); + } + + memberCountLabel.setText(String.valueOf(PushData.allUser.size())); + progressBar.setIndeterminate(false); + progressBar.setValue(progressBar.getMaximum()); + + } + /** * 获取导入数据信息列表 */ @@ -1005,17 +1071,10 @@ public static void renderMemberListTable() { int msgType = App.config.getMsgType(); - // 是否是微信平台类消息 - boolean isWeixinTypeMsg = false; - if (msgType == MessageTypeEnum.MP_TEMPLATE_CODE || msgType == MessageTypeEnum.MA_TEMPLATE_CODE - || msgType == MessageTypeEnum.KEFU_CODE || msgType == MessageTypeEnum.KEFU_PRIORITY_CODE - || msgType == MessageTypeEnum.WX_UNIFORM_MESSAGE_CODE || msgType == MessageTypeEnum.MA_SUBSCRIBE_CODE) { - isWeixinTypeMsg = true; - } // 导入列表 List headerNameList = Lists.newArrayList(); headerNameList.add("Data"); - if (isWeixinTypeMsg) { + if (MessageTypeEnum.isWxMaOrMpType(msgType)) { if (memberForm.getImportOptionAvatarCheckBox().isSelected()) { headerNameList.add("头像"); } @@ -1034,7 +1093,7 @@ public static void renderMemberListTable() { headerNameList.toArray(headerNames); DefaultTableModel model = new DefaultTableModel(null, headerNames); memberListTable.setModel(model); - if (isWeixinTypeMsg && memberForm.getImportOptionAvatarCheckBox().isSelected()) { + if (MessageTypeEnum.isWxMaOrMpType(msgType) && memberForm.getImportOptionAvatarCheckBox().isSelected()) { memberListTable.getColumn("头像").setCellRenderer(new TableInCellImageLabelRenderer()); } @@ -1047,7 +1106,7 @@ public static void renderMemberListTable() { JTableUtil.hideColumn(memberListTable, 0); // 设置行高 - if (isWeixinTypeMsg && memberForm.getImportOptionAvatarCheckBox().isSelected()) { + if (MessageTypeEnum.isWxMaOrMpType(msgType) && memberForm.getImportOptionAvatarCheckBox().isSelected()) { memberListTable.setRowHeight(66); } else { memberListTable.setRowHeight(36); @@ -1056,7 +1115,7 @@ public static void renderMemberListTable() { List rowDataList; WxMpService wxMpService = null; boolean needToGetInfoFromWeiXin = false; - if (isWeixinTypeMsg && (memberForm.getImportOptionBasicInfoCheckBox().isSelected() || + if (MessageTypeEnum.isWxMaOrMpType(msgType) && (memberForm.getImportOptionBasicInfoCheckBox().isSelected() || memberForm.getImportOptionAvatarCheckBox().isSelected())) { needToGetInfoFromWeiXin = true; } diff --git a/src/main/java/com/fangxuele/tool/push/ui/listener/MessageEditListener.java b/src/main/java/com/fangxuele/tool/push/ui/listener/MessageEditListener.java index e5a984c85..3628618ab 100644 --- a/src/main/java/com/fangxuele/tool/push/ui/listener/MessageEditListener.java +++ b/src/main/java/com/fangxuele/tool/push/ui/listener/MessageEditListener.java @@ -139,9 +139,7 @@ public void mousePressed(MouseEvent e) { int msgType = App.config.getMsgType(); String fillParaName = ""; String paraDemo = ""; - if (msgType == MessageTypeEnum.MP_TEMPLATE_CODE || msgType == MessageTypeEnum.KEFU_PRIORITY_CODE - || msgType == MessageTypeEnum.KEFU_CODE || msgType == MessageTypeEnum.WX_UNIFORM_MESSAGE_CODE - || msgType == MessageTypeEnum.MA_SUBSCRIBE_CODE) { + if (MessageTypeEnum.isWxMaOrMpType(msgType)) { fillParaName = "预览消息用户的openId"; paraDemo = "ox_kxwS_gGt63adS-zemlETtuvw1;ox_kxwS_gGt63adS-zemlETtuvw2"; } else if (msgType == MessageTypeEnum.MA_TEMPLATE_CODE) { diff --git a/src/main/java/com/fangxuele/tool/push/ui/listener/MessageManageListener.java b/src/main/java/com/fangxuele/tool/push/ui/listener/MessageManageListener.java index caad195d5..5717eeba4 100644 --- a/src/main/java/com/fangxuele/tool/push/ui/listener/MessageManageListener.java +++ b/src/main/java/com/fangxuele/tool/push/ui/listener/MessageManageListener.java @@ -4,18 +4,7 @@ import cn.hutool.log.Log; import cn.hutool.log.LogFactory; import com.fangxuele.tool.push.App; -import com.fangxuele.tool.push.dao.TMsgDingMapper; -import com.fangxuele.tool.push.dao.TMsgHttpMapper; -import com.fangxuele.tool.push.dao.TMsgKefuMapper; -import com.fangxuele.tool.push.dao.TMsgKefuPriorityMapper; -import com.fangxuele.tool.push.dao.TMsgMaSubscribeMapper; -import com.fangxuele.tool.push.dao.TMsgMaTemplateMapper; -import com.fangxuele.tool.push.dao.TMsgMailMapper; -import com.fangxuele.tool.push.dao.TMsgMpTemplateMapper; -import com.fangxuele.tool.push.dao.TMsgSmsMapper; -import com.fangxuele.tool.push.dao.TMsgWxCpMapper; -import com.fangxuele.tool.push.dao.TMsgWxUniformMapper; -import com.fangxuele.tool.push.dao.TWxAccountMapper; +import com.fangxuele.tool.push.dao.*; import com.fangxuele.tool.push.domain.TWxAccount; import com.fangxuele.tool.push.logic.MessageTypeEnum; import com.fangxuele.tool.push.ui.UiConsts; @@ -54,6 +43,7 @@ public class MessageManageListener { private static TMsgMaTemplateMapper msgMaTemplateMapper = MybatisUtil.getSqlSession().getMapper(TMsgMaTemplateMapper.class); private static TMsgMaSubscribeMapper msgMaSubscribeMapper = MybatisUtil.getSqlSession().getMapper(TMsgMaSubscribeMapper.class); private static TMsgMpTemplateMapper msgMpTemplateMapper = MybatisUtil.getSqlSession().getMapper(TMsgMpTemplateMapper.class); + private static TMsgMpSubscribeMapper msgMpSubscribeMapper = MybatisUtil.getSqlSession().getMapper(TMsgMpSubscribeMapper.class); private static TMsgSmsMapper msgSmsMapper = MybatisUtil.getSqlSession().getMapper(TMsgSmsMapper.class); private static TMsgMailMapper msgMailMapper = MybatisUtil.getSqlSession().getMapper(TMsgMailMapper.class); private static TMsgHttpMapper msgHttpMapper = MybatisUtil.getSqlSession().getMapper(TMsgHttpMapper.class); @@ -111,6 +101,8 @@ public void mousePressed(MouseEvent e) { msgMaSubscribeMapper.deleteByMsgTypeAndName(msgType, msgName); } else if (msgType == MessageTypeEnum.MP_TEMPLATE_CODE) { msgMpTemplateMapper.deleteByMsgTypeAndName(msgType, msgName); + } else if (msgType == MessageTypeEnum.MP_SUBSCRIBE_CODE) { + msgMpSubscribeMapper.deleteByMsgTypeAndName(msgType, msgName); } else if (msgType == MessageTypeEnum.EMAIL_CODE) { msgMailMapper.deleteByMsgTypeAndName(msgType, msgName); } else if (msgType == MessageTypeEnum.HTTP_CODE) { @@ -155,6 +147,7 @@ public void mousePressed(MouseEvent e) { switch (msgType) { case MessageTypeEnum.MP_TEMPLATE_CODE: + case MessageTypeEnum.MP_SUBSCRIBE_CODE: MpTemplateMsgForm.clearAllField(); case MessageTypeEnum.KEFU_CODE: KefuMsgForm.clearAllField(); diff --git a/src/main/java/com/fangxuele/tool/push/ui/listener/MessageTypeListener.java b/src/main/java/com/fangxuele/tool/push/ui/listener/MessageTypeListener.java index 58b2930aa..74ee95828 100644 --- a/src/main/java/com/fangxuele/tool/push/ui/listener/MessageTypeListener.java +++ b/src/main/java/com/fangxuele/tool/push/ui/listener/MessageTypeListener.java @@ -27,6 +27,10 @@ public static void addListeners() { App.config.setMsgType(MessageTypeEnum.MP_TEMPLATE_CODE); saveType(); }); + messageTypeForm.getMpSubscribeRadioButton().addActionListener(e -> { + App.config.setMsgType(MessageTypeEnum.MP_SUBSCRIBE_CODE); + saveType(); + }); messageTypeForm.getMaTemplateRadioButton().addActionListener(e -> { App.config.setMsgType(MessageTypeEnum.MA_TEMPLATE_CODE); saveType(); diff --git a/src/main/java/com/fangxuele/tool/push/ui/listener/SettingListener.java b/src/main/java/com/fangxuele/tool/push/ui/listener/SettingListener.java index ef5e50be3..ca6f1b7e8 100644 --- a/src/main/java/com/fangxuele/tool/push/ui/listener/SettingListener.java +++ b/src/main/java/com/fangxuele/tool/push/ui/listener/SettingListener.java @@ -81,6 +81,11 @@ public static void addListeners() { App.tray = null; } }); + // 设置-常规-关闭窗口时最小化到系统托盘 + settingForm.getCloseToTrayCheckBox().addActionListener(e -> { + App.config.setCloseToTray(settingForm.getCloseToTrayCheckBox().isSelected()); + App.config.save(); + }); // 设置-常规-默认最大化窗口 settingForm.getDefaultMaxWindowCheckBox().addActionListener(e -> { App.config.setDefaultMaxWindow(settingForm.getDefaultMaxWindowCheckBox().isSelected()); diff --git a/src/main/java/com/fangxuele/tool/push/util/ConfigUtil.java b/src/main/java/com/fangxuele/tool/push/util/ConfigUtil.java index 02aed251e..ad7d715fa 100644 --- a/src/main/java/com/fangxuele/tool/push/util/ConfigUtil.java +++ b/src/main/java/com/fangxuele/tool/push/util/ConfigUtil.java @@ -60,6 +60,8 @@ private ConfigUtil() { private boolean useTray; + private boolean closeToTray; + private boolean defaultMaxWindow; private Integer maxThreads; @@ -382,6 +384,14 @@ public void setUseTray(boolean useTray) { setting.put("setting.normal", "useTray", String.valueOf(useTray)); } + public boolean isCloseToTray() { + return setting.getBool("closeToTray", "setting.normal", true); + } + + public void setCloseToTray(boolean closeToTray) { + setting.put("setting.normal", "closeToTray", String.valueOf(closeToTray)); + } + public boolean isDefaultMaxWindow() { return setting.getBool("defaultMaxWindow", "setting.normal", true); } @@ -663,7 +673,7 @@ public void setMysqlPassword(String mysqlPassword) { } public String getTheme() { - return setting.getStr("theme", "setting.appearance", "Darcula(推荐)"); + return setting.getStr("theme", "setting.appearance", "Flat Dark"); } public void setTheme(String theme) { diff --git a/src/main/resources/db_init.sql b/src/main/resources/db_init.sql index 3a391ad7b..f60412a5c 100644 --- a/src/main/resources/db_init.sql +++ b/src/main/resources/db_init.sql @@ -292,3 +292,22 @@ create table if not exists t_msg_ma_subscribe create unique index if not exists t_msg_ma_subscribe_msg_type_msg_name_uindex on t_msg_ma_subscribe (msg_type, msg_name); +create table if not exists t_msg_mp_subscribe +( + id integer + constraint t_msg_mp_subscribe_pk + primary key autoincrement, + msg_type integer, + msg_name text, + template_id text, + url text, + ma_appid text, + ma_page_path text, + preview_user text, + wx_account_id int, + create_time datetime, + modified_time datetime +); +create unique index if not exists t_msg_mp_subscribe_msg_type_msg_name_uindex + on t_msg_mp_subscribe (msg_type, msg_name); + diff --git a/src/main/resources/generatorConfig.xml b/src/main/resources/generatorConfig.xml index 6e5ff7f32..12ec56d31 100644 --- a/src/main/resources/generatorConfig.xml +++ b/src/main/resources/generatorConfig.xml @@ -26,26 +26,26 @@ + targetProject="D:\IdeaCProjects\WePush\src\main\java"> + targetProject="D:\IdeaCProjects\WePush\src\main\resources"> + targetProject="D:\IdeaCProjects\WePush\src\main\java"> + tableName="t_msg_mp_subscribe" domainObjectName="TMsgMpSubscribe">
diff --git a/src/main/resources/mapper/TMsgMpSubscribeMapper.xml b/src/main/resources/mapper/TMsgMpSubscribeMapper.xml new file mode 100644 index 000000000..1a325949d --- /dev/null +++ b/src/main/resources/mapper/TMsgMpSubscribeMapper.xml @@ -0,0 +1,198 @@ + + + + + + + + + + + + + + + + + + id, msg_type, msg_name, template_id, url, ma_appid, ma_page_path, preview_user, wx_account_id, + create_time, modified_time + + + + delete from t_msg_mp_subscribe + where id = #{id,jdbcType=INTEGER} + + + insert into t_msg_mp_subscribe (id, msg_type, msg_name, + template_id, url, ma_appid, + ma_page_path, preview_user, wx_account_id, + create_time, modified_time) + values (#{id,jdbcType=INTEGER}, #{msgType,jdbcType=INTEGER}, #{msgName,jdbcType=VARCHAR}, + #{templateId,jdbcType=VARCHAR}, #{url,jdbcType=VARCHAR}, #{maAppid,jdbcType=VARCHAR}, + #{maPagePath,jdbcType=VARCHAR}, #{previewUser,jdbcType=VARCHAR}, #{wxAccountId,jdbcType=INTEGER}, + #{createTime,jdbcType=VARCHAR}, #{modifiedTime,jdbcType=VARCHAR}) + + + insert into t_msg_mp_subscribe + + + id, + + + msg_type, + + + msg_name, + + + template_id, + + + url, + + + ma_appid, + + + ma_page_path, + + + preview_user, + + + wx_account_id, + + + create_time, + + + modified_time, + + + + + #{id,jdbcType=INTEGER}, + + + #{msgType,jdbcType=INTEGER}, + + + #{msgName,jdbcType=VARCHAR}, + + + #{templateId,jdbcType=VARCHAR}, + + + #{url,jdbcType=VARCHAR}, + + + #{maAppid,jdbcType=VARCHAR}, + + + #{maPagePath,jdbcType=VARCHAR}, + + + #{previewUser,jdbcType=VARCHAR}, + + + #{wxAccountId,jdbcType=INTEGER}, + + + #{createTime,jdbcType=VARCHAR}, + + + #{modifiedTime,jdbcType=VARCHAR}, + + + + + update t_msg_mp_subscribe + + + msg_type = #{msgType,jdbcType=INTEGER}, + + + msg_name = #{msgName,jdbcType=VARCHAR}, + + + template_id = #{templateId,jdbcType=VARCHAR}, + + + url = #{url,jdbcType=VARCHAR}, + + + ma_appid = #{maAppid,jdbcType=VARCHAR}, + + + ma_page_path = #{maPagePath,jdbcType=VARCHAR}, + + + preview_user = #{previewUser,jdbcType=VARCHAR}, + + + wx_account_id = #{wxAccountId,jdbcType=INTEGER}, + + + create_time = #{createTime,jdbcType=VARCHAR}, + + + modified_time = #{modifiedTime,jdbcType=VARCHAR}, + + + where id = #{id,jdbcType=INTEGER} + + + update t_msg_mp_subscribe + set msg_type = #{msgType,jdbcType=INTEGER}, + msg_name = #{msgName,jdbcType=VARCHAR}, + template_id = #{templateId,jdbcType=VARCHAR}, + url = #{url,jdbcType=VARCHAR}, + ma_appid = #{maAppid,jdbcType=VARCHAR}, + ma_page_path = #{maPagePath,jdbcType=VARCHAR}, + preview_user = #{previewUser,jdbcType=VARCHAR}, + wx_account_id = #{wxAccountId,jdbcType=INTEGER}, + create_time = #{createTime,jdbcType=VARCHAR}, + modified_time = #{modifiedTime,jdbcType=VARCHAR} + where id = #{id,jdbcType=INTEGER} + + + + update t_msg_mp_subscribe + set template_id = #{templateId,jdbcType=VARCHAR}, + url = #{url,jdbcType=VARCHAR}, + ma_appid = #{maAppid,jdbcType=VARCHAR}, + ma_page_path = #{maPagePath,jdbcType=VARCHAR}, + modified_time = #{modifiedTime,jdbcType=VARCHAR}, + preview_user = #{previewUser,jdbcType=VARCHAR}, + wx_account_id = #{wxAccountId,jdbcType=INTEGER} + where msg_type = #{msgType,jdbcType=INTEGER} + and msg_name = #{msgName,jdbcType=VARCHAR} + + + delete + from t_msg_mp_subscribe + where msg_type = #{msgType,jdbcType=INTEGER} + and msg_name = #{msgName,jdbcType=VARCHAR} + + + \ No newline at end of file diff --git a/src/main/resources/mybatis-config.xml b/src/main/resources/mybatis-config.xml index 920ef3791..e5e3e920d 100644 --- a/src/main/resources/mybatis-config.xml +++ b/src/main/resources/mybatis-config.xml @@ -31,5 +31,6 @@ + \ No newline at end of file diff --git a/src/main/resources/upgrade/47.sql b/src/main/resources/upgrade/47.sql new file mode 100644 index 000000000..23998d70b --- /dev/null +++ b/src/main/resources/upgrade/47.sql @@ -0,0 +1,18 @@ +create table if not exists t_msg_mp_subscribe +( + id integer + constraint t_msg_mp_subscribe_pk + primary key autoincrement, + msg_type integer, + msg_name text, + template_id text, + url text, + ma_appid text, + ma_page_path text, + preview_user text, + wx_account_id int, + create_time datetime, + modified_time datetime +); +create unique index if not exists t_msg_mp_subscribe_msg_type_msg_name_uindex + on t_msg_mp_subscribe (msg_type, msg_name); \ No newline at end of file diff --git a/src/main/resources/version_summary.json b/src/main/resources/version_summary.json index a20ddb4bc..5ccd02840 100644 --- a/src/main/resources/version_summary.json +++ b/src/main/resources/version_summary.json @@ -1,5 +1,5 @@ { - "currentVersion": "v_4.4.0_210221", + "currentVersion": "v_4.5.0_220107", "versionIndex": { "v_1.1.0_170701": "0", "v_1.2.0_170831": "1", @@ -47,7 +47,10 @@ "v_4.2.4_201222": "43", "v_4.2.5_210117": "44", "v_4.3.0_210123": "45", - "v_4.4.0_210221": "46" + "v_4.4.0_210221": "46", + "v_4.4.1_210323": "47", + "v_4.4.2_210628": "48", + "v_4.5.0_220107": "49" }, "versionDetailList": [ { @@ -284,6 +287,21 @@ "version": "v_4.4.0_210221", "title": "客服消息小程序卡片类型支持上传图片", "log": "● feature:客服消息小程序卡片类型支持上传图片\n● feature:邮件消息支持添加多个附件\n● optimization:调整邮件html在线编辑器为kindeditor\n● optimization:调整默认推荐主题,修复窗口自动最大化表现异常的问题,修复点击消息管理列表经常报错的问题,优化Linux系统兼容性等各种细节优化\n" + }, + { + "version": "v_4.4.1_210323", + "title": "新增支持公众号订阅通知", + "log": "● feature:新增支持公众号订阅通知\n● feature:支持可设置关闭窗口时最小化到系统托盘\n" + }, + { + "version": "v_4.4.2_210628", + "title": "通过公众号导入支持排除分组", + "log": "● feature:通过公众号导入支持排除分组\n" + }, + { + "version": "v_4.5.0_220107", + "title": "调整打包方式", + "log": "● 调整打包方式,内置运行环境,各平台安装更便捷\n● 移除了一部分不好用的主题风格\n" } ] } \ No newline at end of file