44import com .fun90 .airopscat .model .entity .Account ;
55import com .fun90 .airopscat .repository .AccountRepository ;
66import com .fun90 .airopscat .service .AccountOnlineIpService ;
7+ import com .fun90 .airopscat .service .SubscriptionService ;
78import com .fun90 .airopscat .util .JsonUtil ;
89import jakarta .enterprise .context .ApplicationScoped ;
910import jakarta .inject .Inject ;
1314import lombok .extern .slf4j .Slf4j ;
1415import org .eclipse .microprofile .config .inject .ConfigProperty ;
1516
16- import java .net .URLEncoder ;
17- import java .nio .charset .StandardCharsets ;
1817import java .util .HashMap ;
1918import java .util .Map ;
2019import java .util .Optional ;
@@ -32,15 +31,15 @@ public class OpenController {
3231 @ Inject
3332 AccountRepository accountRepository ;
3433
34+ @ Inject
35+ SubscriptionService subscriptionService ;
36+
3537 @ ConfigProperty (name = "airopscat.apple.id" )
3638 String appleId ;
3739
3840 @ ConfigProperty (name = "airopscat.apple.pwd" )
3941 String applePwd ;
4042
41- @ ConfigProperty (name = "airopscat.subscription.url" )
42- String subscriptionUrl ;
43-
4443 @ ConfigProperty (name = "airopscat.api.token" )
4544 String apiToken ;
4645
@@ -64,14 +63,14 @@ public Response getDocsInfo(@PathParam("authCode") String authCode) {
6463 if (accountOpt .isEmpty ()) {
6564 return Response .status (Response .Status .BAD_REQUEST ).entity (Map .of ("error" , "无效的认证码,账户不存在" )).build ();
6665 }
66+ Account account = accountOpt .get ();
6767 // 组装subscriptionUrl
68- String base = subscriptionUrl + "/config/" + authCode ;
6968 Map <String , String > subscriptionUrls = Map .of (
70- "windows" , base + "/ windows/ clash-verge/" ,
71- "linux" , base + "/ linux/ clash-verge/" ,
72- "ios" , base + "/ ios/shadowrocket/" + URLEncoder . encode ( accountOpt . get (). getRemark (), StandardCharsets . UTF_8 ) + "/" ,
73- "macos" , base + "/ macos/ clash-verge/" ,
74- "android" , base + "/ android/ clash-meta/"
69+ "windows" , subscriptionService . getConfigUrl ( account , " windows" , " clash-verge" ) ,
70+ "linux" , subscriptionService . getConfigUrl ( account , " linux" , " clash-verge" ) ,
71+ "ios" , subscriptionService . getConfigUrl ( account , " ios" , "shadowrocket" ) ,
72+ "macos" , subscriptionService . getConfigUrl ( account , " macos" , " clash-verge" ) ,
73+ "android" , subscriptionService . getConfigUrl ( account , " android" , " clash-meta" )
7574 );
7675 Map <String , Object > result = new HashMap <>();
7776 result .put ("subscriptionUrl" , subscriptionUrls );
0 commit comments