chore(stage-ui): pwa toaster prompt

This commit is contained in:
Neko Ayaka
2026-03-30 23:18:29 +08:00
parent 7164318002
commit b6c5882366
4 changed files with 26 additions and 5 deletions
+1 -1
View File
@@ -24,7 +24,7 @@ export const usePWAStore = defineStore('pwa', () => {
const updateSW = registerSW({
onNeedRefresh: () => {
const id = nanoid()
toast(markRaw(h(ToasterPWAUpdateReady, { id, onUpdate: () => updateSW() })), {
toast.custom(markRaw(h(ToasterPWAUpdateReady, { id, onUpdate: () => updateSW() })), {
id,
duration: 30000,
position: isMobile.value ? 'top-center' : 'bottom-right',
@@ -16,7 +16,7 @@ function handlePopToast() {
const id = nanoid()
// eslint-disable-next-line no-console
toast(markRaw(h(ToasterPWAUpdateReady, { id, onUpdate: () => console.debug('Update initiated', id) })), {
toast.custom(markRaw(h(ToasterPWAUpdateReady, { id, onUpdate: () => console.debug('Update initiated', id) })), {
id,
duration: 30000,
position: isMobile.value ? 'top-center' : 'bottom-right',
@@ -25,12 +25,25 @@ function handleNotNow() {
<template>
<div
w-full flex flex-col gap-1 rounded-xl
:class="[
'px-4 py-3',
'backdrop-blur-md shadow-md',
'bg-neutral-100/80 dark:bg-neutral-800/80',
'w-full flex flex-col gap-1 rounded-2xl',
]"
>
<div mb-1 text-nowrap>
<div
:class="[
'mb-1 text-nowrap',
]"
>
{{ t('base.toaster.pwaUpdateReady.message') }}
</div>
<div w-full flex items-center gap-2>
<div
:class="[
'w-full flex items-center gap-2',
]"
>
<Button w-full size="sm" variant="secondary" @click="() => handleNotNow()">
<div i-solar:close-circle-line-duotone />
<div text-nowrap>
@@ -17,7 +17,15 @@ provide(ToasterRootInjectionKey, {
</template>
<style>
[data-sonner-toast=""] {
--border-radius: 1rem;
}
[data-sonner-toast=""] [data-content=""] {
width: 100%;
}
li[data-sonner-toast=""][data-styled='true'] {
padding: 12px;
}
</style>