修复被回滚的内容

This commit is contained in:
copcap 2023-11-19 06:30:19 +08:00
parent 2b2e8885dc
commit e5e57f59ee
No known key found for this signature in database
GPG Key ID: 30E7AB6699451AEE
1 changed files with 27 additions and 30 deletions

View File

@ -8656,36 +8656,33 @@
else src=`image/${type}/${subfolder}/${name}${ext}`; else src=`image/${type}/${subfolder}/${name}${ext}`;
} }
else src=`image/${name}${ext}`; else src=`image/${name}${ext}`;
new Promise((resolve,reject)=>{
const image=new Image();
image.src=`${lib.assetURL}${src}`;
image.onload=resolve;
if(type=='character') image.onerror=reject;
}).then(()=>{
this.setBackgroundImage(src); this.setBackgroundImage(src);
this.style.backgroundPositionX='center'; this.style.backgroundPositionX='center';
this.style.backgroundSize='cover'; this.style.backgroundSize='cover';
}).catch(()=>new Promise((resolve,reject)=>{ if(type=='character'){
new Promise((_,reject)=>{
const image=new Image();
image.src=`${lib.assetURL}${src}`;
image.onerror=reject;
}).catch(()=>new Promise((_,reject)=>{
const nameinfo=get.character(name); const nameinfo=get.character(name);
if(!nameinfo) reject('noinfo');
const sex=nameinfo[0]; const sex=nameinfo[0];
src=`image/character/default_silhouette_${sex}${ext}`; src=`image/character/default_silhouette_${sex}${ext}`;
const image=new Image(); const image=new Image();
image.src=`${lib.assetURL}${src}`; image.src=`${lib.assetURL}${src}`;
image.onload=()=>resolve(src); image.onload=()=>this.setBackgroundImage(src);
image.onerror=reject; image.onerror=()=>reject(`sex:${sex}`);
}).catch(()=>new Promise((resolve,reject)=>{ })).catch(reason=>{
const nameinfo=get.character(name); let sex;
const sex=nameinfo[0]; if(reason=='noinfo') sex='male';
else sex=reason.slice(4);
src=`image/character/default_silhouette_${sex=='female'?'female':'male'}${ext}`; src=`image/character/default_silhouette_${sex=='female'?'female':'male'}${ext}`;
const image=new Image(); const image=new Image();
image.src=`${lib.assetURL}${src}`; image.src=`${lib.assetURL}${src}`;
image.onload=()=>resolve(src); image.onload=()=>this.setBackgroundImage(src);
image.onerror=reject; });
})).then((src)=>{ }
this.setBackgroundImage(src);
this.style.backgroundPositionX='center';
this.style.backgroundSize='cover';
}));
return this; return this;
} }
}); });