fix(regression): ip qs param was ignored
fix: add local (gitignored) config that is merged into single config after the build
This commit is contained in:
parent
36747e6bef
commit
87b795bdc4
5 changed files with 20 additions and 4 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -18,5 +18,6 @@ out
|
|||
generated
|
||||
storybook-static
|
||||
server-jar
|
||||
config.local.json
|
||||
|
||||
src/react/npmReactComponents.ts
|
||||
|
|
|
|||
|
|
@ -95,10 +95,14 @@ const appConfig = defineConfig({
|
|||
fs.copyFileSync('./assets/release.json', './dist/release.json')
|
||||
}
|
||||
const configJson = JSON.parse(fs.readFileSync('./config.json', 'utf8'))
|
||||
let configLocalJson = {}
|
||||
try {
|
||||
configLocalJson = JSON.parse(fs.readFileSync('./config.local.json', 'utf8'))
|
||||
} catch (err) {}
|
||||
if (dev) {
|
||||
configJson.defaultProxy = ':8080'
|
||||
}
|
||||
fs.writeFileSync('./dist/config.json', JSON.stringify(configJson), 'utf8')
|
||||
fs.writeFileSync('./dist/config.json', JSON.stringify({ ...configJson, ...configLocalJson }), 'utf8')
|
||||
// childProcess.execSync('./scripts/prepareSounds.mjs', { stdio: 'inherit' })
|
||||
// childProcess.execSync('tsx ./scripts/genMcDataTypes.ts', { stdio: 'inherit' })
|
||||
// childProcess.execSync('tsx ./scripts/genPixelartTypes.ts', { stdio: 'inherit' })
|
||||
|
|
|
|||
|
|
@ -114,6 +114,9 @@ export type AppConfig = {
|
|||
peerJsServerFallback?: string
|
||||
promoteServers?: Array<{ ip, description, version? }>
|
||||
mapsProvider?: string
|
||||
|
||||
defaultSettings?: Record<string, any>
|
||||
allowAutoConnect?: boolean
|
||||
}
|
||||
|
||||
export const miscUiState = proxy({
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import React from 'react'
|
||||
import React, { useEffect } from 'react'
|
||||
import Screen from './Screen'
|
||||
import Input from './Input'
|
||||
import Button from './Button'
|
||||
|
|
@ -26,11 +26,12 @@ interface Props {
|
|||
accounts?: string[]
|
||||
authenticatedAccounts?: number
|
||||
versions?: string[]
|
||||
allowAutoConnect?: boolean
|
||||
}
|
||||
|
||||
const ELEMENTS_WIDTH = 190
|
||||
|
||||
export default ({ onBack, onConfirm, title = 'Add a Server', initialData, parseQs, onQsConnect, placeholders, accounts, versions, authenticatedAccounts }: Props) => {
|
||||
export default ({ onBack, onConfirm, title = 'Add a Server', initialData, parseQs, onQsConnect, placeholders, accounts, versions, allowAutoConnect }: Props) => {
|
||||
const qsParams = parseQs ? new URLSearchParams(window.location.search) : undefined
|
||||
const qsParamName = qsParams?.get('name')
|
||||
const qsParamIp = qsParams?.get('ip')
|
||||
|
|
@ -40,7 +41,7 @@ export default ({ onBack, onConfirm, title = 'Add a Server', initialData, parseQ
|
|||
const qsParamLockConnect = qsParams?.get('lockConnect')
|
||||
|
||||
const qsIpParts = qsParamIp?.split(':')
|
||||
const ipParts = initialData?.ip.split(':')
|
||||
const ipParts = initialData?.ip ? initialData?.ip.split(':') : undefined
|
||||
|
||||
const [serverName, setServerName] = React.useState(initialData?.name ?? qsParamName ?? '')
|
||||
const [serverIp, setServerIp] = React.useState(ipParts?.[0] ?? qsIpParts?.[0] ?? '')
|
||||
|
|
@ -69,6 +70,12 @@ export default ({ onBack, onConfirm, title = 'Add a Server', initialData, parseQ
|
|||
authenticatedAccountOverride,
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
if (qsParams?.get('autoConnect') === 'true' && qsParams?.get('ip') && allowAutoConnect) {
|
||||
onQsConnect?.(commonUseOptions)
|
||||
}
|
||||
}, [])
|
||||
|
||||
return <Screen title={qsParamIp ? 'Connect to Server' : title} backdrop>
|
||||
<form
|
||||
style={{
|
||||
|
|
|
|||
|
|
@ -252,6 +252,7 @@ const Inner = ({ hidden, customServersList }: { hidden?: boolean, customServersL
|
|||
})
|
||||
|
||||
const editModalJsx = isEditScreenModal ? <AddServerOrConnect
|
||||
allowAutoConnect={miscUiState.appConfig?.allowAutoConnect}
|
||||
placeholders={{
|
||||
proxyOverride: selectedProxy,
|
||||
usernameOverride: defaultUsername,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue