Skip to content

Commit

Permalink
feat: 展示版本号
Browse files Browse the repository at this point in the history
  • Loading branch information
RockChinQ committed Sep 2, 2024
1 parent 97ce81d commit 811d751
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 1 deletion.
9 changes: 9 additions & 0 deletions backend/controller/miscapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package controller
import (
"github.com/RockChinQ/Campux/backend/database"
"github.com/RockChinQ/Campux/backend/service"
"github.com/RockChinQ/Campux/backend/util"
"github.com/gin-gonic/gin"
)

Expand All @@ -23,6 +24,7 @@ func NewMiscRouter(rg *gin.RouterGroup, ms service.MiscService) *MiscRouter {
group.PUT("/set-metadata", mr.SetMetadata)
group.GET("/get-metadata-list", mr.GetMetadataList)
group.PUT("/save-metadatas", mr.SaveMetadata)
group.GET("/get-version", mr.GetVersion)

return mr
}
Expand Down Expand Up @@ -146,3 +148,10 @@ func (mr *MiscRouter) SaveMetadata(c *gin.Context) {

mr.Success(c, nil)
}

// 获取版本信息
func (mr *MiscRouter) GetVersion(c *gin.Context) {
mr.Success(c, gin.H{
"version": util.SEMANTIC_VERSION,
})
}
5 changes: 5 additions & 0 deletions backend/util/constants.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package util

const (
SEMANTIC_VERSION = "v1.0.0"
)
3 changes: 2 additions & 1 deletion frontend/src/pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<!-- 左侧导航栏 -->
<div id="container-wrap" style="height: calc(100vh - 64px)">
<div id="pctabs" v-if="$store.state.account.uin != 0 && $store.state.authMode === 'login'">
<h2 style="text-align: center; background-color: #42A5F5; color: #fff; padding: 8px 0px">Campux</h2>
<h2 style="text-align: center; background-color: #42A5F5; color: #fff; padding: 8px 0px">{{ $store.state.version }}</h2>
<div
style="display: flex; justify-content: space-between; flex-direction: column; align-items: center; height: 100%">
<div>
Expand Down Expand Up @@ -91,6 +91,7 @@ export default {
},
created() {
this.$store.commit('getVersion')
this.$store.commit('tokenCheck', this.$bus)
this.$store.commit('initMetadata', 'banner')
Expand Down
9 changes: 9 additions & 0 deletions frontend/src/store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export default createStore({
"brand": "",
"beianhao": "",
},
version: "Campux",
statusMap: {
"pending_approval": "待审核",
"approved": "已通过",
Expand Down Expand Up @@ -59,6 +60,14 @@ export default createStore({
})
}
},
getVersion(state) {
axios.get(this.state.base_url + '/v1/misc/get-version')
.then(res => {
if (res.data.code === 0) {
state.version = res.data.data.version
}
})
},
setBaseURL(state, url) {
state.base_url = url
},
Expand Down

0 comments on commit 811d751

Please sign in to comment.