mirror of
https://github.com/navidrome/navidrome.git
synced 2025-04-23 07:10:31 +03:00
Consolidate UI configuration in one place, allowing it to be overridden from the server
This commit is contained in:
parent
d0188db4f9
commit
a0f389fc3e
@ -1,11 +1,12 @@
|
||||
import jwtDecode from 'jwt-decode'
|
||||
import md5 from 'md5-hex'
|
||||
import baseUrl from './utils/baseUrl'
|
||||
import config from './config'
|
||||
|
||||
const authProvider = {
|
||||
login: ({ username, password }) => {
|
||||
let url = baseUrl('/app/login')
|
||||
if (localStorage.getItem('initialAccountCreation')) {
|
||||
if (config.firstTime) {
|
||||
url = baseUrl('/app/createAdmin')
|
||||
}
|
||||
const request = new Request(url, {
|
||||
|
20
ui/src/config.js
Normal file
20
ui/src/config.js
Normal file
@ -0,0 +1,20 @@
|
||||
const defaultConfig = {
|
||||
firstTime: false,
|
||||
baseURL: '',
|
||||
loginBackgroundURL: 'https://source.unsplash.com/random/1600x900?music'
|
||||
}
|
||||
|
||||
let config
|
||||
|
||||
try {
|
||||
const appConfig = JSON.parse(window.__APP_CONFIG__)
|
||||
|
||||
config = {
|
||||
...defaultConfig,
|
||||
...appConfig
|
||||
}
|
||||
} catch (e) {
|
||||
config = defaultConfig
|
||||
}
|
||||
|
||||
export default config
|
@ -15,6 +15,7 @@ import LockIcon from '@material-ui/icons/Lock'
|
||||
import { Notification, useLogin, useNotify, useTranslate } from 'react-admin'
|
||||
|
||||
import LightTheme from '../themes/light'
|
||||
import config from '../config'
|
||||
|
||||
const useStyles = makeStyles((theme) => ({
|
||||
main: {
|
||||
@ -23,7 +24,7 @@ const useStyles = makeStyles((theme) => ({
|
||||
minHeight: '100vh',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'flex-start',
|
||||
background: 'url(https://source.unsplash.com/random/1600x900?music)',
|
||||
background: `url(${config.loginBackgroundURL})`,
|
||||
backgroundRepeat: 'no-repeat',
|
||||
backgroundSize: 'cover',
|
||||
backgroundPosition: 'center'
|
||||
@ -253,7 +254,7 @@ const Login = ({ location }) => {
|
||||
return errors
|
||||
}
|
||||
|
||||
if (localStorage.getItem('initialAccountCreation') === 'true') {
|
||||
if (config.firstTime) {
|
||||
return (
|
||||
<FormSignUp
|
||||
handleSubmit={handleSubmit}
|
||||
|
@ -1,5 +1,7 @@
|
||||
import config from '../config'
|
||||
|
||||
const baseUrl = (path) => {
|
||||
const base = localStorage.getItem('baseURL') || ''
|
||||
const base = config.baseURL || ''
|
||||
const parts = [base]
|
||||
parts.push(path.replace(/^\//, ''))
|
||||
return parts.join('/')
|
||||
|
Loading…
x
Reference in New Issue
Block a user