diff --git a/404.html b/404.html
new file mode 100644
index 0000000..57f85f5
--- /dev/null
+++ b/404.html
@@ -0,0 +1,12 @@
+
+
+
+ Page Not Found
+
+
+
+ Page Not Found
+
+
diff --git a/src/layouts/base.tsx b/src/layouts/base.tsx
index 0d6987d..e130285 100644
--- a/src/layouts/base.tsx
+++ b/src/layouts/base.tsx
@@ -12,6 +12,17 @@ export default function BaseLayout() {
const [isDark, setDark] = useState(false);
const navigate = useNavigate();
+ useEffect(() => {
+ if (window.location.search) {
+ const params = new URLSearchParams(window.location.search);
+ const path = params.get('path');
+ if (path) {
+ navigate(`/${path}`);
+ }
+ }
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, [window.location.search])
+
useEffect(() => {
const theme = localStorage.getItem('theme');
const isDark2 = theme === 'dracula';
diff --git a/src/views/GPTDetail.tsx b/src/views/GPTDetail.tsx
index aa03cfb..88b801d 100644
--- a/src/views/GPTDetail.tsx
+++ b/src/views/GPTDetail.tsx
@@ -1,5 +1,5 @@
-import { useLayoutEffect, useMemo } from 'react';
-import { useParams, useNavigate } from 'react-router-dom';
+import { useMemo } from 'react';
+import { useParams } from 'react-router-dom';
import dayjs from 'dayjs';
import { gptLink } from '@/utils';
@@ -11,11 +11,6 @@ import data from '@@/gpthub.json';
export default function GPTs() {
const params = useParams();
- const navigate = useNavigate();
-
- useLayoutEffect(() => {
- navigate(`/gpts/${params?.id}`)
- }, [params?.id, navigate])
const gptInfo = useMemo(() => {
return data?.gpts?.find((item) => item.id === params?.id);
diff --git a/vite.config.ts b/vite.config.ts
index 318101f..3b5c0a7 100644
--- a/vite.config.ts
+++ b/vite.config.ts
@@ -2,10 +2,19 @@ import { defineConfig, splitVendorChunkPlugin } from 'vite';
// import { VitePWA } from 'vite-plugin-pwa';
import react from '@vitejs/plugin-react-swc';
import tsconfigPaths from 'vite-tsconfig-paths';
+import { resolve } from 'path';
// https://vitejs.dev/config/
export default defineConfig({
base: '/',
+ build: {
+ rollupOptions: {
+ input: {
+ main: resolve(__dirname, 'index.html'),
+ 404: resolve(__dirname, '404.html'),
+ },
+ },
+ },
plugins: [
tsconfigPaths(),
react(),