mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-05-21 23:16:48 +00:00
登录结合OpenWrite
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -21,6 +21,8 @@ export default {
|
||||
},
|
||||
COMMON: {
|
||||
THEME: 'Theme',
|
||||
SIGN_IN: '登录',
|
||||
SIGN_OUT: '登出',
|
||||
ARTICLE_LIST: '文章列表',
|
||||
RECOMMEND_POSTS: '推荐文章',
|
||||
MORE: '更多',
|
||||
|
||||
Reference in New Issue
Block a user