From a4ac170f5bd77ad3d52e6b52928fdfcb3850eea6 Mon Sep 17 00:00:00 2001 From: kwaroran Date: Tue, 4 Jun 2024 12:13:33 +0900 Subject: [PATCH] feat: add forked --- src/lib/UI/Realm/RealmPopUp.svelte | 9 ++++++++- src/ts/characterCards.ts | 26 ++++++++++++++++---------- 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/src/lib/UI/Realm/RealmPopUp.svelte b/src/lib/UI/Realm/RealmPopUp.svelte index 255c8158..defb9f1d 100644 --- a/src/lib/UI/Realm/RealmPopUp.svelte +++ b/src/lib/UI/Realm/RealmPopUp.svelte @@ -2,7 +2,7 @@ import { BookIcon, FlagIcon, ImageIcon, PaperclipIcon, SmileIcon, TrashIcon } from "lucide-svelte"; import { language } from "src/lang"; import { alertConfirm, alertInput, alertNormal } from "src/ts/alert"; - import { hubURL, type hubType, downloadRisuHub } from "src/ts/characterCards"; + import { hubURL, type hubType, downloadRisuHub, getRealmInfo } from "src/ts/characterCards"; import { parseMarkdownSafe } from "src/ts/parser"; import { DataBase } from "src/ts/storage/database"; import RealmLicense from "./RealmLicense.svelte"; @@ -24,6 +24,13 @@ {#if openedData.authorname} Made by {openedData.authorname} {/if} + {#if openedData.original} + + {/if}
{openedData.name} diff --git a/src/ts/characterCards.ts b/src/ts/characterCards.ts index 13bf17ad..2b05fbcd 100644 --- a/src/ts/characterCards.ts +++ b/src/ts/characterCards.ts @@ -242,22 +242,26 @@ async function importCharacterProcess(f:{ return db.characters.length - 1 } +export const getRealmInfo = async (realmPath:string) => { + const url = new URL(location.href); + url.searchParams.delete('realm'); + window.history.pushState(null, '', url.toString()); + + const res = await fetch(`${hubURL}/hub/info/${realmPath}`) + if(res.status !== 200){ + alertError(await res.text()) + return + } + showRealmInfoStore.set(await res.json()) +} + export const showRealmInfoStore:Writable = writable(null) export async function characterURLImport() { const realmPath = (new URLSearchParams(location.search)).get('realm') try { if(realmPath){ - const url = new URL(location.href); - url.searchParams.delete('realm'); - window.history.pushState(null, '', url.toString()); - - const res = await fetch(`${hubURL}/hub/info/${realmPath}`) - if(res.status !== 200){ - alertError(await res.text()) - return - } - showRealmInfoStore.set(await res.json()) + getRealmInfo(realmPath) } } catch (error) { @@ -1221,6 +1225,8 @@ export type hubType = { hot:number license:string authorname?:string + original?:string + type:string } export async function getRisuHub(arg:{