chore: update docs [deploy]
This commit is contained in:
@@ -4,7 +4,7 @@ const defaultPreferences: Preferences = {
|
||||
app: {
|
||||
accessMode: 'frontend',
|
||||
authPageLayout: 'panel-right',
|
||||
checkUpdatesPollingTime: 1,
|
||||
checkUpdatesInterval: 1,
|
||||
colorGrayMode: false,
|
||||
colorWeakMode: false,
|
||||
compact: false,
|
||||
|
@@ -22,7 +22,7 @@ interface AppPreferences {
|
||||
/** 登录注册页面布局 */
|
||||
authPageLayout: AuthPageLayoutType;
|
||||
/** 检查更新轮询时间 */
|
||||
checkUpdatesPollingTime: number;
|
||||
checkUpdatesInterval: number;
|
||||
/** 是否开启灰色模式 */
|
||||
colorGrayMode: boolean;
|
||||
/** 是否开启色弱模式 */
|
||||
|
@@ -313,7 +313,7 @@ watch(
|
||||
<Toaster />
|
||||
<CheckUpdates
|
||||
v-if="preferences.app.enableCheckUpdates"
|
||||
:polling-time="preferences.app.checkUpdatesPollingTime"
|
||||
:check-updates-interval="preferences.app.checkUpdatesInterval"
|
||||
/>
|
||||
|
||||
<Transition v-if="preferences.widget.lockScreen" name="slide-up">
|
||||
|
@@ -6,13 +6,13 @@ import { ToastAction, useToast } from '@vben-core/shadcn-ui';
|
||||
|
||||
interface Props {
|
||||
// 轮训时间,分钟
|
||||
pollingTime?: number;
|
||||
checkUpdatesInterval?: number;
|
||||
}
|
||||
|
||||
defineOptions({ name: 'CheckUpdates' });
|
||||
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
pollingTime: 1,
|
||||
checkUpdatesInterval: 1,
|
||||
});
|
||||
|
||||
const lastVersionTag = ref('');
|
||||
@@ -38,7 +38,6 @@ async function getVersionTag() {
|
||||
|
||||
async function checkForUpdates() {
|
||||
const versionTag = await getVersionTag();
|
||||
|
||||
if (!versionTag) {
|
||||
return;
|
||||
}
|
||||
@@ -50,12 +49,11 @@ async function checkForUpdates() {
|
||||
}
|
||||
|
||||
if (lastVersionTag.value !== versionTag) {
|
||||
lastVersionTag.value = versionTag;
|
||||
clearInterval(timer.value);
|
||||
handleNotice();
|
||||
handleNotice(versionTag);
|
||||
}
|
||||
}
|
||||
function handleNotice() {
|
||||
function handleNotice(versionTag: string) {
|
||||
const { dismiss } = toast({
|
||||
action: h('div', [
|
||||
h(
|
||||
@@ -74,6 +72,7 @@ function handleNotice() {
|
||||
altText: $t('common.refresh'),
|
||||
class: 'bg-primary hover:bg-primary-hover mx-1',
|
||||
onClick: () => {
|
||||
lastVersionTag.value = versionTag;
|
||||
window.location.reload();
|
||||
},
|
||||
},
|
||||
@@ -90,7 +89,10 @@ function handleNotice() {
|
||||
|
||||
function start() {
|
||||
// 每5分钟检查一次
|
||||
timer.value = setInterval(checkForUpdates, props.pollingTime * 60 * 1000);
|
||||
timer.value = setInterval(
|
||||
checkForUpdates,
|
||||
props.checkUpdatesInterval * 60 * 1000,
|
||||
);
|
||||
}
|
||||
|
||||
function handleVisibilitychange() {
|
||||
|
Reference in New Issue
Block a user