@@ -6,13 +6,13 @@ import { ToastAction, useToast } from '@vben-core/shadcn-ui';
66
77interface Props {
88 // 轮训时间,分钟
9- pollingTime ? : number ;
9+ checkUpdatesInterval ? : number ;
1010}
1111
1212defineOptions ({ name: ' CheckUpdates' });
1313
1414const props = withDefaults (defineProps <Props >(), {
15- pollingTime : 1 ,
15+ checkUpdatesInterval : 1 ,
1616});
1717
1818const lastVersionTag = ref (' ' );
@@ -38,7 +38,6 @@ async function getVersionTag() {
3838
3939async function checkForUpdates() {
4040 const versionTag = await getVersionTag ();
41-
4241 if (! versionTag ) {
4342 return ;
4443 }
@@ -50,12 +49,11 @@ async function checkForUpdates() {
5049 }
5150
5251 if (lastVersionTag .value !== versionTag ) {
53- lastVersionTag .value = versionTag ;
5452 clearInterval (timer .value );
55- handleNotice ();
53+ handleNotice (versionTag );
5654 }
5755}
58- function handleNotice() {
56+ function handleNotice(versionTag : string ) {
5957 const { dismiss } = toast ({
6058 action: h (' div' , [
6159 h (
@@ -74,6 +72,7 @@ function handleNotice() {
7472 altText: $t (' common.refresh' ),
7573 class: ' bg-primary hover:bg-primary-hover mx-1' ,
7674 onClick : () => {
75+ lastVersionTag .value = versionTag ;
7776 window .location .reload ();
7877 },
7978 },
@@ -90,7 +89,10 @@ function handleNotice() {
9089
9190function start() {
9291 // 每5分钟检查一次
93- timer .value = setInterval (checkForUpdates , props .pollingTime * 60 * 1000 );
92+ timer .value = setInterval (
93+ checkForUpdates ,
94+ props .checkUpdatesInterval * 60 * 1000 ,
95+ );
9496}
9597
9698function handleVisibilitychange() {
0 commit comments