Commit f4818142 authored by wty's avatar wty

调整

parent 70432763
const env = 'prod'
const env = 'local'
const getConfig = ()=>{
switch (env){
......
......@@ -2,9 +2,8 @@ import './App.css';
import DataCenter from "./dataCenter/Root";
import IndexAdmin from "./page/indexAdmin";
import Index from "./page/index";
import Login from "./page/login/login";
import DataCollection from "./page/DataCollection/DataCollection";
import {HashRouter as Router, Redirect, Route, Switch} from "react-router-dom";
import {useEffect} from "react";
function App() {
......@@ -12,9 +11,10 @@ function App() {
<Router>
<DataCenter>
<Switch>
<Route exact path='/' render={()=>(<Redirect to={'/index'}/>)}/>
<Route exact path='/' render={() => (<Redirect to={'/index'}/>)}/>
<Route exact path='/index' component={Index}/>
<Route exact path='/admin' component={IndexAdmin}/>
<Route exact path='/dataCollection' component={DataCollection}/>
</Switch>
</DataCenter>
</Router>
......
const env = 'prod'
const env = 'local'
const apiConfig = {
domain: (() => {
......
import React, {useContext, useEffect} from "react";
import './DataCollection.scss'
import gotoLogin from "../../utils/gotoLogin";
import {useHistory} from "react-router-dom";
import {Root} from "../../dataCenter/Root";
function DataCollection() {
const history = useHistory()
const {fetchData, dataCenter, dispatch} = useContext(Root)
const getUser = () => {
fetchData('/users/getUser', {}, 'userInfo')
.then(res => {
if (+res?.data?.admin !== 1) {
history.push('/')
}
})
.catch(res =>
+res.code === 70001 && (gotoLogin())
)
}
useEffect(async () => {
await getUser()
}, [])
return (
<div className='data-collotion'>
</div>
)
}
export default DataCollection
import logo from "../../static/logo.png";
import './index.scss'
import ToolType from "../../component/ToolType/ToolType";
import Content from '../../component/ContentAdmin/Content'
import {PopContext, Root} from "../../dataCenter/Root";
import {useContext, useEffect, useState} from "react";
import {useContext, useEffect} from "react";
import {NEED_UPDATE_INDEX} from "../../dataCenter/action";
import AdminIndex from "../../component/AdminIndex/AdminIndex";
import {useHistory} from "react-router-dom";
import gotoLogin from "../../utils/gotoLogin";
import IndexContent from "../../component/IndexContent/IndexContent";
import IndexContentAdmin from "../../component/IndexContent/IndexContentAdmin";
function Index() {
const history = useHistory()
const {fetchData, dataCenter, dispatch} = useContext(Root)
const showPop = popComponent => {}
const showPop = popComponent => {
}
const getUser = () => {
fetchData('/users/getUser', {}, 'userInfo')
.then(res => {
if (+res?.data?.admin !== 1){
if (+res?.data?.admin !== 1) {
history.push('/')
}
})
......@@ -36,13 +34,13 @@ function Index() {
useEffect(() => {
if (dataCenter.needUpdateIndex) {
fetchData('/query/queryToolBox', {}, 'toolBox')
.then(()=>fetchData('/typeManage/queryTypeForManage', {}, 'type'))
.then(() => fetchData('/typeManage/queryTypeForManage', {}, 'type'))
.then(() => dispatch(NEED_UPDATE_INDEX()))
}
}, [dataCenter.needUpdateIndex])
useEffect(() => {
getUser()
useEffect(async () => {
await getUser()
dispatch(NEED_UPDATE_INDEX())
}, [])
......@@ -64,11 +62,11 @@ function Index() {
src="https://i.tianqi.com/?c=code&a=getcode&id=40&icon=1"/>
</div>
</div>
<IndexContentAdmin typeData={[ {type_id: 'follow', type_name: '我的收藏'}]}/>
<IndexContentAdmin typeData={[{type_id: 'follow', type_name: '我的收藏'}]}/>
{
Array.isArray(dataCenter?.type) && dataCenter?.type?.map(v => (
<div key={v.type_id}>
<IndexContentAdmin typeData={[v]} />
<IndexContentAdmin typeData={[v]}/>
</div>
))
}
......
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