Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
Dui123
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
王天宇
Dui123
Commits
970d30e1
Commit
970d30e1
authored
Sep 15, 2021
by
wty
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加子分类后端代码
parent
d7fb09d6
Changes
7
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
574 additions
and
503 deletions
+574
-503
query.js
expressServer/routes/query.js
+1
-5
users.js
expressServer/routes/users.js
+9
-8
ToolType.jsx
src/component/ToolType/ToolType.jsx
+45
-21
ToolType.scss
src/component/ToolType/ToolType.scss
+2
-1
Root.jsx
src/dataCenter/Root.jsx
+1
-1
index.js
src/index.js
+14
-5
yarn.lock
yarn.lock
+502
-462
No files found.
expressServer/routes/query.js
View file @
970d30e1
...
@@ -12,13 +12,9 @@ router.get('/queryType', (req, res) => {
...
@@ -12,13 +12,9 @@ router.get('/queryType', (req, res) => {
err
err
})
})
}
}
const
_result
=
result
.
slice
().
map
(
v
=>
{
JSON
.
parse
(
v
.
typeContent
)})
res
.
send
({
res
.
send
({
success
:
true
,
success
:
true
,
data
:
{
data
:
result
.
map
(
v
=>
({...
v
,
typeContent
:
JSON
.
parse
(
v
.
typeContent
)}))
...
result
,
_result
}
})
})
})
})
});
});
...
...
expressServer/routes/users.js
View file @
970d30e1
...
@@ -12,14 +12,15 @@ router.get('/getUser', function (req, res, next) {
...
@@ -12,14 +12,15 @@ router.get('/getUser', function (req, res, next) {
let
{
userId
}
=
req
.
cookies
let
{
userId
}
=
req
.
cookies
console
.
log
(
req
.
cookies
)
console
.
log
(
req
.
cookies
)
console
.
log
(
'userId:'
,
userId
)
console
.
log
(
'userId:'
,
userId
)
if
(
!
userId
)
{
userId
=
req
.
query
.
userId
res
.
send
({
// if (!userId) {
success
:
false
,
// res.send({
code
:
ErrorCode
.
USER_NOT_LOGIN
,
// success: false,
data
:
'用户尚未登录'
// code: ErrorCode.USER_NOT_LOGIN,
})
// data: '用户尚未登录'
return
// })
}
// return
// }
const
SQL
=
'SELECT * FROM `user` WHERE `user`.uid = ?'
const
SQL
=
'SELECT * FROM `user` WHERE `user`.uid = ?'
Mysql
.
query
(
SQL
,
[
userId
],
(
err
,
result
)
=>
{
Mysql
.
query
(
SQL
,
[
userId
],
(
err
,
result
)
=>
{
if
(
err
)
{
if
(
err
)
{
...
...
src/component/ToolType/ToolType.jsx
View file @
970d30e1
...
@@ -2,36 +2,60 @@ import './ToolType.scss'
...
@@ -2,36 +2,60 @@ import './ToolType.scss'
import
{
useContext
,
useEffect
,
useState
}
from
"react"
;
import
{
useContext
,
useEffect
,
useState
}
from
"react"
;
import
{
Root
}
from
"../../dataCenter/Root"
;
import
{
Root
}
from
"../../dataCenter/Root"
;
import
{
NEED_UPDATE_INDEX
}
from
"../../dataCenter/action"
;
import
{
NEED_UPDATE_INDEX
}
from
"../../dataCenter/action"
;
import
{
Tabs
}
from
"antd"
;
function
ToolType
(
props
)
{
function
ToolType
(
props
)
{
const
{
dataCenter
,
fetchData
,
updateIndex
,
dispatch
}
=
useContext
(
Root
)
const
{
dataCenter
,
fetchData
,
updateIndex
,
dispatch
}
=
useContext
(
Root
)
const
[
typeId
,
setTypeId
]
=
useState
(
2
)
const
[
typeId
,
setTypeId
]
=
useState
(
2
)
const
{
TabPane
}
=
Tabs
;
useEffect
(()
=>
{
useEffect
(()
=>
{
updateIndex
()
updateIndex
()
},[
typeId
])
},
[
typeId
])
useEffect
(()
=>
{
useEffect
(()
=>
{
if
(
dataCenter
.
needUpdateIndex
){
if
(
dataCenter
.
needUpdateIndex
)
{
const
_typeId
=
typeId
===
'all'
?
{}
:
typeId
===
'follow'
?
{
isFollow
:
true
,
typeId
:
JSON
.
stringify
(
dataCenter
.
userInfo
.
follow
)}
:
{
typeId
:
typeId
}
const
_typeId
=
typeId
===
'all'
?
{}
:
typeId
===
'follow'
?
{
fetchData
(
'/query/queryToolBox'
,
_typeId
,
'toolBox'
).
then
(()
=>
dispatch
(
NEED_UPDATE_INDEX
()))
isFollow
:
true
,
typeId
:
JSON
.
stringify
(
dataCenter
.
userInfo
.
follow
)
}
:
{
typeId
:
typeId
}
fetchData
(
'/query/queryToolBox'
,
_typeId
,
'toolBox'
).
then
(()
=>
dispatch
(
NEED_UPDATE_INDEX
()))
}
}
},[
dataCenter
.
needUpdateIndex
])
},
[
dataCenter
.
needUpdateIndex
])
console
.
log
(
dataCenter
?.
type
?.
filter
(
v
=>
v
.
typeId
===
typeId
))
return
(
return
(
<>
<
div
className=
"tab-tool-type"
>
<
div
className=
"tab-tool-type"
>
<
div
className=
{
typeId
===
'all'
?
'item-tool-type item-tool-type-selected'
:
'item-tool-type'
}
onClick=
{
()
=>
setTypeId
(
'all'
)
}
>
工具
</
div
>
<
div
className=
{
typeId
===
'all'
?
'item-tool-type item-tool-type-selected'
:
'item-tool-type'
}
<
div
className=
{
typeId
===
'follow'
?
'item-tool-type item-tool-type-selected'
:
'item-tool-type'
}
onClick=
{
()
=>
setTypeId
(
'follow'
)
}
>
我的收藏
</
div
>
onClick=
{
()
=>
setTypeId
(
'all'
)
}
>
工具
</
div
>
<
div
className=
{
typeId
===
'follow'
?
'item-tool-type item-tool-type-selected'
:
'item-tool-type'
}
onClick=
{
()
=>
setTypeId
(
'follow'
)
}
>
我的收藏
</
div
>
{
{
dataCenter
?.
type
?.
length
&&
dataCenter
.
type
.
map
(
v
=>
{
dataCenter
?.
type
?.
length
&&
dataCenter
.
type
.
map
(
v
=>
{
const
classNameArr
=
[
'item-tool-type '
]
const
classNameArr
=
[
'item-tool-type '
]
if
(
v
[
"typeId"
]
===
typeId
)
classNameArr
.
push
(
'item-tool-type-selected'
)
if
(
v
[
"typeId"
]
===
typeId
)
classNameArr
.
push
(
'item-tool-type-selected'
)
return
(
return
(
<
div
key=
{
v
[
"typeId"
]
}
className=
{
classNameArr
.
join
(
''
)
}
onClick=
{
()
=>
setTypeId
(
v
[
"typeId"
])
}
>
{
v
.
typeName
}
</
div
>
<
div
key=
{
v
[
"typeId"
]
}
className=
{
classNameArr
.
join
(
''
)
}
onClick=
{
()
=>
setTypeId
(
v
[
"typeId"
])
}
>
{
v
.
typeName
}
</
div
>
)
})
}
</
div
>
<
div
className=
"child-type"
>
{
dataCenter
?.
type
?.
length
&&
dataCenter
.
type
.
filter
(
v
=>
v
.
typeId
===
typeId
)[
0
].
typeContent
.
map
(
v
=>
{
return
(
<
div
key=
{
v
.
id
}
className=
"item-childType"
>
{
v
.
name
}
</
div
>
)
)
})
})
}
}
</
div
>
</
div
>
</>
)
)
}
}
...
...
src/component/ToolType/ToolType.scss
View file @
970d30e1
...
@@ -29,7 +29,7 @@
...
@@ -29,7 +29,7 @@
}
}
}
}
.child
T
ype
{
.child
-t
ype
{
margin-left
:
0
;
margin-left
:
0
;
font-size
:
15px
;
font-size
:
15px
;
display
:
flex
;
display
:
flex
;
...
@@ -37,6 +37,7 @@
...
@@ -37,6 +37,7 @@
justify-content
:
flex-start
;
justify-content
:
flex-start
;
flex-wrap
:
nowrap
;
flex-wrap
:
nowrap
;
overflow-x
:
auto
;
overflow-x
:
auto
;
border
:
1px
solid
#000
;
.item-childType
{
.item-childType
{
flex
:
0
0
auto
;
flex
:
0
0
auto
;
...
...
src/dataCenter/Root.jsx
View file @
970d30e1
...
@@ -27,7 +27,7 @@ function DataCenter(props) {
...
@@ -27,7 +27,7 @@ function DataCenter(props) {
}
}
const
fetchData
=
(
path
,
requestData
,
dataName
)
=>
const
fetchData
=
(
path
,
requestData
,
dataName
)
=>
fetch
(
generateUrl
(
path
,
requestData
),
{
credentials
:
'include'
})
fetch
(
generateUrl
(
path
,
requestData
),
{
credentials
:
'include'
,
mode
:
'no-cors'
})
.
then
(
res
=>
res
.
json
())
.
then
(
res
=>
res
.
json
())
.
then
(
res
=>
{
.
then
(
res
=>
{
if
(
res
.
success
)
{
if
(
res
.
success
)
{
...
...
src/index.js
View file @
970d30e1
import
React
from
'react'
;
import
React
from
'react'
;
import
ReactDOM
from
'react-dom'
;
import
ReactDOM
from
'react-dom'
;
import
{
ConfigProvider
,
DatePicker
,
message
}
from
'antd'
;
// 由于 antd 组件的默认文案是英文,所以需要修改为中文
import
zhCN
from
'antd/lib/locale/zh_CN'
;
import
moment
from
'moment'
;
import
'moment/locale/zh-cn'
;
import
'antd/dist/antd.css'
;
import
'./index.css'
;
import
'./index.css'
;
import
'./index.css'
;
import
App
from
'./App'
;
import
App
from
'./App'
;
import
reportWebVitals
from
'./reportWebVitals'
;
import
reportWebVitals
from
'./reportWebVitals'
;
moment
.
locale
(
'zh-cn'
);
ReactDOM
.
render
(
ReactDOM
.
render
(
<
React
.
StrictMode
>
<
React
.
StrictMode
>
<
ConfigProvider
locale
=
{
zhCN
}
>
<
App
/>
<
App
/>
<
/ConfigProvider
>
<
/React.StrictMode>
,
<
/React.StrictMode>
,
document
.
getElementById
(
'root'
)
document
.
getElementById
(
'root'
)
);
);
...
...
yarn.lock
View file @
970d30e1
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment