Files

83 lines
2.8 KiB
Vue
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<script setup lang="ts">
import { locale, setLocale, translateText, type Locale } from '~/utils/i18n'
import { p2pActive } from '~/utils/clientTorrent'
const route = useRoute()
const health = useHealth()
const lang = computed<Locale>({
get: () => locale.value,
set: (v) => setLocale(v)
})
onMounted(() => {
refreshHealth()
})
const mongoPill = computed(() => {
if (!health.value) return { cls: '', text: 'MONGO ?' }
return health.value.mongo.ok
? { cls: 'on', text: 'MONGO' }
: { cls: 'off', text: 'MONGO 未连接' }
})
async function logout() {
await $fetch('/api/logout', { method: 'POST' }).catch(() => {})
await navigateTo('/gate', { reload: true })
}
</script>
<template>
<div class="shell">
<header class="topbar">
<div class="wrap topbar-in">
<NuxtLink to="/" class="brand">
<span class="brand-mark">BT</span>
<span>
<span class="brand-name">Torrent Console</span><br />
<span class="brand-sub">预览台 / 投递器</span>
</span>
</NuxtLink>
<nav class="nav">
<NuxtLink to="/" :class="{ active: route.path === '/' }">搜索</NuxtLink>
<NuxtLink to="/downloads" :class="{ active: route.path === '/downloads' }">任务</NuxtLink>
<NuxtLink to="/history" :class="{ active: route.path === '/history' }">历史</NuxtLink>
<NuxtLink to="/settings" :class="{ active: route.path === '/settings' }">设置</NuxtLink>
</nav>
<div class="topbar-right">
<span class="pill hide-sm" :class="health && !health.webTorrent ? 'warn' : ''">
<i class="dot" />
{{ health?.webTorrent ? '磁力解析就绪' : '磁力解析(缓存模式)' }}
</span>
<span class="pill hide-sm" :class="p2pActive ? 'on' : 'dim'">
<i class="dot" />
{{ p2pActive ? translateText('P2P 活动中') : translateText('P2P 空闲') }}
</span>
<NuxtLink to="/settings" class="pill" :class="mongoPill.cls">
<i class="dot" />
{{ mongoPill.text }}
</NuxtLink>
<button v-if="health?.authed" class="pill" type="button" @click="logout" title="退出登录">退出</button>
<select class="pill lang-select" v-model="lang" title="Language" aria-label="Language">
<option value="en">EN</option>
<option value="zh">中文</option>
</select>
</div>
</div>
</header>
<main class="grow wrap">
<slot />
</main>
<footer class="footer">
<div class="wrap spread">
<span>本地自托管 · 单进程 Nuxt 单体应用</span>
<span class="mute">种子只做解析与预览,文件内容由你自己的下载器拉取</span>
</div>
</footer>
</div>
</template>