changes for build for sxsw
This commit is contained in:
@@ -14,8 +14,8 @@
|
||||
|
||||
<!-- Content Area -->
|
||||
<div class="flex flex-col items-center gap-6 mb-6">
|
||||
<!-- Generating state — spinning lock -->
|
||||
<div v-if="!generatedDid && isGenerating" class="text-center">
|
||||
<!-- Waiting for server / Generating state -->
|
||||
<div v-if="!generatedDid && (isGenerating || waitingForServer)" class="text-center">
|
||||
<div class="flex justify-center mb-4">
|
||||
<div class="w-16 h-16 rounded-full bg-white/10 flex items-center justify-center onb-lock-spin">
|
||||
<svg class="w-8 h-8 text-orange-400" fill="none" stroke="currentColor" viewBox="0 0 24 24" stroke-width="2">
|
||||
@@ -23,18 +23,12 @@
|
||||
</svg>
|
||||
</div>
|
||||
</div>
|
||||
<p class="text-lg text-white/80">Generating your identity key...</p>
|
||||
</div>
|
||||
|
||||
<!-- Connection failed - retry -->
|
||||
<div v-if="!generatedDid && !isGenerating && connectionFailed" class="text-center">
|
||||
<p class="text-white/60 text-base mb-4">{{ errorMessage }}</p>
|
||||
<button
|
||||
@click="fetchDid"
|
||||
class="path-action-button path-action-button--continue"
|
||||
>
|
||||
Retry
|
||||
</button>
|
||||
<div v-if="waitingForServer" class="flex items-center justify-center gap-3 mb-2">
|
||||
<p class="text-lg text-white/80">Server starting up</p>
|
||||
<span class="text-sm text-white/40 font-mono tabular-nums">{{ elapsedDisplay }}</span>
|
||||
</div>
|
||||
<p v-if="waitingForServer" class="text-sm text-white/50">This usually takes 1–3 minutes after first boot</p>
|
||||
<p v-if="!waitingForServer" class="text-lg text-white/80">Generating your identity key...</p>
|
||||
</div>
|
||||
|
||||
<!-- Generated DID Display -->
|
||||
@@ -104,17 +98,37 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, onMounted } from 'vue'
|
||||
import { ref, onMounted, onUnmounted } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { rpcClient } from '@/api/rpc-client'
|
||||
|
||||
const router = useRouter()
|
||||
const generatedDid = ref<string>('')
|
||||
const isGenerating = ref(false)
|
||||
const connectionFailed = ref(false)
|
||||
const waitingForServer = ref(false)
|
||||
const autoAdvancing = ref(false)
|
||||
const errorMessage = ref<string>('')
|
||||
const didCopied = ref(false)
|
||||
const elapsedSeconds = ref(0)
|
||||
const elapsedDisplay = ref('0:00')
|
||||
let retryTimer: ReturnType<typeof setTimeout> | null = null
|
||||
let elapsedTimer: ReturnType<typeof setInterval> | null = null
|
||||
let startTime = 0
|
||||
|
||||
function startElapsedTimer() {
|
||||
startTime = Date.now()
|
||||
elapsedTimer = setInterval(() => {
|
||||
const secs = Math.floor((Date.now() - startTime) / 1000)
|
||||
elapsedSeconds.value = secs
|
||||
const m = Math.floor(secs / 60)
|
||||
const s = secs % 60
|
||||
elapsedDisplay.value = `${m}:${s.toString().padStart(2, '0')}`
|
||||
}, 1000)
|
||||
}
|
||||
|
||||
function stopTimers() {
|
||||
if (retryTimer) { clearTimeout(retryTimer); retryTimer = null }
|
||||
if (elapsedTimer) { clearInterval(elapsedTimer); elapsedTimer = null }
|
||||
}
|
||||
|
||||
function storeDidState(did: string, pubkey: string) {
|
||||
localStorage.setItem('neode_did', did)
|
||||
@@ -122,28 +136,26 @@ function storeDidState(did: string, pubkey: string) {
|
||||
}
|
||||
|
||||
async function fetchDid() {
|
||||
isGenerating.value = true
|
||||
connectionFailed.value = false
|
||||
errorMessage.value = ''
|
||||
|
||||
for (let attempt = 0; attempt < 3; attempt++) {
|
||||
try {
|
||||
const { did, pubkey } = await rpcClient.getNodeDid()
|
||||
generatedDid.value = did
|
||||
storeDidState(did, pubkey)
|
||||
autoAdvanceAfterDelay()
|
||||
isGenerating.value = false
|
||||
return
|
||||
} catch (err) {
|
||||
if (attempt < 2) {
|
||||
await new Promise((r) => setTimeout(r, 1000 * (attempt + 1)))
|
||||
}
|
||||
}
|
||||
if (!waitingForServer.value) {
|
||||
isGenerating.value = true
|
||||
}
|
||||
|
||||
isGenerating.value = false
|
||||
connectionFailed.value = true
|
||||
errorMessage.value = 'Could not connect to your server. Please check that it is running and try again.'
|
||||
try {
|
||||
const { did, pubkey } = await rpcClient.getNodeDid()
|
||||
stopTimers()
|
||||
generatedDid.value = did
|
||||
storeDidState(did, pubkey)
|
||||
isGenerating.value = false
|
||||
waitingForServer.value = false
|
||||
autoAdvanceAfterDelay()
|
||||
} catch {
|
||||
isGenerating.value = false
|
||||
if (!waitingForServer.value) {
|
||||
waitingForServer.value = true
|
||||
startElapsedTimer()
|
||||
}
|
||||
retryTimer = setTimeout(fetchDid, 4000)
|
||||
}
|
||||
}
|
||||
|
||||
function autoAdvanceAfterDelay() {
|
||||
@@ -162,11 +174,17 @@ onMounted(() => {
|
||||
}
|
||||
})
|
||||
|
||||
onUnmounted(() => {
|
||||
stopTimers()
|
||||
})
|
||||
|
||||
function proceed() {
|
||||
stopTimers()
|
||||
router.push('/onboarding/identity').catch(() => {})
|
||||
}
|
||||
|
||||
function skipForNow() {
|
||||
stopTimers()
|
||||
router.push('/onboarding/identity').catch(() => {})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user