20260608160402
This commit is contained in:
1 parent
1fd956966c
commit
930f03954a
339 files changed
+2175
-140695
No files matched your search
@@ -1,4 +1,3 @@
|
||||
import React from 'react'
|
||||
import styles from './styles.module.css'
|
||||
|
||||
export interface LinkCardProps {
|
||||
@@ -6,6 +5,16 @@ export interface LinkCardProps {
|
||||
description: string
|
||||
href: string
|
||||
icon?: string
|
||||
note?: string
|
||||
}
|
||||
|
||||
function getHostname(href: string) {
|
||||
try {
|
||||
return new URL(href).hostname.replace(/^www\./, '')
|
||||
}
|
||||
catch {
|
||||
return ''
|
||||
}
|
||||
}
|
||||
|
||||
export default function LinkCard({
|
||||
@@ -13,18 +22,10 @@ export default function LinkCard({
|
||||
description,
|
||||
href,
|
||||
icon,
|
||||
note,
|
||||
}: LinkCardProps) {
|
||||
let favicon = icon
|
||||
|
||||
if (!favicon) {
|
||||
try {
|
||||
const hostname = new URL(href).hostname
|
||||
favicon = `https://www.google.com/s2/favicons?domain=${hostname}&sz=128`
|
||||
}
|
||||
catch {
|
||||
favicon = undefined
|
||||
}
|
||||
}
|
||||
const hostname = getHostname(href)
|
||||
const favicon = icon || (hostname ? `https://www.google.com/s2/favicons?domain=${hostname}&sz=64` : undefined)
|
||||
|
||||
return (
|
||||
<a
|
||||
@@ -33,29 +34,20 @@ export default function LinkCard({
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
<div className={styles.header}>
|
||||
<span className={styles.cardTopline}>
|
||||
{favicon
|
||||
? (
|
||||
<img
|
||||
src={favicon}
|
||||
alt={title}
|
||||
className={styles.icon}
|
||||
/>
|
||||
)
|
||||
: (
|
||||
<div className={styles.placeholder}>
|
||||
{title.charAt(0)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
<span className={styles.title}>
|
||||
{title}
|
||||
? <img src={favicon} alt="" className={styles.icon} loading="lazy" />
|
||||
: <span className={styles.placeholder}>{title.charAt(0)}</span>}
|
||||
<span className={styles.title}>{title}</span>
|
||||
</span>
|
||||
<span className={styles.description}>{description}</span>
|
||||
{hostname && <span className={styles.host}>{hostname}</span>}
|
||||
{note && (
|
||||
<span className={styles.note} role="tooltip">
|
||||
<span className={styles.noteLabel}>备注</span>
|
||||
{note}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div className={styles.description}>
|
||||
{description}
|
||||
</div>
|
||||
)}
|
||||
</a>
|
||||
)
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
import type { LinkCardProps } from './LinkCard'
|
||||
import React, { useEffect, useMemo, useRef, useState } from 'react'
|
||||
import { useMemo, useState } from 'react'
|
||||
import LinkCard from './LinkCard'
|
||||
import styles from './styles.module.css'
|
||||
|
||||
export interface SubGroup {
|
||||
export interface LinkSubGroup {
|
||||
title: string
|
||||
items: LinkCardProps[]
|
||||
}
|
||||
@@ -11,268 +11,183 @@ export interface SubGroup {
|
||||
export interface GroupedLinkCardProps {
|
||||
groupName: string
|
||||
items?: LinkCardProps[]
|
||||
subGroups?: SubGroup[]
|
||||
subGroups?: LinkSubGroup[]
|
||||
}
|
||||
|
||||
interface SearchableLinkGridProps {
|
||||
groups: GroupedLinkCardProps[]
|
||||
}
|
||||
|
||||
const ALL_GROUPS = '全部'
|
||||
|
||||
function getGroupItems(group: GroupedLinkCardProps) {
|
||||
const items = group.items ?? []
|
||||
const subGroupItems = group.subGroups?.flatMap(subGroup => subGroup.items) ?? []
|
||||
return [...items, ...subGroupItems]
|
||||
}
|
||||
|
||||
function countGroupItems(group: GroupedLinkCardProps) {
|
||||
return getGroupItems(group).length
|
||||
}
|
||||
|
||||
function matchesSearch(item: LinkCardProps, groupName: string, sectionName: string, keyword: string) {
|
||||
const text = `${groupName} ${sectionName} ${item.title} ${item.description} ${item.note ?? ''} ${item.href}`.toLowerCase()
|
||||
return text.includes(keyword)
|
||||
}
|
||||
|
||||
function filterItems(items: LinkCardProps[] | undefined, groupName: string, sectionName: string, keyword: string) {
|
||||
if (!items?.length)
|
||||
return undefined
|
||||
|
||||
if (!keyword)
|
||||
return items
|
||||
|
||||
const filtered = items.filter(item => matchesSearch(item, groupName, sectionName, keyword))
|
||||
return filtered.length > 0 ? filtered : undefined
|
||||
}
|
||||
|
||||
function filterGroup(group: GroupedLinkCardProps, activeGroup: string, keyword: string): GroupedLinkCardProps | null {
|
||||
if (activeGroup !== ALL_GROUPS && group.groupName !== activeGroup)
|
||||
return null
|
||||
|
||||
const items = filterItems(group.items, group.groupName, group.groupName, keyword)
|
||||
const subGroups = group.subGroups
|
||||
?.map(subGroup => ({
|
||||
...subGroup,
|
||||
items: filterItems(subGroup.items, group.groupName, subGroup.title, keyword) ?? [],
|
||||
}))
|
||||
.filter(subGroup => subGroup.items.length > 0)
|
||||
|
||||
if (!items?.length && !subGroups?.length)
|
||||
return null
|
||||
|
||||
return {
|
||||
groupName: group.groupName,
|
||||
items,
|
||||
subGroups,
|
||||
}
|
||||
}
|
||||
|
||||
export default function SearchableLinkGrid({ groups }: SearchableLinkGridProps) {
|
||||
const [searchTerm, setSearchTerm] = useState('')
|
||||
const [activeSection, setActiveSection] = useState('')
|
||||
const [expandedGroups, setExpandedGroups] = useState<Set<number>>(new Set([0]))
|
||||
const sidebarRef = useRef<HTMLDivElement>(null)
|
||||
const [activeGroup, setActiveGroup] = useState(ALL_GROUPS)
|
||||
|
||||
useEffect(() => {
|
||||
const navbar = document.querySelector('.navbar')
|
||||
const navbarHeight = navbar ? navbar.offsetHeight : 64
|
||||
const threshold = navbarHeight + 32
|
||||
|
||||
if (sidebarRef.current) {
|
||||
sidebarRef.current.style.top = `${threshold}px`
|
||||
}
|
||||
}, [])
|
||||
|
||||
useEffect(() => {
|
||||
const navbar = document.querySelector('.navbar')
|
||||
const navbarHeight = navbar ? navbar.offsetHeight : 64
|
||||
const threshold = navbarHeight + 20
|
||||
|
||||
const observer = new IntersectionObserver(
|
||||
(entries) => {
|
||||
for (const entry of entries) {
|
||||
if (entry.isIntersecting) {
|
||||
setActiveSection(entry.target.id)
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
rootMargin: `-${threshold}px 0px -80% 0px`,
|
||||
threshold: 0.1,
|
||||
},
|
||||
)
|
||||
|
||||
groups.forEach((group, groupIndex) => {
|
||||
const groupElement = document.getElementById(`group-${groupIndex}`)
|
||||
if (groupElement) {
|
||||
observer.observe(groupElement)
|
||||
}
|
||||
group.subGroups?.forEach((_, subIndex) => {
|
||||
const subGroupElement = document.getElementById(`subgroup-${groupIndex}-${subIndex}`)
|
||||
if (subGroupElement) {
|
||||
observer.observe(subGroupElement)
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
return () => {
|
||||
observer.disconnect()
|
||||
}
|
||||
}, [groups])
|
||||
|
||||
const countGroupItems = (group: GroupedLinkCardProps): number => {
|
||||
let count = group.items?.length || 0
|
||||
if (group.subGroups) {
|
||||
count += group.subGroups.reduce((sum, sg) => sum + sg.items.length, 0)
|
||||
}
|
||||
return count
|
||||
}
|
||||
|
||||
const filterGroup = (group: GroupedLinkCardProps, lowerTerm: string): GroupedLinkCardProps | null => {
|
||||
const filteredItems = group.items?.filter(
|
||||
item =>
|
||||
item.title.toLowerCase().includes(lowerTerm)
|
||||
|| item.description.toLowerCase().includes(lowerTerm),
|
||||
) || []
|
||||
|
||||
const filteredSubGroups = group.subGroups?.map(sg => ({
|
||||
...sg,
|
||||
items: sg.items.filter(
|
||||
item =>
|
||||
item.title.toLowerCase().includes(lowerTerm)
|
||||
|| item.description.toLowerCase().includes(lowerTerm),
|
||||
),
|
||||
})).filter(sg => sg.items.length > 0) || []
|
||||
|
||||
if (filteredItems.length > 0 || filteredSubGroups.length > 0) {
|
||||
return {
|
||||
...group,
|
||||
items: filteredItems.length > 0 ? filteredItems : undefined,
|
||||
subGroups: filteredSubGroups.length > 0 ? filteredSubGroups : undefined,
|
||||
}
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
const filteredGroups = useMemo(() => {
|
||||
if (!searchTerm.trim())
|
||||
return groups
|
||||
|
||||
const lowerTerm = searchTerm.toLowerCase()
|
||||
return groups.map(group => filterGroup(group, lowerTerm)).filter(Boolean) as GroupedLinkCardProps[]
|
||||
}, [searchTerm, groups])
|
||||
|
||||
const totalItems = groups.reduce((sum, group) => sum + countGroupItems(group), 0)
|
||||
const filteredTotalItems = filteredGroups.reduce((sum, group) => sum + countGroupItems(group), 0)
|
||||
|
||||
const scrollToSection = (groupIndex: number, subGroupIndex?: number) => {
|
||||
if (subGroupIndex !== undefined) {
|
||||
const element = document.getElementById(`subgroup-${groupIndex}-${subGroupIndex}`)
|
||||
if (element) {
|
||||
element.scrollIntoView({ behavior: 'smooth', block: 'start' })
|
||||
return
|
||||
}
|
||||
}
|
||||
const element = document.getElementById(`group-${groupIndex}`)
|
||||
if (element) {
|
||||
element.scrollIntoView({ behavior: 'smooth', block: 'start' })
|
||||
}
|
||||
}
|
||||
|
||||
const toggleGroup = (index: number) => {
|
||||
setExpandedGroups((prev) => {
|
||||
const newSet = new Set(prev)
|
||||
if (newSet.has(index)) {
|
||||
newSet.delete(index)
|
||||
}
|
||||
else {
|
||||
newSet.add(index)
|
||||
}
|
||||
return newSet
|
||||
})
|
||||
}
|
||||
|
||||
const renderItems = (items: LinkCardProps[]) => (
|
||||
<div className={styles.grid}>
|
||||
{items.map((item, itemIndex) => (
|
||||
<LinkCard key={itemIndex} {...item} />
|
||||
))}
|
||||
</div>
|
||||
const totalItems = useMemo(
|
||||
() => groups.reduce((sum, group) => sum + countGroupItems(group), 0),
|
||||
[groups],
|
||||
)
|
||||
|
||||
const renderGroup = (group: GroupedLinkCardProps, groupIndex: number) => (
|
||||
<div key={groupIndex} id={`group-${groupIndex}`} className={styles.group}>
|
||||
<h3 className={styles.groupTitle}>{group.groupName}</h3>
|
||||
{group.items && group.items.length > 0 && renderItems(group.items)}
|
||||
{group.subGroups && group.subGroups.map((subGroup, subIndex) => (
|
||||
<div key={subIndex} id={`subgroup-${groupIndex}-${subIndex}`} className={styles.subGroup}>
|
||||
<h4 className={styles.subGroupTitle}>{subGroup.title}</h4>
|
||||
<div className={styles.subGroupContent}>
|
||||
{renderItems(subGroup.items)}
|
||||
</div>
|
||||
</div>
|
||||
const filteredGroups = useMemo(() => {
|
||||
const keyword = searchTerm.trim().toLowerCase()
|
||||
return groups
|
||||
.map(group => filterGroup(group, activeGroup, keyword))
|
||||
.filter(Boolean) as GroupedLinkCardProps[]
|
||||
}, [activeGroup, groups, searchTerm])
|
||||
|
||||
const filteredTotalItems = useMemo(
|
||||
() => filteredGroups.reduce((sum, group) => sum + countGroupItems(group), 0),
|
||||
[filteredGroups],
|
||||
)
|
||||
|
||||
const renderItems = (items: LinkCardProps[], groupName: string, sectionName: string) => (
|
||||
<div className={styles.grid}>
|
||||
{items.map(item => (
|
||||
<LinkCard key={`${groupName}-${sectionName}-${item.href}`} {...item} />
|
||||
))}
|
||||
</div>
|
||||
)
|
||||
|
||||
return (
|
||||
<div className={styles.container}>
|
||||
<div className={styles.mainContent}>
|
||||
<div className={styles.searchContainer}>
|
||||
<div className={styles.searchWrapper}>
|
||||
<svg
|
||||
className={styles.searchIcon}
|
||||
width="18"
|
||||
height="18"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
strokeWidth="2"
|
||||
strokeLinecap="round"
|
||||
strokeLinejoin="round"
|
||||
>
|
||||
<circle cx="11" cy="11" r="8" />
|
||||
<path d="m21 21-4.35-4.35" />
|
||||
<div className={styles.toolbar}>
|
||||
<label className={styles.searchWrapper}>
|
||||
<span className={styles.searchIcon} aria-hidden="true">
|
||||
<svg viewBox="0 0 24 24">
|
||||
<circle cx="11" cy="11" r="7" />
|
||||
<path d="m20 20-3.5-3.5" />
|
||||
</svg>
|
||||
<input
|
||||
type="text"
|
||||
placeholder="搜索资源..."
|
||||
value={searchTerm}
|
||||
onChange={e => setSearchTerm(e.target.value)}
|
||||
className={styles.searchInput}
|
||||
/>
|
||||
</div>
|
||||
<span className={styles.searchCount}>
|
||||
{filteredTotalItems}
|
||||
{' '}
|
||||
/
|
||||
{totalItems}
|
||||
{' '}
|
||||
项
|
||||
</span>
|
||||
</div>
|
||||
|
||||
{filteredGroups.length > 0
|
||||
? (
|
||||
filteredGroups.map((group, groupIndex) => renderGroup(group, groupIndex))
|
||||
)
|
||||
: (
|
||||
<div className={styles.noResults}>
|
||||
<svg
|
||||
className={styles.noResultsIcon}
|
||||
width="48"
|
||||
height="48"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
strokeWidth="1.5"
|
||||
strokeLinecap="round"
|
||||
strokeLinejoin="round"
|
||||
>
|
||||
<circle cx="11" cy="11" r="8" />
|
||||
<path d="m21 21-4.35-4.35" />
|
||||
<path d="M8 11s1.5-2 4-2 4 2 4 2" />
|
||||
</svg>
|
||||
<p>未找到匹配的资源</p>
|
||||
</div>
|
||||
)}
|
||||
<input
|
||||
type="search"
|
||||
placeholder="搜索名称、说明或链接"
|
||||
value={searchTerm}
|
||||
onChange={event => setSearchTerm(event.target.value)}
|
||||
className={styles.searchInput}
|
||||
/>
|
||||
</label>
|
||||
<span className={styles.resultCount}>
|
||||
{filteredTotalItems}
|
||||
{' '}
|
||||
/
|
||||
{' '}
|
||||
{totalItems}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<nav className={styles.sidebar} ref={sidebarRef}>
|
||||
<div className={styles.sidebarHeader}>快速导航</div>
|
||||
<div className={styles.sidebarLinks}>
|
||||
{groups.map((group, groupIndex) => {
|
||||
const hasSubGroups = group.subGroups && group.subGroups.length > 0
|
||||
const isExpanded = expandedGroups.has(groupIndex)
|
||||
<div className={styles.filters} aria-label="资源分类">
|
||||
<button
|
||||
type="button"
|
||||
className={`${styles.filterButton} ${activeGroup === ALL_GROUPS ? styles.active : ''}`}
|
||||
onClick={() => setActiveGroup(ALL_GROUPS)}
|
||||
>
|
||||
{ALL_GROUPS}
|
||||
</button>
|
||||
{groups.map(group => (
|
||||
<button
|
||||
key={group.groupName}
|
||||
type="button"
|
||||
className={`${styles.filterButton} ${activeGroup === group.groupName ? styles.active : ''}`}
|
||||
onClick={() => setActiveGroup(group.groupName)}
|
||||
>
|
||||
{group.groupName}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
|
||||
return (
|
||||
<div key={groupIndex} className={styles.sidebarGroup}>
|
||||
<button
|
||||
onClick={() => {
|
||||
if (hasSubGroups) {
|
||||
toggleGroup(groupIndex)
|
||||
}
|
||||
scrollToSection(groupIndex)
|
||||
}}
|
||||
className={`${styles.sidebarLink} ${styles.sidebarLinkParent} ${activeSection === `group-${groupIndex}` ? styles.active : ''}`}
|
||||
>
|
||||
{hasSubGroups && (
|
||||
<span className={styles.chevron}>
|
||||
{isExpanded ? '▼' : '▶'}
|
||||
{filteredGroups.length > 0
|
||||
? (
|
||||
<div className={styles.sections}>
|
||||
{filteredGroups.map(group => (
|
||||
<section key={group.groupName} className={styles.group}>
|
||||
<div className={styles.groupHeader}>
|
||||
<h2 className={styles.groupTitle}>{group.groupName}</h2>
|
||||
<span className={styles.groupCount}>
|
||||
{countGroupItems(group)}
|
||||
{' '}
|
||||
项
|
||||
</span>
|
||||
)}
|
||||
{group.groupName}
|
||||
</button>
|
||||
{hasSubGroups && isExpanded && (
|
||||
<div className={styles.sidebarSubLinks}>
|
||||
{group.subGroups!.map((subGroup, subIndex) => (
|
||||
<button
|
||||
key={subIndex}
|
||||
onClick={() => scrollToSection(groupIndex, subIndex)}
|
||||
className={`${styles.sidebarLink} ${styles.sidebarLinkChild} ${activeSection === `subgroup-${groupIndex}-${subIndex}` ? styles.active : ''}`}
|
||||
>
|
||||
{subGroup.title}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
{group.items?.length
|
||||
? (
|
||||
<div className={styles.subSection}>
|
||||
{renderItems(group.items, group.groupName, group.groupName)}
|
||||
</div>
|
||||
)
|
||||
: null}
|
||||
|
||||
{group.subGroups?.map(subGroup => (
|
||||
<div key={subGroup.title} className={styles.subSection}>
|
||||
<div className={styles.subHeader}>
|
||||
<h3 className={styles.subTitle}>{subGroup.title}</h3>
|
||||
<span className={styles.subCount}>
|
||||
{subGroup.items.length}
|
||||
{' '}
|
||||
项
|
||||
</span>
|
||||
</div>
|
||||
{renderItems(subGroup.items, group.groupName, subGroup.title)}
|
||||
</div>
|
||||
))}
|
||||
</section>
|
||||
))}
|
||||
</div>
|
||||
)
|
||||
: (
|
||||
<div className={styles.noResults}>
|
||||
<p>没有找到匹配的资源</p>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -1,359 +1,347 @@
|
||||
/* 容器布局 */
|
||||
.container {
|
||||
display: flex;
|
||||
gap: 32px;
|
||||
}
|
||||
|
||||
.mainContent {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
/* 右侧导航 */
|
||||
.sidebar {
|
||||
width: 192px;
|
||||
flex-shrink: 0;
|
||||
position: sticky;
|
||||
top: calc(var(--ifm-navbar-height, 64px) + 1.5rem);
|
||||
height: fit-content;
|
||||
padding: 16px;
|
||||
background: var(--ifm-card-background-color);
|
||||
border-radius: 16px;
|
||||
border: 1px solid var(--ifm-color-emphasis-200);
|
||||
}
|
||||
|
||||
.sidebarHeader {
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
color: var(--ifm-color-emphasis-500);
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.5px;
|
||||
margin-bottom: 12px;
|
||||
padding: 0 4px;
|
||||
}
|
||||
|
||||
.sidebarLinks {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 2px;
|
||||
gap: 1.25rem;
|
||||
}
|
||||
|
||||
.sidebarLink {
|
||||
.toolbar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 9px 12px;
|
||||
font-size: 14px;
|
||||
text-align: left;
|
||||
border: none;
|
||||
background: transparent;
|
||||
color: var(--ifm-color-emphasis-700);
|
||||
border-radius: 10px;
|
||||
cursor: pointer;
|
||||
transition: all 0.2s ease;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.sidebarLink:hover {
|
||||
background-color: var(--ifm-color-emphasis-100);
|
||||
color: var(--ifm-color-emphasis-900);
|
||||
}
|
||||
|
||||
.sidebarLink.active {
|
||||
background-color: var(--ifm-color-primary);
|
||||
color: white;
|
||||
}
|
||||
|
||||
.sidebarGroup {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.sidebarLinkParent {
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.sidebarLinkParent.hasChildren {
|
||||
padding-right: 8px;
|
||||
}
|
||||
|
||||
.chevron {
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
flex-shrink: 0;
|
||||
color: var(--ifm-color-emphasis-400);
|
||||
font-size: 11px;
|
||||
line-height: 1;
|
||||
transition: color 0.2s ease;
|
||||
}
|
||||
|
||||
.sidebarLinkParent:hover .chevron {
|
||||
color: var(--ifm-color-emphasis-600);
|
||||
}
|
||||
|
||||
.sidebarLinkParent.active .chevron {
|
||||
color: white;
|
||||
}
|
||||
|
||||
.sidebarSubLinks {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 3px;
|
||||
padding-left: 8px;
|
||||
margin: 4px 0 6px 16px;
|
||||
}
|
||||
|
||||
.sidebarLinkChild {
|
||||
padding: 9px 14px;
|
||||
font-size: 14px;
|
||||
padding-left: 26px;
|
||||
color: var(--ifm-color-emphasis-600);
|
||||
border-radius: 10px;
|
||||
}
|
||||
|
||||
.sidebarLinkChild:hover {
|
||||
background-color: rgba(0, 0, 0, 0.04);
|
||||
color: var(--ifm-color-emphasis-800);
|
||||
}
|
||||
|
||||
.sidebarLinkChild.active {
|
||||
background-color: var(--ifm-color-primary);
|
||||
color: white;
|
||||
}
|
||||
|
||||
/* 网格布局 */
|
||||
.grid {
|
||||
display: grid;
|
||||
gap: 16px;
|
||||
margin-top: 16px;
|
||||
grid-template-columns: repeat(4, minmax(0, 1fr));
|
||||
}
|
||||
|
||||
@media (max-width: 1200px) {
|
||||
.grid {
|
||||
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 996px) {
|
||||
.grid {
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 576px) {
|
||||
.grid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 1280px) {
|
||||
.sidebar {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
/* 卡片 */
|
||||
.card {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding: 20px;
|
||||
border-radius: 16px;
|
||||
border: 1px solid var(--ifm-color-emphasis-200);
|
||||
background: var(--ifm-card-background-color);
|
||||
color: inherit;
|
||||
text-decoration: none;
|
||||
transition: all 0.25s ease;
|
||||
}
|
||||
|
||||
.card:hover {
|
||||
color: inherit;
|
||||
text-decoration: none;
|
||||
transform: translateY(-4px);
|
||||
border-color: var(--ifm-color-primary);
|
||||
box-shadow: 0 12px 28px rgba(0, 0, 0, 0.08);
|
||||
}
|
||||
|
||||
/* 标题区域 */
|
||||
.header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 14px;
|
||||
}
|
||||
|
||||
/* 图标 */
|
||||
.icon {
|
||||
width: 36px;
|
||||
height: 36px;
|
||||
object-fit: contain;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.placeholder {
|
||||
width: 44px;
|
||||
height: 44px;
|
||||
border-radius: 12px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background: linear-gradient(135deg, var(--ifm-color-primary) 0%, var(--ifm-color-primary-dark) 100%);
|
||||
color: white;
|
||||
font-size: 18px;
|
||||
font-weight: 700;
|
||||
flex-shrink: 0;
|
||||
box-shadow: 0 4px 12px rgba(var(--ifm-color-primary-rgb), 0.2);
|
||||
}
|
||||
|
||||
/* 标题 */
|
||||
.title {
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
line-height: 1.4;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
/* 描述 */
|
||||
.description {
|
||||
margin-top: 12px;
|
||||
font-size: 14px;
|
||||
line-height: 1.6;
|
||||
color: var(--ifm-color-emphasis-600);
|
||||
overflow: hidden;
|
||||
display: -webkit-box;
|
||||
-webkit-line-clamp: 2;
|
||||
-webkit-box-orient: vertical;
|
||||
}
|
||||
|
||||
/* 搜索容器 */
|
||||
.searchContainer {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 16px;
|
||||
margin-bottom: 28px;
|
||||
width: 100%;
|
||||
gap: 0.75rem;
|
||||
padding: 0.25rem 0 0.5rem;
|
||||
}
|
||||
|
||||
.searchWrapper {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
background: var(--ifm-card-background-color);
|
||||
border: 1px solid var(--ifm-color-emphasis-200);
|
||||
border-radius: 14px;
|
||||
padding: 4px 4px 4px 18px;
|
||||
transition: all 0.2s ease;
|
||||
gap: 0.625rem;
|
||||
height: 44px;
|
||||
padding: 0 0.875rem;
|
||||
border: 1px solid transparent;
|
||||
border-radius: 8px;
|
||||
background: var(--oneao-surface-muted);
|
||||
transition: border-color 0.16s ease, box-shadow 0.16s ease;
|
||||
}
|
||||
|
||||
.searchWrapper:focus-within {
|
||||
border-color: var(--ifm-color-primary);
|
||||
box-shadow: 0 0 0 3px var(--ifm-color-primary-alpha-10);
|
||||
box-shadow: 0 0 0 3px rgba(46, 133, 85, 0.12);
|
||||
}
|
||||
|
||||
.searchIcon {
|
||||
color: var(--ifm-color-emphasis-400);
|
||||
margin-right: 12px;
|
||||
flex-shrink: 0;
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
color: var(--ifm-color-emphasis-500);
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.searchIcon svg {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
fill: none;
|
||||
stroke: currentColor;
|
||||
stroke-width: 2;
|
||||
stroke-linecap: round;
|
||||
stroke-linejoin: round;
|
||||
}
|
||||
|
||||
.searchInput {
|
||||
flex: 1;
|
||||
width: 100%;
|
||||
padding: 13px 16px 13px 0;
|
||||
border: none;
|
||||
border-radius: 0 12px 12px 0;
|
||||
font-size: 15px;
|
||||
min-width: 0;
|
||||
border: 0;
|
||||
outline: 0;
|
||||
background: transparent;
|
||||
color: var(--ifm-font-color-base);
|
||||
}
|
||||
|
||||
.searchInput:focus {
|
||||
outline: none;
|
||||
font-size: 0.95rem;
|
||||
}
|
||||
|
||||
.searchInput::placeholder {
|
||||
color: var(--ifm-color-emphasis-500);
|
||||
}
|
||||
|
||||
.searchCount {
|
||||
font-size: 13px;
|
||||
color: var(--ifm-color-emphasis-500);
|
||||
white-space: nowrap;
|
||||
padding: 8px 14px;
|
||||
background: var(--ifm-color-emphasis-100);
|
||||
border-radius: 20px;
|
||||
font-weight: 500;
|
||||
.resultCount {
|
||||
flex-shrink: 0;
|
||||
color: var(--ifm-color-emphasis-600);
|
||||
font-size: 0.875rem;
|
||||
}
|
||||
|
||||
/* 分组样式 */
|
||||
.group {
|
||||
margin-bottom: 36px;
|
||||
scroll-margin-top: calc(var(--ifm-navbar-height, 64px) + 1.5rem);
|
||||
.filters {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
.group:last-child {
|
||||
margin-bottom: 0;
|
||||
.filterButton {
|
||||
height: 34px;
|
||||
padding: 0 0.875rem;
|
||||
border: 1px solid transparent;
|
||||
border-radius: 8px;
|
||||
background: var(--oneao-surface-muted);
|
||||
color: var(--ifm-color-emphasis-700);
|
||||
font-size: 0.875rem;
|
||||
cursor: pointer;
|
||||
transition: border-color 0.16s ease, background-color 0.16s ease, color 0.16s ease;
|
||||
}
|
||||
|
||||
.groupTitle {
|
||||
font-size: 18px;
|
||||
font-weight: 700;
|
||||
.filterButton:hover {
|
||||
border-color: var(--ifm-color-emphasis-400);
|
||||
color: var(--ifm-color-emphasis-900);
|
||||
margin-bottom: 20px;
|
||||
padding: 8px 0 8px 16px;
|
||||
border-left: 4px solid var(--ifm-color-primary);
|
||||
background: linear-gradient(90deg, rgba(var(--ifm-color-primary-rgb), 0.05) 0%, transparent 100%);
|
||||
}
|
||||
|
||||
/* 子分组样式 */
|
||||
.subGroup {
|
||||
margin-top: 24px;
|
||||
.filterButton.active {
|
||||
border-color: var(--ifm-color-primary);
|
||||
background: var(--ifm-color-primary);
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.sections {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 2rem;
|
||||
}
|
||||
|
||||
.group {
|
||||
scroll-margin-top: calc(var(--ifm-navbar-height, 64px) + 1rem);
|
||||
}
|
||||
|
||||
.subGroup:first-child {
|
||||
margin-top: 16px;
|
||||
}
|
||||
|
||||
.subGroupTitle {
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
color: var(--ifm-color-emphasis-800);
|
||||
margin-bottom: 14px;
|
||||
padding: 6px 0 6px 24px;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.subGroupContent {
|
||||
margin-left: 24px;
|
||||
padding-left: 16px;
|
||||
border-left: 2px solid var(--ifm-color-emphasis-100);
|
||||
}
|
||||
|
||||
/* 无结果状态 */
|
||||
.noResults {
|
||||
.groupHeader {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
justify-content: space-between;
|
||||
gap: 1rem;
|
||||
margin-bottom: 1rem;
|
||||
padding-bottom: 0.5rem;
|
||||
border-bottom: 1px solid var(--oneao-border);
|
||||
}
|
||||
|
||||
.groupTitle {
|
||||
margin: 0;
|
||||
font-size: 1.125rem;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.groupCount {
|
||||
color: var(--ifm-color-emphasis-500);
|
||||
font-size: 0.8125rem;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.subSection {
|
||||
margin-top: 1rem;
|
||||
}
|
||||
|
||||
.subSection:first-of-type {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
.subHeader {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
margin-bottom: 0.625rem;
|
||||
}
|
||||
|
||||
.subTitle {
|
||||
margin: 0;
|
||||
color: var(--ifm-color-emphasis-800);
|
||||
font-size: 0.95rem;
|
||||
font-weight: 650;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.subCount {
|
||||
color: var(--ifm-color-emphasis-500);
|
||||
font-size: 0.75rem;
|
||||
}
|
||||
|
||||
.grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(5, minmax(0, 1fr));
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
.card {
|
||||
position: relative;
|
||||
display: flex;
|
||||
min-width: 0;
|
||||
min-height: 86px;
|
||||
flex-direction: column;
|
||||
padding: 0.72rem 0.75rem 0.7rem 0.85rem;
|
||||
border: 1px solid transparent;
|
||||
border-left: 3px solid var(--oneao-border);
|
||||
border-radius: 8px;
|
||||
background: var(--oneao-surface-soft);
|
||||
color: inherit;
|
||||
text-decoration: none;
|
||||
transition: background-color 0.16s ease, border-color 0.16s ease, transform 0.16s ease;
|
||||
}
|
||||
|
||||
.card:hover,
|
||||
.card:focus-visible {
|
||||
color: inherit;
|
||||
text-decoration: none;
|
||||
border-color: var(--ifm-color-primary);
|
||||
background: var(--oneao-hover);
|
||||
transform: translateY(-1px);
|
||||
}
|
||||
|
||||
.card:focus-visible {
|
||||
outline: 2px solid var(--ifm-color-primary);
|
||||
outline-offset: 2px;
|
||||
}
|
||||
|
||||
.cardTopline {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.45rem;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.icon,
|
||||
.placeholder {
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.icon {
|
||||
object-fit: contain;
|
||||
}
|
||||
|
||||
.placeholder {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 80px 20px;
|
||||
color: var(--ifm-color-emphasis-600);
|
||||
border-radius: 6px;
|
||||
background: var(--ifm-background-surface-color);
|
||||
color: var(--ifm-color-emphasis-700);
|
||||
font-size: 0.8125rem;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.noResultsIcon {
|
||||
color: var(--ifm-color-emphasis-400);
|
||||
margin-bottom: 20px;
|
||||
width: 56px;
|
||||
height: 56px;
|
||||
.title {
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
color: var(--ifm-color-emphasis-900);
|
||||
font-size: 0.88rem;
|
||||
font-weight: 650;
|
||||
line-height: 1.35;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.description {
|
||||
display: -webkit-box;
|
||||
overflow: hidden;
|
||||
margin-top: 0.45rem;
|
||||
color: var(--ifm-color-emphasis-700);
|
||||
font-size: 0.78rem;
|
||||
line-height: 1.42;
|
||||
-webkit-box-orient: vertical;
|
||||
-webkit-line-clamp: 2;
|
||||
}
|
||||
|
||||
.host {
|
||||
overflow: hidden;
|
||||
margin-top: auto;
|
||||
padding-top: 0.48rem;
|
||||
color: var(--ifm-color-emphasis-500);
|
||||
font-size: 0.7rem;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.note {
|
||||
position: absolute;
|
||||
right: 0.75rem;
|
||||
bottom: calc(100% - 0.25rem);
|
||||
left: 0.75rem;
|
||||
z-index: 5;
|
||||
display: block;
|
||||
padding: 0.75rem;
|
||||
border: 1px solid var(--oneao-border);
|
||||
border-radius: 8px;
|
||||
background: var(--ifm-card-background-color);
|
||||
box-shadow: 0 12px 30px var(--oneao-shadow);
|
||||
color: var(--ifm-color-emphasis-800);
|
||||
font-size: 0.8125rem;
|
||||
line-height: 1.6;
|
||||
opacity: 0;
|
||||
pointer-events: none;
|
||||
transform: translateY(0.35rem);
|
||||
transition: opacity 0.16s ease, transform 0.16s ease;
|
||||
}
|
||||
|
||||
.note::after {
|
||||
position: absolute;
|
||||
right: 1rem;
|
||||
bottom: -6px;
|
||||
width: 10px;
|
||||
height: 10px;
|
||||
border-right: 1px solid var(--oneao-border);
|
||||
border-bottom: 1px solid var(--oneao-border);
|
||||
background: var(--ifm-card-background-color);
|
||||
content: "";
|
||||
transform: rotate(45deg);
|
||||
}
|
||||
|
||||
.card:hover .note,
|
||||
.card:focus-visible .note {
|
||||
opacity: 1;
|
||||
transform: translateY(0);
|
||||
}
|
||||
|
||||
.noteLabel {
|
||||
display: block;
|
||||
margin-bottom: 0.25rem;
|
||||
color: var(--ifm-color-primary-dark);
|
||||
font-size: 0.75rem;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.noResults {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
min-height: 180px;
|
||||
border: 1px dashed var(--ifm-color-emphasis-300);
|
||||
border-radius: 8px;
|
||||
color: var(--ifm-color-emphasis-600);
|
||||
}
|
||||
|
||||
.noResults p {
|
||||
margin: 0;
|
||||
font-size: 15px;
|
||||
}
|
||||
|
||||
[data-theme="dark"] .placeholder {
|
||||
background: rgba(255, 255, 255, 0.08);
|
||||
}
|
||||
|
||||
@media (max-width: 996px) {
|
||||
.grid {
|
||||
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 576px) {
|
||||
.toolbar {
|
||||
align-items: stretch;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.resultCount {
|
||||
align-self: flex-end;
|
||||
}
|
||||
|
||||
.grid {
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
}
|
||||
}
|
||||
|
||||
@media (min-width: 1440px) {
|
||||
.grid {
|
||||
grid-template-columns: repeat(6, minmax(0, 1fr));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user