diff --git a/app/components/home.tsx b/app/components/home.tsx index ad832d5b..28f39e74 100644 --- a/app/components/home.tsx +++ b/app/components/home.tsx @@ -26,6 +26,7 @@ import { copyToClipboard, downloadAs, isIOS, selectOrCopy } from "../utils"; import Locale from "../locales"; import dynamic from "next/dynamic"; +import { REPO_URL } from "../constant"; export function Loading(props: { noLogo?: boolean }) { return ( @@ -466,10 +467,7 @@ export function Home() { />
- + } />
diff --git a/app/components/settings.tsx b/app/components/settings.tsx index f5db18b1..4966e9c4 100644 --- a/app/components/settings.tsx +++ b/app/components/settings.tsx @@ -1,4 +1,4 @@ -import { useState } from "react"; +import { useState, useEffect } from "react"; import EmojiPicker, { Theme as EmojiTheme } from "emoji-picker-react"; @@ -15,6 +15,9 @@ import { SubmitKey, useChatStore, Theme, ALL_MODELS } from "../store"; import { Avatar } from "./home"; import Locale, { changeLang, getLang } from "../locales"; +import { checkUpstreamLatestCommitId, getCurrentCommitId } from "../utils"; +import Link from "next/link"; +import { UPDATE_URL } from "../constant"; function SettingItem(props: { title: string; @@ -45,6 +48,23 @@ export function Settings(props: { closeSettings: () => void }) { ] ); + const currentId = getCurrentCommitId(); + const [checkingUpdate, setCheckingUpdate] = useState(false); + const [remoteId, setRemoteId] = useState(); + const hasNewVersion = currentId !== remoteId; + + function checkUpdate(force = false) { + setCheckingUpdate(true); + checkUpstreamLatestCommitId(force).then((id) => { + setRemoteId(id); + setCheckingUpdate(false); + }); + } + + useEffect(() => { + checkUpdate(); + }, []); + return ( <>
@@ -109,6 +129,31 @@ export function Settings(props: { closeSettings: () => void }) { + + {checkingUpdate ? ( +
+ ) : hasNewVersion ? ( + + {Locale.Settings.Update.GoToUpdate} + + ) : ( + } + text={Locale.Settings.Update.CheckUpdate} + onClick={() => checkUpdate(true)} + /> + )} + +