diff --git a/TODO.md b/TODO.md index 71361fc..3f4b426 100644 --- a/TODO.md +++ b/TODO.md @@ -20,3 +20,7 @@ - [ ] Избранное - [ ] История - [ ] ... + +## интерфейс + +- [X] Динамический цвет от аватарки diff --git a/backend/main.py b/backend/main.py index 57d2b46..6dc7653 100644 --- a/backend/main.py +++ b/backend/main.py @@ -1,5 +1,6 @@ import uvicorn from fastapi import FastAPI +from modules import proxy from modules.pages import favorites from modules.pages import index from modules.pages import search @@ -48,5 +49,7 @@ app.include_router(index.router, prefix="/api/index", tags=["Index"]) app.include_router(favorites.router, prefix="/api/favorites", tags=["Favorites"]) app.include_router(search.router, prefix="/api/search", tags=["Search"]) +app.include_router(proxy.router, prefix="/api/proxy") + if __name__ == "__main__": uvicorn.run("main:app", host="0.0.0.0", port=8000) diff --git a/backend/modules/proxy.py b/backend/modules/proxy.py index 36e4a22..43c2c44 100644 --- a/backend/modules/proxy.py +++ b/backend/modules/proxy.py @@ -2,7 +2,9 @@ from typing import TypedDict from typing import Union import requests +from fastapi import APIRouter from fastapi import Request +from fastapi import Response class Endpoints(TypedDict): @@ -67,3 +69,17 @@ async def apiRequest( if r.status_code != 200: return {"error": r.text} return r.json() + + +router = APIRouter() + + +@router.get( + "/image", + responses={200: {"content": {"image/jpg": {}, "image/png": {}}}}, + response_class=Response, +) +async def imageProxy(url: str): + type = url.split(".")[-1] + response: bytes = requests.get(url).content + return Response(content=response, media_type=f"image/{type}") diff --git a/frontend/app/components/ColorPicker/ColorPicker.jsx b/frontend/app/components/ColorPicker/ColorPicker.jsx index 10aba87..e2f6e21 100644 --- a/frontend/app/components/ColorPicker/ColorPicker.jsx +++ b/frontend/app/components/ColorPicker/ColorPicker.jsx @@ -2,8 +2,10 @@ import { useState } from "react"; import Styles from "./ColorPicker.module.css"; +import { useUserStore } from "@/app/store/user-store"; export const ColorPicker = (props) => { + const userStore = useUserStore(); const colors = [ { hex: "#ffffff", color: "white" }, { hex: "#e91e63", color: "pink" }, @@ -35,6 +37,21 @@ export const ColorPicker = (props) => { > ); })} + {userStore.user ? ( + + ) : ( + "" + )}