Skip to content

Commit

Permalink
Merge pull request #42 from handong-app/fix/junglesub/kakao-inapp
Browse files Browse the repository at this point in the history
Fix/junglesub/kakao inapp
  • Loading branch information
junglesub authored Nov 1, 2024
2 parents bc66306 + bdcc0ac commit 4225274
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 5 deletions.
44 changes: 44 additions & 0 deletions src/main/front/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,50 @@
);
}
}, 3000);

// In-app 브라우저 Bypass
var inappdeny_exec_vanillajs = (callback) => {
if (document.readyState !== "loading") {
callback();
} else {
document.addEventListener("DOMContentLoaded", callback);
}
};
inappdeny_exec_vanillajs(() => {
/* Do things after DOM has fully loaded */
function copytoclipboard(val) {
var t = document.createElement("textarea");
document.body.appendChild(t);
t.value = val;
t.select();
document.execCommand("copy");
document.body.removeChild(t);
}
function inappbrowserout() {
copytoclipboard(window.location.href);
alert(
'URL주소가 복사되었습니다.\n\nSafari가 열리면 주소창을 길게 터치한 뒤, "붙여놓기 및 이동"를 누르면 정상적으로 이용하실 수 있습니다.'
);
location.href = "x-web-search://?";
}

var useragt = navigator.userAgent.toLowerCase();
var target_url = location.href;

if (useragt.match(/kakaotalk/i)) {
//카카오톡 외부브라우저로 호출
location.href =
"kakaotalk://web/openExternal?url=" +
encodeURIComponent(target_url);
} else if (useragt.match(/line/i)) {
//라인 외부브라우저로 호출
if (target_url.indexOf("?") !== -1) {
location.href = target_url + "&openExternalBrowser=1";
} else {
location.href = target_url + "?openExternalBrowser=1";
}
}
});
</script>
</body>
</html>
16 changes: 11 additions & 5 deletions src/main/front/src/components/modals/ShareModal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,8 @@ const ShareModal = ({ openState, item }) => {
if (navigator.share) {
navigator
.share({
title: "한동피드 공유하기",
title: "한동피드",
text: shareText,
url: shareLink,
})
.then(() => {
setSnackbarMessage("공유 성공!");
Expand All @@ -69,10 +68,17 @@ const ShareModal = ({ openState, item }) => {
handleClose();
};

if (!shareHash) return <></>;
if (!shareHash || !item?.content) return <></>;

const shareLink = `${window.location.origin}/k/${shareHash.shortHash}`;
const shareText = `${item?.content}`;
const prefix = `[한동피드]\n`;
const suffix = `\n\n[한동피드] ${shareLink}`;
const prefixSuffixLen = prefix.length + suffix.length;
const shareText = `${
item.content.length + prefixSuffixLen > 430
? item.content.substr(0, 430) + "(...한동피드에서 더보기)"
: item.content
}${suffix}`;

return (
<>
Expand Down Expand Up @@ -106,7 +112,7 @@ const ShareModal = ({ openState, item }) => {
<TextField
multiline
rows={4}
value={`${shareText}\n\n[ 한동피드 ${shareLink} ]`}
value={`${shareText}`}
variant="outlined"
fullWidth
inputRef={textFieldRef}
Expand Down

0 comments on commit 4225274

Please sign in to comment.