laravel-pwa

所属分类:后台框架
开发工具:PHP
文件大小:248KB
下载次数:0
上传日期:2023-03-15 10:48:35
上 传 者sh-1993
说明:  看起来像个应用程序,感觉像个应用,但不是应用程序。
(Looks like an app, feels like an app, but IS NOT an app.)

文件列表:
Config (0, 2021-04-01)
Config\config.php (2719, 2021-04-01)
Console (0, 2021-04-01)
Console\DeployManifest.php (974, 2021-04-01)
Http (0, 2021-04-01)
Http\Controllers (0, 2021-04-01)
Http\Controllers\LaravelPWAController.php (457, 2021-04-01)
Http\routes.php (217, 2021-04-01)
LICENSE (1069, 2021-04-01)
Providers (0, 2021-04-01)
Providers\LaravelPWAServiceProvider.php (2975, 2021-04-01)
Providers\RouteServiceProvider.php (955, 2021-04-01)
Services (0, 2021-04-01)
Services\ManifestService.php (2529, 2021-04-01)
Services\MetaService.php (362, 2021-04-01)
Tests (0, 2021-04-01)
assets (0, 2021-04-01)
assets\images (0, 2021-04-01)
assets\images\icons (0, 2021-04-01)
assets\images\icons\icon-128x128.png (6754, 2021-04-01)
assets\images\icons\icon-144x144.png (7672, 2021-04-01)
assets\images\icons\icon-152x152.png (8134, 2021-04-01)
assets\images\icons\icon-192x192.png (10580, 2021-04-01)
assets\images\icons\icon-384x384.png (24415, 2021-04-01)
assets\images\icons\icon-512x512.png (22508, 2021-04-01)
assets\images\icons\icon-72x72.png (3252, 2021-04-01)
assets\images\icons\icon-96x96.png (4693, 2021-04-01)
assets\images\icons\splash-1125x2436.png (36047, 2021-04-01)
assets\images\icons\splash-1242x2208.png (30134, 2021-04-01)
assets\images\icons\splash-1242x2688.png (33765, 2021-04-01)
assets\images\icons\splash-1536x2048.png (31551, 2021-04-01)
assets\images\icons\splash-1668x2224.png (34491, 2021-04-01)
assets\images\icons\splash-1668x2388.png (35903, 2021-04-01)
assets\images\icons\splash-2048x2732.png (43341, 2021-04-01)
assets\images\icons\splash-640x1136.png (19254, 2021-04-01)
assets\images\icons\splash-750x1334.png (20970, 2021-04-01)
... ...

# Laravel (PWA) Progressive Web Aplication [![Laravel 5.x](https://img.shields.io/badge/Laravel-5.x-orange.svg)](https://laravel.com/docs/5.8) [![Laravel 6.x](https://img.shields.io/badge/Laravel-6.x-blue.svg)](https://laravel.com/docs/6.x) [![Laravel 7.x](https://img.shields.io/badge/Laravel-7.x-red.svg)](https://laravel.com) [![Latest Stable Version](https://poser.pugx.org/silviolleite/laravelpwa/v/stable)](https://packagist.org/packages/silviolleite/laravelpwa) [![Total Downloads](https://poser.pugx.org/silviolleite/laravelpwa/downloads.png)](https://packagist.org/packages/silviolleite/laravelpwa) [![License](https://img.shields.io/github/license/mashape/apistatus.svg)](https://packagist.org/packages//silviolleite/laravelpwa) This Laravel pakage turns your project into a [progressive web app](https://developers.google.com/web/progressive-web-apps/). Navigating to your site on an Android phone will prompt you to add the app to your home screen. Launching the app from your home screen will display your app. As such, it's critical that your application provides all navigation within the HTML (no reliance on the browser back or forward button). See too the [Laravel PWA Demo](https://github.com/silviolleite/laravel-pwa-demo) Requirements ===== Progressive Web Apps require HTTPS unless being served from localhost. If you're not already using HTTPS on your site, check out [Let's Encrypt](https://letsencrypt.org/) and [ZeroSSL](https://zerossl.com/). ## Installation Add the following to your `composer.json` file : ```json "require": { "silviolleite/laravelpwa": "~2.0.3", }, ``` or execute ```bash composer require silviolleite/laravelpwa --prefer-dist ``` ### Publish ```bash $ php artisan vendor:publish --provider="LaravelPWA\Providers\LaravelPWAServiceProvider" ``` ### Configuration Configure your app name, description, icons and splashes in `config/laravelpwa.php`. ```php 'manifest' => [ 'name' => env('APP_NAME', 'My PWA App'), 'short_name' => 'PWA', 'start_url' => '/', 'background_color' => '#ffffff', 'theme_color' => '#000000', 'display' => 'standalone', 'orientation' => 'any', 'status_bar' => 'black', 'icons' => [ '72x72' => [ 'path' => '/images/icons/icon-72x72.png', 'purpose' => 'any' ], '96x96' => [ 'path' => '/images/icons/icon-96x96.png', 'purpose' => 'any' ], '128x128' => [ 'path' => '/images/icons/icon-128x128.png', 'purpose' => 'any' ], '144x144' => [ 'path' => '/images/icons/icon-144x144.png', 'purpose' => 'any' ], '152x152' => [ 'path' => '/images/icons/icon-152x152.png', 'purpose' => 'any' ], '192x192' => [ 'path' => '/images/icons/icon-192x192.png', 'purpose' => 'any' ], '384x384' => [ 'path' => '/images/icons/icon-384x384.png', 'purpose' => 'any' ], '512x512' => [ 'path' => '/images/icons/icon-512x512.png', 'purpose' => 'any' ], ], 'splash' => [ '***0x1136' => '/images/icons/splash-***0x1136.png', '750x1334' => '/images/icons/splash-750x1334.png', '828x1792' => '/images/icons/splash-828x1792.png', '1125x2436' => '/images/icons/splash-1125x2436.png', '1242x2208' => '/images/icons/splash-1242x2208.png', '1242x2688' => '/images/icons/splash-1242x2688.png', '1536x2048' => '/images/icons/splash-1536x2048.png', '1668x2224' => '/images/icons/splash-1668x2224.png', '1668x2388' => '/images/icons/splash-1668x2388.png', '2048x2732' => '/images/icons/splash-2048x2732.png', ], 'shortcuts' => [ [ 'name' => 'Shortcut Link 1', 'description' => 'Shortcut Link 1 Description', 'url' => '/shortcutlink1', 'icons' => [ "src" => "/images/icons/icon-72x72.png", "purpose" => "any" ] ], [ 'name' => 'Shortcut Link 2', 'description' => 'Shortcut Link 2 Description', 'url' => '/shortcutlink2' ] ], 'custom' => [] ] ``` You can specify the size of each icon as key of the array or specify it: ``` [ 'path' => '/images/icons/icon-512x512.png', 'sizes' => '512x512', 'purpose' => 'any' ], ``` Obs: In the `custom` tag you can insert personalized tags to `manifest.json` like this e.g: ```php ... 'custom' => [ 'tag_name' => 'tag_value', 'tag_name2' => 'tag_value2', ... ] ... ``` Include within your `` the blade directive `@laravelPWA`. ```html My Title ... @laravelPWA ... My content ... ``` This should include the appropriate meta tags, the link to `manifest.json` and the serviceworker script. how this example: ```html ``` Troubleshooting ===== While running the Laravel test server: 1. Verify that `/manifest.json` is being served 1. Verify that `/serviceworker.js` is being served 1. Use the Application tab in the Chrome Developer Tools to verify the progressive web app is configured correctly. 1. Use the "Add to homescreen" link on the Application Tab to verify you can add the app successfully. The Service Worker ===== By default, the service worker implemented by this app is: ```js var staticCacheName = "pwa-v" + new Date().getTime(); var filesToCache = [ '/offline', '/css/app.css', '/js/app.js', '/images/icons/icon-72x72.png', '/images/icons/icon-96x96.png', '/images/icons/icon-128x128.png', '/images/icons/icon-144x144.png', '/images/icons/icon-152x152.png', '/images/icons/icon-192x192.png', '/images/icons/icon-384x384.png', '/images/icons/icon-512x512.png', '/images/icons/splash-***0x1136.png', '/images/icons/splash-750x1334.png', '/images/icons/splash-1242x2208.png', '/images/icons/splash-1125x2436.png', '/images/icons/splash-828x1792.png', '/images/icons/splash-1242x2688.png', '/images/icons/splash-1536x2048.png', '/images/icons/splash-1668x2224.png', '/images/icons/splash-1668x2388.png', '/images/icons/splash-2048x2732.png' ]; // Cache on install self.addEventListener("install", event => { this.skipWaiting(); event.waitUntil( caches.open(staticCacheName) .then(cache => { return cache.addAll(filesToCache); }) ) }); // Clear cache on activate self.addEventListener('activate', event => { event.waitUntil( caches.keys().then(cacheNames => { return Promise.all( cacheNames .filter(cacheName => (cacheName.startsWith("pwa-"))) .filter(cacheName => (cacheName !== staticCacheName)) .map(cacheName => caches.delete(cacheName)) ); }) ); }); // Serve from Cache self.addEventListener("fetch", event => { event.respondWith( caches.match(event.request) .then(response => { return response || fetch(event.request); }) .catch(() => { return caches.match('offline'); }) ) }); ``` To customize service worker functionality, update the `public_path/serviceworker.js`. The offline view ===== By default, the offline view is implemented in `resources/views/vendor/laravelpwa/offline.blade.php` ```html @extends('layouts.app') @section('content')

You are currently not connected to any networks.

@endsection ``` To customize update this file. ## Contributing Contributing is easy! Just fork the repo, make your changes then send a pull request on GitHub. If your PR is languishing in the queue and nothing seems to be happening, then send Silvio an [email](mailto:silviolleite@gmail.com).

近期下载者

相关文件


收藏者