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
2b43a4a9
Commit
2b43a4a9
authored
Sep 30, 2021
by
wty
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
上线前准备
parent
82b30992
Changes
9
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
1075 additions
and
86 deletions
+1075
-86
package.json
expressServer/package.json
+1
-0
add.js
expressServer/routes/add.js
+24
-15
query.js
expressServer/routes/query.js
+4
-2
typeManage.js
expressServer/routes/typeManage.js
+54
-7
users.js
expressServer/routes/users.js
+4
-5
yarn.lock
expressServer/yarn.lock
+958
-19
ContentItem.jsx
src/component/Content/ContentItem.jsx
+2
-1
reducer.js
src/dataCenter/reducer.js
+3
-2
index.jsx
src/page/index/index.jsx
+25
-35
No files found.
expressServer/package.json
View file @
2b43a4a9
...
...
@@ -17,6 +17,7 @@
"morgan"
:
"~1.9.1"
,
"mysql"
:
"^2.18.1"
,
"nodemon"
:
"^2.0.12"
,
"pm2"
:
"^5.1.2"
,
"request"
:
"^2.88.2"
}
}
expressServer/routes/add.js
View file @
2b43a4a9
...
...
@@ -5,25 +5,34 @@ const router = express.Router()
router
.
get
(
'/addToolBox'
,
(
req
,
res
)
=>
{
const
{
toolBoxName
,
toolBoxIcon
,
toolBoxDesc
,
toolBoxUrl
,
typeId
,
childTypeId
}
=
req
.
query
// res.send({success: true})
const
SQL
=
'INSERT INTO toolbox (toolBoxName, toolBoxIcon, toolBoxDesc, toolBoxUrl, sortId) VALUES (?,?,?,?)'
const
typeSQL
=
`INSERT INTO toolbox_type (typeId,toolBoxId) VALUES (?,?)`
try
{
Mysql
.
query
(
SQL
,
[
toolBoxName
,
toolBoxDesc
,
toolBoxIcon
,
toolBoxUrl
],
(
err
,
result
)
=>
{
if
(
err
)
{
const
SQL
=
'INSERT INTO toolbox (toolBoxName, toolBoxIcon, toolBoxDesc, toolBoxUrl,sortId) VALUES (?,?,?,?,?)'
Mysql
.
query
(
SQL
,
[
toolBoxName
,
toolBoxDesc
,
toolBoxIcon
,
toolBoxUrl
,
0
],
(
err
,
result
)
=>
{
if
(
err
)
{
res
.
send
({
success
:
false
,
err
})
return
}
request
(
domain
+
'/query/queryToolBox'
,
{},
(
a
,
b
,
body
)
=>
{
const
data
=
JSON
.
parse
(
body
).
data
const
lastToolBoxId
=
data
[
data
.
length
-
1
].
toolBoxId
const
SQL
=
'INSERT INTO type_childtype_toolbox (toolBoxId,typeId,childTypeId) VALUES (?,?,?)'
Mysql
.
query
(
SQL
,
[
lastToolBoxId
,
typeId
,
childTypeId
],
(
err
,
result
)
=>
{
if
(
err
)
{
res
.
send
({
success
:
false
,
err
})
return
}
res
.
send
({
success
:
false
,
err
success
:
true
})
}
res
.
send
({
success
:
true
,
data
:
result
})
})
}
catch
(
e
)
{
console
.
error
(
e
)
}
})
})
router
.
get
(
'/addType'
,
(
req
,
res
)
=>
{
...
...
expressServer/routes/query.js
View file @
2b43a4a9
...
...
@@ -40,6 +40,9 @@ router.get('/queryChildType', (req, res) => {
router
.
get
(
'/queryToolBox'
,
(
req
,
res
)
=>
{
let
{
isFollow
,
typeId
}
=
req
.
query
let
SQL
=
`SELECT toolbox.*, type_childtype_toolbox.childTypeId FROM type_childtype_toolbox INNER JOIN toolbox ON type_childtype_toolbox.toolBoxId = toolbox.toolBoxId WHERE type_childtype_toolbox.typeId = ?`
if
(
!
isFollow
&&
!
typeId
){
SQL
=
`SELECT * FROM toolBox`
}
if
(
isFollow
)
{
typeId
=
JSON
.
parse
(
typeId
)
SQL
=
'SELECT * FROM toolbox WHERE toolboxId IN (?)'
...
...
@@ -52,11 +55,10 @@ router.get('/queryToolBox', (req, res) => {
})
throw
err
}
const
_result
=
result
.
slice
()
res
.
send
({
success
:
true
,
data
:
_result
.
sort
((
a
,
b
)
=>
a
.
sortId
-
b
.
sortId
)
data
:
result
})
})
});
...
...
expressServer/routes/typeManage.js
View file @
2b43a4a9
...
...
@@ -40,23 +40,23 @@ router.get('/queryChildType', (req, res) => {
router
.
get
(
'/queryTypeForManage'
,
(
req
,
res
)
=>
{
const
SQL
=
'SELECT child_type.childTypeId, child_type.childTypeName, child_type.typeId, type.typeName FROM child_type INNER JOIN type ON child_type.typeId = type.typeId'
Mysql
.
query
(
SQL
,
[],
(
err
,
result
)
=>
{
console
.
log
(
result
)
const
dataArr
=
[]
const
combineType
=
(
typeId
)
=>
{
if
(
dataArr
.
filter
(
v
=>
v
.
typeId
===
typeId
).
length
)
return
const
childType
=
result
.
filter
(
v
=>
v
.
typeId
===
2
).
map
(
v
=>
({
const
combineType
=
(
value
)
=>
{
if
(
dataArr
.
filter
(
v
=>
v
.
typeId
===
value
.
typeId
).
length
)
return
const
childType
=
result
.
filter
(
v
=>
v
.
typeId
===
value
.
typeId
).
map
(
v
=>
({
childTypeId
:
v
.
childTypeId
,
childTypeName
:
v
.
childTypeName
}))
dataArr
.
push
({
typeId
:
result
[
0
]
.
typeId
,
typeName
:
result
[
0
]
.
typeName
,
typeId
:
value
.
typeId
,
typeName
:
value
.
typeName
,
children
:
childType
})
}
result
.
forEach
(
v
=>
{
combineType
(
v
.
typeId
)
combineType
(
v
)
})
res
.
send
({
success
:
true
,
data
:
dataArr
...
...
@@ -64,4 +64,51 @@ router.get('/queryTypeForManage', (req, res) => {
})
})
router
.
get
(
'/deleteChildType'
,
((
req
,
res
)
=>
{
const
{
childTypeId
}
=
req
.
query
let
SQL
=
'DELETE FROM child_type WHERE childTypeId = ?;
\
n'
+
'DELETE FROM type_childtype_toolbox WHERE childTypeId = ?;'
Mysql
.
query
(
SQL
,
[
childTypeId
,
childTypeId
],
(
err
,
result
)
=>
{
if
(
err
)
{
res
.
send
({
success
:
false
,
err
})
return
}
res
.
send
({
success
:
true
,
})
})
}))
router
.
get
(
'/updateType'
,
(
req
,
res
)
=>
{
const
{
typeId
,
typeName
,
childTypeId
,
childTypeName
}
=
req
.
query
let
SQL
const
values
=
[]
if
(
typeId
)
{
SQL
=
'UPDATE type SET typeName = ? WHERE typeId = ?'
values
.
push
(
typeName
)
values
.
push
(
typeId
)
}
else
{
SQL
=
'UPDATE child_type SET childTypeName = ? WHERE childTypeId = ?'
values
.
push
(
childTypeName
)
values
.
push
(
childTypeId
)
}
Mysql
.
query
(
SQL
,
values
,
(
err
,
result
)
=>
{
if
(
err
)
{
res
.
send
({
success
:
false
,
err
})
return
}
res
.
send
({
success
:
true
,
})
})
})
module
.
exports
=
router
expressServer/routes/users.js
View file @
2b43a4a9
...
...
@@ -10,8 +10,6 @@ const ErrorCode = {
/* GET users listing. */
router
.
get
(
'/getUser'
,
function
(
req
,
res
,
next
)
{
let
{
userId
}
=
req
.
cookies
console
.
log
(
req
.
cookies
)
console
.
log
(
'userId:'
,
userId
)
if
(
!
userId
){
userId
=
req
.
query
.
userId
}
...
...
@@ -30,11 +28,13 @@ router.get('/getUser', function (req, res, next) {
success
:
false
,
err
})
throw
err
return
}
const
_result
=
result
.
slice
()
_result
[
0
].
follow
=
JSON
.
parse
(
_result
[
0
].
follow
)
// console.log(JSON.parse(_result[0]))
res
.
send
({
success
:
true
,
...
...
@@ -80,12 +80,11 @@ router.get('/follow', (req, res) => {
success
:
false
,
err
})
throw
err
return
}
res
.
send
({
success
:
true
,
})
})
})
...
...
expressServer/yarn.lock
View file @
2b43a4a9
This diff is collapsed.
Click to expand it.
src/component/Content/ContentItem.jsx
View file @
2b43a4a9
...
...
@@ -20,8 +20,9 @@ function ContentItem(props) {
const
index
=
_follow
.
indexOf
(
toolBoxId
)
_follow
.
splice
(
index
,
1
)
}
console
.
log
(
{
follow
:
JSON
.
stringify
(
_follow
),
userId
:
dataCenter
.
userInfo
.
uid
})
fetchData
(
'/users/follow'
,
{
follow
:
JSON
.
stringify
(
_follow
),
userId
:
dataCenter
.
userInfo
.
uid
})
.
then
(()
=>
fetchData
(
'/users/getUser'
,
{},
'userInfo'
))
.
then
(()
=>
fetchData
(
'/users/getUser'
,
{
userId
:
100001
},
'userInfo'
))
}
useEffect
(()
=>
{
...
...
src/dataCenter/reducer.js
View file @
2b43a4a9
...
...
@@ -4,7 +4,7 @@ const initDataCenter = {
childType
:
null
,
userInfo
:
null
,
needUpdateIndex
:
false
,
typeId
:
2
,
typeId
:
'follow'
,
childTypeId
:
'all'
}
...
...
@@ -34,7 +34,8 @@ function deepFreeze(obj) {
deepFreeze
(
initDataCenter
)
const
dataReducer
=
(
state
,
action
)
=>
{
console
.
log
(
action
)
// console.log(action)
console
.
table
(
action
,[
'dataCenter的dispatch'
])
switch
(
action
.
type
)
{
case
'UPDATE_DATA'
:
return
Object
.
assign
({},
state
,
{
...
...
src/page/index/index.jsx
View file @
2b43a4a9
...
...
@@ -2,29 +2,23 @@ import logo from "../../static/logo.png";
import
'./index.scss'
import
ToolType
from
"../../component/ToolType/ToolType"
;
import
Content
from
"../../component/Content/Content"
;
import
{
PopContext
,
Root
}
from
"../../dataCenter/Root"
;
import
{
useContext
,
useEffect
,
useState
}
from
"react"
;
import
{
Root
}
from
"../../dataCenter/Root"
;
import
{
useContext
,
useEffect
}
from
"react"
;
import
{
NEED_UPDATE_INDEX
}
from
"../../dataCenter/action"
;
function
Index
()
{
const
[
pop
,
setPop
]
=
useState
()
const
{
fetchData
,
dataCenter
,
dispatch
}
=
useContext
(
Root
)
const
showPop
=
popComponent
=>
{
setPop
(
popComponent
)
}
const
getUser
=
()
=>
{
fetchData
(
'/users/getUser'
,
{
userId
:
'100001'
},
'userInfo'
)
.
catch
(
res
=>
res
.
code
===
70001
&&
(
window
.
location
.
href
=
'/login'
)
)
}
useEffect
(()
=>
{
fetchData
(
'/query/queryType'
,
{},
'type'
)
.
then
(()
=>
fetchData
(
'/query/queryChildType'
,{
typeId
:
dataCenter
.
typeId
},
'childType'
))
.
then
(()
=>
fetchData
(
'/query/queryChildType'
,
{
typeId
:
dataCenter
.
typeId
},
'childType'
))
.
then
(()
=>
dispatch
(
NEED_UPDATE_INDEX
()))
},
[
dataCenter
.
typeId
])
useEffect
(()
=>
{
if
(
dataCenter
.
needUpdateIndex
)
{
const
_typeId
=
dataCenter
.
typeId
===
'follow'
?
{
...
...
@@ -40,39 +34,35 @@ function Index() {
},
[])
return
(
<
PopContext
.
Provider
value=
{
{
hidePop
:
()
=>
setPop
(
''
),
showPop
:
popName
=>
showPop
(
popName
)}
}
>
<
div
className=
"index"
>
<
div
className=
"welcome-top"
>
<
div
className=
"index"
>
<
div
className=
"welcome-top"
>
<
span
>
欢迎您!
<
span
className=
"welcome-uname"
>
{
dataCenter
?.
userInfo
?.
uname
}
</
span
>
<
a
className=
"login-btn"
>
退出登录
</
a
>
</
span
>
</
div
>
<
div
className=
"nav"
>
<
div
className=
"nav-title"
>
<
img
src=
{
logo
}
alt=
""
/>
</
div
>
<
div
className=
"nav"
>
<
div
className=
"nav-title"
>
<
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=
"tool-nav"
>
<
ToolType
/>
</
div
>
<
div
className=
"container"
>
<
Content
/>
</
div
>
{
pop
}
<
div
className=
"index-footer"
>
兑吧研发中心·杭州兑吧网络科技游戏公司版权所有
<
br
/>
浙ICP备14017299号-1
<
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
>
</
PopContext
.
Provider
>
<
div
className=
"tool-nav"
>
<
ToolType
/>
</
div
>
<
div
className=
"container"
>
<
Content
/>
</
div
>
<
div
className=
"index-footer"
>
兑吧研发中心·杭州兑吧网络科技游戏公司版权所有
<
br
/>
浙ICP备14017299号-1
</
div
>
</
div
>
)
}
...
...
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