Skip to content

Commit 990589d

Browse files
authored
Merge pull request #165 from DDD-Community/feat/#164
[feat/#164] web share api 사용한 링크 공유 추가
2 parents 2d7f55d + b31cc88 commit 990589d

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/pages/HomePage.tsx

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,25 @@ const REST_API_KEY = import.meta.env.VITE_OAUTH_KAKAO_REST_API_KEY
66
const REDIRECT_URI = import.meta.env.VITE_OAUTH_KAKAO_REDIRECT_URI
77
const LOGIN_LINK = `https://kauth.kakao.com/oauth/authorize?client_id=${REST_API_KEY}&redirect_uri=${REDIRECT_URI}&response_type=code`
88

9+
const SHARE_DATA = {
10+
title: "자세공작소와 함께하는 일상의 변화",
11+
url: window.location.origin,
12+
}
13+
914
const HomePage: React.FC = () => {
1015
const loginHandler = (): void => {
1116
window.location.href = LOGIN_LINK
1217
}
1318

19+
const shareLinkHandler = async (): Promise<void> => {
20+
try {
21+
await navigator.share(SHARE_DATA)
22+
console.log("공유 성공")
23+
} catch (e) {
24+
console.log("공유 실패")
25+
}
26+
}
27+
1428
useEffect(() => {
1529
logAnalytics("view_login")
1630
}, [])
@@ -33,6 +47,12 @@ const HomePage: React.FC = () => {
3347
>
3448
카카오톡으로 계속하기
3549
</div>
50+
<div
51+
className="flex w-fit cursor-pointer rounded-full bg-zinc-900 px-7 py-2 leading-[34px] text-white"
52+
onClick={shareLinkHandler}
53+
>
54+
링크 공유
55+
</div>
3656
</div>
3757
<div className="absolute bottom-0 left-10 h-[292px] w-[528px]">
3858
<img src={IntroImage} alt="Intro" />

0 commit comments

Comments
 (0)