UNPKG

koishi-plugin-beatsaber-bot

Version:

一个 用于 BeatSaber 的 koishi Bot 插件

22 lines (21 loc) 7.63 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"); const RankIcon_1 = __importDefault(require("../components/icons/RankIcon")); const lucide_react_1 = require("lucide-react"); const dayjs_1 = __importDefault(require("dayjs")); const utils_1 = require("../utils"); const getMods_1 = require("../utils/getMods"); const progressbar_1 = __importDefault(require("../components/progressbar")); const characteristic_1 = require("../components/characteristic"); function BSMapShare({ bsMap, bsMapQrUrl, previewQrUrl, }) { // if ranked fetch rank star const bg = "https://www.loliapi.com/acg/pe/"; return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)("div", { className: "w-[400px] rounded-none flex flex-col relative h-auto my-auto", id: "render-result", children: (0, jsx_runtime_1.jsxs)("div", { className: "relative z-10", children: [(0, jsx_runtime_1.jsxs)("div", { className: "bg-blend-darken bg-black/[.8] text-white rounded-none", children: [(0, jsx_runtime_1.jsx)("img", { src: bsMap.versions[0].coverURL, className: "w-[400px]", loading: "eager", alt: "bsmap cover" }), (0, jsx_runtime_1.jsx)("div", { className: "flex w-full h-auto flex-col", children: (0, jsx_runtime_1.jsxs)("div", { className: "p-4", children: [(0, jsx_runtime_1.jsx)("div", { className: "text-ellipsis line-clamp-2", children: (0, jsx_runtime_1.jsx)("span", { className: "text-ellipsis line-clamp-2 text-xl font-weight bg-gradient-to-r bg-clip-text text-transparent from-red-300 to-blue-300", children: bsMap.name }) }), (0, jsx_runtime_1.jsx)("div", { className: "flex items-center justify-between", children: (0, jsx_runtime_1.jsxs)("div", { className: "author flex space-x-4 items-center ", children: [(0, jsx_runtime_1.jsx)("img", { src: bsMap.uploader.avatar, className: "rounded-full w-8 h-8", loading: "eager", alt: "bsmap mapper avatar" }), (0, jsx_runtime_1.jsx)("span", { className: "text-xl", children: bsMap.uploader.name })] }) }), (0, jsx_runtime_1.jsxs)("div", { className: "meta flex space-x-4 text-xs py-2 items-center", children: [(0, jsx_runtime_1.jsx)(RankIcon_1.default, { blrank: bsMap.blRanked, ssrank: bsMap.ranked }), (0, jsx_runtime_1.jsxs)("div", { className: "flex space-x-1 items-center justify-between", children: [(0, jsx_runtime_1.jsx)(lucide_react_1.HeartPulse, { className: "w-3 h-3" }), (0, jsx_runtime_1.jsx)("span", { children: bsMap.metadata.bpm.toFixed(0) })] }), (0, jsx_runtime_1.jsxs)("div", { className: "flex space-x-1 items-center justify-between", children: [(0, jsx_runtime_1.jsx)(lucide_react_1.Clock, { className: "w-3 h-3" }), (0, jsx_runtime_1.jsx)("span", { children: dayjs_1.default.duration(bsMap.metadata.duration, 'seconds').format('mm:ss') })] }), (0, jsx_runtime_1.jsxs)("div", { className: "flex space-x-1 items-center justify-between", children: [(0, jsx_runtime_1.jsx)(lucide_react_1.Key, { className: "w-3 h-3" }), (0, jsx_runtime_1.jsx)("span", { className: "font-weight bg-gradient-to-r bg-clip-text text-transparent from-red-300 to-blue-300", children: bsMap.id })] }), (0, jsx_runtime_1.jsxs)("div", { className: "flex space-x-2 text-xs", children: [(0, jsx_runtime_1.jsx)("span", { children: (0, jsx_runtime_1.jsx)(lucide_react_1.Calendar, { className: "h-3 w-3" }) }), (0, jsx_runtime_1.jsx)("span", { children: (0, utils_1.formatTime)(bsMap.lastPublishedAt) })] })] }), (0, jsx_runtime_1.jsx)("div", { className: "tags flex flex-wrap justify-start", children: bsMap.tags?.sort(((a, b) => b.length - a.length)) ?.map(item => ((0, jsx_runtime_1.jsx)("span", { className: "text-xs mx-1 text-white bg-red-500 rounded px-1", children: (0, utils_1.getTag)(item) }, item))) }), (0, jsx_runtime_1.jsx)("div", { className: "tags flex flex-wrap justify-start pt-2", children: (0, getMods_1.getMods)(bsMap)?.sort(((a, b) => b.length - a.length)) ?.map(item => ((0, jsx_runtime_1.jsx)("span", { className: "text-xs mx-1 text-white bg-blue-500 rounded px-1", children: item }, item))) }), (0, jsx_runtime_1.jsxs)("div", { className: "flex space-x-2", children: [(0, jsx_runtime_1.jsxs)("div", { className: "percentage w-42 py-2 flex text-xs items-center space-x-4", children: [(0, jsx_runtime_1.jsx)(progressbar_1.default, { value: bsMap.stats.score * 100 }), (0, jsx_runtime_1.jsxs)("span", { children: [(bsMap.stats.score * 100).toFixed(1), "%"] })] }), (0, jsx_runtime_1.jsxs)("div", { className: "flex space-x-1 items-center text-xs", children: [(0, jsx_runtime_1.jsx)("span", { children: (0, jsx_runtime_1.jsx)(lucide_react_1.ThumbsUp, { className: "h-3 w-3" }) }), (0, jsx_runtime_1.jsx)("span", { children: (0, utils_1.formatNumber)(bsMap.stats.upvotes) })] }), (0, jsx_runtime_1.jsxs)("div", { className: "flex space-x-1 items-center text-xs", children: [(0, jsx_runtime_1.jsx)("span", { children: (0, jsx_runtime_1.jsx)(lucide_react_1.ThumbsDown, { className: "h-3 w-3" }) }), (0, jsx_runtime_1.jsx)("span", { children: (0, utils_1.formatNumber)(bsMap.stats.downvotes) })] })] }), (0, jsx_runtime_1.jsx)("span", { className: "font-bold", children: "\u96BE\u5EA6" }), (0, jsx_runtime_1.jsx)("div", { className: "grid grid-cols-2", children: bsMap.versions[0].diffs.map(diff => ((0, jsx_runtime_1.jsxs)("div", { className: "text-xs space-x-1 flex items-center", children: [(0, jsx_runtime_1.jsx)("span", { className: "h-3 w-3 shrink-0", children: (0, jsx_runtime_1.jsx)(characteristic_1.CharacteristicIcon, { characteristic: diff.characteristic }) }), (0, jsx_runtime_1.jsx)("span", { children: (0, utils_1.diffConv)(diff.difficulty) }), (0, jsx_runtime_1.jsx)("span", { children: (0, jsx_runtime_1.jsx)(lucide_react_1.Gauge, { className: 'w-3 h-3 ml-1' }) }), (0, jsx_runtime_1.jsx)("span", { children: (diff.nps).toFixed(2) }), diff.stars && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("span", { children: (0, jsx_runtime_1.jsx)(lucide_react_1.Star, { className: 'w-3 h-3 ml-1' }) }), (0, jsx_runtime_1.jsx)("span", { children: (diff.stars)?.toFixed(2) })] }))] }, diff.difficulty + diff.characteristic))) }), (0, jsx_runtime_1.jsx)("span", { className: "font-bold", children: "\u63CF\u8FF0" }), (0, jsx_runtime_1.jsx)("p", { className: "text-xs", children: bsMap.description }), (0, jsx_runtime_1.jsxs)("div", { className: 'flex items-center justify-between pt-2', children: [(0, jsx_runtime_1.jsx)("div", { className: 'text-[10px] text-opacity-70 text-slate-100 align-bottom mt-auto mb-0', children: "Powered by BSBot" }), (0, jsx_runtime_1.jsxs)("div", { className: "flex items-center space-x-2", children: [(0, jsx_runtime_1.jsxs)("div", { className: 'flex flex-col items-center', children: [(0, jsx_runtime_1.jsx)("img", { width: 80, height: 80, src: bsMapQrUrl, className: "w-20 h-20" }), (0, jsx_runtime_1.jsx)("div", { className: "text-[8px] font-light", children: "beatsaver" })] }), (0, jsx_runtime_1.jsxs)("div", { className: 'flex flex-col items-center', children: [(0, jsx_runtime_1.jsx)("img", { width: 80, height: 80, src: previewQrUrl, className: "w-20 h-20" }), (0, jsx_runtime_1.jsx)("div", { className: "text-[8px] font-light", children: "preview" })] })] })] })] }) })] }), (0, jsx_runtime_1.jsx)("img", { src: bg, className: 'inset-0 absolute h-full object-cover -z-10', loading: 'eager', alt: "random background img" })] }) }) })); } exports.default = BSMapShare;