Skip to content

Commit

Permalink
Merge pull request #170 from tangly1024/feature_from_hellwalker
Browse files Browse the repository at this point in the history
Feature from hellwalker
  • Loading branch information
tangly1024 authored Apr 11, 2022
2 parents 0995556 + e3ebc00 commit 82a4c73
Show file tree
Hide file tree
Showing 9 changed files with 52 additions and 51 deletions.
18 changes: 9 additions & 9 deletions lib/cache/cache_manager.js
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
import { getCacheFromMemory, setCacheToMemory, delCacheFromMemory } from '@/lib/cache/memory_cache'
// import { getCacheFromFile, setCacheToFile, delCacheFromFile } from './local_file_cache'
const enableCache = true // 生产环境禁用
import { getCacheFromMemory as getCache, setCacheToMemory as setCache, delCacheFromMemory as delCache } from '@/lib/cache/memory_cache'
// import { getCacheFromFile as getCache, setCacheToFile as setCache, delCacheFromFile as delCache } from './local_file_cache'
const enableCache = true

/**
* 为减少频繁接口请求,notion数据将被缓存
* @param {*} key
* @returns
*/
export async function getDataFromCache (key) {
export async function getDataFromCache(key) {
if (!enableCache) {
return null
}
const dataFromCache = await getCacheFromMemory(key)
const dataFromCache = await getCache(key)
if (JSON.stringify(dataFromCache) === '[]') {
return null
}
return dataFromCache
}

export async function setDataToCache (key, data) {
export async function setDataToCache(key, data) {
if (!enableCache || !data) {
return
}
await setCacheToMemory(key, data)
await setCache(key, data)
}

export async function delCacheData (key) {
export async function delCacheData(key) {
if (!enableCache) {
return
}
await delCacheFromMemory(key)
await delCache(key)
}
12 changes: 7 additions & 5 deletions themes/fukasawa/components/TopNav.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { useState } from 'react'
import Collapse from './Collapse'
import GroupMenu from './GroupMenu'
import Logo from './Logo'
import SearchInput from './SearchInput'

/**
* 顶部导航
Expand All @@ -21,22 +22,23 @@ const TopNav = props => {
<div id='sticky-nav' className={'lg:relative w-full top-0 z-20 transform duration-500 bg-white dark:bg-black'}>
<Collapse isOpen={isOpen}>
<div className='py-1 px-5'>
<GroupMenu {...props}/>
</div>
<GroupMenu {...props} />
<SearchInput {...props} />
</div>
</Collapse>
<div className='w-full flex justify-between items-center p-4 '>
{/* 左侧LOGO 标题 */}
<div className='flex flex-none flex-grow-0'>
<Logo {...props}/>
<Logo {...props} />
</div>
<div className='flex'>
</div>

{/* 右侧功能 */}
<div className='mr-1 flex justify-end items-center text-sm space-x-4 font-serif dark:text-gray-200'>
<div onClick={toggleMenuOpen} className='w-18 cursor-pointer'>
菜单 { isOpen ? <i className='fas fa-times'/> : <i className='fas fa-bars'/> }
</div>
菜单 {isOpen ? <i className='fas fa-times' /> : <i className='fas fa-bars' />}
</div>
</div>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion themes/fukasawa/config_fuka.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const FUKA_CONFIG = {
MENU_CATEGORY: true, // 显示分类
MENU_TAG: true, // 显示标签
MENU_ARCHIVE: true, // 显示归档
MENU_SEARCH: true // 显示搜索
MENU_SEARCH: false // 显示搜索

}
export default FUKA_CONFIG
4 changes: 2 additions & 2 deletions themes/hexo/components/HeaderArticle.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export default function HeaderArticle({ post, siteInfo }) {
<div className='dark:text-gray-200'>
{post.category && <>
<Link href={`/category/${post.category}`} passHref>
<div className="cursor-pointer mr-2 dark:hover:text-white border-b dark:border-gray-500 border-dashed">
<div className="cursor-pointer mr-2 dark:hover:text-white hover:underline">
<i className="mr-1 fas fa-folder-open" />
{post.category}
</div>
Expand All @@ -77,7 +77,7 @@ export default function HeaderArticle({ post, siteInfo }) {
href={`/archive#${post?.date?.start_date?.substr(0, 7)}`}
passHref
>
<a className="pl-1 mr-2 cursor-pointer border-b dark:border-gray-500 border-dashed">
<a className="pl-1 mr-2 cursor-pointer hover:underline">
{locale.COMMON.POST_TIME}: {date}
</a>
</Link>
Expand Down
12 changes: 5 additions & 7 deletions themes/hexo/components/PaginationNumber.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { useRouter } from 'next/router'
const PaginationNumber = ({ page, totalPage }) => {
const router = useRouter()
const currentPage = +page
const showNext = page !== totalPage
const showNext = page < totalPage
const pages = generatePages(page, currentPage, totalPage)

return (
Expand All @@ -30,9 +30,8 @@ const PaginationNumber = ({ page, totalPage }) => {
>
<div
rel="prev"
className={`${
currentPage === 1 ? 'invisible' : 'block'
} pb-0.5 border-white dark:border-indigo-700 hover:border-indigo-400 dark:hover:border-indigo-400 w-6 text-center cursor-pointer duration-200 hover:font-bold`}
className={`${currentPage === 1 ? 'invisible' : 'block'
} pb-0.5 border-white dark:border-indigo-700 hover:border-indigo-400 dark:hover:border-indigo-400 w-6 text-center cursor-pointer duration-200 hover:font-bold`}
>
<i className="fas fa-angle-left" />
</div>
Expand All @@ -50,9 +49,8 @@ const PaginationNumber = ({ page, totalPage }) => {
>
<div
rel="next"
className={`${
+showNext ? 'block' : 'invisible'
} pb-0.5 border-b border-indigo-300 dark:border-indigo-700 hover:border-indigo-400 dark:hover:border-indigo-400 w-6 text-center cursor-pointer duration-500 hover:font-bold`}
className={`${+showNext ? 'block' : 'invisible'
} pb-0.5 border-b border-indigo-300 dark:border-indigo-700 hover:border-indigo-400 dark:hover:border-indigo-400 w-6 text-center cursor-pointer duration-500 hover:font-bold`}
>
<i className="fas fa-angle-right" />
</div>
Expand Down
2 changes: 1 addition & 1 deletion themes/next/LayoutIndex.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const LayoutIndex = (props) => {
const { latestPosts } = props
const rightAreaSlot = CONFIG_NEXT.RIGHT_LATEST_POSTS && <Card><LatestPostsGroup latestPosts={latestPosts} /></Card>
return <LayoutBase
headerSlot={CONFIG_NEXT.HOME_BANNER && <Header />}
headerSlot={CONFIG_NEXT.HOME_BANNER && <Header {...props} />}
sideBarSlot={<LatestPostsGroup posts={latestPosts} />}
rightAreaSlot={rightAreaSlot}
{...props}
Expand Down
11 changes: 6 additions & 5 deletions themes/next/components/Header.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ let autoScroll = false
*
* @returns 头图
*/
export default function Header () {
export default function Header(props) {
const { siteInfo } = props
const [typed, changeType] = useState()
useEffect(() => {
if (!typed && window && document.getElementById('typed')) {
Expand Down Expand Up @@ -71,7 +72,7 @@ export default function Header () {
}
}

function updateHeaderHeight () {
function updateHeaderHeight() {
setTimeout(() => {
if (window) {
const wrapperElement = document.getElementById('wrapper')
Expand All @@ -97,19 +98,19 @@ export default function Header () {
className="duration-500 md:bg-fixed w-full bg-cover bg-center h-screen bg-black"
style={{
backgroundImage:
`linear-gradient(rgba(0, 0, 0, 0.8), rgba(0,0,0,0.2), rgba(0, 0, 0, 0.8) ),url("${CONFIG_NEXT.HOME_BANNER_IMAGE}")`
`linear-gradient(rgba(0, 0, 0, 0.8), rgba(0,0,0,0.2), rgba(0, 0, 0, 0.8) ),url("${siteInfo.pageCover}")`
}}
>
<div className="absolute flex h-full items-center lg:-mt-14 justify-center w-full text-4xl md:text-7xl text-white">
<div id='typed' className='flex text-center font-serif'/>
<div id='typed' className='flex text-center font-serif' />
</div>
<div
onClick={() => {
window.scrollTo({ top: wrapperTop, behavior: 'smooth' })
}}
className="cursor-pointer w-full text-center py-4 text-5xl absolute bottom-10 text-white"
>
<i className='animate-bounce fas fa-angle-down'/>
<i className='animate-bounce fas fa-angle-down' />
</div>
</header>
)
Expand Down
10 changes: 5 additions & 5 deletions themes/next/components/Logo.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import Link from 'next/link'
import React from 'react'

const Logo = props => {
const { siteInfo } = props
const { siteInfo, className } = props
return <Link href='/' passHref>
<div className='flex flex-col justify-center items-center cursor-pointer bg-black space-y-3 h-32 font-bold'>
<div className='font-serif text-xl text-white'> {siteInfo?.title}</div>
<div className='text-sm text-gray-300 font-light'> {siteInfo?.description}</div>
</div>
<div className={'flex flex-col justify-center items-center cursor-pointer bg-black space-y-3 font-bold ' + className}>
<div className='font-serif text-xl text-white'> {siteInfo?.title}</div>
<div className='text-sm text-gray-300 font-light'> {siteInfo?.description}</div>
</div>
</Link>
}
export default Logo
32 changes: 16 additions & 16 deletions themes/next/components/SideAreaLeft.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,22 @@ const SideAreaLeft = props => {
<section className='w-60'>
{/* 菜单 */}
<section className='shadow hidden lg:block mb-5 pb-4 bg-white dark:bg-hexo-black-gray hover:shadow-xl duration-200'>
<Logo {...props}/>
<Logo {...props} className='h-32' />
<div className='pt-2 px-2 font-sans'>
<MenuButtonGroup allowCollapse={true} {...props} />
<MenuButtonGroup allowCollapse={true} {...props} />
</div>
{CONFIG_NEXT.MENU_SEARCH && <div className='px-2 pt-2 font-sans'>
<SearchInput {...props} />
<SearchInput {...props} />
</div>}
</section>
</section>

<div className='sticky top-4 hidden lg:block'>
<Card>
<Tabs>
<Card>
<Tabs>
{showToc && (
<div key={locale.COMMON.TABLE_OF_CONTENTS} className='dark:text-gray-400 text-gray-600 bg-white dark:bg-hexo-black-gray duration-200'>
<Toc toc={post.toc}/>
<Toc toc={post.toc} />
</div>
)}

Expand All @@ -52,21 +52,21 @@ const SideAreaLeft = props => {
<div className='mt-2 text-center dark:text-gray-300 font-light text-xs'>
<span className='px-1 '>
<strong className='font-medium'>{postCount}</strong>{locale.COMMON.POSTS}</span>
<span className='px-1 busuanzi_container_site_uv hidden'>
| <strong className='pl-1 busuanzi_value_site_uv font-medium'/>{locale.COMMON.VISITORS}</span>
{/* <span className='px-1 busuanzi_container_site_pv hidden'>
<span className='px-1 busuanzi_container_site_uv hidden'>
| <strong className='pl-1 busuanzi_value_site_uv font-medium' />{locale.COMMON.VISITORS}</span>
{/* <span className='px-1 busuanzi_container_site_pv hidden'>
| <strong className='pl-1 busuanzi_value_site_pv font-medium'/>{locale.COMMON.VIEWS}</span> */}
</div>
</>
</div>
</Tabs>
</Card>
</Tabs>
</Card>

{slot && <div className='flex justify-center'>
{slot}
</div>}
</div>
{slot && <div className='flex justify-center'>
{slot}
</div>}
</div>

</aside>
</aside>
}
export default SideAreaLeft

1 comment on commit 82a4c73

@vercel
Copy link

@vercel vercel bot commented on 82a4c73 Apr 11, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.