import { Modal } from "@/app/components/ui-lib"; import { useSyncStore } from "@/app/store/sync"; import Locale from "@/app/locales"; import { IconButton } from "@/app/components/button"; import { ProviderType } from "@/app/utils/cloud"; import { STORAGE_KEY } from "@/app/constant"; import { useMemo, useState } from "react"; import ConnectionIcon from "@/app/icons/connection.svg"; import CloudSuccessIcon from "@/app/icons/cloud-success.svg"; import CloudFailIcon from "@/app/icons/cloud-fail.svg"; import ConfirmIcon from "@/app/icons/confirm.svg"; import LoadingIcon from "@/app/icons/three-dots.svg"; import List, { ListItem } from "@/app/components/List"; import Switch from "@/app/components/Switch"; import Select from "@/app/components/Select"; import Input from "@/app/components/Input"; import { useAppConfig } from "@/app/store"; function CheckButton() { const syncStore = useSyncStore(); const couldCheck = useMemo(() => { return syncStore.cloudSync(); }, [syncStore]); const [checkState, setCheckState] = useState< "none" | "checking" | "success" | "failed" >("none"); async function check() { setCheckState("checking"); const valid = await syncStore.check(); setCheckState(valid ? "success" : "failed"); } if (!couldCheck) return null; return ( ) : checkState === "checking" ? ( ) : checkState === "success" ? ( ) : checkState === "failed" ? ( ) : ( ) } > ); } export default function SyncConfigModal(props: { onClose?: () => void }) { const syncStore = useSyncStore(); const config = useAppConfig(); const { isMobileScreen } = config; return (
props.onClose?.()} actions={[ , } bordered text={Locale.UI.Confirm} />, ]} className="!bg-modal-mask active-new" > { syncStore.update((config) => (config.proxyUrl = e)); }} > ) : null} {syncStore.provider === ProviderType.WebDAV && ( <> { syncStore.update((config) => (config.webdav.endpoint = e)); }} > { syncStore.update((config) => (config.webdav.username = e)); }} > { syncStore.update((config) => (config.webdav.password = e)); }} > )} {syncStore.provider === ProviderType.UpStash && ( <> { syncStore.update((config) => (config.upstash.endpoint = e)); }} > { syncStore.update((config) => (config.upstash.username = e)); }} > { syncStore.update((config) => (config.upstash.apiKey = e)); }} > )}
); }