Showing
7 changed files
with
40 additions
and
28 deletions
... | @@ -10,13 +10,17 @@ import Header from "./views/header"; | ... | @@ -10,13 +10,17 @@ import Header from "./views/header"; |
10 | import Body from "./views/body"; | 10 | import Body from "./views/body"; |
11 | import Footer from "./views/footer"; | 11 | import Footer from "./views/footer"; |
12 | import './assets/style/App.scss'; | 12 | import './assets/style/App.scss'; |
13 | +import {getState} from "@src/store/state"; | ||
13 | 14 | ||
14 | const App = (pathname : string) : string => { | 15 | const App = (pathname : string) : string => { |
16 | + /* id 없을 시 id 입력으로 redirect */ | ||
17 | + if(!getState().insta_id) pathname = ''; | ||
18 | + | ||
15 | history.pushState('','', pathname); | 19 | history.pushState('','', pathname); |
16 | 20 | ||
17 | return ` | 21 | return ` |
18 | <div class="container"> | 22 | <div class="container"> |
19 | - ${Header()} | 23 | + ${pathname && Header()} |
20 | ${Body(pathname)} | 24 | ${Body(pathname)} |
21 | </div> | 25 | </div> |
22 | ${Footer()} | 26 | ${Footer()} | ... | ... |
1 | .footer { | 1 | .footer { |
2 | height: 120px; | 2 | height: 120px; |
3 | - background-color: #afafaf; | 3 | + background-color: #f3f3f3; |
4 | display: flex; | 4 | display: flex; |
5 | justify-content: center; | 5 | justify-content: center; |
6 | align-items: center; | 6 | align-items: center; |
7 | font-size: .8rem; | 7 | font-size: .8rem; |
8 | width: 100%; | 8 | width: 100%; |
9 | - color: #fafafa; | 9 | + color: #aaaaaa; |
10 | } | 10 | } |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
... | @@ -6,7 +6,7 @@ | ... | @@ -6,7 +6,7 @@ |
6 | 6 | ||
7 | import {BASE_URL} from "@src/config/url"; | 7 | import {BASE_URL} from "@src/config/url"; |
8 | import {randomTransition} from "@src/components/pageTransition"; | 8 | import {randomTransition} from "@src/components/pageTransition"; |
9 | -import {getState, setState} from "@src/store/state"; | 9 | +import {setState} from "@src/store/state"; |
10 | 10 | ||
11 | export const addEvent = async ( | 11 | export const addEvent = async ( |
12 | e : Event, | 12 | e : Event, |
... | @@ -38,11 +38,7 @@ export const addEvent = async ( | ... | @@ -38,11 +38,7 @@ export const addEvent = async ( |
38 | console.log('res!',result); | 38 | console.log('res!',result); |
39 | result && $App && (()=>{ | 39 | result && $App && (()=>{ |
40 | randomTransition(); | 40 | randomTransition(); |
41 | - setState({ | 41 | + setState(result); |
42 | - insta_id : insta_id, | ||
43 | - followers : result.followers, | ||
44 | - following : result.following | ||
45 | - }); | ||
46 | setTimeout(()=>{ | 42 | setTimeout(()=>{ |
47 | $App.innerHTML = App('main'); | 43 | $App.innerHTML = App('main'); |
48 | },1200) | 44 | },1200) |
... | @@ -66,11 +62,7 @@ export const addEvent = async ( | ... | @@ -66,11 +62,7 @@ export const addEvent = async ( |
66 | console.log(result); | 62 | console.log(result); |
67 | result && $App && (()=>{ | 63 | result && $App && (()=>{ |
68 | randomTransition(); | 64 | randomTransition(); |
69 | - setState({ | 65 | + setState(result); |
70 | - insta_id : insta_id, | ||
71 | - followers : result.followers, | ||
72 | - following : result.following | ||
73 | - }); | ||
74 | setTimeout(()=>{ | 66 | setTimeout(()=>{ |
75 | $App.innerHTML = App('main'); | 67 | $App.innerHTML = App('main'); |
76 | },1200) | 68 | },1200) | ... | ... |
app/src/store/index.ts
deleted
100644 → 0
1 | -export {default} from './state'; |
... | @@ -8,13 +8,15 @@ | ... | @@ -8,13 +8,15 @@ |
8 | export interface StateType{ | 8 | export interface StateType{ |
9 | insta_id? : string, | 9 | insta_id? : string, |
10 | followers? : Array<string>, | 10 | followers? : Array<string>, |
11 | - following? : Array<string> | 11 | + following? : Array<string>, |
12 | + src? : string | ||
12 | } | 13 | } |
13 | 14 | ||
14 | const initialState = { | 15 | const initialState = { |
15 | insta_id : '', | 16 | insta_id : '', |
16 | followers : [''], | 17 | followers : [''], |
17 | following : [''], | 18 | following : [''], |
19 | + src : '', | ||
18 | } | 20 | } |
19 | let state: StateType = initialState; | 21 | let state: StateType = initialState; |
20 | 22 | ||
... | @@ -27,6 +29,4 @@ export const setState = (newState: StateType): void => { | ... | @@ -27,6 +29,4 @@ export const setState = (newState: StateType): void => { |
27 | 29 | ||
28 | export const getState = () => { | 30 | export const getState = () => { |
29 | return state | 31 | return state |
30 | -} | 32 | +} |
31 | - | ||
32 | -export default state; | ||
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
... | @@ -5,20 +5,33 @@ | ... | @@ -5,20 +5,33 @@ |
5 | * 업데이트하기 | 5 | * 업데이트하기 |
6 | * 다른 메뉴 보기 | 6 | * 다른 메뉴 보기 |
7 | **/ | 7 | **/ |
8 | -import state from "@src/store"; | ||
9 | import {getState} from "@src/store/state"; | 8 | import {getState} from "@src/store/state"; |
10 | 9 | ||
11 | const Main = () => { | 10 | const Main = () => { |
12 | - let contents = `<div>${state.insta_id}</div>` | 11 | + const state = getState(); |
13 | - | 12 | + let followers : string = ''; |
14 | - contents += getState().followers?.map(id => `<div>followers ${id}</div>`) | 13 | + let following : string = ''; |
15 | - | 14 | + state.followers?.forEach(id => { |
16 | - contents += getState().following?.map(id => `<div>following ${id}</div>`) | 15 | + followers += `<div>${id}</div>` |
16 | + }); | ||
17 | + state.following?.forEach(id => { | ||
18 | + following += `<div>${id}</div>` | ||
19 | + }); | ||
17 | 20 | ||
18 | return ` | 21 | return ` |
19 | <div class="main"> | 22 | <div class="main"> |
20 | - its main | 23 | + <div id="profile"> |
21 | - ${contents} | 24 | + <img src="${state.src}" alt="${state.insta_id}-image"/> |
25 | + <span class="profile-id">${state.insta_id}</span> | ||
26 | + </div> | ||
27 | + <div id="list"> | ||
28 | + <div id="followers"> | ||
29 | + ${followers} | ||
30 | + </div> | ||
31 | + <div id="following"> | ||
32 | + ${following} | ||
33 | + </div> | ||
34 | + </div> | ||
22 | </div> | 35 | </div> |
23 | ` | 36 | ` |
24 | } | 37 | } | ... | ... |
... | @@ -35,6 +35,9 @@ def login(driver): | ... | @@ -35,6 +35,9 @@ def login(driver): |
35 | 35 | ||
36 | 36 | ||
37 | def get_list(insta_id, driver): | 37 | def get_list(insta_id, driver): |
38 | + # get profile src | ||
39 | + src = driver.find_element_by_css_selector('.XjzKX .RR-M- span img').get_attribute('src') | ||
40 | + | ||
38 | # check followers | 41 | # check followers |
39 | followers_list = check_people(driver, "followers") | 42 | followers_list = check_people(driver, "followers") |
40 | 43 | ||
... | @@ -49,7 +52,8 @@ def get_list(insta_id, driver): | ... | @@ -49,7 +52,8 @@ def get_list(insta_id, driver): |
49 | data = { | 52 | data = { |
50 | "followers" : followers_list, | 53 | "followers" : followers_list, |
51 | "following" : following_list, | 54 | "following" : following_list, |
52 | - "insta_id" : insta_id | 55 | + "insta_id" : insta_id, |
56 | + "src" : src | ||
53 | } | 57 | } |
54 | update_data(insta_id, data) | 58 | update_data(insta_id, data) |
55 | 59 | ... | ... |
-
Please register or login to post a comment