mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-05-13 23:16:47 +00:00
DashBoard组件相关
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
'use client'
|
||||
import { UserProfile } from '@clerk/nextjs'
|
||||
import dynamic from 'next/dynamic'
|
||||
import { useRouter } from 'next/router'
|
||||
import DashboardUser from './DashboardUser'
|
||||
|
||||
const DashboardMenuList = dynamic(() => import('./DashboardMenuList'))
|
||||
const DashboardItemMembership = dynamic(
|
||||
@@ -25,21 +25,11 @@ export default function DashboardBody() {
|
||||
<div className='side-tabs w-full md:w-72'>
|
||||
<DashboardMenuList />
|
||||
</div>
|
||||
{/* 控制台右侧内容 */}
|
||||
<div className='main-content-wrapper w-full'>
|
||||
{basePath === '/dashboard' && <DashboardItemHome />}
|
||||
{(basePath === '/dashboard/user-profile' ||
|
||||
basePath === '/dashboard/user-profile/security') && (
|
||||
<UserProfile
|
||||
appearance={{
|
||||
elements: {
|
||||
cardBox: 'w-full',
|
||||
rootBox: 'w-full'
|
||||
}
|
||||
}}
|
||||
className='bg-blue-300'
|
||||
routing='path'
|
||||
path='/dashboard/user-profile'
|
||||
/>
|
||||
{basePath?.indexOf('/dashboard/user-profile') === 0 && (
|
||||
<DashboardUser />
|
||||
)}
|
||||
{basePath === '/dashboard/balance' && <DashboardItemBalance />}
|
||||
{basePath === '/dashboard/membership' && <DashboardItemMembership />}
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import LazyImage from '@/components/LazyImage'
|
||||
import { useGlobal } from '@/lib/global'
|
||||
import formatDate from '@/lib/utils/formatDate'
|
||||
import { SignOutButton } from '@clerk/nextjs'
|
||||
import Link from 'next/link'
|
||||
import DashboardSignOutButton from './DashboardSignOutButton'
|
||||
|
||||
/**
|
||||
* 仪表盘页头
|
||||
* @returns
|
||||
@@ -39,13 +40,7 @@ export default function DashboardHeader() {
|
||||
|
||||
{/* 登出按钮 */}
|
||||
<div className='flex items-center'>
|
||||
<SignOutButton redirectUrl='/'>
|
||||
<button className='text-white bg-gray-800 hover:bg-gray-900 hover:ring-4 hover:ring-gray-300 focus:outline-none focus:ring-4 focus:ring-gray-300 font-medium rounded-lg text-sm px-5 py-2.5 me-2 mb-2 dark:bg-gray-800 dark:hover:bg-gray-700 dark:focus:ring-gray-700 dark:border-gray-700'>
|
||||
<span className='text-nowrap'>
|
||||
<i className='fas fa-right-from-bracket' /> Sign Out
|
||||
</span>
|
||||
</button>
|
||||
</SignOutButton>
|
||||
<DashboardSignOutButton />
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
|
||||
20
components/ui/dashboard/DashboardSignOutButton.js
Normal file
20
components/ui/dashboard/DashboardSignOutButton.js
Normal file
@@ -0,0 +1,20 @@
|
||||
import { SignOutButton } from '@clerk/nextjs'
|
||||
/**
|
||||
* 控制台登出按钮
|
||||
* @returns
|
||||
*/
|
||||
export default function DashboardSignOutButton() {
|
||||
const enableClerk = process.env.NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY
|
||||
if (!enableClerk) {
|
||||
return null
|
||||
}
|
||||
return (
|
||||
<SignOutButton redirectUrl='/'>
|
||||
<button className='text-white bg-gray-800 hover:bg-gray-900 hover:ring-4 hover:ring-gray-300 focus:outline-none focus:ring-4 focus:ring-gray-300 font-medium rounded-lg text-sm px-5 py-2.5 me-2 mb-2 dark:bg-gray-800 dark:hover:bg-gray-700 dark:focus:ring-gray-700 dark:border-gray-700'>
|
||||
<span className='text-nowrap'>
|
||||
<i className='fas fa-right-from-bracket' /> Sign Out
|
||||
</span>
|
||||
</button>
|
||||
</SignOutButton>
|
||||
)
|
||||
}
|
||||
24
components/ui/dashboard/DashboardUser.js
Normal file
24
components/ui/dashboard/DashboardUser.js
Normal file
@@ -0,0 +1,24 @@
|
||||
import { UserProfile } from '@clerk/nextjs'
|
||||
/**
|
||||
* 控制台用户账号面板
|
||||
* @returns
|
||||
*/
|
||||
export default function DashboardUser() {
|
||||
const enableClerk = process.env.NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY
|
||||
if (!enableClerk) {
|
||||
return null
|
||||
}
|
||||
return (
|
||||
<UserProfile
|
||||
appearance={{
|
||||
elements: {
|
||||
cardBox: 'w-full',
|
||||
rootBox: 'w-full'
|
||||
}
|
||||
}}
|
||||
className='bg-blue-300'
|
||||
routing='path'
|
||||
path='/dashboard/user-profile'
|
||||
/>
|
||||
)
|
||||
}
|
||||
6
lib/cache/cache_manager.js
vendored
6
lib/cache/cache_manager.js
vendored
@@ -10,10 +10,11 @@ import MemoryCache from './memory_cache'
|
||||
export async function getDataFromCache(key, force) {
|
||||
if (BLOG.ENABLE_CACHE || force) {
|
||||
const dataFromCache = await getApi().getCache(key)
|
||||
if (JSON.stringify(dataFromCache) === '[]') {
|
||||
if (!dataFromCache || JSON.stringify(dataFromCache) === '[]') {
|
||||
return null
|
||||
}
|
||||
return getApi().getCache(key)
|
||||
// console.trace('[API-->>缓存]:', key, dataFromCache)
|
||||
return dataFromCache
|
||||
} else {
|
||||
return null
|
||||
}
|
||||
@@ -23,6 +24,7 @@ export async function setDataToCache(key, data) {
|
||||
if (!data) {
|
||||
return
|
||||
}
|
||||
// console.trace('[API-->>缓存写入]:', key)
|
||||
await getApi().setCache(key, data)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user