From 81c8a762cfb542d3a2e15f82799c1d23d234dc06 Mon Sep 17 00:00:00 2001 From: eericxu <2681350846@qq.com> Date: Tue, 2 Jul 2024 12:22:35 +0800 Subject: [PATCH] adapter ipns url and ipfs url --- RELEASE.txt | 13 +++++++++++++ lib/hooks/useConfigDomain.ts | 27 ++++++++++++++++++++------- lib/useUpload.ts | 2 +- 3 files changed, 34 insertions(+), 8 deletions(-) create mode 100644 RELEASE.txt diff --git a/RELEASE.txt b/RELEASE.txt new file mode 100644 index 00000000..0344a710 --- /dev/null +++ b/RELEASE.txt @@ -0,0 +1,13 @@ +IPFS hash of the deployment: + CIDv1: bafybeidsucvs434zirxhib6npfzfqg4jagv6xkccfxjz3gmegib2bu36zq + +The latest release is always mirrored at [crustfiles.io](https://crustfiles.io). + + +Your Uniswap settings are never remembered across different URLs. + +IPFS gateways: + +- https://bafybeidsucvs434zirxhib6npfzfqg4jagv6xkccfxjz3gmegib2bu36zq.ipfs.dweb.link/ +- https://bafybeidsucvs434zirxhib6npfzfqg4jagv6xkccfxjz3gmegib2bu36zq.ipfs.cf-ipfs.com/ +- [ipfs://QmW47HPC4SPLcqU9J19iTWNzjsqyaTmbUyhxUyNLcPNqhu/](ipfs://QmW47HPC4SPLcqU9J19iTWNzjsqyaTmbUyhxUyNLcPNqhu/) \ No newline at end of file diff --git a/lib/hooks/useConfigDomain.ts b/lib/hooks/useConfigDomain.ts index 754ba922..b218b866 100644 --- a/lib/hooks/useConfigDomain.ts +++ b/lib/hooks/useConfigDomain.ts @@ -1,13 +1,26 @@ -import { useEffect } from 'react' +import { useEffect } from "react"; export const DomainRef = { - value: 'crustfiles.io', -} + value: "crustfiles.io", +}; + +const supportDomain = ["crustfiles.io", "crustfiles.com", "crustfiles.xyz"]; +export const getAvilableDomain = () => { + if (location.hostname == "localhost") return supportDomain[0]; + if (location.hostname.match(/^\d+\.\d+\.\d+\.\d+$/)?.length == 1) return supportDomain[0]; + const domains = location.hostname.split("."); + let domain = domains.slice(-2).join("."); + if (domains[1] == "ipns") { + domain = domains[0].replaceAll("-", "."); + } + if (supportDomain.includes(domain)) { + return location.hostname; + } + return supportDomain[0]; +}; export function useConfigDomain() { useEffect(() => { - if (location.hostname !== 'localhost' && location.hostname !== DomainRef.value) { - DomainRef.value = location.hostname - } - }, []) + DomainRef.value = getAvilableDomain(); + }, []); } diff --git a/lib/useUpload.ts b/lib/useUpload.ts index 58867135..3553a98d 100644 --- a/lib/useUpload.ts +++ b/lib/useUpload.ts @@ -128,7 +128,7 @@ export function useUpload(user: WrapLoginUser, options: Options): UseUpload { setUpState({ progress: Math.round(percent * 99), up: true }); }, - params: { pin: true }, + params: { pin: true, 'cid-version': 1, }, url: `${UpEndpoint}/api/v0/add` });