mirror of
https://github.com/ragestudio/comty.git
synced 2025-06-09 18:44:16 +00:00
switch to window.requireQuery method, also include URLSearchParams support for key indexing
This commit is contained in:
parent
1ec9c2c822
commit
4981cdf4bd
@ -1,5 +1,5 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
import { Menu } from 'antd'
|
import { Menu, Result } from 'antd'
|
||||||
import * as Icons from 'components/Icons'
|
import * as Icons from 'components/Icons'
|
||||||
|
|
||||||
import styles from './style.less'
|
import styles from './style.less'
|
||||||
@ -76,7 +76,7 @@ const menuList = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
@connect(({ app }) => ({ app }))
|
@connect(({ app }) => ({ app }))
|
||||||
class GeneralSettings extends React.PureComponent {
|
class GeneralSettings extends React.Component {
|
||||||
state = {
|
state = {
|
||||||
loading: true,
|
loading: true,
|
||||||
selectKey: 'base',
|
selectKey: 'base',
|
||||||
@ -103,7 +103,7 @@ class GeneralSettings extends React.PureComponent {
|
|||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
data.forEach(async (element) => {
|
data.forEach(async (element) => {
|
||||||
if (typeof(element.require) !== 'undefined') {
|
if (typeof(element.require) !== 'undefined') {
|
||||||
const validRequire = await this.requireQuery(element.require)
|
const validRequire = await window.requireQuery(element.require)
|
||||||
validRequire? tmp.push(element) : null
|
validRequire? tmp.push(element) : null
|
||||||
}else{
|
}else{
|
||||||
tmp.push(element)
|
tmp.push(element)
|
||||||
@ -132,22 +132,27 @@ class GeneralSettings extends React.PureComponent {
|
|||||||
|
|
||||||
renderChildren = () => {
|
renderChildren = () => {
|
||||||
let titlesArray = []
|
let titlesArray = []
|
||||||
this.state.menus.forEach(e => {
|
this.state.menus.forEach(e => { titlesArray[e.key] = e })
|
||||||
titlesArray[e.key] = e
|
|
||||||
})
|
if(this.state.selectKey && titlesArray[this.state.selectKey]){
|
||||||
if(this.state.selectKey){
|
|
||||||
return <>
|
return <>
|
||||||
<div>
|
<div>
|
||||||
<h2>{titlesArray[this.state.selectKey].icon || null}{titlesArray[this.state.selectKey].title || null}</h2>
|
<h2>{titlesArray[this.state.selectKey].icon || null}{titlesArray[this.state.selectKey].title || null}</h2>
|
||||||
</div>
|
</div>
|
||||||
{Settings[this.state.selectKey]}
|
{Settings[this.state.selectKey]}
|
||||||
</>
|
</>
|
||||||
}else{
|
}else {
|
||||||
<div> Select an setting </div>
|
return(
|
||||||
|
<Result title="Select an Option" state="info" />
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount(){
|
componentDidMount(){
|
||||||
|
const keyIndex = new URLSearchParams(location.search).get('key')
|
||||||
|
if(keyIndex && typeof(Settings[keyIndex]) !== "undefined"){
|
||||||
|
this.setState({selectKey: keyIndex})
|
||||||
|
}
|
||||||
this.queryMenu()
|
this.queryMenu()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user