Skip to content

Commit

Permalink
Merge pull request #475 from LikeLion-at-DGU/dev
Browse files Browse the repository at this point in the history
🚀 Deploy
  • Loading branch information
Chaem03 authored Aug 6, 2024
2 parents 3e467ca + d68933f commit 4c53d30
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
10 changes: 5 additions & 5 deletions src/pages/Share/Share.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const SharePage = () => {
try {
const res = await getStarContent(starid);
setStarP(res);
console.log(res);
} catch (error) {
console.error("Error fetching star data:", error);
}
Expand All @@ -35,14 +36,13 @@ const SharePage = () => {

const handleCapture = async () => {
setIsButtonVisible(false);
try {

setTimeout(async () => {
const canvas = await html2canvas(captureRef.current, { useCORS: true });
await captureScreenshot(canvas);
} catch (error) {
console.error("Error capturing screenshot:", error);
} finally {
setIsButtonVisible(true);
}
console.log("버튼 true설정 완료");
}, 100);
};

const starData = starP && starP.data ? starP.data : null;
Expand Down
8 changes: 6 additions & 2 deletions src/utils/share.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,18 @@ export const captureScreenshot = async (canvas) => {

// Web Share API 사용
if (navigator.share) {
alert("클릭");
navigator
.share({
files: [new File([blob], "start.png", { type: "image/png" })],
title: "STAR.T",
text: "likelion-start.site",
})
.then(() => console.log("Share was successful."))
.catch((error) => console.log("Sharing failed", error));
.then(() => alert("성공"))
.catch((error) => {
console.log("Sharing failed", error);
alert(error);
});
} else {
alert("모바일 기기에서 실행해주세요!");
}
Expand Down

0 comments on commit 4c53d30

Please sign in to comment.