feat(nostr): Add Nostr relay connection and status management
- Integrate nostr-tools for Nostr relay connectivity - Create NostrClient for managing relay connections - Implement useNostr composable for reactive connection handling - Add ConnectionStatus component to display relay connection state - Configure environment variable for Nostr relay endpoints - Update App.vue to manage Nostr connection lifecycle
This commit is contained in:
parent
6a5b64a382
commit
2a83972b47
7 changed files with 244 additions and 2 deletions
16
src/App.vue
16
src/App.vue
|
|
@ -1,7 +1,20 @@
|
|||
<script setup lang="ts">
|
||||
import { onMounted, onUnmounted } from 'vue'
|
||||
import Navbar from '@/components/layout/Navbar.vue'
|
||||
import Footer from '@/components/layout/Footer.vue'
|
||||
import ConnectionStatus from '@/components/nostr/ConnectionStatus.vue'
|
||||
import { useNostr } from '@/composables/useNostr'
|
||||
|
||||
const relays = JSON.parse(import.meta.env.VITE_NOSTR_RELAYS as string)
|
||||
const { isConnected, error, connect, disconnect } = useNostr({ relays })
|
||||
|
||||
onMounted(async () => {
|
||||
await connect()
|
||||
})
|
||||
|
||||
onUnmounted(() => {
|
||||
disconnect()
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
|
@ -10,8 +23,9 @@ import Footer from '@/components/layout/Footer.vue'
|
|||
style="padding-top: env(safe-area-inset-top); padding-bottom: env(safe-area-inset-bottom)">
|
||||
<header
|
||||
class="sticky top-0 z-50 w-full border-b bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/60">
|
||||
<nav class="container flex h-14 items-center">
|
||||
<nav class="container flex h-14 items-center justify-between">
|
||||
<Navbar />
|
||||
<ConnectionStatus :is-connected="isConnected" :error="error" />
|
||||
</nav>
|
||||
</header>
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue