feat: Remove unused import in CharConfig.svelte and update shareRisuHub function
This commit is contained in:
@@ -13,7 +13,7 @@
|
|||||||
import { onDestroy } from "svelte";
|
import { onDestroy } from "svelte";
|
||||||
import {isEqual} from 'lodash'
|
import {isEqual} from 'lodash'
|
||||||
import Help from "../Others/Help.svelte";
|
import Help from "../Others/Help.svelte";
|
||||||
import { exportChar, shareRisuHub } from "src/ts/characterCards";
|
import { exportChar } from "src/ts/characterCards";
|
||||||
import { getElevenTTSVoices, getWebSpeechTTSVoices, getVOICEVOXVoices, oaiVoices, getNovelAIVoices, FixNAITTS } from "src/ts/process/tts";
|
import { getElevenTTSVoices, getWebSpeechTTSVoices, getVOICEVOXVoices, oaiVoices, getNovelAIVoices, FixNAITTS } from "src/ts/process/tts";
|
||||||
import { checkCharOrder, getFileSrc } from "src/ts/storage/globalApi";
|
import { checkCharOrder, getFileSrc } from "src/ts/storage/globalApi";
|
||||||
import { addGroupChar, rmCharFromGroup } from "src/ts/process/group";
|
import { addGroupChar, rmCharFromGroup } from "src/ts/process/group";
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import { checkNullish, decryptBuffer, encryptBuffer, selectFileByDom, selectMult
|
|||||||
import { language } from "src/lang"
|
import { language } from "src/lang"
|
||||||
import { v4 as uuidv4 } from 'uuid';
|
import { v4 as uuidv4 } from 'uuid';
|
||||||
import { characterFormatUpdate } from "./characters"
|
import { characterFormatUpdate } from "./characters"
|
||||||
import { AppendableBuffer, checkCharOrder, downloadFile, loadAsset, LocalWriter, readImage, saveAsset, VirtualWriter } from "./storage/globalApi"
|
import { AppendableBuffer, checkCharOrder, downloadFile, loadAsset, LocalWriter, openURL, readImage, saveAsset, VirtualWriter } from "./storage/globalApi"
|
||||||
import { CurrentCharacter, selectedCharID } from "./stores"
|
import { CurrentCharacter, selectedCharID } from "./stores"
|
||||||
import { convertImage, hasher } from "./parser"
|
import { convertImage, hasher } from "./parser"
|
||||||
import { CCardLib } from '@risuai/ccardlib'
|
import { CCardLib } from '@risuai/ccardlib'
|
||||||
@@ -745,6 +745,12 @@ export async function exportSpecV2(char:character, type:'png'|'json'|'rcc' = 'pn
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function shareRisuHub3() {
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
export async function shareRisuHub2(char:character, arg:{
|
export async function shareRisuHub2(char:character, arg:{
|
||||||
nsfw: boolean,
|
nsfw: boolean,
|
||||||
tag:string
|
tag:string
|
||||||
@@ -772,6 +778,14 @@ export async function shareRisuHub2(char:character, arg:{
|
|||||||
|
|
||||||
const writer = new VirtualWriter()
|
const writer = new VirtualWriter()
|
||||||
await exportSpecV2(char, 'png', {writer: writer})
|
await exportSpecV2(char, 'png', {writer: writer})
|
||||||
|
const dat = Buffer.from(writer.buf.buffer).toString('base64') + '&' + 'rt.png'
|
||||||
|
|
||||||
|
openURL(`https://realm.risuai.net/hub/realm/upload#filedata=${encodeURIComponent(dat)}`)
|
||||||
|
|
||||||
|
let testMode = true
|
||||||
|
if(testMode){
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
const fetchPromise = fetch(hubURL + '/hub/realm/upload', {
|
const fetchPromise = fetch(hubURL + '/hub/realm/upload', {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
@@ -808,85 +822,6 @@ export async function shareRisuHub2(char:character, arg:{
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function shareRisuHub(char:character, arg:{
|
|
||||||
nsfw: boolean,
|
|
||||||
tag:string
|
|
||||||
license: string
|
|
||||||
anon: boolean
|
|
||||||
}) {
|
|
||||||
char = structuredClone(char)
|
|
||||||
char.license = arg.license
|
|
||||||
let tagList = arg.tag.split(',')
|
|
||||||
|
|
||||||
if(arg.nsfw){
|
|
||||||
tagList.push("nsfw")
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
let tags = tagList.filter((v, i) => {
|
|
||||||
return (!!v) && (tagList.indexOf(v) === i)
|
|
||||||
})
|
|
||||||
char.tags = tags
|
|
||||||
|
|
||||||
|
|
||||||
let img = await readImage(char.image)
|
|
||||||
|
|
||||||
try{
|
|
||||||
const card = await createBaseV2(char)
|
|
||||||
let resources:[string,string][] = []
|
|
||||||
if(card.data.extensions.risuai.emotions && card.data.extensions.risuai.emotions.length > 0){
|
|
||||||
for(let i=0;i<card.data.extensions.risuai.emotions.length;i++){
|
|
||||||
alertStore.set({
|
|
||||||
type: 'wait',
|
|
||||||
msg: `Loading... (Adding Emotions ${i} / ${card.data.extensions.risuai.emotions.length})`
|
|
||||||
})
|
|
||||||
const data = card.data.extensions.risuai.emotions[i][1]
|
|
||||||
const rData = await readImage(data)
|
|
||||||
resources.push([data, Buffer.from(await convertImage(rData)).toString('base64')])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(card.data.extensions.risuai.additionalAssets && card.data.extensions.risuai.additionalAssets.length > 0){
|
|
||||||
for(let i=0;i<card.data.extensions.risuai.additionalAssets.length;i++){
|
|
||||||
alertStore.set({
|
|
||||||
type: 'wait',
|
|
||||||
msg: `Loading... (Adding Additional Assets ${i} / ${card.data.extensions.risuai.additionalAssets.length})`
|
|
||||||
})
|
|
||||||
const data = card.data.extensions.risuai.additionalAssets[i][1]
|
|
||||||
const rData = await readImage(data)
|
|
||||||
resources.push([data, Buffer.from(await convertImage(rData)).toString('base64')])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const da = await fetch(hubURL + '/hub/upload', {
|
|
||||||
method: "POST",
|
|
||||||
body: JSON.stringify({
|
|
||||||
card: card,
|
|
||||||
img: Buffer.from(img).toString('base64'),
|
|
||||||
resources: resources,
|
|
||||||
token: get(DataBase)?.account?.token,
|
|
||||||
username: arg.anon ? '' : (get(DataBase)?.account?.id),
|
|
||||||
apiver: 3
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
if(da.status !== 200){
|
|
||||||
alertError(await da.text())
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
alertMd(await da.text())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch(e){
|
|
||||||
alertError(`${e}`)
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
export type hubType = {
|
export type hubType = {
|
||||||
name:string
|
name:string
|
||||||
desc: string
|
desc: string
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { get } from "svelte/store";
|
import { get } from "svelte/store";
|
||||||
import { exportSpecV2 } from "./characterCards";
|
import { exportSpecV2 } from "./characterCards";
|
||||||
import { VirtualWriter } from "./storage/globalApi";
|
import { VirtualWriter, isTauri, openURL } from "./storage/globalApi";
|
||||||
import { sleep } from "./util";
|
import { sleep } from "./util";
|
||||||
import { CurrentCharacter } from "./stores";
|
import { CurrentCharacter } from "./stores";
|
||||||
import { DataBase, type character } from "./storage/database";
|
import { DataBase, type character } from "./storage/database";
|
||||||
@@ -26,21 +26,8 @@ export async function shareRealmCard() {
|
|||||||
export async function openRealm(name:string,data:ArrayBuffer) {
|
export async function openRealm(name:string,data:ArrayBuffer) {
|
||||||
const tk = get(DataBase)?.account?.token;
|
const tk = get(DataBase)?.account?.token;
|
||||||
const id = get(DataBase)?.account?.id
|
const id = get(DataBase)?.account?.id
|
||||||
const win = window.open(`https://realm.risuai.net/upload?token=${tk}&token_id=${id}`, "_blank");
|
const trimedName = name.replace(/[^a-zA-Z0-9]/g, '') || 'character';
|
||||||
pong = false;
|
const filedata = encodeURIComponent(Buffer.from(data).toString('base64')) + `&${trimedName}.png`;
|
||||||
while(true){
|
const url = `https://realm.risuai.net/upload?token=${tk}&token_id=${id}#filedata=${filedata}`
|
||||||
if(pong){
|
window.open(url, '_blank')
|
||||||
break;
|
|
||||||
}
|
|
||||||
win.postMessage("ping", "https://realm.risuai.net")
|
|
||||||
await sleep(500);
|
|
||||||
}
|
|
||||||
alertStore.set({
|
|
||||||
type: 'none',
|
|
||||||
msg: ''
|
|
||||||
})
|
|
||||||
|
|
||||||
const nameBuf = new TextEncoder().encode(name);
|
|
||||||
|
|
||||||
win.postMessage("filedata", "https://realm.risuai.net", [nameBuf,data]);
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user