From 320b961205881b3a9e920d121ff3599ab24eba90 Mon Sep 17 00:00:00 2001 From: Gayan Sandamal Date: Mon, 7 Oct 2024 16:49:23 +0530 Subject: [PATCH] Customizable PWA icon support --- nodes/config/ui_base.js | 22 ++++++++++++++++++++++ vite.config.js | 5 +---- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/nodes/config/ui_base.js b/nodes/config/ui_base.js index f7573a283..a4bc95b09 100644 --- a/nodes/config/ui_base.js +++ b/nodes/config/ui_base.js @@ -139,6 +139,28 @@ module.exports = function (RED) { res.sendFile(path.join(__dirname, '../../dist/index.html')) }) + uiShared.app.get('/dashboard/manifest.webmanifest', (req, res) => { + const hasAppIcon = (config.appIcon && config.appIcon.trim() !== '') + const manifest = { + name: 'Node-RED Dashboard 2.0', + short_name: 'Dashboard', + start_url: './', + display: 'standalone', + background_color: '#ffffff', + lang: 'en', + scope: './', + description: 'Node-RED Dashboard 2.0', + theme_color: '#ffffff', + icons: [ + { src: hasAppIcon ? config.appIcon : 'pwa-64x64.png', sizes: '64x64', type: 'image/png' }, + { src: hasAppIcon ? config.appIcon : 'pwa-192x192.png', sizes: '192x192', type: 'image/png' }, + { src: hasAppIcon ? config.appIcon : 'pwa-512x512.png', sizes: '512x512', type: 'image/png' }, + { src: hasAppIcon ? config.appIcon : 'pwa-512x512.png', sizes: '512x512', type: 'image/png', purpose: 'maskable' } + ] + } + return res.json(manifest) + }) + uiShared.app.get(config.path + '/*', uiShared.httpMiddleware, (req, res) => { res.sendFile(path.join(__dirname, '../../dist/index.html')) }) diff --git a/vite.config.js b/vite.config.js index 99e56421f..cd223ffe9 100644 --- a/vite.config.js +++ b/vite.config.js @@ -1,9 +1,6 @@ import vue from '@vitejs/plugin-vue' import { defineConfig } from 'vite' import { VitePWA } from 'vite-plugin-pwa' - -import manifest from './manifest.json' - /** * Vite is used to build the UI for the dashboard, * is is not used for the nodes themselves. @@ -24,7 +21,7 @@ export default defineConfig({ registerType: 'autoUpdate', injectRegister: false, - manifest, + manifest: false, injectManifest: { maximumFileSizeToCacheInBytes: 3000000,