Browse Source

feat: 增加自动更新检测 (#621)

pull/643/head
ssongliu 2 years ago committed by GitHub
parent
commit
975663f0ff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 15
      frontend/src/components/system-upgrade/index.vue
  2. 1
      frontend/src/store/index.ts
  3. 1
      frontend/src/store/interface/index.ts
  4. 13
      frontend/src/views/home/index.vue

15
frontend/src/components/system-upgrade/index.vue

@ -1,10 +1,21 @@
<template>
<div>
<span class="version">{{ version }}</span>
<el-button v-if="version !== 'Waiting'" style="margin-top: -2px" type="primary" link @click="onLoadUpgradeInfo">
<el-badge is-dot class="item" v-if="version !== 'Waiting' && globalStore.hasNewVersion">
<el-button style="margin-top: -8px" type="primary" link @click="onLoadUpgradeInfo">
{{ $t('setting.upgradeCheck') }}
</el-button>
</el-badge>
<el-button
v-if="version !== 'Waiting' && !globalStore.hasNewVersion"
style="margin-top: -2px"
type="primary"
link
@click="onLoadUpgradeInfo"
>
{{ $t('setting.upgradeCheck') }}
</el-button>
<el-tag v-else round style="margin-left: 10px">{{ $t('setting.upgrading') }}</el-tag>
<el-tag v-if="version === 'Waiting'" round style="margin-left: 10px">{{ $t('setting.upgrading') }}</el-tag>
</div>
<el-drawer :close-on-click-modal="false" :key="refresh" v-model="drawerVisiable" size="50%" append-to-body>

1
frontend/src/store/index.ts

@ -21,6 +21,7 @@ export const GlobalStore = defineStore({
},
isFullScreen: false,
agreeLicense: false,
hasNewVersion: false,
}),
getters: {},
actions: {

1
frontend/src/store/interface/index.ts

@ -17,6 +17,7 @@ export interface GlobalState {
themeConfig: ThemeConfigProp;
isFullScreen: boolean;
agreeLicense: boolean;
hasNewVersion: boolean;
}
export interface MenuState {

13
frontend/src/views/home/index.vue

@ -210,7 +210,10 @@ import { useRouter } from 'vue-router';
import RouterButton from '@/components/router-button/index.vue';
import { loadBaseInfo, loadCurrentInfo } from '@/api/modules/dashboard';
import { getIOOptions, getNetworkOptions } from '@/api/modules/monitor';
import { loadUpgradeInfo } from '@/api/modules/setting';
import { GlobalStore } from '@/store';
const router = useRouter();
const globalStore = GlobalStore();
const statuRef = ref();
const appRef = ref();
@ -470,7 +473,17 @@ const loadData = async () => {
}
};
const loadUpgradeStatus = async () => {
const res = await loadUpgradeInfo();
if (res.data) {
globalStore.hasNewVersion = true;
} else {
globalStore.hasNewVersion = false;
}
};
onMounted(() => {
loadUpgradeStatus();
onLoadNetworkOptions();
onLoadIOOptions();
onLoadBaseInfo(true, 'all');

Loading…
Cancel
Save