Skip to content

Commit

Permalink
feat: add version label
Browse files Browse the repository at this point in the history
  • Loading branch information
RockChinQ committed Oct 7, 2023
1 parent 35eba4b commit 9a23514
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
19 changes: 19 additions & 0 deletions free_one_api/impls/router/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
})
24 changes: 24 additions & 0 deletions web/src/components/Home.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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 = () => {
Expand All @@ -27,6 +36,7 @@ onresize = () => {
<div id="content">
<div id="content_header">
<h1>free-one-api</h1>
<span v-if="version_str!=''" id="version_label">{{ version_str }}</span>
</div>
<div id="content_body">
<p>
Expand Down Expand Up @@ -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;
}
</style>

0 comments on commit 9a23514

Please sign in to comment.