test publish
Some checks failed
Deploy / deploy (push) Has been cancelled
Deploy / publish-web (push) Successful in 1m43s
Deploy / publish-tauri (push) Has been cancelled

This commit is contained in:
2025-12-22 19:23:06 +06:00
parent e3d0106d8f
commit 76f0ec74b5
27 changed files with 2123 additions and 1344 deletions

View File

@@ -1,41 +1,20 @@
import { relaunch } from '@tauri-apps/plugin-process'
import { check } from '@tauri-apps/plugin-updater'
export default defineNuxtRouteMiddleware(async (to, from) => {
if (import.meta.dev || import.meta.server)
return
const { isTauri } = useApp()
if (!isTauri.value)
return
if (from?.name)
return
const update = await check()
const { checkForUpdates } = useUpdater()
console.log(update)
if (import.meta.dev)
return
const update = await checkForUpdates()
if (update) {
console.log(
`found update ${update.version} from ${update.date} with notes ${update.body}`,
)
let downloaded = 0
let contentLength = 0
// alternatively we could also call update.download() and update.install() separately
await update.downloadAndInstall((event) => {
switch (event.event) {
case 'Started':
contentLength = event.data.contentLength ?? 0
console.log(`started downloading ${event.data.contentLength} bytes`)
break
case 'Progress':
downloaded += event.data.chunkLength
console.log(`downloaded ${downloaded} from ${contentLength}`)
break
case 'Finished':
console.log('download finished')
break
}
})
console.log('update installed')
await relaunch()
return navigateTo({ name: 'Updating' })
}
})