diff --git a/free_one_api/impls/router/api.py b/free_one_api/impls/router/api.py index 36c9485..0ee760b 100644 --- a/free_one_api/impls/router/api.py +++ b/free_one_api/impls/router/api.py @@ -293,3 +293,22 @@ async def list_logs(): "code": 1, "message": str(e), }) + + @self.api("/info/version", ["GET"], auth=False) + async def info_version(): + try: + + from ...common import version + + return quart.jsonify({ + "code": 0, + "message": "ok", + "data": "v"+version.__version__, + }) + except Exception as e: + import traceback + traceback.print_exc() + return quart.jsonify({ + "code": 1, + "message": str(e), + }) diff --git a/web/src/components/Home.vue b/web/src/components/Home.vue index 48dcced..8a99c97 100644 --- a/web/src/components/Home.vue +++ b/web/src/components/Home.vue @@ -11,8 +11,17 @@ function recalcContentContainerWidth() { console.log(contentContainerWidth.value); } +const version_str = ref("") + +function getVersion(){ + axios.get("/api/info/version").then((res) => { + version_str.value = res.data.data + }) +} + onMounted(() => { recalcContentContainerWidth(); + getVersion() }); onresize = () => { @@ -27,6 +36,7 @@ onresize = () => {

free-one-api

+ {{ version_str }}

@@ -74,4 +84,18 @@ onresize = () => { border-radius: 5px; box-shadow: 0 0 10px rgba(0, 0, 0, 0.3); } + +#version_label { + position: absolute; + top: 0; + right: 0; + margin: 0.6rem; + font-size: 0.8rem; + font-weight: bold; + color: #ffffff; + background-color: #348de5; + padding-inline: 0.4rem; + border-radius: 0.2rem; + padding-block: 0.1rem; +}