feat: update homepage
This commit is contained in:
@@ -18,9 +18,9 @@ type Sentence struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
lineCount int
|
lineCount int
|
||||||
lineOffsets []int64
|
lineOffsets []int64
|
||||||
sentenceOnce sync.Once
|
sentenceOnce sync.Once
|
||||||
)
|
)
|
||||||
|
|
||||||
// initSentences 初始化:统计行数和记录每行偏移
|
// initSentences 初始化:统计行数和记录每行偏移
|
||||||
@@ -51,6 +51,9 @@ func GetRandomSentence() string {
|
|||||||
if currentLine == targetLine {
|
if currentLine == targetLine {
|
||||||
var s Sentence
|
var s Sentence
|
||||||
if err := json.Unmarshal(scanner.Bytes(), &s); err == nil && s.Name != "" {
|
if err := json.Unmarshal(scanner.Bytes(), &s); err == nil && s.Name != "" {
|
||||||
|
if s.From != "" {
|
||||||
|
return "\"" + s.Name + "\"—— " + s.From
|
||||||
|
}
|
||||||
return s.Name
|
return s.Name
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
|
|||||||
@@ -101,19 +101,13 @@ onMounted(() => {
|
|||||||
<template>
|
<template>
|
||||||
<div class="flex h-screen bg-muted/40">
|
<div class="flex h-screen bg-muted/40">
|
||||||
<!-- Mobile Menu Overlay -->
|
<!-- Mobile Menu Overlay -->
|
||||||
<div
|
<div v-if="mobileMenuOpen" class="fixed inset-0 bg-black/50 z-40 lg:hidden" @click="mobileMenuOpen = false" />
|
||||||
v-if="mobileMenuOpen"
|
|
||||||
class="fixed inset-0 bg-black/50 z-40 lg:hidden"
|
|
||||||
@click="mobileMenuOpen = false"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<!-- Sidebar -->
|
<!-- Sidebar -->
|
||||||
<aside
|
<aside :class="[
|
||||||
:class="[
|
'fixed lg:static inset-y-0 left-0 z-50 w-44 border-r bg-background flex flex-col transform transition-transform duration-200 ease-in-out lg:transform-none',
|
||||||
'fixed lg:static inset-y-0 left-0 z-50 w-44 border-r bg-background flex flex-col transform transition-transform duration-200 ease-in-out lg:transform-none',
|
mobileMenuOpen ? 'translate-x-0' : '-translate-x-full lg:translate-x-0'
|
||||||
mobileMenuOpen ? 'translate-x-0' : '-translate-x-full lg:translate-x-0'
|
]">
|
||||||
]"
|
|
||||||
>
|
|
||||||
<div class="h-14 flex items-center justify-center px-4 font-semibold text-lg border-b relative">
|
<div class="h-14 flex items-center justify-center px-4 font-semibold text-lg border-b relative">
|
||||||
<span>{{ siteSettings.title }}</span>
|
<span>{{ siteSettings.title }}</span>
|
||||||
<Button variant="ghost" size="icon" class="h-8 w-8 lg:hidden absolute right-2" @click="mobileMenuOpen = false">
|
<Button variant="ghost" size="icon" class="h-8 w-8 lg:hidden absolute right-2" @click="mobileMenuOpen = false">
|
||||||
@@ -121,25 +115,18 @@ onMounted(() => {
|
|||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
<nav class="flex-1 px-3 py-6 space-y-1 flex flex-col items-center">
|
<nav class="flex-1 px-3 py-6 space-y-1 flex flex-col items-center">
|
||||||
<RouterLink
|
<RouterLink v-for="item in navItems" :key="item.to" :to="item.to" custom v-slot="{ navigate }">
|
||||||
v-for="item in navItems"
|
<Button variant="ghost"
|
||||||
:key="item.to"
|
|
||||||
:to="item.to"
|
|
||||||
custom
|
|
||||||
v-slot="{ navigate }"
|
|
||||||
>
|
|
||||||
<Button
|
|
||||||
variant="ghost"
|
|
||||||
:class="['justify-start gap-3 h-9 px-3', isItemActive(item) && 'bg-accent text-accent-foreground']"
|
:class="['justify-start gap-3 h-9 px-3', isItemActive(item) && 'bg-accent text-accent-foreground']"
|
||||||
@click="handleNavClick(navigate)"
|
@click="handleNavClick(navigate)">
|
||||||
>
|
|
||||||
<component :is="item.icon" class="h-4 w-4" />
|
<component :is="item.icon" class="h-4 w-4" />
|
||||||
{{ item.label }}
|
{{ item.label }}
|
||||||
</Button>
|
</Button>
|
||||||
</RouterLink>
|
</RouterLink>
|
||||||
</nav>
|
</nav>
|
||||||
<div class="px-3 py-4 border-t flex justify-center">
|
<div class="px-3 py-4 border-t flex justify-center">
|
||||||
<Button variant="ghost" class="justify-start gap-3 h-9 px-3 text-muted-foreground hover:text-foreground" @click="logout">
|
<Button variant="ghost" class="justify-start gap-3 h-9 px-3 text-muted-foreground hover:text-foreground"
|
||||||
|
@click="logout">
|
||||||
<LogOut class="h-4 w-4" />
|
<LogOut class="h-4 w-4" />
|
||||||
退出登录
|
退出登录
|
||||||
</Button>
|
</Button>
|
||||||
@@ -153,7 +140,7 @@ onMounted(() => {
|
|||||||
<Button variant="ghost" size="icon" class="h-8 w-8 lg:hidden" @click="mobileMenuOpen = true">
|
<Button variant="ghost" size="icon" class="h-8 w-8 lg:hidden" @click="mobileMenuOpen = true">
|
||||||
<Menu class="h-5 w-5" />
|
<Menu class="h-5 w-5" />
|
||||||
</Button>
|
</Button>
|
||||||
<span class="text-sm text-muted-foreground truncate max-w-[200px] sm:max-w-none">{{ sentence }}</span>
|
<span class="text-sm text-muted-foreground truncate max-w-[300px] sm:max-w-none">{{ sentence }}</span>
|
||||||
</div>
|
</div>
|
||||||
<ThemeToggle />
|
<ThemeToggle />
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user