1
0
mirror of https://github.com/1Panel-dev/1Panel.git synced 2025-01-19 08:19:15 +08:00

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

This commit is contained in:
ssongliu 2023-04-14 15:06:55 +08:00 committed by GitHub
parent 9603389586
commit 975663f0ff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 28 additions and 2 deletions

View File

@ -1,10 +1,21 @@
<template> <template>
<div> <div>
<span class="version">{{ version }}</span> <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') }} {{ $t('setting.upgradeCheck') }}
</el-button> </el-button>
<el-tag v-else round style="margin-left: 10px">{{ $t('setting.upgrading') }}</el-tag> </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-if="version === 'Waiting'" round style="margin-left: 10px">{{ $t('setting.upgrading') }}</el-tag>
</div> </div>
<el-drawer :close-on-click-modal="false" :key="refresh" v-model="drawerVisiable" size="50%" append-to-body> <el-drawer :close-on-click-modal="false" :key="refresh" v-model="drawerVisiable" size="50%" append-to-body>

View File

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

View File

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

View File

@ -210,7 +210,10 @@ import { useRouter } from 'vue-router';
import RouterButton from '@/components/router-button/index.vue'; import RouterButton from '@/components/router-button/index.vue';
import { loadBaseInfo, loadCurrentInfo } from '@/api/modules/dashboard'; import { loadBaseInfo, loadCurrentInfo } from '@/api/modules/dashboard';
import { getIOOptions, getNetworkOptions } from '@/api/modules/monitor'; import { getIOOptions, getNetworkOptions } from '@/api/modules/monitor';
import { loadUpgradeInfo } from '@/api/modules/setting';
import { GlobalStore } from '@/store';
const router = useRouter(); const router = useRouter();
const globalStore = GlobalStore();
const statuRef = ref(); const statuRef = ref();
const appRef = 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(() => { onMounted(() => {
loadUpgradeStatus();
onLoadNetworkOptions(); onLoadNetworkOptions();
onLoadIOOptions(); onLoadIOOptions();
onLoadBaseInfo(true, 'all'); onLoadBaseInfo(true, 'all');