feat: add forked
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
import { BookIcon, FlagIcon, ImageIcon, PaperclipIcon, SmileIcon, TrashIcon } from "lucide-svelte";
|
import { BookIcon, FlagIcon, ImageIcon, PaperclipIcon, SmileIcon, TrashIcon } from "lucide-svelte";
|
||||||
import { language } from "src/lang";
|
import { language } from "src/lang";
|
||||||
import { alertConfirm, alertInput, alertNormal } from "src/ts/alert";
|
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 { parseMarkdownSafe } from "src/ts/parser";
|
||||||
import { DataBase } from "src/ts/storage/database";
|
import { DataBase } from "src/ts/storage/database";
|
||||||
import RealmLicense from "./RealmLicense.svelte";
|
import RealmLicense from "./RealmLicense.svelte";
|
||||||
@@ -24,6 +24,13 @@
|
|||||||
{#if openedData.authorname}
|
{#if openedData.authorname}
|
||||||
<span class="text-borderc">Made by {openedData.authorname}</span>
|
<span class="text-borderc">Made by {openedData.authorname}</span>
|
||||||
{/if}
|
{/if}
|
||||||
|
{#if openedData.original}
|
||||||
|
<button class="text-blue-400 text-start" on:click={() => {
|
||||||
|
const original = openedData.original
|
||||||
|
openedData = null
|
||||||
|
getRealmInfo(original)
|
||||||
|
}}>Forked</button>
|
||||||
|
{/if}
|
||||||
<div class="flex justify-start gap-4 mt-4">
|
<div class="flex justify-start gap-4 mt-4">
|
||||||
<img class="h-36 w-36 rounded-md object-top object-cover" alt={openedData.name} src={`${hubURL}/resource/` + openedData.img}>
|
<img class="h-36 w-36 rounded-md object-top object-cover" alt={openedData.name} src={`${hubURL}/resource/` + openedData.img}>
|
||||||
<MultiLangDisplay value={openedData.desc} markdown={true} />
|
<MultiLangDisplay value={openedData.desc} markdown={true} />
|
||||||
|
|||||||
@@ -242,22 +242,26 @@ async function importCharacterProcess(f:{
|
|||||||
return db.characters.length - 1
|
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<null|hubType> = writable(null)
|
export const showRealmInfoStore:Writable<null|hubType> = writable(null)
|
||||||
|
|
||||||
export async function characterURLImport() {
|
export async function characterURLImport() {
|
||||||
const realmPath = (new URLSearchParams(location.search)).get('realm')
|
const realmPath = (new URLSearchParams(location.search)).get('realm')
|
||||||
try {
|
try {
|
||||||
if(realmPath){
|
if(realmPath){
|
||||||
const url = new URL(location.href);
|
getRealmInfo(realmPath)
|
||||||
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())
|
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|
||||||
@@ -1221,6 +1225,8 @@ export type hubType = {
|
|||||||
hot:number
|
hot:number
|
||||||
license:string
|
license:string
|
||||||
authorname?:string
|
authorname?:string
|
||||||
|
original?:string
|
||||||
|
type:string
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getRisuHub(arg:{
|
export async function getRisuHub(arg:{
|
||||||
|
|||||||
Reference in New Issue
Block a user