优化密码找回流程、管理后台批量操作和上传体验 (#2)

Reviewed-on: #2
This commit was merged in pull request #2.
This commit is contained in:
2026-05-31 17:00:16 +08:00
parent e087dd46e2
commit 217b81c506
15 changed files with 736 additions and 158 deletions
+10 -33
View File
@@ -2,7 +2,7 @@
import { ref, onMounted, onUnmounted } from 'vue'
import { useRouter } from 'vue-router'
import { NButton, NCard, NResult, NSpin } from 'naive-ui'
import { createClient } from '@supabase/supabase-js'
import { createDetachedAuthClient, resolveEmailAuthCallback } from '@/lib/authEmail'
const router = useRouter()
@@ -22,43 +22,20 @@ function startCountdown() {
onMounted(async () => {
try {
const hash = window.location.hash.slice(1)
const params = new URLSearchParams(hash)
const accessToken = params.get('access_token')
const refreshToken = params.get('refresh_token')
const type = params.get('type')
const error = params.get('error')
const confirmClient = createDetachedAuthClient()
const result = await resolveEmailAuthCallback({
client: confirmClient,
allowedTypes: ['signup', 'email'],
})
if (error) {
if (!result.ok) {
state.value = 'failed'
return
}
if (type === 'signup' && accessToken && refreshToken) {
const confirmClient = createClient(
import.meta.env.VITE_SUPABASE_URL,
import.meta.env.VITE_SUPABASE_PUBLISHABLE_KEY,
)
const { error: setSessionError } = await confirmClient.auth.setSession({
access_token: accessToken,
refresh_token: refreshToken,
})
if (setSessionError) {
state.value = 'failed'
return
}
await confirmClient.auth.signOut()
window.history.replaceState(null, '', window.location.pathname)
state.value = 'success'
startCountdown()
return
}
state.value = 'failed'
await confirmClient.auth.signOut()
state.value = 'success'
startCountdown()
} catch {
state.value = 'failed'
}