feat: MongoDB 仅保留连接状态 + 站点级密码门禁(WEBPASSWORD)

This commit is contained in:
ice-a
2026-10-16 19:11:19 +08:00
parent 090a7254e0
commit 9b3113bc33
9 changed files with 150 additions and 23 deletions
+1 -1
View File
@@ -45,7 +45,7 @@ const mongoPill = computed(() => {
<i class="dot" />
{{ health?.webTorrent ? '磁力解析就绪' : '磁力解析不可用' }}
</span>
<NuxtLink to="/settings" class="pill" :class="mongoPill.cls" :title="health?.mongo.error || ''">
<NuxtLink to="/settings" class="pill" :class="mongoPill.cls">
<i class="dot" />
{{ mongoPill.text }}
</NuxtLink>
+83
View File
@@ -0,0 +1,83 @@
<script setup lang="ts">
import { ref } from 'vue'
const password = ref('')
const error = ref('')
const loading = ref(false)
async function unlock() {
if (!password.value) {
error.value = '请输入密码'
return
}
loading.value = true
error.value = ''
try {
const res = await $fetch<{ ok?: boolean; enabled?: boolean }>('/api/unlock', {
method: 'POST',
body: { password: password.value }
})
if (res && (res.ok || res.enabled === false)) {
await navigateTo('/', { reload: true })
}
} catch (e: unknown) {
const msg = (e as { data?: { statusMessage?: string } })?.data?.statusMessage
error.value = msg === 'invalid password' ? '密码错误' : '验证失败'
} finally {
loading.value = false
}
}
</script>
<template>
<div class="gate">
<form class="gate-card" @submit.prevent="unlock">
<div class="brand-mark big">BT</div>
<h1>需要密码</h1>
<p class="mute">请输入访问密码以进入</p>
<input
v-model="password"
type="password"
class="input"
placeholder="访问密码"
autofocus
@keyup.enter="unlock"
/>
<button class="btn btn-primary" type="submit" :disabled="loading">
<span v-if="loading" class="spin" />
{{ loading ? '验证中' : '进入' }}
</button>
<p v-if="error" class="err small">{{ error }}</p>
</form>
</div>
</template>
<style scoped>
.gate {
min-height: 70vh;
display: flex;
align-items: center;
justify-content: center;
}
.gate-card {
width: 320px;
max-width: 90vw;
border: 1px solid var(--line);
border-radius: 16px;
background: var(--panel);
padding: 28px 24px;
text-align: center;
display: flex;
flex-direction: column;
gap: 12px;
}
.brand-mark.big {
width: 56px;
height: 56px;
font-size: 22px;
margin: 0 auto;
}
.gate-card input {
text-align: center;
}
</style>
-1
View File
@@ -321,7 +321,6 @@ onMounted(load)
<dt>MongoDB</dt>
<dd>
<span :class="health?.mongo.ok ? 'ok' : 'err'">{{ health?.mongo.ok ? '已连接' : '未连接' }}</span>
<div v-if="health?.mongo.error" class="small err mono break">{{ health.mongo.error }}</div>
</dd>
<dt>磁力解析</dt>
<dd :class="health?.webTorrent ? 'ok' : 'err'">
+1 -1
View File
@@ -95,7 +95,7 @@ export interface ClientsResponse {
export interface HealthResponse {
ok: boolean
time: string
mongo: { ok: boolean; error: string | null }
mongo: { ok: boolean }
webTorrent: boolean
providers: { id: string; label: string; homepage: string }[]
enabledProviders: string[]
+11 -1
View File
@@ -225,7 +225,17 @@ export const zh2en: Record<string, string> = {
'点击关键词直接搜索': 'Click a keyword to search',
'已写入 MongoDB': 'Saved to MongoDB',
'MongoDB 未连接,未记录': 'MongoDB not connected, not recorded',
'MongoDB 未连接,搜索记录与种子缓存不会被保存(其余功能可用)。在 .env 配置正确的 MONGODB_URI 后刷新即可。': 'MongoDB not connected; search history and torrent cache will not be saved (other features still work). Set a valid MONGODB_URI in .env and refresh.'
'MongoDB 未连接,搜索记录与种子缓存不会被保存(其余功能可用)。在 .env 配置正确的 MONGODB_URI 后刷新即可。': 'MongoDB not connected; search history and torrent cache will not be saved (other features still work). Set a valid MONGODB_URI in .env and refresh.',
// ===== 访问密码门禁 =====
'需要密码': 'Password required',
'请输入访问密码以进入': 'Enter the access password to continue',
'访问密码': 'Access password',
'进入': 'Enter',
'验证中': 'Verifying…',
'密码错误': 'Wrong password',
'验证失败': 'Verification failed',
'请输入密码': 'Please enter the password'
}
export const en2zh: Record<string, string> = Object.fromEntries(