Toggle navigation
Toggle navigation
This project
Loading...
Sign in
최은석
/
ossw-project
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
최은석
2022-06-04 19:27:56 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
ae1ff31b659f0067d11cc26f29cb1537dec7fe31
ae1ff31b
1 parent
2ac98b6c
connect main page with today post & change todayMenu from GET to POST
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
49 additions
and
41 deletions
client/src/Component/mainpage.js
client/src/index.js
server/Router/api.js
client/src/Component/mainpage.js
View file @
ae1ff31
import
'./App.css'
;
import
axios
from
"axios"
;
import
{
useEffect
,
useState
}
from
'react'
;
import
'./
MainP
age.css'
import
'./
mainp
age.css'
function
InnerContent
(
props
){
function
InnerContent
(
props
)
{
return
(
<
div
>
<
div
style
=
{{
fontSize
:
'15px'
,
height
:
'10px'
,
width
:
'100%'
,
backgroundColor
:
'#FDF5E6'
}}
>
{
props
.
title
}
{
props
.
content
}
<
/div
>
<
div
style
=
{{
fontSize
:
'15px'
,
height
:
'10px'
,
width
:
'100%'
,
backgroundColor
:
'#FDF5E6'
}}
>
{
props
.
title
}
{
props
.
content
}
<
/div
>
<
/div
>
);
}
function
MainPage
()
{
const
[
list
,
setList
]
=
useState
([{
title
:
'하이'
,
content
:
'바보'
},{
title
:
'하이2'
,
content
:
'바보2'
},{
title
:
'하이3'
,
content
:
'바보3'
}]);
const
[
list
,
setList
]
=
useState
([{
title
:
'하이'
,
content
:
'바보'
},
{
title
:
'하이2'
,
content
:
'바보2'
},
{
title
:
'하이3'
,
content
:
'바보3'
}]);
let
currentYear
=
new
Date
().
getFullYear
();
let
currentMonth
=
new
Date
().
getMonth
();
let
currentMonth
=
new
Date
().
getMonth
()
+
1
;
let
currentDate
=
new
Date
().
getDate
();
let
today
=
currentYear
+
'/'
+
currentMonth
+
'/'
+
currentDate
;
const
todayMealTable
=
async
()
=>
{
let
today
=
currentYear
+
'/'
+
currentMonth
+
'/'
+
currentDate
;
const
todayMealTable
=
async
()
=>
{
axios
.
get
(
"/api/todayMenu"
).
then
(
(
res
)
=>
{
const
makeTable
=
(
arr_
,
dom_
)
=>
{
arr_
.
forEach
((
elem
)
=>
{
arr_
.
forEach
((
elem
)
=>
{
let
span_
=
document
.
createElement
(
'div'
);
span_
.
innerHTML
=
elem
;
dom_
.
appendChild
(
span_
);
});
};
const
index1
=
res
.
data
[
0
].
indexOf
(
':'
);
const
index2
=
res
.
data
[
1
].
indexOf
(
':'
);
let
lunchArr
=
res
.
data
[
0
].
substring
(
index1
+
1
);
let
dinnerArr
=
res
.
data
[
1
].
substring
(
index2
+
1
);
};
const
lunchDom
=
document
.
getElementsByClassName
(
'lunchTable'
)[
0
];
const
dinnerDom
=
document
.
getElementsByClassName
(
'dinnerTable'
)[
0
];
if
(
res
.
data
!==
"weekend"
)
{
const
index1
=
res
.
data
[
0
].
indexOf
(
':'
);
const
index2
=
res
.
data
[
1
].
indexOf
(
':'
);
let
lunchArr
=
res
.
data
[
0
].
substring
(
index1
+
1
);
console
.
log
(
lunchArr
)
let
dinnerArr
=
res
.
data
[
1
].
substring
(
index2
+
1
);
if
(
index1
!==
-
1
)
{
lunchArr
=
lunchArr
.
split
(
','
);
}
if
(
index1
!==
-
1
)
{
dinnerArr
=
dinnerArr
.
split
(
','
);
}
if
(
index1
!==
-
1
){
lunchArr
=
lunchArr
.
split
(
','
);
makeTable
(
lunchArr
,
lunchDom
);
makeTable
(
dinnerArr
,
dinnerDom
);
}
if
(
index1
!==
-
1
){
dinnerArr
=
dinnerArr
.
split
(
','
);
else
{
makeTable
([
"오늘은"
],
lunchDom
);
makeTable
([
"주말입니다."
],
dinnerDom
);
}
const
lunchDom
=
document
.
getElementsByClassName
(
'lunchTable'
)[
0
];
const
dinnerDom
=
document
.
getElementsByClassName
(
'dinnerTable'
)[
0
];
makeTable
(
lunchArr
,
lunchDom
);
makeTable
(
dinnerArr
,
dinnerDom
);
}
)
};
const
todayInnerContent
=
async
()
=>
{
// 게시글 목록 가져오기
axios
.
get
(
'/api/get'
).
then
((
res
)
=>
{
const
todayInnerContent
=
async
()
=>
{
// 게시글 목록 가져오기
const
arr
=
(
await
axios
.
get
(
'/api/getList'
)).
data
;
var
idArray
=
[];
for
(
var
id
of
arr
)
idArray
.
push
(
id
);
axios
.
post
(
'/api/get'
,{
idArray
:
idArray
}).
then
((
res
)
=>
{
setList
(
res
.
data
);
console
.
log
(
res
.
data
);
}
);
})
}
useEffect
(()
=>
{
useEffect
(()
=>
{
todayMealTable
();
todayInnerContent
();
},
[]);
return
(
<
div
className
=
'mainpage'
>
<
div
>
<
div
className
=
'haksikTitle'
>
{
today
}
제
2
기숙사
학식
...
...
@@ -76,17 +86,15 @@ function MainPage() {
<
div
><
/div
>
<
div
>
점심
<
/div
>
<
div
>
저녁
<
/div
>
<
div
className
=
'lunchTable'
>
<
/div
>
<
div
className
=
'lunchTable'
><
/div
>
<
div
className
=
'dinnerTable'
><
/div
>
<
/div
>
<
div
className
=
'mainpageUnder'
>
<
div
>
메뉴에
대한
이야기
<
/div
>
<
div
>
{
list
.
map
((
item
,
index
)
=>
{
return
(
<
InnerContent
key
=
{
index
}
title
=
{
item
.
title
}
content
=
{
item
.
content
}
/
>
{
list
.
map
((
item
,
index
)
=>
{
return
(
<
InnerContent
key
=
{
index
}
title
=
{
item
.
title
}
content
=
{
item
.
content
}
/
>
)
})}
<
/div
>
...
...
client/src/index.js
View file @
ae1ff31
...
...
@@ -7,7 +7,7 @@ import 'bootstrap/dist/css/bootstrap.min.css';
//컴포넌트
import
TopBanner
from
'./Component/TopBanner'
;
// 상단 메뉴
import
SideChat
from
'./Component/SideChat'
;
// 측면 대기시간 채팅
import
MainPage
from
'./Component/
MainP
age'
;
// 초기화면
import
MainPage
from
'./Component/
mainp
age'
;
// 초기화면
import
MenuPage
from
'./Component/MenuPage'
;
// 학식 메뉴 화면
import
Writing
from
'./Component/Writing'
;
// 글 작성 화면
...
...
server/Router/api.js
View file @
ae1ff31
...
...
@@ -80,7 +80,7 @@ router.get('/api/getList/:date', async (req, res) => {
}
});
router
.
ge
t
(
'/api/get'
,
async
(
req
,
res
)
=>
{
// 특정 id(여러개)의 게시물 내용 요약 불러오기
router
.
pos
t
(
'/api/get'
,
async
(
req
,
res
)
=>
{
// 특정 id(여러개)의 게시물 내용 요약 불러오기
try
{
const
idArray
=
req
.
body
.
idArray
;
var
resultArray
=
[];
...
...
Please
register
or
login
to post a comment