diff --git a/package.json b/package.json index 9e115ba..546073e 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,7 @@ "@headlessui/react": "^1.7.18", "@heroicons/react": "^2.1.1", "@tailwindcss/typography": "^0.5.10", + "ahooks": "^3.7.10", "clsx": "^2.1.0", "next": "14.1.0", "next-intl": "^3.7.0", @@ -20,14 +21,14 @@ "uuid": "^9.0.1" }, "devDependencies": { - "typescript": "^5", "@types/node": "^20", "@types/react": "^18", "@types/react-dom": "^18", "autoprefixer": "^10.0.1", + "eslint": "^8", + "eslint-config-next": "14.1.0", "postcss": "^8", "tailwindcss": "^3.3.0", - "eslint": "^8", - "eslint-config-next": "14.1.0" + "typescript": "^5" } } diff --git a/src/app/[locale]/PageComponent.tsx b/src/app/[locale]/PageComponent.tsx index a721c38..fedc326 100644 --- a/src/app/[locale]/PageComponent.tsx +++ b/src/app/[locale]/PageComponent.tsx @@ -6,6 +6,7 @@ import {useState} from "react"; import {allVideoList, randomVideo} from "~/data/openaiVideo"; import HeadInfo from "~/components/HeadInfo"; import {useCommonContext} from "~/context/common-context"; +import {useInterval} from "ahooks"; const PageComponent = ({ locale = '', @@ -51,12 +52,49 @@ const PageComponent = ({ url: result.data[0].url } setVideo(video); + + // add storage + const videoHistoryListStr = localStorage.getItem('videoHistoryList'); + if (!videoHistoryListStr) { + const videoHistoryList = []; + videoHistoryList.unshift(video); + localStorage.setItem('videoHistoryList', JSON.stringify(videoHistoryList)); + } else { + const videoHistoryList = JSON.parse(videoHistoryListStr); + // check exist + let exist = false; + for (let i = 0; i < videoHistoryList.length; i++) { + const videoHistory = videoHistoryList[i]; + if (videoHistory.revised_prompt == video.revised_prompt) { + exist = true; + return; + } + } + if (!exist) { + videoHistoryList.unshift(video); + // const newList = videoHistoryList.slice(0, 3); + localStorage.setItem('videoHistoryList', JSON.stringify(videoHistoryList)); + } + } } } const [video, setVideo] = useState({revised_prompt:'', url:''}); const [videoList, setVideoList] = useState(initVideoList); + const [videoHistoryList, setVideoHistoryList] = useState([]); + const [intervalLocalStorage, setIntervalLocalStorage] = useState(500); + + useInterval(() => { + const videoHistoryListStr = localStorage.getItem('videoHistoryList'); + if (videoHistoryListStr) { + const videoHistoryList = JSON.parse(videoHistoryListStr); + setVideoHistoryList(videoHistoryList) + } else { + setVideoHistoryList([]) + } + }, intervalLocalStorage); + return ( <> 0 ? +
+
+

History

+
    + { + videoHistoryList?.map((item, index) => ( +
  • +
    +
    + +
    +
    + {currentLanguageText.prompt}: {item.revised_prompt} +
    +
    +
  • + )) + } +
+
+
+ : + null + } +
@@ -146,7 +217,7 @@ const PageComponent = ({
    { videoList?.map((item, index) => ( -
  • +
  • diff --git a/src/components/Header.tsx b/src/components/Header.tsx index 1f1cbc7..c6eb7c5 100644 --- a/src/components/Header.tsx +++ b/src/components/Header.tsx @@ -10,6 +10,24 @@ import {useCommonContext} from '~/context/common-context' import LoadingModal from "./LoadingModal"; import Image from "next/image"; +const navigation = { + social: [ + { + name: 'GitHub', + href: 'https://github.com/SoraWebui/SoraWebui', + icon: (props) => ( + + + + ), + } + ] +} + export default function Header({ locale = '', page = '', @@ -48,7 +66,7 @@ export default function Header({