-
-
Notifications
You must be signed in to change notification settings - Fork 341
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
72 changed files
with
13,736 additions
and
86 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { posthog } from '@demo/utils/posthog'; | ||
import { useEffect, useState } from 'react'; | ||
|
||
export const useShowLiveChat = () => { | ||
const [featureEnabled, setFeatureEnabled] = useState(false); | ||
|
||
useEffect(() => { | ||
posthog.onFeatureFlags(function () { | ||
console.log('posthog.show_live_chat', posthog.isFeatureEnabled('show_live_chat')); | ||
if (posthog.isFeatureEnabled('show_live_chat')) { | ||
setFeatureEnabled(true); | ||
} | ||
}); | ||
}, []); | ||
|
||
return { showLiveChat: featureEnabled }; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Environment variables declared in this file are automatically made available to Prisma. | ||
# See the documentation for more detail: https://pris.ly/d/prisma-schema#accessing-environment-variables-from-the-schema | ||
|
||
# Prisma supports the native connection string format for PostgreSQL, MySQL, SQLite, SQL Server, MongoDB and CockroachDB (Preview). | ||
# See the documentation for all the connection string options: https://pris.ly/d/connection-strings | ||
|
||
DATABASE_URL="" | ||
|
||
SECRET='SECRET' | ||
|
||
# When deploying to production, set the `NEXTAUTH_URL` environment variable to the canonical URL of your site. | ||
NEXTAUTH_URL='http://localhost:3000' | ||
|
||
# GitHub OAuth | ||
GITHUB_ID="" | ||
GITHUB_SECRET="" | ||
|
||
# Google Auth | ||
GOOGLE_CLIENT_ID= | ||
GOOGLE_CLIENT_SECRET= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
node_modules/ | ||
.next/ | ||
.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
### Install dependence | ||
|
||
```sh | ||
pnpm install | ||
|
||
``` | ||
|
||
### Rename .env.example to .env | ||
|
||
### install db | ||
|
||
npx prisma migrate dev | ||
|
||
### Open server | ||
|
||
npm run dev |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import { useShowLiveChat } from '@/client/hooks/useShowLiveChat'; | ||
import { pushEvent } from '@/client/utils/pushEvent'; | ||
import { Alert } from '@arco-design/web-react'; | ||
|
||
import React, { useEffect } from 'react'; | ||
import { useSessionStorage } from 'react-use'; | ||
|
||
export const CommercialBanner = ({ page }: { page: 'HOME' | 'EDITOR' }) => { | ||
const [visible, setVisible] = useSessionStorage( | ||
'commercialEmailEditorBannerVisible', | ||
true, | ||
); | ||
|
||
const { showLiveChat } = useShowLiveChat(); | ||
|
||
useEffect(() => { | ||
pushEvent({ event: `Show_Banner_at_${page}` }); | ||
}, [page]); | ||
|
||
if (!visible) return null; | ||
return ( | ||
<Alert | ||
closable | ||
onClose={() => setVisible(false)} | ||
style={{ | ||
alignItems: 'flex-start', | ||
}} | ||
banner | ||
content={ | ||
<div> | ||
<div> | ||
Is the current Easy Email not meeting <strong>your requirements</strong> ? | ||
It's time to try our more powerful commercial version of the email editor.{' '} | ||
<span> | ||
{showLiveChat ? ( | ||
<> | ||
<a | ||
onClick={() => { | ||
pushEvent({ event: `Contact_at_${page}` }); | ||
(window as any).$crisp?.push(['do', 'chat:open']); | ||
}} | ||
target='_blank' | ||
style={{ fontSize: 16 }} | ||
> | ||
<strong>Open Live Chat</strong> | ||
</a> | ||
</> | ||
) : ( | ||
<> | ||
Contact us for more information. Email:{' '} | ||
<a | ||
onClick={() => { | ||
pushEvent({ event: `Contact_at_${page}` }); | ||
}} | ||
target='_blank' | ||
href='mailto:ch.mao@qq.com' | ||
style={{ fontSize: 16 }} | ||
> | ||
<strong>ch.mao@qq.com</strong> | ||
</a> | ||
. | ||
</> | ||
)} | ||
</span> | ||
</div> | ||
</div> | ||
} | ||
></Alert> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { Spin } from "@arco-design/web-react"; | ||
import { FC } from "react"; | ||
|
||
interface LoadingScreenProps { | ||
size?: number; | ||
isFullScreen?: boolean; | ||
} | ||
|
||
const FullScreenLoading: FC<LoadingScreenProps> = ({ | ||
size = 40, | ||
isFullScreen, | ||
}) => { | ||
return ( | ||
<div | ||
style={{ | ||
width: isFullScreen ? "100vw" : "100%", | ||
height: isFullScreen ? "100vh" : "100%", | ||
display: "flex", | ||
flexDirection: "column", | ||
alignItems: "center", | ||
justifyContent: "center", | ||
}} | ||
> | ||
<Spin size={size} /> | ||
</div> | ||
); | ||
}; | ||
|
||
export default FullScreenLoading; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import React, { useState } from 'react'; | ||
import { useInterval } from 'react-use'; | ||
import { createPortal } from 'react-dom'; | ||
|
||
interface Props | ||
extends React.DetailedHTMLProps< | ||
React.IframeHTMLAttributes<HTMLIFrameElement>, | ||
HTMLIFrameElement | ||
> { | ||
children: React.ReactNode; | ||
title?: string; | ||
onChangeHeight?: (val: number) => void; | ||
windowRef?: (e: Window) => void; | ||
} | ||
|
||
export const IframeComponent = ({ | ||
children, | ||
title, | ||
windowRef, | ||
style, | ||
onChangeHeight, | ||
...props | ||
}: Props) => { | ||
const [mountNode, setMountNode] = useState<HTMLBodyElement | null>(null); | ||
const [height, setHeight] = useState(0); | ||
|
||
const onLoad: React.ReactEventHandler<HTMLIFrameElement> = evt => { | ||
const contentWindow = (evt.target as any)?.contentWindow; | ||
if (!contentWindow) return; | ||
windowRef?.(contentWindow); | ||
const innerBody = contentWindow.document.body; | ||
innerBody.style.backgroundColor = 'transparent'; | ||
setMountNode(innerBody); | ||
}; | ||
|
||
useInterval(() => { | ||
const scrollHeight = mountNode?.scrollHeight || 0; | ||
if (scrollHeight > 0) { | ||
setHeight(scrollHeight); | ||
onChangeHeight && onChangeHeight(scrollHeight); | ||
} | ||
}, 1000); | ||
|
||
return ( | ||
<iframe | ||
title={title} | ||
srcDoc={ | ||
'<!doctype html> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office"> <head></head> <body> </body> </html>' | ||
} | ||
style={{ | ||
height: `${height}px`, | ||
width: '100%', | ||
padding: 0, | ||
margin: 0, | ||
display: 'block', | ||
...style, | ||
}} | ||
frameBorder='none' | ||
{...(props as any)} | ||
onLoad={onLoad} | ||
> | ||
{mountNode && createPortal(children, mountNode)} | ||
</iframe> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import React from 'react'; | ||
import { Avatar, Dropdown, Menu } from '@arco-design/web-react'; | ||
import { IconPoweroff } from '@arco-design/web-react/icon'; | ||
|
||
import styles from './style/index.module.less'; | ||
import { signOut, useSession } from 'next-auth/react'; | ||
|
||
export const Navbar: React.FC = () => { | ||
const { data } = useSession(); | ||
|
||
const user = data?.user; | ||
const droplist = ( | ||
<Menu> | ||
<Menu.Item | ||
key='logout' | ||
onClick={() => { | ||
signOut(); | ||
}} | ||
> | ||
<IconPoweroff className={styles['dropdown-icon']} /> | ||
Logout | ||
</Menu.Item> | ||
<Menu.Item key='email'>{user?.email}</Menu.Item> | ||
</Menu> | ||
); | ||
|
||
return ( | ||
<div className={styles.navbar}> | ||
<div className={styles.left}> | ||
<div className={styles.logo}>Easy Email</div> | ||
</div> | ||
<ul className={styles.right}> | ||
{user && ( | ||
<li> | ||
<Dropdown | ||
droplist={droplist} | ||
position='br' | ||
> | ||
<Avatar | ||
size={32} | ||
style={{ cursor: 'pointer', backgroundColor: '#1d1d3d' }} | ||
> | ||
{(user.name || user.email)?.toUpperCase()} | ||
</Avatar> | ||
</Dropdown> | ||
</li> | ||
)} | ||
</ul> | ||
</div> | ||
); | ||
}; |
Oops, something went wrong.