mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2026-03-25 00:53:47 +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 newPort The server's port.
|
||||
*/
|
||||
export async function setServerDetails(newAddress: string | null, newPort: string | null): Promise<void> {
|
||||
// Apply the new details.
|
||||
if (newAddress != null) {
|
||||
address = newAddress;
|
||||
localStorage.setItem("address", newAddress);
|
||||
}
|
||||
if (newPort != null) {
|
||||
port = newPort;
|
||||
localStorage.setItem("port", newPort);
|
||||
export async function setServerDetails(newAddress: string | null, newPort: string | number | null): Promise<void> {
|
||||
if (!getWindowDetails().disable) {
|
||||
if (typeof newPort == "number")
|
||||
newPort = newPort.toString();
|
||||
|
||||
// Apply the new details.
|
||||
if (newAddress != null) {
|
||||
address = newAddress;
|
||||
localStorage.setItem("address", newAddress);
|
||||
}
|
||||
if (newPort != null) {
|
||||
port = newPort;
|
||||
localStorage.setItem("port", newPort);
|
||||
}
|
||||
}
|
||||
|
||||
// Check if the server is encrypted.
|
||||
|
||||
@@ -2,9 +2,9 @@ import React from "react";
|
||||
|
||||
import emitter from "@backend/events";
|
||||
import { targetPlayer, address, port, setServerDetails, url, setTargetPlayer } from "@backend/server";
|
||||
import { getWindowDetails } from "@app/utils";
|
||||
|
||||
import "@css/widgets/ServerSettings.scss";
|
||||
import { getWindowDetails } from "@app/utils";
|
||||
|
||||
interface IState {
|
||||
webview: boolean;
|
||||
@@ -51,7 +51,7 @@ class ServerSettings extends React.Component<{}, IState> {
|
||||
* @private
|
||||
*/
|
||||
private authenticate(): void {
|
||||
setServerDetails(null, null).then(() => {
|
||||
setServerDetails(this.state.address, this.state.port).then(() => {
|
||||
this.setState({ webview: true });
|
||||
});
|
||||
|
||||
@@ -133,7 +133,8 @@ class ServerSettings extends React.Component<{}, IState> {
|
||||
}}
|
||||
disabled={disable}
|
||||
style={{
|
||||
cursor: disable ? "not-allowed" : "text"
|
||||
cursor: disable ? "not-allowed" : "text",
|
||||
userSelect: disable ? "none" : "auto"
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
@@ -155,7 +156,8 @@ class ServerSettings extends React.Component<{}, IState> {
|
||||
}}
|
||||
disabled={disable}
|
||||
style={{
|
||||
cursor: disable ? "not-allowed" : "text"
|
||||
cursor: disable ? "not-allowed" : "text",
|
||||
userSelect: disable ? "none" : "auto"
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -174,8 +174,11 @@ export function getWindowDetails(): WindowDetails {
|
||||
const { address, port, disable } = details;
|
||||
|
||||
return {
|
||||
address: address == "{{DETAILS_ADDRESS}}" ? "127.0.0.1" : address,
|
||||
port: port == "{{DETAILS_PORT}}" ? 443 : parseInt(port),
|
||||
disable: disable == "{{DETAILS_DISABLE}}" ? false : disable == "true"
|
||||
address: (address as string).includes("DETAILS_ADDRESS")
|
||||
? "127.0.0.1" : address,
|
||||
port: (port as string).includes("DETAILS_PORT")
|
||||
? 443 : parseInt(port),
|
||||
disable: (disable as string).includes("DETAILS_DISABLE")
|
||||
? false : disable == "true"
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user