登录结合OpenWrite

This commit is contained in:
tangly1024.com
2024-09-24 18:19:48 +08:00
parent 32a113fbce
commit 964513b1e9
18 changed files with 244 additions and 24 deletions

View File

@@ -5,6 +5,7 @@ import {
initDarkMode,
saveDarkModeToLocalStorage
} from '@/themes/theme'
import { useUser } from '@clerk/nextjs'
import { useRouter } from 'next/router'
import { createContext, useContext, useEffect, useState } from 'react'
import {
@@ -13,6 +14,10 @@ import {
redirectUserLang,
saveLangToLocalStorage
} from './lang'
/**
* 全局上下文
*/
const GlobalContext = createContext()
export function GlobalContextProvider(props) {
@@ -37,6 +42,12 @@ export function GlobalContextProvider(props) {
const [onLoading, setOnLoading] = useState(true) // 抓取文章数据
const router = useRouter()
// 登录验证相关
const enableClerk = process.env.NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY
const { isLoaded, isSignedIn, user } = enableClerk
? useUser()
: { isLoaded: true, isSignedIn: false, user: false }
// 是否全屏
const fullWidth = post?.fullWidth ?? false
@@ -119,6 +130,9 @@ export function GlobalContextProvider(props) {
return (
<GlobalContext.Provider
value={{
isLoaded,
isSignedIn,
user,
fullWidth,
NOTION_CONFIG,
THEME_CONFIG,

View File

@@ -21,6 +21,8 @@ export default {
},
COMMON: {
THEME: 'Theme',
SIGN_IN: 'Sign In',
SIGN_OUT: 'Sign Out',
ARTICLE_LIST: 'Article List',
RECOMMEND_POSTS: 'Recommend Posts',
MORE: 'More',

View File

@@ -21,6 +21,8 @@ export default {
},
COMMON: {
THEME: 'Theme',
SIGN_IN: '登录',
SIGN_OUT: '登出',
ARTICLE_LIST: '文章列表',
RECOMMEND_POSTS: '推荐文章',
MORE: '更多',