chore: Update characterCards.ts to improve asset path handling
This commit is contained in:
@@ -939,6 +939,7 @@ export async function exportCharacterCard(char:character, type:'png'|'json'|'cha
|
|||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
let type = 'other'
|
let type = 'other'
|
||||||
|
let itype = 'other'
|
||||||
switch(card.data.assets[i].type){
|
switch(card.data.assets[i].type){
|
||||||
case 'emotion':
|
case 'emotion':
|
||||||
type = 'emotion'
|
type = 'emotion'
|
||||||
@@ -953,13 +954,56 @@ export async function exportCharacterCard(char:character, type:'png'|'json'|'cha
|
|||||||
type = 'icon'
|
type = 'icon'
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
switch(card.data.assets[i].ext){
|
||||||
|
case 'png':
|
||||||
|
case 'jpg':
|
||||||
|
case 'jpeg':
|
||||||
|
case 'gif':
|
||||||
|
case 'webp':
|
||||||
|
case 'avif':
|
||||||
|
itype = 'image'
|
||||||
|
break
|
||||||
|
case 'mp3':
|
||||||
|
case 'wav':
|
||||||
|
case 'ogg':
|
||||||
|
case 'flac':
|
||||||
|
itype = 'audio'
|
||||||
|
break
|
||||||
|
case 'mp4':
|
||||||
|
case 'webm':
|
||||||
|
case 'mov':
|
||||||
|
case 'avi':
|
||||||
|
case 'mkv':
|
||||||
|
itype = 'video'
|
||||||
|
break
|
||||||
|
case 'mmd':
|
||||||
|
case 'obj':
|
||||||
|
itype = 'model'
|
||||||
|
break
|
||||||
|
case 'safetensors':
|
||||||
|
case 'cpkt':
|
||||||
|
case 'onnx':
|
||||||
|
itype = 'ai'
|
||||||
|
break
|
||||||
|
case 'otf':
|
||||||
|
case 'ttf':
|
||||||
|
case 'woff':
|
||||||
|
case 'woff2':
|
||||||
|
itype = 'fonts'
|
||||||
|
break
|
||||||
|
case 'js':
|
||||||
|
case 'ts':
|
||||||
|
case 'lua':
|
||||||
|
itype = 'code'
|
||||||
|
}
|
||||||
|
|
||||||
let path = ''
|
let path = ''
|
||||||
const name = `${assetIndex}`
|
const name = `${assetIndex}`
|
||||||
if(card.data.assets[i].ext === 'unknown'){
|
if(card.data.assets[i].ext === 'unknown'){
|
||||||
path = `assets/${type}/${name}.png`
|
path = `assets/${type}/image/${name}.png`
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
path = `assets/${type}/${name}.${card.data.assets[i].ext}`
|
path = `assets/${type}/${itype}/${name}.${card.data.assets[i].ext}`
|
||||||
}
|
}
|
||||||
card.data.assets[i].uri = 'embeded://' + path
|
card.data.assets[i].uri = 'embeded://' + path
|
||||||
await writer.write(path, rData)
|
await writer.write(path, rData)
|
||||||
|
|||||||
Reference in New Issue
Block a user