feat(pwa): installable PWA + mobile responsive chrome
PWA対応とモバイルUX改善。 - app/manifest.ts: Nextファイルベースでマニフェスト生成(name/short_name/display:standalone/icons 192+512 any+maskable + svg) - public/icon.svg + 生成PNG(192/512): scripts/generate-icons.mjs で sharp を用いてSVGをラスタライズ - public/sw.js: アプリシェルのプリキャッシュ、ナビゲーションはネットワーク優先(オフラインはキャッシュ/'/'にフォールバック)、静的アセットはキャッシュ優先。API/非GET/クロスオリジンはキャッシュせず、res.ok&&basic でエラー/リダイレクト結果を弾く - components/pwa/ServiceWorkerRegister: 本番のみ /sw.js を登録(開発HMRとの衝突回避) - app/layout.tsx: export const viewport(device-width, cover, themeColor) + metadata.icons/appleWebApp - middleware: sw.js/manifest/icon を認証ガードから除外(ログイン前でも取得可能) - ProjectNav: 横スクロールStrip(折り返さない)、Header: モバイルでダッシュボードテキストリンクを非表示
This commit is contained in:
@ -1,12 +1,30 @@
|
||||
import type { Metadata } from 'next';
|
||||
import type { Metadata, Viewport } from 'next';
|
||||
import { cookies } from 'next/headers';
|
||||
import './globals.css';
|
||||
import { I18nProvider } from '@/lib/i18n/I18nProvider';
|
||||
import { ServiceWorkerRegister } from '@/components/pwa/ServiceWorkerRegister';
|
||||
import type { Locale, Theme } from '@/lib/types';
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: 'Groupware',
|
||||
description: 'Project-based team collaboration tool',
|
||||
applicationName: 'Groupware',
|
||||
appleWebApp: {
|
||||
capable: true,
|
||||
statusBarStyle: 'default',
|
||||
title: 'Groupware',
|
||||
},
|
||||
icons: {
|
||||
icon: '/icon.svg',
|
||||
apple: '/icon-192.png',
|
||||
},
|
||||
};
|
||||
|
||||
export const viewport: Viewport = {
|
||||
width: 'device-width',
|
||||
initialScale: 1,
|
||||
viewportFit: 'cover',
|
||||
themeColor: '#2563eb',
|
||||
};
|
||||
|
||||
function resolveTheme(v: string | undefined): Theme {
|
||||
@ -36,6 +54,7 @@ export default async function RootLayout({
|
||||
<I18nProvider initialLocale={locale} initialTheme={theme}>
|
||||
{children}
|
||||
</I18nProvider>
|
||||
<ServiceWorkerRegister />
|
||||
</body>
|
||||
</html>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user