Compare commits

..

1 Commits

Author SHA1 Message Date
Diego
57a4038577 pwa安装提示优化 2025-06-12 10:20:52 +08:00
6 changed files with 53 additions and 13 deletions

View File

@@ -1,9 +1,9 @@
<Project>
<PropertyGroup>
<PluginVersion>10.7.52</PluginVersion>
<ProPluginVersion>10.7.52</ProPluginVersion>
<AuthenticationVersion>2.5.0</AuthenticationVersion>
<PluginVersion>10.7.53</PluginVersion>
<ProPluginVersion>10.7.53</ProPluginVersion>
<AuthenticationVersion>2.6.0</AuthenticationVersion>
<NET8Version>8.0.17</NET8Version>
<NET9Version>9.0.6</NET9Version>
</PropertyGroup>

View File

@@ -105,11 +105,12 @@ public partial class PluginDebugPage
Title = pluginInfo.Name,
ContentTemplate = debugRender,
Max = false,
Width = "1440px",
Height = "810px",
Top = "70px",
Left = "220px",
Width = "80%",
Height = "80%",
Top = "0%",
Left = "10%",
Background = "var(--bb-primary-color)",
Overflow = true
};
await WinBoxService.Show(option);
}

View File

@@ -45,6 +45,42 @@
<!-- PWA Service Worker -->
<script type="text/javascript">'serviceWorker' in navigator && navigator.serviceWorker.register('./service-worker.js')</script>
<script>
let installPromptTriggered = false;
function getCookie(name) {
const match = document.cookie.match(new RegExp('(^| )' + name + '=([^;]+)'));
return match ? match[2] : null;
}
function hasShownInstallPrompt() {
return getCookie("tgPWAInstallPromptShown") === "true";
}
function markInstallPromptShown() {
document.cookie = "tgPWAInstallPromptShown=true; max-age=31536000; path=/";
}
window.addEventListener('beforeinstallprompt', (e) => {
e.preventDefault();
if (!hasShownInstallPrompt() && !installPromptTriggered) {
installPromptTriggered = true;
setTimeout(() => {
e.prompt()
.then(() => e.userChoice)
.then(choiceResult => {
markInstallPromptShown();
})
.catch(err => {
});
}, 2000); // 延迟 2 秒提示
} else {
// console.log("已提示过安装,不再弹出");
}
});
</script>
</body>
</html>

View File

@@ -146,11 +146,12 @@ public partial class MainLayout : IDisposable
Title = title,
ContentTemplate = item,
Max = false,
Width = "1440px",
Height = "810px",
Top = "70px",
Left = "220px",
Width = "80%",
Height = "80%",
Top = "0%",
Left = "10%",
Background = "var(--bb-primary-color)",
Overflow = true
};
await WinBoxService.Show(option);
}

View File

@@ -1,4 +1,6 @@

.mainlayout ::deep .layout-header {
z-index: 5;
}
.mainlayout ::deep .menu-icon {
width: 16px;
}

View File

@@ -1,6 +1,6 @@
<Project>
<PropertyGroup>
<Version>10.7.52</Version>
<Version>10.7.53</Version>
</PropertyGroup>
<ItemGroup>