mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-06-08 07:26:47 +00:00
theme-heo-notice-bar
This commit is contained in:
@@ -1,23 +1,38 @@
|
|||||||
|
import CONFIG from '../config'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 博客统计卡牌
|
||||||
|
* @param {*} props
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
export function AnalyticsCard(props) {
|
export function AnalyticsCard(props) {
|
||||||
|
const targetDate = new Date(CONFIG.SITE_CREATE_TIME)
|
||||||
|
const today = new Date()
|
||||||
|
const diffTime = today.getTime() - targetDate.getTime() // 获取两个日期之间的毫秒数差值
|
||||||
|
const diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24)) // 将毫秒数差值转换为天数差值
|
||||||
|
|
||||||
const { postCount } = props
|
const { postCount } = props
|
||||||
return <>
|
return <>
|
||||||
<div className='ml-2 mb-3 '>
|
<div className='text-md flex flex-col space-y-1 justify-center px-3'>
|
||||||
<i className='fas fa-chart-area' /> 统计
|
|
||||||
</div>
|
|
||||||
<div className='text-xs font-light justify-center mx-7'>
|
|
||||||
<div className='inline'>
|
<div className='inline'>
|
||||||
<div className='flex justify-between'>
|
<div className='flex justify-between'>
|
||||||
<div>文章数:</div>
|
<div>文章数:</div>
|
||||||
<div>{postCount}</div>
|
<div>{postCount}</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className='hidden busuanzi_container_page_pv ml-2'>
|
<div className='inline'>
|
||||||
|
<div className='flex justify-between'>
|
||||||
|
<div>建站天数:</div>
|
||||||
|
<div>{diffDays} 天</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className='hidden busuanzi_container_page_pv'>
|
||||||
<div className='flex justify-between'>
|
<div className='flex justify-between'>
|
||||||
<div>访问量:</div>
|
<div>访问量:</div>
|
||||||
<div className='busuanzi_value_page_pv' />
|
<div className='busuanzi_value_page_pv' />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className='hidden busuanzi_container_site_uv ml-2'>
|
<div className='hidden busuanzi_container_site_uv'>
|
||||||
<div className='flex justify-between'>
|
<div className='flex justify-between'>
|
||||||
<div>访客数:</div>
|
<div>访客数:</div>
|
||||||
<div className='busuanzi_value_site_uv' />
|
<div className='busuanzi_value_site_uv' />
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ import CONFIG from '../config'
|
|||||||
*/
|
*/
|
||||||
const Hero = props => {
|
const Hero = props => {
|
||||||
return (
|
return (
|
||||||
<div id="hero-wrapper" className='recent-top-post-group w-full mt-20 overflow-hidden select-none px-5 mb-4'>
|
<div id="hero-wrapper" className='recent-top-post-group w-full overflow-hidden select-none px-5 mb-4'>
|
||||||
<hero id="hero" style={{ zIndex: 1 }} className="recent-post-top rounded-[12px] 2xl:px-5 recent-top-post-group max-w-[86rem] overflow-x-scroll w-full mx-auto flex-row flex-nowrap flex relative space-x-3" >
|
<hero id="hero" style={{ zIndex: 1 }} className="recent-post-top rounded-[12px] 2xl:px-5 recent-top-post-group max-w-[86rem] overflow-x-scroll w-full mx-auto flex-row flex-nowrap flex relative space-x-3" >
|
||||||
{/* 左侧banner组 */}
|
{/* 左侧banner组 */}
|
||||||
<BannerGroup {...props} />
|
<BannerGroup {...props} />
|
||||||
|
|||||||
@@ -1,18 +1,37 @@
|
|||||||
|
|
||||||
import { ArrowRightCircle } from '@/components/HeroIcons'
|
import { ArrowRightCircle } from '@/components/HeroIcons'
|
||||||
import Link from 'next/link'
|
import CONFIG from '../config'
|
||||||
|
import Swipe from './Swipe'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通知横幅
|
* 通知横幅
|
||||||
*/
|
*/
|
||||||
export function NoticeBar() {
|
export function NoticeBar() {
|
||||||
|
const notices = CONFIG.NOTICE_BAR
|
||||||
|
|
||||||
|
if (!notices || notices?.length === 0) {
|
||||||
|
return <></>
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<notice className="max-w-[86rem] w-full mx-auto flex h-12 mb-4 px-5 font-bold">
|
<notice className="max-w-[86rem] w-full mx-auto flex h-12 mb-4 px-5 font-bold">
|
||||||
<Link href='https://tangly1024.com' className="bg-white hover:border-indigo-600 duration-200 hover:shadow-md transition-all rounded-xl border w-full h-full flex items-center justify-between px-5">
|
<div className="group cursor-pointer bg-white hover:border-indigo-600 duration-200 hover:shadow-md transition-all rounded-xl border w-full h-full flex items-center justify-between px-5">
|
||||||
<span className='whitespace-nowrap'>此刻</span>
|
<span className='whitespace-nowrap'>此刻</span>
|
||||||
<div className="w-full h-full hover:text-indigo-600 flex justify-center items-center">欢迎来到我的博客</div>
|
<div className="w-full h-full hover:text-indigo-600 flex justify-center items-center">
|
||||||
<div><ArrowRightCircle className={'w-5 h-5'} /></div>
|
<Swipe items={notices} />
|
||||||
</Link>
|
</div>
|
||||||
</notice>
|
<div><ArrowRightCircle className={'w-5 h-5'} /></div>
|
||||||
|
</div>
|
||||||
|
</notice>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {notices?.map((n, index) => {
|
||||||
|
return <Link key={index} href={n.url} className="bg-white hover:border-indigo-600 duration-200 hover:shadow-md transition-all rounded-xl border w-full h-full flex items-center justify-between px-5">
|
||||||
|
<span className='whitespace-nowrap'>{n.category}</span>
|
||||||
|
<div className="w-full h-full hover:text-indigo-600 flex justify-center items-center">{n.title}</div>
|
||||||
|
<div><ArrowRightCircle className={'w-5 h-5'} /></div>
|
||||||
|
</Link>
|
||||||
|
})}
|
||||||
|
*/
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import Catalog from './Catalog'
|
|||||||
import { InfoCard } from './InfoCard'
|
import { InfoCard } from './InfoCard'
|
||||||
import dynamic from 'next/dynamic'
|
import dynamic from 'next/dynamic'
|
||||||
import Live2D from '@/components/Live2D'
|
import Live2D from '@/components/Live2D'
|
||||||
import MenuGroupCard from './MenuGroupCard'
|
|
||||||
import FlipCard from '@/components/FlipCard'
|
import FlipCard from '@/components/FlipCard'
|
||||||
import Link from 'next/link'
|
import Link from 'next/link'
|
||||||
import { AnalyticsCard } from './AnalyticsCard'
|
import { AnalyticsCard } from './AnalyticsCard'
|
||||||
@@ -63,7 +62,6 @@ export default function SideRight(props) {
|
|||||||
<Card className={'sticky top-20 bg-white'}>
|
<Card className={'sticky top-20 bg-white'}>
|
||||||
<TagGroups tags={tagOptions} currentTag={currentTag} />
|
<TagGroups tags={tagOptions} currentTag={currentTag} />
|
||||||
<hr className='mx-1 flex border-dashed relative my-2'/>
|
<hr className='mx-1 flex border-dashed relative my-2'/>
|
||||||
<MenuGroupCard {...props} />
|
|
||||||
<AnalyticsCard {...props} />
|
<AnalyticsCard {...props} />
|
||||||
</Card>
|
</Card>
|
||||||
|
|
||||||
|
|||||||
73
themes/heo/components/Swipe.js
Normal file
73
themes/heo/components/Swipe.js
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
import { isBrowser } from '@/lib/utils'
|
||||||
|
import { useEffect, useState } from 'react'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 一个swipe组件
|
||||||
|
* 垂直方向,定时滚动
|
||||||
|
* @param {*} param0
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
export function Swipe({ items }) {
|
||||||
|
const [activeIndex, setActiveIndex] = useState(0)
|
||||||
|
|
||||||
|
const handleClick = (item) => {
|
||||||
|
if (isBrowser()) {
|
||||||
|
window.open(item?.url)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const interval = setInterval(() => {
|
||||||
|
setActiveIndex((activeIndex + 1) % items.length)
|
||||||
|
}, 3000)
|
||||||
|
return () => clearInterval(interval)
|
||||||
|
}, [activeIndex, items.length])
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="h-full relative w-full overflow-hidden">
|
||||||
|
{items.map((item, index) => (
|
||||||
|
<div
|
||||||
|
onClick={() => handleClick(item)}
|
||||||
|
key={index}
|
||||||
|
className={`absolute top-0 bottom-0 w-full h-full flex justify-center items-center line-clamp-1 transform transition-transform duration-500 ${index === activeIndex ? 'translate-y-0 slide-in' : 'translate-y-full slide-out'
|
||||||
|
}`}
|
||||||
|
>
|
||||||
|
{item.title}
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
<style jsx>{`
|
||||||
|
.slide-in {
|
||||||
|
animation-name: slide-in;
|
||||||
|
animation-duration: 0.5s;
|
||||||
|
animation-fill-mode: forwards;
|
||||||
|
}
|
||||||
|
|
||||||
|
.slide-out {
|
||||||
|
animation-name: slide-out;
|
||||||
|
animation-duration: 0.5s;
|
||||||
|
animation-fill-mode: forwards;
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes slide-in {
|
||||||
|
from {
|
||||||
|
transform: translateY(100%);
|
||||||
|
}
|
||||||
|
to {
|
||||||
|
transform: translateY(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes slide-out {
|
||||||
|
from {
|
||||||
|
transform: translateY(0);
|
||||||
|
}
|
||||||
|
to {
|
||||||
|
transform: translateY(-100%);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`}</style>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
};
|
||||||
|
|
||||||
|
export default Swipe
|
||||||
@@ -1,6 +1,15 @@
|
|||||||
const CONFIG = {
|
const CONFIG = {
|
||||||
HOME_BANNER_ENABLE: true,
|
HOME_BANNER_ENABLE: true,
|
||||||
// 欢迎语
|
|
||||||
|
SITE_CREATE_TIME: '2021-09-21', // 建站日期,用于计算网站运行的第几天
|
||||||
|
|
||||||
|
// 首页顶部通知条滚动内容,如不需要可以留空 []
|
||||||
|
NOTICE_BAR: [
|
||||||
|
{ url: 'https://blog.tangly1024.com', title: '欢迎来到我的博客' },
|
||||||
|
{ url: 'https://docs.tangly1024.com', title: '访问文档中心获取更多帮助' }
|
||||||
|
],
|
||||||
|
|
||||||
|
// 个人资料卡牌欢迎语
|
||||||
INFOCARD_GREETINGS: [
|
INFOCARD_GREETINGS: [
|
||||||
'你好!我是',
|
'你好!我是',
|
||||||
'🔍 分享与热心帮助',
|
'🔍 分享与热心帮助',
|
||||||
|
|||||||
@@ -134,11 +134,11 @@ const LayoutIndex = (props) => {
|
|||||||
*/
|
*/
|
||||||
const LayoutPostList = (props) => {
|
const LayoutPostList = (props) => {
|
||||||
// 博客列表上方嵌入一个 通知横幅和英雄块
|
// 博客列表上方嵌入一个 通知横幅和英雄块
|
||||||
const headerSlot = <>
|
const headerSlot = <div className='mt-20'>
|
||||||
{/* 通知横幅 */}
|
{/* 通知横幅 */}
|
||||||
<NoticeBar />
|
<NoticeBar />
|
||||||
<Hero {...props} />
|
<Hero {...props} />
|
||||||
</>
|
</div>
|
||||||
|
|
||||||
// 右侧栏
|
// 右侧栏
|
||||||
const slotRight = <SideRight {...props} />
|
const slotRight = <SideRight {...props} />
|
||||||
|
|||||||
Reference in New Issue
Block a user