Browse Source

Merge pull request #2686 from nocodb/refactor/version

refactor: version api
pull/2693/head
աɨռɢӄաօռɢ 2 years ago committed by GitHub
parent
commit
f579907d52
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      packages/nc-gui/components/ReleaseInfo.vue
  2. 17
      packages/nc-gui/plugins/projectLoader.js
  3. 6
      packages/nc-gui/store/app.js
  4. 5
      packages/nocodb/src/lib/meta/api/utilApis.ts

6
packages/nc-gui/components/ReleaseInfo.vue

@ -42,9 +42,9 @@ export default {
get() {
return (
!this.loading &&
this.$store.state.app.releaseVersion &&
this.$store.state.app.currentVersion &&
this.$store.state.app.latestRelease &&
this.$store.state.app.releaseVersion !== this.$store.state.app.latestRelease &&
this.$store.state.app.currentVersion !== this.$store.state.app.latestRelease &&
this.$store.state.app.latestRelease !== this.$store.state.app.hiddenRelease
);
},
@ -53,7 +53,7 @@ export default {
},
},
releaseVersion() {
return this.$store.state.app.releaseVersion;
return this.$store.state.app.latestRelease;
},
},
mounted() {

17
packages/nc-gui/plugins/projectLoader.js

@ -68,13 +68,15 @@ export default async({ store, redirect, $axios, $toast, $api, route }) => {
// fetch latest release info
const fetchReleaseInfo = async() => {
try {
const releaseInfo = await $api.utils.appInfo()
const latestRelease = await $api.utils.appVersion()
if (releaseInfo && latestRelease && releaseInfo.version) {
store.commit('app/MutReleaseVersion', releaseInfo.version)
store.commit('app/MutLatestRelease', latestRelease.releaseVersion || null)
const versionInfo = await $api.utils.appVersion()
if (versionInfo &&
versionInfo.releaseVersion &&
versionInfo.currentVersion &&
!(/[^0-9.]/.test(versionInfo.currentVersion))) {
store.commit('app/MutCurrentVersion', versionInfo.currentVersion)
store.commit('app/MutLatestRelease', versionInfo.releaseVersion)
} else {
store.commit('app/MutReleaseVersion', null)
store.commit('app/MutCurrentVersion', null)
store.commit('app/MutLatestRelease', null)
}
} catch (e) {
@ -82,8 +84,7 @@ export default async({ store, redirect, $axios, $toast, $api, route }) => {
}
}
fetchReleaseInfo().then(() => {
})
fetchReleaseInfo()
setInterval(fetchReleaseInfo, 10 * 60 * 1000)
handleFeedbackForm({ store, $axios })
}

6
packages/nc-gui/store/app.js

@ -1,12 +1,12 @@
export const state = () => ({
releaseVersion: null,
currentVersion: null,
hiddenRelease: null,
latestRelease: null
})
export const mutations = {
MutReleaseVersion(state, releaseVersion) {
state.releaseVersion = releaseVersion
MutCurrentVersion(state, currentVersion) {
state.currentVersion = currentVersion
},
MutHiddenRelease(state, hiddenRelease) {
state.hiddenRelease = hiddenRelease

5
packages/nocodb/src/lib/meta/api/utilApis.ts

@ -45,11 +45,12 @@ export async function appInfo(req: Request, res: Response) {
res.json(result);
}
export async function releaseVersion(_req: Request, res: Response) {
export async function versionInfo(_req: Request, res: Response) {
const result = await axios
.get('https://github.com/nocodb/nocodb/releases/latest')
.then((response) => {
return {
currentVersion: packageVersion,
releaseVersion: response.request.res.responseUrl.replace(
'https://github.com/nocodb/nocodb/releases/tag/',
''
@ -153,7 +154,7 @@ export default (router) => {
);
router.get('/api/v1/db/meta/nocodb/info', catchError(appInfo));
router.post('/api/v1/db/meta/axiosRequestMake', catchError(axiosRequestMake));
router.get('/api/v1/version', catchError(releaseVersion));
router.get('/api/v1/version', catchError(versionInfo));
router.get('/api/v1/health', catchError(appHealth));
router.get('/api/v1/feedback_form', catchError(feedbackFormGet));
};

Loading…
Cancel
Save