fix: 홈 화면에 추가를 PC Chrome·Edge(설치창을 띄울 수 있는 브라우저)에서도 보이게, PC Safari·Firefox 에선 숨김
This commit is contained in:
1 parent
77d29ce24f
commit
c788430fa7
3 files changed
+16
-8
No files matched your search
@@ -26,7 +26,7 @@ import { cx } from '../lib/utils'
|
|||||||
import { useAuth } from './authContext'
|
import { useAuth } from './authContext'
|
||||||
import { ago, ARTICLE_CAT, articleMeta, AVATAR_COLORS, cardBg, CHARACTERS, dateRange, loadOf, MOODS, shortDay } from './lib'
|
import { ago, ARTICLE_CAT, articleMeta, AVATAR_COLORS, cardBg, CHARACTERS, dateRange, loadOf, MOODS, shortDay } from './lib'
|
||||||
import { GoogleButton } from './googleLogin'
|
import { GoogleButton } from './googleLogin'
|
||||||
import { onPhone, useInstall } from './install'
|
import { useInstall, useInstallable } from './install'
|
||||||
import { InstallSheet } from './installBanner'
|
import { InstallSheet } from './installBanner'
|
||||||
import { MixSheet } from './myGak'
|
import { MixSheet } from './myGak'
|
||||||
import { ownPage, useRegion } from './regionContext'
|
import { ownPage, useRegion } from './regionContext'
|
||||||
@@ -870,6 +870,7 @@ function LoginSheet({ onDone, onLoggedIn }: { onDone: () => void; onLoggedIn: ()
|
|||||||
/* ---------- 내 정보: 캐릭터·닉네임·로그아웃 ---------- */
|
/* ---------- 내 정보: 캐릭터·닉네임·로그아웃 ---------- */
|
||||||
function MeSheet({ onDone }: { onDone: () => void }) {
|
function MeSheet({ onDone }: { onDone: () => void }) {
|
||||||
const install = useInstall()
|
const install = useInstall()
|
||||||
|
const installable = useInstallable()
|
||||||
const { me, logout } = useAuth()
|
const { me, logout } = useAuth()
|
||||||
const queryClient = useQueryClient()
|
const queryClient = useQueryClient()
|
||||||
const update = useMutation(updateMeMutation())
|
const update = useMutation(updateMeMutation())
|
||||||
@@ -905,7 +906,7 @@ function MeSheet({ onDone }: { onDone: () => void }) {
|
|||||||
<Avatar character={me.character} color={me.color} mood={me.mood} size={64} />
|
<Avatar character={me.character} color={me.color} mood={me.mood} size={64} />
|
||||||
<p className="m-0 text-center text-sm font-semibold text-(--ink2)">{me.provider === AuthProvider.GOOGLE ? '구글 계정으로 로그인했어요' : `${me.login_id}(으)로 로그인했어요`}</p>
|
<p className="m-0 text-center text-sm font-semibold text-(--ink2)">{me.provider === AuthProvider.GOOGLE ? '구글 계정으로 로그인했어요' : `${me.login_id}(으)로 로그인했어요`}</p>
|
||||||
</div>
|
</div>
|
||||||
{onPhone() && (
|
{installable && (
|
||||||
<button type="button" onClick={() => install('menu')} className="cursor-pointer rounded-2xl bg-[#fff4ec] py-2.5 font-jua text-[15.5px] text-(--orange)">
|
<button type="button" onClick={() => install('menu')} className="cursor-pointer rounded-2xl bg-[#fff4ec] py-2.5 font-jua text-[15.5px] text-(--orange)">
|
||||||
📲 홈 화면에 추가
|
📲 홈 화면에 추가
|
||||||
</button>
|
</button>
|
||||||
|
|||||||
@@ -37,8 +37,13 @@ export function platform(): Platform {
|
|||||||
return 'other'
|
return 'other'
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 휴대폰에서만 홈 화면 추가를 권한다 (PC 는 안 보임) */
|
const onPhone = () => ['ios', 'android', 'inapp'].includes(platform())
|
||||||
export const onPhone = () => ['ios', 'android', 'inapp'].includes(platform())
|
|
||||||
|
/** 설치를 권할 곳: 휴대폰 브라우저, 그리고 설치창을 띄울 수 있는 PC 브라우저(Chrome·Edge). PC Safari·Firefox 와 이미 설치해 연 화면은 뺀다 */
|
||||||
|
export function useInstallable() {
|
||||||
|
const canPrompt = useCanPrompt()
|
||||||
|
return platform() !== 'standalone' && (onPhone() || canPrompt)
|
||||||
|
}
|
||||||
|
|
||||||
/** 설치창을 바로 띄울 수 있는지 (안드로이드 Chrome 등) */
|
/** 설치창을 바로 띄울 수 있는지 (안드로이드 Chrome 등) */
|
||||||
export function useCanPrompt() {
|
export function useCanPrompt() {
|
||||||
|
|||||||
@@ -1,13 +1,15 @@
|
|||||||
import { useEffect, useState } from 'react'
|
import { useEffect, useState } from 'react'
|
||||||
import { track } from '../lib/analytics'
|
import { track } from '../lib/analytics'
|
||||||
import { dismiss, dismissed, onPhone, platform, useInstall } from './install'
|
import { dismiss, dismissed, platform, useInstall, useInstallable } from './install'
|
||||||
|
|
||||||
const SITE = 'https://weather.o2o.kr'
|
const SITE = 'https://weather.o2o.kr'
|
||||||
|
|
||||||
/** 오늘 탭의 작은 설치 카드. 오늘의 각까지 본 뒤 자리에 놓고, 휴대폰 브라우저에서만 보인다. 닫으면 2주 숨긴다 (홈 화면에서 연 경우·PC 는 안 보임) */
|
/** 오늘 탭의 작은 설치 카드. 오늘의 각까지 본 뒤 자리에 놓고, 설치할 수 있는 곳(휴대폰, PC Chrome·Edge)에서만 보인다. 닫으면 2주 숨긴다 */
|
||||||
export function InstallBanner() {
|
export function InstallBanner() {
|
||||||
const install = useInstall()
|
const install = useInstall()
|
||||||
const [hidden, setHidden] = useState(() => !onPhone() || dismissed())
|
const installable = useInstallable()
|
||||||
|
const [closed, setClosed] = useState(dismissed)
|
||||||
|
const hidden = !installable || closed
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!hidden) track('install_banner_view', {})
|
if (!hidden) track('install_banner_view', {})
|
||||||
@@ -28,7 +30,7 @@ export function InstallBanner() {
|
|||||||
type="button"
|
type="button"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
dismiss()
|
dismiss()
|
||||||
setHidden(true)
|
setClosed(true)
|
||||||
}}
|
}}
|
||||||
className="cursor-pointer rounded-full bg-[#eef4fc] px-3 py-1.5 text-[13px] font-extrabold text-(--ink2)"
|
className="cursor-pointer rounded-full bg-[#eef4fc] px-3 py-1.5 text-[13px] font-extrabold text-(--ink2)"
|
||||||
>
|
>
|
||||||
|
|||||||
Reference in new issue
Block a user