From f393496a1b34641fcb41edc02dfce338794d5a2a Mon Sep 17 00:00:00 2001 From: leca Date: Wed, 19 Feb 2025 17:33:47 +0300 Subject: [PATCH] moved skins&capes url to config --- public/js/skin3d.js | 11 +++++++---- src/controllers/api.js | 8 ++++++++ src/routers/api.js | 4 ++++ 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/public/js/skin3d.js b/public/js/skin3d.js index e2f461b..04f39c5 100644 --- a/public/js/skin3d.js +++ b/public/js/skin3d.js @@ -52,16 +52,19 @@ window.onload = async function() { document.getElementById("elytra").checked = false; } - const username = await (await (fetch("/api/getUsername"))).text(); + const username = await (await (fetch('/api/getUsername'))).text(); + const skinsUrl = (await (await fetch('/api/skinsUrl')).text()).replace('%username%', username); + const capesUrl = (await (await fetch('/api/capesUrl')).text()).replace('%username%', username); let skinViewer = new skinview3d.SkinViewer({ canvas: document.getElementById("skin_container"), width: 300, height: 400, - skin: `https://launcher.foxarmy.org/skins/${username}.png`, - cape: `https://launcher.foxarmy.org/cloaks/${username}.png` + skin: skinsUrl, + cape: capesUrl }); + skinViewer.nameTag = username; skinViewer.loadPanorama("images/panorama.jpeg"); skinViewer.fov = 120; @@ -69,7 +72,7 @@ window.onload = async function() { skinViewer.autoRotate = true; function set_cape_type(type) { - skinViewer.loadCape(`https://launcher.foxarmy.org/cloaks/${username}.png`, { backEquipment: type }); + skinViewer.loadCape(capesUrl, { backEquipment: type }); } diff --git a/src/controllers/api.js b/src/controllers/api.js index c37d574..c046df9 100644 --- a/src/controllers/api.js +++ b/src/controllers/api.js @@ -13,6 +13,14 @@ class ApiController { async getWebsocketConnection(req, res) { return res.status(200).send(config.ws_connection_string); } + + async getSkinsUrl(req, res) { + return res.status(200).send(config.skins_url); + } + + async getCapesUrl(req, res) { + return res.status(200).send(config.capes_url); + } } export default new ApiController(); \ No newline at end of file diff --git a/src/routers/api.js b/src/routers/api.js index 7d96573..4f7e088 100644 --- a/src/routers/api.js +++ b/src/routers/api.js @@ -14,10 +14,14 @@ ApiRouter.post('/register', requiredParameters.requireUsername, requiredParamete ApiRouter.post('/login', requiredParameters.requireUsername, requiredParameters.requirePassword, existance.userExist, UserController.login); ApiRouter.get('/logout', auth.authenticate, UserController.logout); ApiRouter.post('/changepassword', auth.authenticate, existance.userExist, UserController.changePassword); + ApiRouter.post('/uploadSkin', existance.userExist, auth.authenticate, utils.upload.single('file'), requiredParameters.requireFile, UserController.uploadSkin); ApiRouter.post('/uploadCape', existance.userExist, auth.authenticate, auth.canHaveCloak, utils.upload.single('file'), requiredParameters.requireFile, UserController.uploadCape); + ApiRouter.get('/getUsername', existance.userExist, auth.authenticate, UserController.getUsername); ApiRouter.get('/getChatMessages/:offset/:limit', auth.authenticate, ApiController.getChatMessages); ApiRouter.get('/webSocketConnection', auth.authenticate, ApiController.getWebsocketConnection) +ApiRouter.get('/skinsUrl', auth.authenticate, ApiController.getSkinsUrl); +ApiRouter.get('/capesUrl', auth.authenticate, ApiController.getCapesUrl) export default ApiRouter; \ No newline at end of file