From 5326429e39edde35a98fcac62e741e782eef9778 Mon Sep 17 00:00:00 2001 From: wangsq <944414428@qq.com> Date: Fri, 19 Apr 2024 09:45:54 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E8=8E=B7=E5=8F=96=E5=BE=AE?= =?UTF-8?q?=E4=BF=A1=E9=A1=B5=E9=9D=A2=E9=93=BE=E6=8E=A5=E5=89=8D=E7=BC=80?= =?UTF-8?q?=E7=9A=84=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/ynxbd/push/config/IniConfig.java | 38 ++++++++++++++++++- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/ynxbd/push/config/IniConfig.java b/src/main/java/com/ynxbd/push/config/IniConfig.java index feaf7da..ff084f4 100644 --- a/src/main/java/com/ynxbd/push/config/IniConfig.java +++ b/src/main/java/com/ynxbd/push/config/IniConfig.java @@ -4,6 +4,7 @@ import com.ynxbd.push.helper.IPHelper; import com.ynxbd.push.helper.ProperHelper; import lombok.extern.slf4j.Slf4j; import org.ini4j.Wini; +import org.springframework.util.ObjectUtils; import org.springframework.util.ResourceUtils; import java.io.IOException; @@ -61,13 +62,46 @@ public class IniConfig { /** * 测试是否读取成功 - * */ public static String test() { return WINI.fetch("10.20.10.60", "name"); } +// public static void main(String[] args) { +// System.out.println(test()); +// } + + /** + * 获取微信页面链接 + * + * @param isSuffix 是否需要后缀/ + */ + public static String getWxWebPath(boolean isSuffix) { + String domain = IniConfig.getInstance("domain"); + if (!ObjectUtils.isEmpty(domain)) { + String suffix = domain.substring(domain.length() - 1); + if (suffix.equals("/")) { + domain = domain.substring(0, domain.length() - 1); + } + } + String weChatUIPath = IniConfig.getInstance("weChatUIPath"); + if (!ObjectUtils.isEmpty(weChatUIPath) && weChatUIPath.length() > 1) { + String prefix = weChatUIPath.substring(0, 1); + String suffix = weChatUIPath.substring(weChatUIPath.length() - 1); + if (!prefix.equals("/")) { + weChatUIPath = "/" + weChatUIPath; + } + if (suffix.equals("/")) { + weChatUIPath = weChatUIPath.substring(0, weChatUIPath.length() - 1); + } + } else { + weChatUIPath = ""; + } + return domain + "/wx" + weChatUIPath + (isSuffix ? "/" : ""); + } + public static void main(String[] args) { - System.out.println(test()); + String wxWebPath = getWxWebPath(false); + System.out.println(wxWebPath); } }