Commit 31ee1c6f authored by wty's avatar wty

优化子类样式等

parent f04f2a92
...@@ -4,25 +4,20 @@ import {useContext, useEffect, useState} from "react"; ...@@ -4,25 +4,20 @@ import {useContext, useEffect, useState} from "react";
import {Root} from "../../dataCenter/Root"; import {Root} from "../../dataCenter/Root";
function Content(props) { function Content(props) {
const {dataCenter, fetchData} = useContext(Root) const {dataCenter} = useContext(Root)
const [toolBoxData, setToolBoxData] = useState([])
useEffect(()=>{
setToolBoxData(dataCenter?.toolBox?.filter(v => {
if (dataCenter.childTypeId === 'all') return true
else return v.childTypeId === dataCenter.childTypeId
}) || [])
},[dataCenter.childTypeId])
return ( return (
<div className="content"> <div className="content">
{ {
toolBoxData.length ? toolBoxData.map(v => { dataCenter.childType?.length ? dataCenter?.toolBox?.filter(v => {
return ( if (dataCenter.childTypeId === 'all') return true
<ContentItem key={v['toolBoxId']} value={v}/> else return v.childTypeId === dataCenter.childTypeId
) }).map(v => {
}) return (
: <ContentItem key={v['toolBoxId']} value={v}/>
'没有数据了!' )
})
:
'没有数据了!'
} }
</div> </div>
) )
......
...@@ -4,21 +4,15 @@ import {useContext, useEffect, useState} from "react"; ...@@ -4,21 +4,15 @@ import {useContext, useEffect, useState} from "react";
import {Root} from "../../dataCenter/Root"; import {Root} from "../../dataCenter/Root";
function Content(props) { function Content(props) {
const {dataCenter, fetchData} = useContext(Root) const {dataCenter} = useContext(Root)
const [gridPosition, setGridPosition] = useState([])
const updatePosition = ()=>{
fetchData('/update/updateToolBoxSort',{sortArr: JSON.stringify([{toolBoxId: 10, sortId: 1}])})
}
useEffect(() => {
setGridPosition(dataCenter.toolBox && dataCenter.toolBox.map(v => v.toolBoxId))
}, [dataCenter.toolBox])
return ( return (
<div className="content"> <div className="content">
{ {
dataCenter?.toolBox?.length ? dataCenter.toolBox.map(v => { dataCenter.childType?.length ? dataCenter?.toolBox?.filter(v => {
if (dataCenter.childTypeId === 'all') return true
else return v.childTypeId === dataCenter.childTypeId
}).map(v => {
return ( return (
<ContentItem key={v['toolBoxId']} value={v}/> <ContentItem key={v['toolBoxId']} value={v}/>
) )
......
import logo from "../../static/logo.png";
import './index.scss' import './index.scss'
import ToolType from "../../component/ToolType/ToolType"; import ToolType from "../../component/ToolType/ToolType";
import Content from "../../component/ContentAdmin/Content"; import Content from "../../component/Content/Content";
import { useContext, useEffect, useState } from "react"; import {PopContext, Root} from "../../dataCenter/Root";
import PopAddToolBox from "../../component/Pop_addToolBox/Pop_addToolBox"; import {useContext, useEffect, useState} from "react";
import { PopContext, Root } from "../../dataCenter/Root"; import {NEED_UPDATE_INDEX} from "../../dataCenter/action";
import PopAddType from "../../component/Pop_addType/Pop_addType"; import AdminIndex from "../../component/AdminIndex/AdminIndex";
import logo from '../../static/logo.png'
import AdminIndex from '../../component/AdminIndex/AdminIndex'
function Index() {
function IndexAdmin() {
const { updateIndex } = useContext(Root)
const {fetchData, dataCenter} = useContext(Root)
const [pop, setPop] = useState() const [pop, setPop] = useState()
const {fetchData, dataCenter, dispatch} = useContext(Root)
const showPop = popComponent => { const showPop = popComponent => {
setPop(popComponent) setPop(popComponent)
} }
const getUser = () => {
const getUser = ()=>{ fetchData('/users/getUser', {userId: '100001'}, 'userInfo')
fetchData('/users/getUser', {userId:'100001'}, 'userInfo')
.catch(res => .catch(res =>
res.code === 70001 && (window.location.href = '/login') res.code === 70001 && (window.location.href = '/login')
) )
} }
useEffect(()=>{
getUser()
},[])
useEffect(() => { useEffect(() => {
updateIndex() fetchData('/query/queryType', {}, 'type')
// dataCenter() .then(()=> fetchData('/query/queryChildType',{typeId: dataCenter.typeId},'childType'))
.then(() => dispatch(NEED_UPDATE_INDEX()))
}, [dataCenter.typeId])
useEffect(() => {
if (dataCenter.needUpdateIndex) {
const _typeId = dataCenter.typeId === 'all' ? {} : dataCenter.typeId === 'follow' ? {
isFollow: true,
typeId: JSON.stringify(dataCenter.userInfo.follow)
} : {typeId: dataCenter.typeId}
fetchData('/query/queryToolBox', _typeId, 'toolBox').then(() => dispatch(NEED_UPDATE_INDEX()))
}
}, [dataCenter.needUpdateIndex])
useEffect(() => {
getUser()
}, []) }, [])
return ( return (
...@@ -44,9 +51,12 @@ function IndexAdmin() { ...@@ -44,9 +51,12 @@ function IndexAdmin() {
</div> </div>
<div className="nav"> <div className="nav">
<div className="nav-title"> <div className="nav-title">
<img src={logo} alt=""/> <img src={logo} alt=""/>
</div>
<div className="nav-weather">
<iframe width="360" height="40" frameBorder="0" scrolling="no" hspace="0"
src="https://i.tianqi.com/?c=code&a=getcode&id=40&icon=1"/>
</div> </div>
<div className="nav-weather"><iframe width="360" height="40" frameBorder="0" scrolling="no" hspace="0" src="https://i.tianqi.com/?c=code&a=getcode&id=40&icon=1"/></div>
</div> </div>
<div className="tool-nav"> <div className="tool-nav">
<ToolType/> <ToolType/>
...@@ -57,34 +67,16 @@ function IndexAdmin() { ...@@ -57,34 +67,16 @@ function IndexAdmin() {
{ {
pop pop
} }
<div className></div>
<div className="index-footer"> <div className="index-footer">
兑吧研发中心·杭州兑吧网络科技游戏公司版权所有 兑吧研发中心·杭州兑吧网络科技游戏公司版权所有
<br/> <br/>
浙ICP备14017299号-1 浙ICP备14017299号-1
</div>
<AdminIndex />
{/* <div className="adminTool">
<button className='btn-admin' onClick={() => setPop((<PopAddToolBox/>))}>新建工具盒</button>
<button className='btn-admin' onClick={() => setPop((<PopAddType/>))}>新建类型</button>
</div> </div>
<div className="tool-nav"> <AdminIndex/>
<ToolType/>
</div>
<div className="container">
<Content/>
</div>
{
pop
} */}
</div> </div>
</PopContext.Provider> </PopContext.Provider>
) )
} }
export default IndexAdmin export default Index
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment