Commit 9eaa2cc0 authored by wty's avatar wty

修改页面

parent 27f42770
...@@ -8,11 +8,12 @@ ...@@ -8,11 +8,12 @@
<excludeFolder url="file://$MODULE_DIR$/build" /> <excludeFolder url="file://$MODULE_DIR$/build" />
<excludeFolder url="file://$MODULE_DIR$/expressServer/.idea" /> <excludeFolder url="file://$MODULE_DIR$/expressServer/.idea" />
<excludeFolder url="file://$MODULE_DIR$/.idea/inspectionProfiles" /> <excludeFolder url="file://$MODULE_DIR$/.idea/inspectionProfiles" />
<excludeFolder url="file://$MODULE_DIR$/node_modules" />
<excludeFolder url="file://$MODULE_DIR$/server/node_modules" /> <excludeFolder url="file://$MODULE_DIR$/server/node_modules" />
<excludeFolder url="file://$MODULE_DIR$/server/staticFile/build" /> <excludeFolder url="file://$MODULE_DIR$/server/staticFile/build" />
<excludeFolder url="file://$MODULE_DIR$/node_modules" />
</content> </content>
<content url="file://$MODULE_DIR$/node_modules" /> <content url="file://$MODULE_DIR$/node_modules" />
<content url="file://$MODULE_DIR$/node_modules/@types" />
<content url="file://$MODULE_DIR$/server/node_modules" /> <content url="file://$MODULE_DIR$/server/node_modules" />
<content url="file://$MODULE_DIR$/server/node_modules/@types" /> <content url="file://$MODULE_DIR$/server/node_modules/@types" />
<content url="file://$MODULE_DIR$/server/node_modules/sso-oauth2" /> <content url="file://$MODULE_DIR$/server/node_modules/sso-oauth2" />
......
...@@ -42,7 +42,7 @@ getMysql.then(Mysql => { ...@@ -42,7 +42,7 @@ getMysql.then(Mysql => {
let {isFollow, type_id} = req.query let {isFollow, type_id} = req.query
let SQL = `SELECT toolbox.*, type_childtype_toolbox.child_type_id FROM type_childtype_toolbox INNER JOIN toolbox ON type_childtype_toolbox.toolbox_id = toolbox.toolbox_id WHERE type_childtype_toolbox.type_id = ?` let SQL = `SELECT toolbox.*, type_childtype_toolbox.child_type_id FROM type_childtype_toolbox INNER JOIN toolbox ON type_childtype_toolbox.toolbox_id = toolbox.toolbox_id WHERE type_childtype_toolbox.type_id = ?`
if (!isFollow && !type_id){ if (!isFollow && !type_id){
SQL = `SELECT * FROM toolbox` SQL = `SELECT toolbox.*, type_childtype_toolbox.child_type_id, type_childtype_toolbox.type_id FROM type_childtype_toolbox INNER JOIN toolbox ON type_childtype_toolbox.toolbox_id = toolbox.toolbox_id`
} }
if (isFollow) { if (isFollow) {
// type_id = JSON.parse(type_id) // type_id = JSON.parse(type_id)
......
...@@ -13,6 +13,16 @@ const ErrorCode = { ...@@ -13,6 +13,16 @@ const ErrorCode = {
getMysql.then(Mysql => { getMysql.then(Mysql => {
/* GET users listing. */ /* GET users listing. */
router.get('/getUser', async (req, res) => { router.get('/getUser', async (req, res) => {
res.send({
success: true,
data: {
name: '王天宇',
id: 1,
follow: []
}
})
const {sso_ticket} = req.cookies const {sso_ticket} = req.cookies
console.info('cookies: ', req.cookies) console.info('cookies: ', req.cookies)
if (!sso_ticket) { if (!sso_ticket) {
......
...@@ -4,18 +4,25 @@ import {useContext} from "react"; ...@@ -4,18 +4,25 @@ import {useContext} from "react";
import {Root} from "../../dataCenter/Root"; import {Root} from "../../dataCenter/Root";
function Content(props) { function Content(props) {
const {childTypeId, typeId} = props
const {dataCenter} = useContext(Root) const {dataCenter} = useContext(Root)
return ( return (
<div className="content"> <div className="content">
{ {
dataCenter.toolBox?.length ? dataCenter?.toolBox?.filter(v => { dataCenter.toolBox?.length ? dataCenter?.toolBox
if (dataCenter.child_type_id === 'all') return true .filter(v => {
else return v.child_type_id === dataCenter.child_type_id if (typeId === 'all') return true
}).map(v => { else if (typeId === 'follow') return dataCenter.userInfo.follow.includes(v.type_id)
return ( else return v.type_id === typeId
<ContentItem key={v['toolbox_id']} value={v}/> })
) .filter(v => {
}) if (childTypeId === 'all') return true
else return v.child_type_id === childTypeId
}).map(v => {
return (
<ContentItem key={v['toolbox_id']} value={v}/>
)
})
: :
'没有数据了!' '没有数据了!'
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
.content{ .content{
width: 100%; width: 100%;
max-width: 1190px; max-width: 1190px;
min-width: 612px; min-width: 1190px;
background: $backgroundColor; background: $backgroundColor;
border-radius: 0 0 3px 3px; border-radius: 0 0 3px 3px;
box-sizing: border-box; box-sizing: border-box;
......
import './Content.scss' import './Content.scss'
import ContentItemAdmin from "./ContentItemAdmin";
import {useContext} from "react"; import {useContext} from "react";
import {Root} from "../../dataCenter/Root"; import {Root} from "../../dataCenter/Root";
import ContentItem from "../Content/ContentItem"; import ContentItemAdmin from "./ContentItemAdmin";
function Content(props) { function ContentAdmin(props) {
const {childTypeId, typeId} = props
const {dataCenter} = useContext(Root) const {dataCenter} = useContext(Root)
return ( return (
<div className="content"> <div className="content">
{ {
dataCenter.toolBox?.length ? dataCenter?.toolBox?.filter(v => { dataCenter.toolBox?.length ? dataCenter?.toolBox
if (dataCenter.child_type_id === 'all') return true .filter(v => {
else return v.child_type_id === dataCenter.child_type_id if (typeId === 'all') return true
}).map(v => { else if (typeId === 'follow') return dataCenter.userInfo.follow.includes(v.type_id)
return ( else return v.type_id === typeId
<ContentItemAdmin key={v['toolbox_id']} value={v}/> })
) .filter(v => {
}) if (childTypeId === 'all') return true
else return v.child_type_id === childTypeId
}).map(v => {
return (
<ContentItemAdmin key={v['toolbox_id']} value={v}/>
)
})
: :
'没有数据了!' '没有数据了!'
} }
...@@ -25,4 +30,4 @@ function Content(props) { ...@@ -25,4 +30,4 @@ function Content(props) {
) )
} }
export default Content export default ContentAdmin
import ToolType from "../ToolType/ToolType";
import Content from "../Content/Content";
import {useState} from "react";
function IndexContent(props){
const {typeData} = props
const [typeId, setTypeId] = useState(typeData[0].type_id)
const [childTypeId, setChildTypeId] = useState('all')
return (
<>
<div className="tool-nav">
<ToolType typeData={typeData} setChildTypeId={setChildTypeId} setTypeId={setTypeId} typeId={typeId} childTypeId={childTypeId}/>
</div>
<div className="container">
<Content typeId={typeId} childTypeId={childTypeId}/>
</div>
</>
)
}
export default IndexContent
import ToolType from "../ToolType/ToolType";
import Content from "../Content/Content";
import {useState} from "react";
import ContentAdmin from "../ContentAdmin/Content";
function IndexContent(props){
const {typeData} = props
const [typeId, setTypeId] = useState(typeData[0].type_id)
const [childTypeId, setChildTypeId] = useState('all')
return (
<>
<div className="tool-nav">
<ToolType typeData={typeData} setChildTypeId={setChildTypeId} setTypeId={setTypeId} typeId={typeId} childTypeId={childTypeId}/>
</div>
<div className="container">
<ContentAdmin typeId={typeId} childTypeId={childTypeId}/>
</div>
</>
)
}
export default IndexContent
import './ToolType.scss' import './ToolType.scss'
import {useContext} from "react"; import {useContext} from "react";
import {Root} from "../../dataCenter/Root"; import {Root} from "../../dataCenter/Root";
import {CHANGE_CHILD_TYPE, CHANGE_TYPE} from "../../dataCenter/action";
const ChildTypeItem = props => { const ChildTypeItem = props => {
const {dataCenter, dispatch} = useContext(Root) const {dataCenter, dispatch} = useContext(Root)
const {child_type_id, child_type_name} = props const {childTypeId, child_type_id, child_type_name, setChildTypeId} = props
const classNameArr = ['child-type-item'] const classNameArr = ['child-type-item']
if (child_type_id === dataCenter.child_type_id) { if (child_type_id === childTypeId) {
classNameArr.push('child-type-item-selected') classNameArr.push('child-type-item-selected')
} }
const handleClick = () => { const handleClick = () => {
console.log(child_type_id) setChildTypeId(child_type_id)
dispatch(CHANGE_CHILD_TYPE(child_type_id))
} }
return ( return (
<div className={classNameArr.join(' ')} onClick={handleClick}>{child_type_name}</div> <div className={classNameArr.join(' ')} onClick={handleClick}>{child_type_name}</div>
...@@ -21,31 +19,40 @@ const ChildTypeItem = props => { ...@@ -21,31 +19,40 @@ const ChildTypeItem = props => {
function ToolType(props) { function ToolType(props) {
const {typeData, setChildTypeId, setTypeId, typeId, childTypeId} = props
const {dataCenter, dispatch} = useContext(Root) const {dataCenter, dispatch} = useContext(Root)
const getTypeData = ()=>{
return typeData.filter(v => v.type_id === typeId)[0]
}
if (!Array.isArray(typeData)) return (<div>无数据,或数据格式错误</div>)
return ( return (
<> <>
<div className="tab-tool-type"> <div className="tab-tool-type">
<div className={dataCenter.type_id === 'follow' ? 'item-tool-type item-tool-type-selected' : 'item-tool-type'}
onClick={() => dispatch(CHANGE_TYPE('follow'))}>我的收藏
</div>
{ {
dataCenter?.type?.length > 0 && dataCenter.type.map(v => { Array.isArray(typeData) && typeData.map(v => (
const classNameArr = ['item-tool-type '] <div
if (v["type_id"] === dataCenter.type_id) classNameArr.push('item-tool-type-selected') className={typeId === v.type_id ? 'item-tool-type item-tool-type-selected' : 'item-tool-type'}
return ( onClick={() => setTypeId(v?.type_id)} key={v.type_id}>
<div key={v["type_id"]} className={classNameArr.join('')} {v?.type_name}
onClick={() => dispatch(CHANGE_TYPE( v["type_id"]))}>{v.type_name}</div> </div>
) ))
})
} }
</div> </div>
<div className="child-type"> <div className="child-type">
<ChildTypeItem key={'all'} child_type_id={'all'} child_type_name={'全部'}/>
{ {
dataCenter?.childType?.length > 0 && dataCenter?.childType.map(v => { typeId !== 'all' &&
<ChildTypeItem key={'all'} child_type_id={'all'} child_type_name={'全部'}
setChildTypeId={setChildTypeId} childTypeId={childTypeId}/>
}
{
Array.isArray(getTypeData()?.children) && getTypeData().children.map(v => {
return ( return (
<ChildTypeItem key={v.child_type_id} child_type_id={v.child_type_id} <ChildTypeItem key={v.child_type_id} child_type_id={v.child_type_id}
child_type_name={v.child_type_name}/> child_type_name={v.child_type_name}
setChildTypeId={setChildTypeId}
childTypeId={childTypeId}
/>
) )
}) })
} }
......
...@@ -4,7 +4,7 @@ const initDataCenter = { ...@@ -4,7 +4,7 @@ const initDataCenter = {
childType: null, childType: null,
userInfo: null, userInfo: null,
needUpdateIndex: false, needUpdateIndex: false,
type_id: 'follow', type_id: 'all',
child_type_id: 'all' child_type_id: 'all'
} }
......
...@@ -7,6 +7,7 @@ import {useContext, useEffect} from "react"; ...@@ -7,6 +7,7 @@ import {useContext, useEffect} from "react";
import {NEED_UPDATE_INDEX} from "../../dataCenter/action"; import {NEED_UPDATE_INDEX} from "../../dataCenter/action";
import {useHistory} from "react-router-dom"; import {useHistory} from "react-router-dom";
import gotoLogin from "../../utils/gotoLogin"; import gotoLogin from "../../utils/gotoLogin";
import IndexContent from "../../component/IndexContent/IndexContent";
function Index() { function Index() {
const history = useHistory() const history = useHistory()
...@@ -18,8 +19,8 @@ function Index() { ...@@ -18,8 +19,8 @@ function Index() {
) )
} }
useEffect(() => { useEffect(() => {
fetchData('/query/queryType', {}, 'type') fetchData('/typeManage/queryTypeForManage', {}, 'type')
.then(() => fetchData('/query/queryChildType', {type_id: dataCenter.type_id}, 'childType')) // .then(() => fetchData('/query/queryChildType', {type_id: dataCenter.type_id}, 'childType'))
.then(() => dispatch(NEED_UPDATE_INDEX())) .then(() => dispatch(NEED_UPDATE_INDEX()))
}, [dataCenter.type_id]) }, [dataCenter.type_id])
...@@ -28,7 +29,7 @@ function Index() { ...@@ -28,7 +29,7 @@ function Index() {
const _typeId = dataCenter.type_id === 'follow' ? { const _typeId = dataCenter.type_id === 'follow' ? {
isFollow: true, isFollow: true,
type_id: JSON.stringify(dataCenter?.userInfo?.follow) type_id: JSON.stringify(dataCenter?.userInfo?.follow)
} : {type_id: dataCenter.type_id} } : {}
fetchData('/query/queryToolBox', _typeId, 'toolBox').then(() => dispatch(NEED_UPDATE_INDEX())) fetchData('/query/queryToolBox', _typeId, 'toolBox').then(() => dispatch(NEED_UPDATE_INDEX()))
} }
}, [dataCenter.needUpdateIndex]) }, [dataCenter.needUpdateIndex])
...@@ -55,12 +56,12 @@ function Index() { ...@@ -55,12 +56,12 @@ function Index() {
src="https://i.tianqi.com/?c=code&a=getcode&id=40&icon=1"/> src="https://i.tianqi.com/?c=code&a=getcode&id=40&icon=1"/>
</div> </div>
</div> </div>
<div className="tool-nav"> <IndexContent typeData={[{type_id: 'all', type_name: '全部'}, {type_id: 'follow', type_name: '我的收藏'}]}/>
<ToolType/> {
</div> Array.isArray(dataCenter?.type) && dataCenter?.type?.map(v => (
<div className="container"> <IndexContent typeData={[v]} key={v.type_id}/>
<Content/> ))
</div> }
<div className="index-footer"> <div className="index-footer">
兑吧研发中心·杭州兑吧网络科技有限公司版权所有 兑吧研发中心·杭州兑吧网络科技有限公司版权所有
<br/> <br/>
......
...@@ -8,6 +8,8 @@ import {NEED_UPDATE_INDEX} from "../../dataCenter/action"; ...@@ -8,6 +8,8 @@ import {NEED_UPDATE_INDEX} from "../../dataCenter/action";
import AdminIndex from "../../component/AdminIndex/AdminIndex"; import AdminIndex from "../../component/AdminIndex/AdminIndex";
import {useHistory} from "react-router-dom"; import {useHistory} from "react-router-dom";
import gotoLogin from "../../utils/gotoLogin"; import gotoLogin from "../../utils/gotoLogin";
import IndexContent from "../../component/IndexContent/IndexContent";
import IndexContentAdmin from "../../component/IndexContent/IndexContentAdmin";
function Index() { function Index() {
const history = useHistory() const history = useHistory()
...@@ -21,8 +23,8 @@ function Index() { ...@@ -21,8 +23,8 @@ function Index() {
} }
useEffect(() => { useEffect(() => {
fetchData('/query/queryType', {}, 'type') fetchData('/typeManage/queryTypeForManage', {}, 'type')
.then(()=> fetchData('/query/queryChildType',{type_id: dataCenter.type_id},'childType')) // .then(()=> fetchData('/query/queryChildType',{type_id: dataCenter.type_id},'childType'))
.then(() => dispatch(NEED_UPDATE_INDEX())) .then(() => dispatch(NEED_UPDATE_INDEX()))
}, [dataCenter.type_id]) }, [dataCenter.type_id])
...@@ -58,12 +60,12 @@ function Index() { ...@@ -58,12 +60,12 @@ function Index() {
src="https://i.tianqi.com/?c=code&a=getcode&id=40&icon=1"/> src="https://i.tianqi.com/?c=code&a=getcode&id=40&icon=1"/>
</div> </div>
</div> </div>
<div className="tool-nav"> <IndexContentAdmin typeData={[{type_id: 'all', type_name: '全部'}, {type_id: 'follow', type_name: '我的收藏'}]}/>
<ToolType/> {
</div> Array.isArray(dataCenter?.type) && dataCenter?.type?.map(v => (
<div className="container"> <IndexContentAdmin typeData={[v]} key={v.type_id}/>
<Content/> ))
</div> }
<div className="index-footer"> <div className="index-footer">
兑吧研发中心·杭州兑吧网络科技游戏公司版权所有 兑吧研发中心·杭州兑吧网络科技游戏公司版权所有
<br/> <br/>
......
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