Refactor URL handling in initTransformers function

This commit is contained in:
kwaroran
2024-01-06 22:41:08 +09:00
parent de17fe3afa
commit 8eccda086d

View File

@@ -25,7 +25,13 @@ async function initTransformers(){
if(typeof url === 'string'){
if(url.startsWith('/tf/Xenova/')){
const newURL = 'https://sv.risuai.xyz/transformers/' + url.substring(11)
await tfCache.add(newURL)
const v = await tfCache.match(newURL)
if(v){
return v
}
const response = await fetch(newURL)
await tfCache.put(newURL, response.clone())
return response
}
if(Object.keys(tfMap).includes(url)){
const assetId = tfMap[url]