UNPKG

steam-family-bot-core

Version:

一个用于新版 Steam 家庭的库存监控 Bot 插件

43 lines 3.29 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const jsx_runtime_1 = require("react/jsx-runtime"); /** @jsxImportSource react */ const dayjs_1 = __importDefault(require("dayjs")); const getAvatar = (hash) => `https://avatars.akamai.steamstatic.com/${hash}_full.jpg`; const getGameAsset = (game, filename) => { const format = game.detail.assets?.assetUrlFormat; const prefix = 'https://cdn.akamai.steamstatic.com/'; const url = format?.replace('${FILENAME}', filename); return prefix + url; }; const getGameTrailer = (game) => { try { const format = game.detail.trailers.highlights?.[0].trailerUrlFormat; const prefix = 'https://cdn.akamai.steamstatic.com/'; // // https://cdn.akamai.steamstatic.com/steam/apps/256689996/microtrailer.webm const filename = game.detail.trailers.highlights?.[0].microtrailer[0].filename; const url = format.replace('${FILENAME}', filename); return prefix + url; } catch (e) { return null; } }; const getGameHeader = (game) => { return getGameAsset(game, game.detail.assets.header); }; const getGameCapsule = (game) => { return getGameAsset(game, game.detail.assets?.libraryCapsule ?? ''); }; function Game({ game, players }) { return ((0, jsx_runtime_1.jsx)("div", { className: 'relative w-24 sm:w-36 md:w-36 aspect-[6/9] rounded-lg text-xs text-zinc-600/60', children: (0, jsx_runtime_1.jsxs)("div", { className: 'w-full h-full relative', children: [(0, jsx_runtime_1.jsx)("img", { src: getGameCapsule(game), className: ' rounded-lg absolute z-0 inset-0', loading: 'eager' }), (0, jsx_runtime_1.jsx)("div", { className: 'absolute text-white text-[8px] top-0 left-0 bg-zinc-700/50 px-1 py-0.5 rounded-md text-xs', children: (0, jsx_runtime_1.jsx)("div", { children: dayjs_1.default.unix(game.rtTimeAcquired).format('YY年MM月DD日') }) }), (0, jsx_runtime_1.jsx)("div", { className: 'absolute bottom-0 left-0 p-1 flex text-white space-x-2', children: game.playtime && ((0, jsx_runtime_1.jsx)("div", { children: game.playtime.players.map((playtime) => { const player = players.find((it) => it.steamid?.toString() == playtime.steamid); return ((0, jsx_runtime_1.jsxs)("div", { children: [player?.personaName, ":", ' ', (playtime.secondsPlayed / 3600).toFixed(1), " h"] }, playtime.steamid)); }) })) }), (0, jsx_runtime_1.jsx)("div", { className: ' absolute bottom-0 right-0 p-1 flex text-white space-x-2', children: (0, jsx_runtime_1.jsx)("div", { className: 'mt-auto ml-auto flex flex-col group ', children: game.owners.map((it, index) => ((0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsx)("div", { className: 'h-6 w-6 border-[2px] border-zinc-700 -mt-[10px] group-hover:mb-[10px] transition-all ease-in-out rounded-full', children: (0, jsx_runtime_1.jsx)("img", { src: getAvatar(it?.avatar_hash ?? ''), alt: `@${it?.personaName}`, className: 'h-6 w-6 rounded-full', loading: 'eager' }) }) }, index))) }) })] }) }, game.appid)); } exports.default = Game; //# sourceMappingURL=game.js.map