From 9a23514b248f093413f8c169a5e2721aed6db108 Mon Sep 17 00:00:00 2001 From: Junyan Qin <1010553892@qq.com> Date: Sat, 7 Oct 2023 12:12:15 +0000 Subject: [PATCH] feat: add version label --- free_one_api/impls/router/api.py | 19 +++++++++++++++++++ web/src/components/Home.vue | 24 ++++++++++++++++++++++++ 2 files changed, 43 insertions(+) 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; +}