Support android

This commit is contained in:
xtaodada 2022-05-14 11:19:39 +08:00
parent 645436a0e4
commit 309b9ceffb
Signed by: xtaodada
GPG Key ID: 4CBB3F4FA8C85659
3 changed files with 24 additions and 7 deletions

View File

@ -2,9 +2,9 @@ package com.xtaolabs.gcauth_oauth;
import emu.grasscutter.Grasscutter;
import emu.grasscutter.plugin.Plugin;
import emu.grasscutter.server.dispatch.DispatchHttpJsonHandler;
import static emu.grasscutter.Configuration.*;
import com.xtaolabs.gcauth_oauth.handler.JsonHandler;
import com.xtaolabs.gcauth_oauth.handler.VerifyHandler;
import com.xtaolabs.gcauth_oauth.handler.RequestHandler;
@ -39,12 +39,7 @@ public class GCAuth_OAuth extends Plugin {
String folder_name = PLUGINS_FOLDER + "/GCAuth/OAuth/";
Express app = Grasscutter.getDispatchServer().getServer();
app.get("/Api/twitter_login", new DispatchHttpJsonHandler(
String.format("{\"code\":200,\"data\":{\"auth_url\":\"%s\",\"info\":\"\",\"msg\":\"Success\",\"status\":1}}",
"http" + (DISPATCH_ENCRYPTION.useEncryption ? "s" : "") + "://"
+ lr(DISPATCH_INFO.accessAddress, DISPATCH_INFO.bindAddress) + ":"
+ lr(DISPATCH_INFO.accessPort, DISPATCH_INFO.bindPort) + "/gcauth_oauth/login.html")
));
app.get("/Api/twitter_login", new JsonHandler());
app.post("/gcauth_oauth/login", new RequestHandler());

View File

@ -0,0 +1,21 @@
package com.xtaolabs.gcauth_oauth.handler;
import java.io.IOException;
import express.http.HttpContextHandler;
import express.http.Request;
import express.http.Response;
public final class JsonHandler implements HttpContextHandler {
@Override
public void handle(Request req, Response res) throws IOException {
String Login_Html_Url = "https://account.mihoyo.com/gcauth_oauth/login.html";
res.set("server", "tsa_m");
res.set("Content-Type", "application/json; charset=utf-8");
res.set("access-control-allow-credentials", "true");
res.set("access-control-allow-origin", "https://account.hoyoverse.com");
res.send(String.format("{\"code\":200,\"data\":{\"auth_url\":\"%s\",\"info\":\"\",\"msg\":\"Success\",\"status\":1}}",
Login_Html_Url));
}
}

View File

@ -3,6 +3,7 @@ package com.xtaolabs.gcauth_oauth.json;
public final class VerifyJson {
public String thirdparty;
public String access_token;
public String game_key;
public String cb_url;
public Boolean no_regist;
}