import LoadingIcon from "@/app/icons/three-dots.svg"; import ResetIcon from "@/app/icons/reload.svg"; import styles from "./index.module.scss"; import { useEffect, useState } from "react"; import { Avatar, AvatarPicker } from "@/app/components/emoji"; import { Popover } from "@/app/components/ui-lib"; import Locale, { AllLangs, changeLang, getLang } from "@/app/locales"; import Link from "next/link"; import { IconButton } from "@/app/components/button"; import { useUpdateStore } from "@/app/store/update"; import { SubmitKey, Theme, ThemeConfig, useAppConfig, } from "@/app/store/config"; import { getClientConfig } from "@/app/config/client"; import { RELEASE_URL, UPDATE_URL } from "@/app/constant"; import List, { ListItem } from "@/app/components/List"; import Select from "@/app/components/Select"; import SlideRange from "@/app/components/SlideRange"; import Switch from "@/app/components/Switch"; export interface AppSettingProps {} export default function AppSetting(props: AppSettingProps) { const [checkingUpdate, setCheckingUpdate] = useState(false); const [showEmojiPicker, setShowEmojiPicker] = useState(false); const updateStore = useUpdateStore(); const config = useAppConfig(); const { update: updateConfig, isMobileScreen } = config; const currentVersion = updateStore.formatVersion(updateStore.version); const remoteId = updateStore.formatVersion(updateStore.remoteVersion); const hasNewVersion = currentVersion !== remoteId; const updateUrl = getClientConfig()?.isApp ? RELEASE_URL : UPDATE_URL; function checkUpdate(force = false) { setCheckingUpdate(true); updateStore.getLatestVersion(force).then(() => { setCheckingUpdate(false); }); console.log("[Update] local version ", updateStore.version); console.log("[Update] remote version ", updateStore.remoteVersion); } useEffect(() => { // checks per minutes checkUpdate(); // eslint-disable-next-line react-hooks/exhaustive-deps }, []); return ( setShowEmojiPicker(false)} content={ { updateConfig((config) => (config.avatar = avatar)); setShowEmojiPicker(false); }} /> } open={showEmojiPicker} >
{ setShowEmojiPicker(!showEmojiPicker); }} >
{checkingUpdate ? ( ) : hasNewVersion ? ( {Locale.Settings.Update.GoToUpdate} ) : ( } text={Locale.Settings.Update.CheckUpdate} onClick={() => checkUpdate(true)} /> )} ({ value: k as Theme, label: t.title, icon: , }))} onSelect={(e) => { updateConfig((config) => (config.theme = e)); }} />