From d908e21fc49b9b33ea0b422a0980b73cc640b42c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BD=95=E8=88=AA?= Date: Fri, 10 Nov 2023 01:23:40 +0800 Subject: [PATCH] Pwa for ios --- web/index.html | 5 +++++ web/scripts/fix.ts | 5 +---- web/src/App.vue | 29 ++++++++++++++++------------- web/src/components/Footer.vue | 2 -- web/src/stores/setting.ts | 10 +++++++++- web/src/utils/utils.ts | 7 +++++++ web/vite.config.ts | 3 ++- 7 files changed, 40 insertions(+), 21 deletions(-) diff --git a/web/index.html b/web/index.html index a39c319..61652cf 100644 --- a/web/index.html +++ b/web/index.html @@ -3,6 +3,11 @@ + + + 音乐和 diff --git a/web/scripts/fix.ts b/web/scripts/fix.ts index 5c96f47..d039c97 100644 --- a/web/scripts/fix.ts +++ b/web/scripts/fix.ts @@ -59,10 +59,7 @@ function transformIndexHtmlHandler(html: string) { prependedHtml += '\n ' + scriptPwa; html = html.replace(matchScript, ''); } - return html.replace( - '', - '' + prependedHtml.replaceAll('="./', '="/musiche/') - ); + return html.replace('', '' + prependedHtml); } export const FixPwaPlugin = function () { diff --git a/web/src/App.vue b/web/src/App.vue index c3a870d..6681149 100644 --- a/web/src/App.vue +++ b/web/src/App.vue @@ -6,7 +6,7 @@ import Footer from './components/Footer.vue'; import CurrentList from './components/CurrentList.vue'; import PlayDetail from './components/PlayDetail.vue'; import WindowHelper from './components/WindowHelper.vue'; -import { webView2Services } from './utils/utils'; +import { isIOS, isInStandaloneMode, webView2Services } from './utils/utils'; import { MusicConnection } from './stores/connection'; import { usePlayStore } from './stores/play'; import { useSettingStore } from './stores/setting'; @@ -29,13 +29,16 @@ iconLink.rel = 'icon'; iconLink.href = LogoCircleImage; document.head.appendChild(iconLink); new MusicConnection(webView2Services.enabled); +let rootClass = webView2Services.enabled ? 'webview-host' : ''; +if (isInStandaloneMode) rootClass += ' standalone'; +if (isIOS) rootClass += ' ios';