mirror of
https://github.com/an-anime-team/an-anime-game-launcher.git
synced 2024-12-23 18:20:19 +03:00
Delete old background if new background exists
This commit is contained in:
parent
555f52f6d7
commit
364eddbb2d
1 changed files with 5 additions and 2 deletions
|
@ -103,6 +103,8 @@ export class Genshinlib
|
||||||
await fetch(`https://sdk-os-static.mihoyo.com/hk4e_global/mdk/launcher/api/content?filter_adv=true&launcher_id=10&language=${this.lang.launcher}`)
|
await fetch(`https://sdk-os-static.mihoyo.com/hk4e_global/mdk/launcher/api/content?filter_adv=true&launcher_id=10&language=${this.lang.launcher}`)
|
||||||
.then(res => res.json())
|
.then(res => res.json())
|
||||||
.then(resdone => {
|
.then(resdone => {
|
||||||
|
let oldbg = this.getConfig().background.name;
|
||||||
|
|
||||||
this.setConfig({
|
this.setConfig({
|
||||||
...this.getConfig(),
|
...this.getConfig(),
|
||||||
background: {
|
background: {
|
||||||
|
@ -118,10 +120,11 @@ export class Genshinlib
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this.downloadFile(resdone.data.adv.background, path.join(this.launcherDir, this.getConfig().background.name), (current: number, total: number, difference: number) => null).then(() => {
|
this.downloadFile(resdone.data.adv.background, path.join(this.launcherDir, this.getConfig().background.name), (current: number, total: number, difference: number) => null).then(() => {
|
||||||
|
fs.unlinkSync(path.join(this.launcherDir, oldbg));
|
||||||
bg = path.join(this.launcherDir, this.getConfig().background.name);
|
bg = path.join(this.launcherDir, this.getConfig().background.name);
|
||||||
})
|
})
|
||||||
}
|
};
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue