mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2026-03-26 17:43:07 +01:00
Fix handbook server details
This commit is contained in:
@@ -64,15 +64,20 @@ export function setTargetPlayer(player: number, token: string | null = null): vo
|
|||||||
* @param newAddress The server's address.
|
* @param newAddress The server's address.
|
||||||
* @param newPort The server's port.
|
* @param newPort The server's port.
|
||||||
*/
|
*/
|
||||||
export async function setServerDetails(newAddress: string | null, newPort: string | null): Promise<void> {
|
export async function setServerDetails(newAddress: string | null, newPort: string | number | null): Promise<void> {
|
||||||
// Apply the new details.
|
if (!getWindowDetails().disable) {
|
||||||
if (newAddress != null) {
|
if (typeof newPort == "number")
|
||||||
address = newAddress;
|
newPort = newPort.toString();
|
||||||
localStorage.setItem("address", newAddress);
|
|
||||||
}
|
// Apply the new details.
|
||||||
if (newPort != null) {
|
if (newAddress != null) {
|
||||||
port = newPort;
|
address = newAddress;
|
||||||
localStorage.setItem("port", newPort);
|
localStorage.setItem("address", newAddress);
|
||||||
|
}
|
||||||
|
if (newPort != null) {
|
||||||
|
port = newPort;
|
||||||
|
localStorage.setItem("port", newPort);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if the server is encrypted.
|
// Check if the server is encrypted.
|
||||||
|
|||||||
@@ -2,9 +2,9 @@ import React from "react";
|
|||||||
|
|
||||||
import emitter from "@backend/events";
|
import emitter from "@backend/events";
|
||||||
import { targetPlayer, address, port, setServerDetails, url, setTargetPlayer } from "@backend/server";
|
import { targetPlayer, address, port, setServerDetails, url, setTargetPlayer } from "@backend/server";
|
||||||
|
import { getWindowDetails } from "@app/utils";
|
||||||
|
|
||||||
import "@css/widgets/ServerSettings.scss";
|
import "@css/widgets/ServerSettings.scss";
|
||||||
import { getWindowDetails } from "@app/utils";
|
|
||||||
|
|
||||||
interface IState {
|
interface IState {
|
||||||
webview: boolean;
|
webview: boolean;
|
||||||
@@ -51,7 +51,7 @@ class ServerSettings extends React.Component<{}, IState> {
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
private authenticate(): void {
|
private authenticate(): void {
|
||||||
setServerDetails(null, null).then(() => {
|
setServerDetails(this.state.address, this.state.port).then(() => {
|
||||||
this.setState({ webview: true });
|
this.setState({ webview: true });
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -133,7 +133,8 @@ class ServerSettings extends React.Component<{}, IState> {
|
|||||||
}}
|
}}
|
||||||
disabled={disable}
|
disabled={disable}
|
||||||
style={{
|
style={{
|
||||||
cursor: disable ? "not-allowed" : "text"
|
cursor: disable ? "not-allowed" : "text",
|
||||||
|
userSelect: disable ? "none" : "auto"
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@@ -155,7 +156,8 @@ class ServerSettings extends React.Component<{}, IState> {
|
|||||||
}}
|
}}
|
||||||
disabled={disable}
|
disabled={disable}
|
||||||
style={{
|
style={{
|
||||||
cursor: disable ? "not-allowed" : "text"
|
cursor: disable ? "not-allowed" : "text",
|
||||||
|
userSelect: disable ? "none" : "auto"
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -174,8 +174,11 @@ export function getWindowDetails(): WindowDetails {
|
|||||||
const { address, port, disable } = details;
|
const { address, port, disable } = details;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
address: address == "{{DETAILS_ADDRESS}}" ? "127.0.0.1" : address,
|
address: (address as string).includes("DETAILS_ADDRESS")
|
||||||
port: port == "{{DETAILS_PORT}}" ? 443 : parseInt(port),
|
? "127.0.0.1" : address,
|
||||||
disable: disable == "{{DETAILS_DISABLE}}" ? false : disable == "true"
|
port: (port as string).includes("DETAILS_PORT")
|
||||||
|
? 443 : parseInt(port),
|
||||||
|
disable: (disable as string).includes("DETAILS_DISABLE")
|
||||||
|
? false : disable == "true"
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
package emu.grasscutter.server.http.documentation;
|
package emu.grasscutter.server.http.documentation;
|
||||||
|
|
||||||
import static emu.grasscutter.config.Configuration.HANDBOOK;
|
|
||||||
|
|
||||||
import emu.grasscutter.Grasscutter;
|
import emu.grasscutter.Grasscutter;
|
||||||
import emu.grasscutter.auth.AuthenticationSystem.AuthenticationRequest;
|
import emu.grasscutter.auth.AuthenticationSystem.AuthenticationRequest;
|
||||||
import emu.grasscutter.server.http.Router;
|
import emu.grasscutter.server.http.Router;
|
||||||
@@ -13,6 +11,8 @@ import io.javalin.Javalin;
|
|||||||
import io.javalin.http.ContentType;
|
import io.javalin.http.ContentType;
|
||||||
import io.javalin.http.Context;
|
import io.javalin.http.Context;
|
||||||
|
|
||||||
|
import static emu.grasscutter.config.Configuration.HANDBOOK;
|
||||||
|
|
||||||
/** Handles requests for the new GM Handbook. */
|
/** Handles requests for the new GM Handbook. */
|
||||||
public final class HandbookHandler implements Router {
|
public final class HandbookHandler implements Router {
|
||||||
private String handbook;
|
private String handbook;
|
||||||
@@ -32,7 +32,7 @@ public final class HandbookHandler implements Router {
|
|||||||
this.handbook
|
this.handbook
|
||||||
.replace("{{DETAILS_ADDRESS}}", server.address)
|
.replace("{{DETAILS_ADDRESS}}", server.address)
|
||||||
.replace("{{DETAILS_PORT}}", String.valueOf(server.port))
|
.replace("{{DETAILS_PORT}}", String.valueOf(server.port))
|
||||||
.replace("{{DETAILS_DISABLE}}", Boolean.toString(server.canChange));
|
.replace("{{DETAILS_DISABLE}}", Boolean.toString(!server.canChange));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user