Commit d7fb09d6 authored by wty's avatar wty

增加子分类后端代码

parent 2381606f
......@@ -55,4 +55,6 @@ router.get('/addType', (req, res) => {
})
module.exports = router
......@@ -12,9 +12,13 @@ router.get('/queryType', (req, res) => {
err
})
}
const _result = result.slice().map(v => {JSON.parse(v.typeContent)})
res.send({
success: true,
data: result
data: {
...result,
_result
}
})
})
});
......
......@@ -29,5 +29,27 @@ router.get('/updateToolBoxSort',(req, res) => {
})
})
router.get('/updateChildType', (req, res) => {
const childrenTypeArr = [{id: 1, name: '运营'},{id: 2, name: '测试'},]
const SQL = 'UPDATE type SET typeContent = ? WHERE typeId = 2'
try {
Mysql.query(SQL, [JSON.stringify(childrenTypeArr)], (err, result) => {
if (err) {
res.send({
success: false,
err
})
throw err
}
res.send({
success: true,
data: result
})
})
} catch (e) {
console.error(e)
}
})
module.exports = router
......@@ -10,7 +10,8 @@ const ErrorCode = {
/* GET users listing. */
router.get('/getUser', function (req, res, next) {
let {userId} = req.cookies
userId = 100001
console.log(req.cookies)
console.log('userId:',userId)
if (!userId) {
res.send({
success: false,
......
......@@ -2,23 +2,26 @@ import './App.css';
import DataCenter from "./dataCenter/Root";
import IndexAdmin from "./page/indexAdmin";
import Index from "./page/index";
import {useState} from "react";
import Login from "./page/login/login";
import {Route, BrowserRouter as Router, Switch} from "react-router-dom";
function App() {
const [page, setPage] = useState('login')
return (
<DataCenter>
{
page === 'index' && <Index setPage={setPage}/>
}
{
page === 'login' && <Login setPage={setPage}/>
}
{
page === 'indexAdmin' && <IndexAdmin setPage={setPage}/>
}
</DataCenter>
<Router>
<DataCenter>
<Switch>
<Route path='/login'>
<Login/>
</Route>
<Route path='/index'>
<Index/>
</Route>
<Route path='/admin'>
<IndexAdmin/>
</Route>
</Switch>
</DataCenter>
</Router>
);
}
......
......@@ -5,7 +5,7 @@ import {NEED_UPDATE_INDEX} from "../../dataCenter/action";
function ToolType (props) {
const {dataCenter, fetchData, updateIndex, dispatch} = useContext(Root)
const [typeId, setTypeId] = useState('all')
const [typeId, setTypeId] = useState(2)
useEffect(()=>{
updateIndex()
......
......@@ -28,3 +28,18 @@
color: #444;
}
}
.childType{
margin-left: 0;
font-size: 15px;
display: flex;
gap: 10px;
justify-content: flex-start;
flex-wrap: nowrap;
overflow-x: auto;
.item-childType{
flex: 0 0 auto;
margin: 0;
}
}
const apiConfig = {
domain: 'http://172.16.229.109:3001',
domain: 'http://' + window.location.hostname + ':3001',
}
export default apiConfig
......@@ -7,18 +7,26 @@ import {useContext, useEffect, useState} from "react";
function Index() {
const [pop, setPop] = useState()
const {fetchData, dataCenter} = useContext(Root)
const showPop = popComponent => {
setPop(popComponent)
}
const getUser = ()=>{
fetchData('/users/getUser', {}, 'userInfo')
.catch(res =>
res.code === 70001 && (window.location.href = '/login')
)
}
useEffect(()=>{
getUser()
},[])
return (
<PopContext.Provider value={{hidePop: () => setPop(''), showPop: popName => showPop(popName)}}>
<div className="index">
<div className="welcome-top">
<span>欢迎您!
<span className="welcome-uname">王天宇</span>
<span className="welcome-uname">{dataCenter?.userInfo?.uname}</span>
<a className="login-btn">退出登录</a>
</span>
</div>
......@@ -26,7 +34,7 @@ function Index() {
<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"></iframe></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/>
......
......@@ -9,6 +9,7 @@ function Login(props) {
const [input, setInput] = useFormState()
const getUser = ()=>{
fetchData('/users/getUser', {}, 'userInfo')
.then(res => res.data.uid && (window.location.href = '/index'))
.catch(res =>
res.code === 70001 && setNeedLogin(true)
)
......@@ -25,7 +26,7 @@ function Login(props) {
}
useEffect(() => {
if (dataCenter.userInfo) {
props.setPage('index')
// window.location.href = '/index'
}
}, [dataCenter.userInfo])
......
......@@ -1191,7 +1191,7 @@
dependencies:
regenerator-runtime "^0.13.4"
"@babel/runtime@^7.10.1", "@babel/runtime@^7.10.2", "@babel/runtime@^7.10.4", "@babel/runtime@^7.11.1", "@babel/runtime@^7.11.2", "@babel/runtime@^7.12.5", "@babel/runtime@^7.5.5", "@babel/runtime@^7.7.2", "@babel/runtime@^7.8.4", "@babel/runtime@^7.9.2":
"@babel/runtime@^7.1.2", "@babel/runtime@^7.10.1", "@babel/runtime@^7.10.2", "@babel/runtime@^7.10.4", "@babel/runtime@^7.11.1", "@babel/runtime@^7.11.2", "@babel/runtime@^7.12.1", "@babel/runtime@^7.12.13", "@babel/runtime@^7.12.5", "@babel/runtime@^7.5.5", "@babel/runtime@^7.7.2", "@babel/runtime@^7.8.4", "@babel/runtime@^7.9.2":
version "7.15.3"
resolved "http://npm.dui88.com:80/@babel%2fruntime/-/runtime-7.15.3.tgz#2e1c2880ca118e5b2f9988322bd8a7656a32502b"
integrity sha1-LhwogMoRjlsvmYgyK9inZWoyUCs=
......@@ -5878,6 +5878,18 @@ hex-color-regex@^1.1.0:
resolved "http://npm.dui88.com:80/hex-color-regex/-/hex-color-regex-1.1.0.tgz#4c06fccb4602fe2602b3c93df82d7e7dbf1a8a8e"
integrity sha1-TAb8y0YC/iYCs8k9+C1+fb8aio4=
history@^4.9.0:
version "4.10.1"
resolved "http://npm.dui88.com:80/history/-/history-4.10.1.tgz#33371a65e3a83b267434e2b3f3b1b4c58aad4cf3"
integrity sha1-MzcaZeOoOyZ0NOKz87G0xYqtTPM=
dependencies:
"@babel/runtime" "^7.1.2"
loose-envify "^1.2.0"
resolve-pathname "^3.0.0"
tiny-invariant "^1.0.2"
tiny-warning "^1.0.0"
value-equal "^1.0.1"
hmac-drbg@^1.0.1:
version "1.0.1"
resolved "http://npm.dui88.com:80/hmac-drbg/-/hmac-drbg-1.0.1.tgz#d2745701025a6c775a6c545793ed502fc0c649a1"
......@@ -5887,6 +5899,13 @@ hmac-drbg@^1.0.1:
minimalistic-assert "^1.0.0"
minimalistic-crypto-utils "^1.0.1"
hoist-non-react-statics@^3.1.0:
version "3.3.2"
resolved "http://npm.dui88.com:80/hoist-non-react-statics/-/hoist-non-react-statics-3.3.2.tgz#ece0acaf71d62c2969c2ec59feff42a4b1a85b45"
integrity sha1-7OCsr3HWLClpwuxZ/v9CpLGoW0U=
dependencies:
react-is "^16.7.0"
hoopy@^0.1.4:
version "0.1.4"
resolved "http://npm.dui88.com:80/hoopy/-/hoopy-0.1.4.tgz#609207d661100033a9a9402ad3dea677381c1b1d"
......@@ -6616,6 +6635,11 @@ is-wsl@^2.1.1, is-wsl@^2.2.0:
dependencies:
is-docker "^2.0.0"
isarray@0.0.1:
version "0.0.1"
resolved "http://npm.dui88.com:80/isarray/-/isarray-0.0.1.tgz#8a18acfca9a8f4177e09abfc6038939b05d1eedf"
integrity sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=
isarray@1.0.0, isarray@^1.0.0, isarray@~1.0.0:
version "1.0.0"
resolved "http://npm.dui88.com:80/isarray/-/isarray-1.0.0.tgz#bb935d48582cba168c06834957a54a3e07124f11"
......@@ -7521,7 +7545,7 @@ loglevel@^1.6.8:
resolved "http://npm.dui88.com:80/loglevel/-/loglevel-1.7.1.tgz#005fde2f5e6e47068f935ff28573e125ef72f197"
integrity sha1-AF/eL15uRwaPk1/yhXPhJe9y8Zc=
loose-envify@^1.0.0, loose-envify@^1.1.0, loose-envify@^1.4.0:
loose-envify@^1.0.0, loose-envify@^1.1.0, loose-envify@^1.2.0, loose-envify@^1.3.1, loose-envify@^1.4.0:
version "1.4.0"
resolved "http://npm.dui88.com:80/loose-envify/-/loose-envify-1.4.0.tgz#71ee51fa7be4caec1a63839f7e682d8132d30caf"
integrity sha1-ce5R+nvkyuwaY4OffmgtgTLTDK8=
......@@ -7764,6 +7788,14 @@ min-indent@^1.0.0:
resolved "http://npm.dui88.com:80/min-indent/-/min-indent-1.0.1.tgz#a63f681673b30571fbe8bc25686ae746eefa9869"
integrity sha1-pj9oFnOzBXH76LwlaGrnRu76mGk=
mini-create-react-context@^0.4.0:
version "0.4.1"
resolved "http://npm.dui88.com:80/mini-create-react-context/-/mini-create-react-context-0.4.1.tgz#072171561bfdc922da08a60c2197a497cc2d1d5e"
integrity sha1-ByFxVhv9ySLaCKYMIZekl8wtHV4=
dependencies:
"@babel/runtime" "^7.12.1"
tiny-warning "^1.0.3"
mini-css-extract-plugin@0.11.3:
version "0.11.3"
resolved "http://npm.dui88.com:80/mini-css-extract-plugin/-/mini-css-extract-plugin-0.11.3.tgz#15b0910a7f32e62ffde4a7430cfefbd700724ea6"
......@@ -8621,6 +8653,13 @@ path-to-regexp@0.1.7:
resolved "http://npm.dui88.com:80/path-to-regexp/-/path-to-regexp-0.1.7.tgz#df604178005f522f15eb4490e7247a1bfaa67f8c"
integrity sha1-32BBeABfUi8V60SQ5yR6G/qmf4w=
path-to-regexp@^1.7.0:
version "1.8.0"
resolved "http://npm.dui88.com:80/path-to-regexp/-/path-to-regexp-1.8.0.tgz#887b3ba9d84393e87a0a0b9f4cb756198b53548a"
integrity sha1-iHs7qdhDk+h6CgufTLdWGYtTVIo=
dependencies:
isarray "0.0.1"
path-type@^1.0.0:
version "1.1.0"
resolved "http://npm.dui88.com:80/path-type/-/path-type-1.1.0.tgz#59c44f7ee491da704da415da5a4070ba4f8fe441"
......@@ -9502,7 +9541,7 @@ prompts@^2.0.1:
kleur "^3.0.3"
sisteransi "^1.0.5"
prop-types@15.x, prop-types@^15.0.0, prop-types@^15.6.0, prop-types@^15.7.2:
prop-types@15.x, prop-types@^15.0.0, prop-types@^15.6.0, prop-types@^15.6.2, prop-types@^15.7.2:
version "15.7.2"
resolved "http://npm.dui88.com:80/prop-types/-/prop-types-15.7.2.tgz#52c41e75b8c87e72b9d9360e0206b99dcbffa6c5"
integrity sha1-UsQedbjIfnK52TYOAga5ncv/psU=
......@@ -10090,7 +10129,7 @@ react-grid-layout@^1.2.5:
react-draggable "^4.0.0"
react-resizable "^3.0.1"
react-is@^16.12.0, react-is@^16.8.1:
react-is@^16.12.0, react-is@^16.6.0, react-is@^16.7.0, react-is@^16.8.1:
version "16.13.1"
resolved "http://npm.dui88.com:80/react-is/-/react-is-16.13.1.tgz#789729a4dc36de2999dc156dd6c1d9c18cea56a4"
integrity sha1-eJcppNw23imZ3BVt1sHZwYzqVqQ=
......@@ -10113,6 +10152,35 @@ react-resizable@^3.0.1:
prop-types "15.x"
react-draggable "^4.0.3"
react-router-dom@^5.2.1:
version "5.2.1"
resolved "http://npm.dui88.com:80/react-router-dom/-/react-router-dom-5.2.1.tgz#34af8b551a4ce17487d3f80e651b91651978dff6"
integrity sha1-NK+LVRpM4XSH0/gOZRuRZRl43/Y=
dependencies:
"@babel/runtime" "^7.12.13"
history "^4.9.0"
loose-envify "^1.3.1"
prop-types "^15.6.2"
react-router "5.2.1"
tiny-invariant "^1.0.2"
tiny-warning "^1.0.0"
react-router@5.2.1, react-router@^5.2.1:
version "5.2.1"
resolved "http://npm.dui88.com:80/react-router/-/react-router-5.2.1.tgz#4d2e4e9d5ae9425091845b8dbc6d9d276239774d"
integrity sha1-TS5OnVrpQlCRhFuNvG2dJ2I5d00=
dependencies:
"@babel/runtime" "^7.12.13"
history "^4.9.0"
hoist-non-react-statics "^3.1.0"
loose-envify "^1.3.1"
mini-create-react-context "^0.4.0"
path-to-regexp "^1.7.0"
prop-types "^15.6.2"
react-is "^16.6.0"
tiny-invariant "^1.0.2"
tiny-warning "^1.0.0"
react-scripts@4.0.3:
version "4.0.3"
resolved "http://npm.dui88.com:80/react-scripts/-/react-scripts-4.0.3.tgz#b1cafed7c3fa603e7628ba0f187787964cb5d345"
......@@ -10498,6 +10566,11 @@ resolve-from@^5.0.0:
resolved "http://npm.dui88.com:80/resolve-from/-/resolve-from-5.0.0.tgz#c35225843df8f776df21c57557bc087e9dfdfc69"
integrity sha1-w1IlhD3493bfIcV1V7wIfp39/Gk=
resolve-pathname@^3.0.0:
version "3.0.0"
resolved "http://npm.dui88.com:80/resolve-pathname/-/resolve-pathname-3.0.0.tgz#99d02224d3cf263689becbb393bc560313025dcd"
integrity sha1-mdAiJNPPJjaJvsuzk7xWAxMCXc0=
resolve-url-loader@^3.1.2:
version "3.1.4"
resolved "http://npm.dui88.com:80/resolve-url-loader/-/resolve-url-loader-3.1.4.tgz#3c16caebe0b9faea9c7cc252fa49d2353c412320"
......@@ -11710,6 +11783,16 @@ timsort@^0.3.0:
resolved "http://npm.dui88.com:80/timsort/-/timsort-0.3.0.tgz#405411a8e7e6339fe64db9a234de11dc31e02bd4"
integrity sha1-QFQRqOfmM5/mTbmiNN4R3DHgK9Q=
tiny-invariant@^1.0.2:
version "1.1.0"
resolved "http://npm.dui88.com:80/tiny-invariant/-/tiny-invariant-1.1.0.tgz#634c5f8efdc27714b7f386c35e6760991d230875"
integrity sha1-Y0xfjv3CdxS384bDXmdgmR0jCHU=
tiny-warning@^1.0.0, tiny-warning@^1.0.3:
version "1.0.3"
resolved "http://npm.dui88.com:80/tiny-warning/-/tiny-warning-1.0.3.tgz#94a30db453df4c643d0fd566060d60a875d84754"
integrity sha1-lKMNtFPfTGQ9D9VmBg1gqHXYR1Q=
tmpl@1.0.x:
version "1.0.4"
resolved "http://npm.dui88.com:80/tmpl/-/tmpl-1.0.4.tgz#23640dd7b42d00433911140820e5cf440e521dd1"
......@@ -12163,6 +12246,11 @@ validate-npm-package-license@^3.0.1:
spdx-correct "^3.0.0"
spdx-expression-parse "^3.0.0"
value-equal@^1.0.1:
version "1.0.1"
resolved "http://npm.dui88.com:80/value-equal/-/value-equal-1.0.1.tgz#1e0b794c734c5c0cade179c437d356d931a34d6c"
integrity sha1-Hgt5THNMXAyt4XnEN9NW2TGjTWw=
vary@~1.1.2:
version "1.1.2"
resolved "http://npm.dui88.com:80/vary/-/vary-1.1.2.tgz#2299f02c6ded30d4a5961b0b9f74524a18f634fc"
......
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