Skip to content

Commit

Permalink
config env
Browse files Browse the repository at this point in the history
  • Loading branch information
newfish-cmyk committed Nov 28, 2023
1 parent bf6c42b commit 789d6da
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 25 deletions.
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"i18n-ally.localesPaths": [
"projects/*/public/locales"
]
],
"i18n-ally.keystyle": "nested"
}
8 changes: 3 additions & 5 deletions projects/xiaoyi/src/pages/404.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import React, { useEffect } from 'react';
import { useRouter } from 'next/router';

const NonePage = () => {
const router = useRouter();
const NonePage = ({ appUrl }: { appUrl: string }) => {
useEffect(() => {
window.location.href = process.env.NEXT_PUBLIC_APP_LIST_URL || "";
}, [router]);
window.location.href = "/";
}, [appUrl]);

return <div></div>;
};
Expand Down
4 changes: 2 additions & 2 deletions projects/xiaoyi/src/pages/components/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { useTranslation } from 'next-i18next';
import Avatar from '@/components/Avatar';
import CommunityModal from '@/components/CommunityModal';

const Footer = () => {
const Footer = ({ appUrl }: { appUrl: string }) => {
const { t } = useTranslation();
const { isOpen, onOpen, onClose } = useDisclosure();
const list = useMemo(
Expand All @@ -15,7 +15,7 @@ const Footer = () => {
{
label: t('home.Footer FastGPT Cloud', { title: '小亦 AI' }),
onClick: () => {
window.location.href = process.env.NEXT_PUBLIC_APP_LIST_URL || "";
window.location.href = appUrl;
}
},
{
Expand Down
4 changes: 2 additions & 2 deletions projects/xiaoyi/src/pages/components/Hero.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Box, Flex, Button, Image } from '@chakra-ui/react';
import React from 'react';
import { useTranslation } from 'next-i18next';

const Hero = () => {
const Hero = ({ appUrl }: { appUrl: string }) => {
const { t } = useTranslation();

return (
Expand All @@ -20,7 +20,7 @@ const Hero = () => {
borderRadius={'xl'}
py={[2, 3]}
w={'150px'}
onClick={() => window.location.href = process.env.NEXT_PUBLIC_APP_LIST_URL || ""}
onClick={() => window.location.href = appUrl}
>
{t('home.Start Now')}
</Button>
Expand Down
11 changes: 6 additions & 5 deletions projects/xiaoyi/src/pages/components/Navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import CommunityModal from '@/components/CommunityModal';
import { useSystemStore } from '@/web/common/system/useSystemStore';
import MyIcon from '@/components/Icon';

const Navbar = () => {
const Navbar = (props: {loginUrl: string, appUrl: string}) => {
const { loginUrl, appUrl } = props;
const { t } = useTranslation();
const [scrollTop, setScrollTop] = useState(0);
const {
Expand Down Expand Up @@ -115,10 +116,10 @@ const Navbar = () => {
{item.label}
</Box>
))}
<Box {...menuStyles} onClick={() => {window.location.href = process.env.NEXT_PUBLIC_LOGIN_PAGE_URL || ""}}>
<Box {...menuStyles} onClick={() => {window.location.href = loginUrl}}>
{t('home.Login')}
</Box>
<Button ml={4} h={'36px'} borderRadius={'3xl'} onClick={() => {window.location.href = process.env.NEXT_PUBLIC_APP_LIST_URL || ""}}>
<Button ml={4} h={'36px'} borderRadius={'3xl'} onClick={() => {window.location.href = appUrl}}>
{t('home.Start Now')}
</Button>
</>
Expand All @@ -138,10 +139,10 @@ const Navbar = () => {
</Box>
))}
<Box bg={'myGray.500'} h={'1.5px'} w={'20px'} mb={8} />
<Box mb={10} onClick={() => window.location.href = process.env.NEXT_PUBLIC_LOGIN_PAGE_URL || ""}>
<Box mb={10} onClick={() => window.location.href = loginUrl}>
{t('home.Login')}
</Box>
<Button h={'36px'} borderRadius={'3xl'} onClick={() => window.location.href = process.env.NEXT_PUBLIC_APP_LIST_URL || ""}>
<Button h={'36px'} borderRadius={'3xl'} onClick={() => window.location.href = appUrl}>
{t('home.Start Now')}
</Button>
</Box>
Expand Down
16 changes: 6 additions & 10 deletions projects/xiaoyi/src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,9 @@ import Choice from './components/Choice';
import Footer from './components/Footer';
import Loading from '@/components/Loading';

const Home = ({ homeUrl = '/' }: { homeUrl: string }) => {
const Home = ({ loginUrl, appUrl }: { loginUrl: string, appUrl: string }) => {
const router = useRouter();

if (homeUrl !== '/') {
router.replace(homeUrl);
}

useEffect(() => {
router.prefetch('/app/list');
router.prefetch('/login');
Expand All @@ -26,22 +22,21 @@ const Home = ({ homeUrl = '/' }: { homeUrl: string }) => {
<>
<Box id="home" bg={'myWhite.600'} h={'100vh'} overflowY={'auto'} overflowX={'hidden'}>
<Box position={'fixed'} zIndex={10} top={0} left={0} right={0}>
<Navbar />
<Navbar loginUrl={loginUrl} appUrl={appUrl} />
</Box>
<Box maxW={'1200px'} pt={'70px'} m={'auto'}>
<Hero />
<Hero appUrl={appUrl} />
<Ability />
<Box my={[4, 6]}>
<Choice />
</Box>
</Box>
{false && (
<Box bg={'white'}>
<Footer />
<Footer appUrl={appUrl} />
</Box>
)}
</Box>
{homeUrl !== '/' && <Loading bg={'white'} />}
</>
);
};
Expand All @@ -50,7 +45,8 @@ export async function getServerSideProps(content: any) {
return {
props: {
...(await serviceSideProps(content)),
homeUrl: process.env.HOME_URL || '/'
loginUrl: process.env.LOGIN_URL || '/login',
appUrl: process.env.APP_URL || '/app/list',
}
};
}
Expand Down

0 comments on commit 789d6da

Please sign in to comment.