allow screenshot from game as thumbnail header

This commit is contained in:
2026-02-07 12:48:13 +02:00
parent ab9c4d0508
commit 1978e82888
5 changed files with 42 additions and 2 deletions
+11 -1
View File
@@ -1,3 +1,5 @@
import sharp from 'sharp';
sharp.cache({ files : 0 });
const collection = 'games';
/**
@@ -11,7 +13,7 @@ class GamesManager{
* @param {App} app Class initializer, основна апликация
*/
init(app){
const {db, am} = app;
const {db, am, config} = app;
/**
* Creates a new game definition, създаване на нова игрова дефиниция
@@ -69,6 +71,14 @@ class GamesManager{
project: { name:1, id:1, thumb: 1}
});
}
this.setHeader = async function(ctx, id, file){
await sharp(file.path).resize({height: 500}).webp({quality: 75}).toFile(`${config.fs.repo}/thumb/${id}.webp`);
await sharp(file.path).webp({quality: 75}).toFile(`${config.fs.repo}/default/${id}.webp`);
let object = await this.read(id);
object.thumb = id;
await this.update(ctx, object);
}
}
/**