fix: Fix manifest PWA non registrato correttamente
This commit is contained in:
parent
83d1c1ddd4
commit
e894086b4c
|
@ -4,6 +4,7 @@ import {createInertiaApp} from '@maicol07/inertia-mithril';
|
||||||
import {showSnackbar} from '@osm/utils/misc';
|
import {showSnackbar} from '@osm/utils/misc';
|
||||||
import Mithril from 'mithril';
|
import Mithril from 'mithril';
|
||||||
import Stream from 'mithril/stream';
|
import Stream from 'mithril/stream';
|
||||||
|
import {pwaInfo} from 'virtual:pwa-info';
|
||||||
import {registerSW} from 'virtual:pwa-register';
|
import {registerSW} from 'virtual:pwa-register';
|
||||||
|
|
||||||
import {resolvePage} from '~inertia';
|
import {resolvePage} from '~inertia';
|
||||||
|
@ -63,3 +64,15 @@ const updateSW = registerSW({
|
||||||
void showSnackbar(__('È ora possibile lavorare offline!'), false);
|
void showSnackbar(__('È ora possibile lavorare offline!'), false);
|
||||||
}
|
}
|
||||||
}) as (reloadPage?: boolean) => Promise<void>;
|
}) as (reloadPage?: boolean) => Promise<void>;
|
||||||
|
|
||||||
|
if (pwaInfo) {
|
||||||
|
const {href, useCredentials} = pwaInfo.webManifest;
|
||||||
|
/* Add link to head: href is the link */
|
||||||
|
const linkElement = document.createElement('link');
|
||||||
|
linkElement.setAttribute('rel', 'manifest');
|
||||||
|
linkElement.setAttribute('href', href);
|
||||||
|
if (useCredentials) {
|
||||||
|
linkElement.setAttribute('crossorigin', 'use-credentials');
|
||||||
|
}
|
||||||
|
document.head.append(linkElement);
|
||||||
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
// noinspection JSFileReferences,JSUnusedGlobalSymbols,LocalVariableNamingConventionJS
|
// noinspection JSFileReferences,JSUnusedGlobalSymbols,LocalVariableNamingConventionJS
|
||||||
import 'inertia-plugin/client';
|
import 'inertia-plugin/client';
|
||||||
import 'vite-plugin-pwa/client.d';
|
import 'vite-plugin-pwa/client.d';
|
||||||
|
import 'vite-plugin-pwa/info.d';
|
||||||
import 'vite/client';
|
import 'vite/client';
|
||||||
|
|
||||||
import type Mithril from 'mithril';
|
import type Mithril from 'mithril';
|
||||||
|
|
|
@ -65,7 +65,12 @@ export default defineConfig(async () => {
|
||||||
assetsInclude: '**/*.xml',
|
assetsInclude: '**/*.xml',
|
||||||
build: {
|
build: {
|
||||||
sourcemap: true,
|
sourcemap: true,
|
||||||
target: 'esnext'
|
target: 'esnext',
|
||||||
|
rollupOptions: {
|
||||||
|
output: {
|
||||||
|
assetFileNames: '[name].[ext]'
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
resolve: {
|
resolve: {
|
||||||
alias: aliases
|
alias: aliases
|
||||||
|
@ -102,15 +107,11 @@ export default defineConfig(async () => {
|
||||||
// }),
|
// }),
|
||||||
VitePWA({
|
VitePWA({
|
||||||
registerType: 'autoUpdate',
|
registerType: 'autoUpdate',
|
||||||
outDir: 'public',
|
buildBase: '/build/',
|
||||||
buildBase: '/',
|
|
||||||
scope: '/',
|
|
||||||
// TODO: Check options
|
|
||||||
includeAssets: [
|
includeAssets: [
|
||||||
'resources/images/favicon/favicon.ico',
|
'build/assets/*.ico',
|
||||||
'../robots.txt',
|
'robots.txt',
|
||||||
'resources/images/favicon/apple-touch-icon.png',
|
'build/assets/*.png'
|
||||||
'resources/images/*.png'
|
|
||||||
],
|
],
|
||||||
manifest: {
|
manifest: {
|
||||||
name: 'OpenSTAManager',
|
name: 'OpenSTAManager',
|
||||||
|
@ -119,7 +120,6 @@ export default defineConfig(async () => {
|
||||||
categories: ['business', 'productivity'],
|
categories: ['business', 'productivity'],
|
||||||
display: 'minimal-ui',
|
display: 'minimal-ui',
|
||||||
theme_color: '#3f3f3f',
|
theme_color: '#3f3f3f',
|
||||||
background_color: '#fffff',
|
|
||||||
icons: [
|
icons: [
|
||||||
{
|
{
|
||||||
src: 'android-chrome-192x192.png',
|
src: 'android-chrome-192x192.png',
|
||||||
|
@ -134,8 +134,7 @@ export default defineConfig(async () => {
|
||||||
{
|
{
|
||||||
src: 'android-chrome-512x512.png',
|
src: 'android-chrome-512x512.png',
|
||||||
sizes: '512x512',
|
sizes: '512x512',
|
||||||
type: 'image/png',
|
type: 'image/png'
|
||||||
purpose: 'any maskable'
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue