|
| 1 | +<script setup lang="ts"> |
| 2 | +import Tag from 'primevue/tag' |
| 3 | +import Dialog from 'primevue/dialog' |
| 4 | +import Button from 'primevue/button' |
| 5 | +import { usePwaInstall } from '../composables/usePwaInstall' |
| 6 | +import SettingsCard from './SettingsCard.vue' |
| 7 | +
|
| 8 | +const { |
| 9 | + canInstall, |
| 10 | + isInstalled, |
| 11 | + isIos, |
| 12 | + isStandalone, |
| 13 | + showIosInstallGuide, |
| 14 | + promptInstall, |
| 15 | + dismissIosGuide |
| 16 | +} = usePwaInstall() |
| 17 | +
|
| 18 | +async function handleInstall() { |
| 19 | + await promptInstall() |
| 20 | +} |
| 21 | +</script> |
| 22 | + |
| 23 | +<template> |
| 24 | + <SettingsCard header="App"> |
| 25 | + <!-- 既にインストール済み(スタンドアロンモード) --> |
| 26 | + <div v-if="isStandalone" class="settings-item"> |
| 27 | + <div class="item-content"> |
| 28 | + <div class="item-left"> |
| 29 | + <i class="pi pi-check-circle item-icon" style="color: var(--p-green-500);"></i> |
| 30 | + <span class="item-label">Installed as App</span> |
| 31 | + </div> |
| 32 | + <Tag severity="success" value="Active" /> |
| 33 | + </div> |
| 34 | + </div> |
| 35 | + |
| 36 | + <!-- インストール可能(非iOS) --> |
| 37 | + <button |
| 38 | + v-else-if="canInstall && !isIos" |
| 39 | + class="settings-item clickable" |
| 40 | + @click="handleInstall" |
| 41 | + > |
| 42 | + <div class="item-content"> |
| 43 | + <div class="item-left"> |
| 44 | + <i class="pi pi-download item-icon"></i> |
| 45 | + <span class="item-label">Install App</span> |
| 46 | + </div> |
| 47 | + <div class="item-right"> |
| 48 | + <Tag severity="info" value="Available" /> |
| 49 | + <i class="pi pi-chevron-right item-chevron"></i> |
| 50 | + </div> |
| 51 | + </div> |
| 52 | + </button> |
| 53 | + |
| 54 | + <!-- iOS用インストールガイド --> |
| 55 | + <button |
| 56 | + v-else-if="canInstall && isIos" |
| 57 | + class="settings-item clickable" |
| 58 | + @click="handleInstall" |
| 59 | + > |
| 60 | + <div class="item-content"> |
| 61 | + <div class="item-left"> |
| 62 | + <i class="pi pi-apple item-icon"></i> |
| 63 | + <span class="item-label">Add to Home Screen</span> |
| 64 | + </div> |
| 65 | + <div class="item-right"> |
| 66 | + <i class="pi pi-chevron-right item-chevron"></i> |
| 67 | + </div> |
| 68 | + </div> |
| 69 | + </button> |
| 70 | + |
| 71 | + <!-- インストール不可(ブラウザが非対応など) --> |
| 72 | + <div v-else-if="!isInstalled && !canInstall" class="settings-item"> |
| 73 | + <div class="item-content"> |
| 74 | + <div class="item-left"> |
| 75 | + <i class="pi pi-info-circle item-icon" style="color: var(--p-text-muted-color);"></i> |
| 76 | + <div class="item-text"> |
| 77 | + <span class="item-label">Install App</span> |
| 78 | + <span class="item-description">Not supported in this browser</span> |
| 79 | + </div> |
| 80 | + </div> |
| 81 | + </div> |
| 82 | + </div> |
| 83 | + |
| 84 | + <!-- iOS インストールガイドダイアログ --> |
| 85 | + <Dialog |
| 86 | + v-model:visible="showIosInstallGuide" |
| 87 | + modal |
| 88 | + header="Add to Home Screen" |
| 89 | + :style="{ width: '90vw', maxWidth: '400px' }" |
| 90 | + > |
| 91 | + <div class="ios-guide"> |
| 92 | + <ol class="ios-guide-steps"> |
| 93 | + <li> |
| 94 | + <div class="step-content"> |
| 95 | + <span>Tap the</span> |
| 96 | + <i class="pi pi-ellipsis-h menu-icon"></i> |
| 97 | + <span>menu button at bottom right</span> |
| 98 | + </div> |
| 99 | + </li> |
| 100 | + <li> |
| 101 | + <div class="step-content"> |
| 102 | + <span>Select "Share" then tap "More"</span> |
| 103 | + </div> |
| 104 | + </li> |
| 105 | + <li> |
| 106 | + <div class="step-content"> |
| 107 | + <span>Select "Add to Home Screen"</span> |
| 108 | + </div> |
| 109 | + </li> |
| 110 | + <li> |
| 111 | + <div class="step-content"> |
| 112 | + <span>Tap "Add" to complete</span> |
| 113 | + </div> |
| 114 | + </li> |
| 115 | + </ol> |
| 116 | + </div> |
| 117 | + <template #footer> |
| 118 | + <Button label="Close" @click="dismissIosGuide" /> |
| 119 | + </template> |
| 120 | + </Dialog> |
| 121 | + </SettingsCard> |
| 122 | +</template> |
| 123 | + |
| 124 | +<style scoped> |
| 125 | +.ios-guide { |
| 126 | + padding: 0.5rem 0; |
| 127 | +} |
| 128 | +
|
| 129 | +.ios-guide-steps { |
| 130 | + margin: 0; |
| 131 | + padding: 0 0 0 1.5rem; |
| 132 | + display: flex; |
| 133 | + flex-direction: column; |
| 134 | + gap: 1rem; |
| 135 | +} |
| 136 | +
|
| 137 | +.ios-guide-steps li { |
| 138 | + font-size: 0.9375rem; |
| 139 | + line-height: 1.5; |
| 140 | +} |
| 141 | +
|
| 142 | +.step-content { |
| 143 | + display: flex; |
| 144 | + align-items: center; |
| 145 | + gap: 0.375rem; |
| 146 | + flex-wrap: wrap; |
| 147 | +} |
| 148 | +
|
| 149 | +.menu-icon { |
| 150 | + display: inline-flex; |
| 151 | + align-items: center; |
| 152 | + justify-content: center; |
| 153 | + width: 1.75rem; |
| 154 | + height: 1.75rem; |
| 155 | + background: var(--p-surface-200); |
| 156 | + color: var(--p-text-color); |
| 157 | + border-radius: 0.375rem; |
| 158 | + font-size: 0.875rem; |
| 159 | +} |
| 160 | +</style> |
0 commit comments