mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-06-07 23:16:52 +00:00
feat(email encrypt): implement base64 encoding for contact email config, only supports HEO theme
This commit is contained in:
@@ -3,7 +3,12 @@
|
|||||||
*/
|
*/
|
||||||
module.exports = {
|
module.exports = {
|
||||||
// 社交链接,不需要可留空白,例如 CONTACT_WEIBO:''
|
// 社交链接,不需要可留空白,例如 CONTACT_WEIBO:''
|
||||||
CONTACT_EMAIL: process.env.NEXT_PUBLIC_CONTACT_EMAIL || '', // 邮箱地址 例如mail@tangly1024.com
|
CONTACT_EMAIL:
|
||||||
|
(process.env.NEXT_PUBLIC_CONTACT_EMAIL &&
|
||||||
|
btoa(
|
||||||
|
unescape(encodeURIComponent(process.env.NEXT_PUBLIC_CONTACT_EMAIL))
|
||||||
|
)) ||
|
||||||
|
'', // 邮箱地址 例如mail@tangly1024.com
|
||||||
CONTACT_WEIBO: process.env.NEXT_PUBLIC_CONTACT_WEIBO || '', // 你的微博个人主页
|
CONTACT_WEIBO: process.env.NEXT_PUBLIC_CONTACT_WEIBO || '', // 你的微博个人主页
|
||||||
CONTACT_TWITTER: process.env.NEXT_PUBLIC_CONTACT_TWITTER || '', // 你的twitter个人主页
|
CONTACT_TWITTER: process.env.NEXT_PUBLIC_CONTACT_TWITTER || '', // 你的twitter个人主页
|
||||||
CONTACT_GITHUB: process.env.NEXT_PUBLIC_CONTACT_GITHUB || '', // 你的github个人主页 例如 https://github.com/tangly1024
|
CONTACT_GITHUB: process.env.NEXT_PUBLIC_CONTACT_GITHUB || '', // 你的github个人主页 例如 https://github.com/tangly1024
|
||||||
|
|||||||
@@ -157,9 +157,14 @@ export async function getConfigMapFromConfigPage(allPages) {
|
|||||||
// 只导入生效的配置
|
// 只导入生效的配置
|
||||||
if (config.enable) {
|
if (config.enable) {
|
||||||
// console.log('[Notion配置]', config.key, config.value)
|
// console.log('[Notion配置]', config.key, config.value)
|
||||||
notionConfig[config.key] =
|
if (config.key === 'CONTACT_EMAIL') {
|
||||||
parseTextToJson(config.value) || config.value || null
|
notionConfig[config.key] =
|
||||||
// 配置不能是undefined,至少是null
|
(config.value && btoa(unescape(encodeURIComponent(config.value)))) || null
|
||||||
|
} else {
|
||||||
|
notionConfig[config.key] =
|
||||||
|
parseTextToJson(config.value) || config.value || null
|
||||||
|
// 配置不能是undefined,至少是null
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
12
lib/plugins/mailEncrypt.js
Normal file
12
lib/plugins/mailEncrypt.js
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
export const handleEmailClick = (e, emailIcon, CONTACT_EMAIL) => {
|
||||||
|
if (CONTACT_EMAIL && emailIcon && !emailIcon.current.href) {
|
||||||
|
e.preventDefault()
|
||||||
|
try {
|
||||||
|
const email = decodeURIComponent(escape(atob(CONTACT_EMAIL)))
|
||||||
|
emailIcon.current.href = `mailto:${email}`
|
||||||
|
emailIcon.current.click()
|
||||||
|
} catch (error) {
|
||||||
|
console.error('解密邮箱失败:', error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,6 @@
|
|||||||
import { siteConfig } from '@/lib/config'
|
import { siteConfig } from '@/lib/config'
|
||||||
|
import { useRef } from 'react'
|
||||||
|
import { handleEmailClick } from '@/lib/plugins/mailEncrypt'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 社交联系方式按钮组
|
* 社交联系方式按钮组
|
||||||
@@ -16,6 +18,9 @@ const SocialButton = () => {
|
|||||||
const ENABLE_RSS = siteConfig('ENABLE_RSS')
|
const ENABLE_RSS = siteConfig('ENABLE_RSS')
|
||||||
const CONTACT_BILIBILI = siteConfig('CONTACT_BILIBILI')
|
const CONTACT_BILIBILI = siteConfig('CONTACT_BILIBILI')
|
||||||
const CONTACT_YOUTUBE = siteConfig('CONTACT_YOUTUBE')
|
const CONTACT_YOUTUBE = siteConfig('CONTACT_YOUTUBE')
|
||||||
|
|
||||||
|
const emailIcon = useRef(null)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className='w-full justify-center flex-wrap flex'>
|
<div className='w-full justify-center flex-wrap flex'>
|
||||||
<div className='space-x-12 text-3xl text-gray-600 dark:text-gray-300 '>
|
<div className='space-x-12 text-3xl text-gray-600 dark:text-gray-300 '>
|
||||||
@@ -75,10 +80,10 @@ const SocialButton = () => {
|
|||||||
)}
|
)}
|
||||||
{CONTACT_EMAIL && (
|
{CONTACT_EMAIL && (
|
||||||
<a
|
<a
|
||||||
target='_blank'
|
onClick={e => handleEmailClick(e, emailIcon, CONTACT_EMAIL)}
|
||||||
rel='noreferrer'
|
title='email'
|
||||||
title={'email'}
|
className='cursor-pointer'
|
||||||
href={`mailto:${CONTACT_EMAIL}`}>
|
ref={emailIcon}>
|
||||||
<i className='transform hover:scale-125 duration-150 fas fa-envelope dark:hover:text-indigo-400 hover:text-indigo-600' />
|
<i className='transform hover:scale-125 duration-150 fas fa-envelope dark:hover:text-indigo-400 hover:text-indigo-600' />
|
||||||
</a>
|
</a>
|
||||||
)}
|
)}
|
||||||
|
|||||||
Reference in New Issue
Block a user