Add PWA support with service worker, manifest, and offline page
This commit is contained in:
67
resources/views/layouts/app.blade.php
Normal file
67
resources/views/layouts/app.blade.php
Normal file
@@ -0,0 +1,67 @@
|
||||
{{-- <link rel="manifest" href="{{ asset('manifest.json') }}">
|
||||
<meta name="theme-color" content="#007bff">
|
||||
<script>
|
||||
if ('serviceWorker' in navigator) {
|
||||
navigator.serviceWorker.register('/service-worker.js')
|
||||
.then(function(registration) {
|
||||
console.log('Service Worker registered with scope:', registration.scope);
|
||||
}).catch(function(err) {
|
||||
console.log('Service Worker registration failed:', err);
|
||||
});
|
||||
}
|
||||
</script> --}}
|
||||
|
||||
{{-- <!DOCTYPE html>
|
||||
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
|
||||
<title>{{ config('app.name', 'Laravel') }}</title>
|
||||
|
||||
<!-- PWA manifest and theme color -->
|
||||
<link rel="manifest" href="{{ asset('manifest.json') }}">
|
||||
<meta name="theme-color" content="#007bff">
|
||||
|
||||
<!-- Styles -->
|
||||
<link href="{{ mix('css/app.css') }}" rel="stylesheet">
|
||||
|
||||
<!-- Service Worker -->
|
||||
<script>
|
||||
if ('serviceWorker' in navigator) {
|
||||
navigator.serviceWorker.register('/service-worker.js')
|
||||
.then(function(registration) {
|
||||
console.log('Service Worker registered with scope:', registration.scope);
|
||||
}).catch(function(err) {
|
||||
console.log('Service Worker registration failed:', err);
|
||||
});
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
@yield('content')
|
||||
</body>
|
||||
</html> --}}
|
||||
<!DOCTYPE html>
|
||||
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
|
||||
<title>@yield('title', 'Weight Scale Validation')</title>
|
||||
|
||||
<!-- Laravel PWA manifest and meta tags -->
|
||||
@PwaHead
|
||||
|
||||
<link href="{{ mix('css/app.css') }}" rel="stylesheet">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
@yield('content')
|
||||
|
||||
<script src="{{ mix('js/app.js') }}"></script>
|
||||
@RegisterServiceWorkerScript
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user