mirror of
https://github.com/dreamhunter2333/cloudflare_temp_email.git
synced 2026-09-07 00:17:12 +08:00
feat: |UI| add configAutoRefreshInterval && autoRefresh useStorage (#549)
* feat: |UI| add configAutoRefreshInterval && autoRefresh useStorage * Update MailBox.vue * Update MailBox.vue
This commit is contained in:
@@ -50,11 +50,10 @@ const props = defineProps({
|
|||||||
})
|
})
|
||||||
|
|
||||||
const {
|
const {
|
||||||
isDark, mailboxSplitSize, indexTab, loading, useUTCDate,
|
isDark, mailboxSplitSize, indexTab, loading, useUTCDate, autoRefresh, configAutoRefreshInterval,
|
||||||
useIframeShowMail, sendMailModel, preferShowTextMail
|
useIframeShowMail, sendMailModel, preferShowTextMail
|
||||||
} = useGlobalState()
|
} = useGlobalState()
|
||||||
const autoRefresh = ref(false)
|
const autoRefreshInterval = ref(configAutoRefreshInterval.value)
|
||||||
const autoRefreshInterval = ref(30)
|
|
||||||
const data = ref([])
|
const data = ref([])
|
||||||
const timer = ref(null)
|
const timer = ref(null)
|
||||||
|
|
||||||
@@ -119,14 +118,16 @@ const { t } = useI18n({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const setupAutoRefresh = async (autoRefresh) => {
|
const setupAutoRefresh = async (autoRefresh) => {
|
||||||
// auto refresh every 30 seconds
|
// auto refresh every configAutoRefreshInterval seconds
|
||||||
autoRefreshInterval.value = 30;
|
autoRefreshInterval.value = configAutoRefreshInterval.value;
|
||||||
if (autoRefresh) {
|
if (autoRefresh) {
|
||||||
|
clearInterval(timer.value);
|
||||||
timer.value = setInterval(async () => {
|
timer.value = setInterval(async () => {
|
||||||
|
if (loading.value) return;
|
||||||
autoRefreshInterval.value--;
|
autoRefreshInterval.value--;
|
||||||
if (autoRefreshInterval.value <= 0) {
|
if (autoRefreshInterval.value <= 0) {
|
||||||
autoRefreshInterval.value = 30;
|
autoRefreshInterval.value = configAutoRefreshInterval.value;
|
||||||
await refresh();
|
await backFirstPageAndRefresh();
|
||||||
}
|
}
|
||||||
}, 1000)
|
}, 1000)
|
||||||
} else {
|
} else {
|
||||||
@@ -137,7 +138,7 @@ const setupAutoRefresh = async (autoRefresh) => {
|
|||||||
|
|
||||||
watch(autoRefresh, async (autoRefresh, old) => {
|
watch(autoRefresh, async (autoRefresh, old) => {
|
||||||
setupAutoRefresh(autoRefresh)
|
setupAutoRefresh(autoRefresh)
|
||||||
})
|
}, { immediate: true })
|
||||||
|
|
||||||
watch([page, pageSize], async ([page, pageSize], [oldPage, oldPageSize]) => {
|
watch([page, pageSize], async ([page, pageSize], [oldPage, oldPageSize]) => {
|
||||||
if (page !== oldPage || pageSize !== oldPageSize) {
|
if (page !== oldPage || pageSize !== oldPageSize) {
|
||||||
@@ -170,6 +171,11 @@ const refresh = async () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const backFirstPageAndRefresh = async () =>{
|
||||||
|
page.value = 1;
|
||||||
|
await refresh();
|
||||||
|
}
|
||||||
|
|
||||||
const clickRow = async (row) => {
|
const clickRow = async (row) => {
|
||||||
if (multiActionMode.value) {
|
if (multiActionMode.value) {
|
||||||
row.checked = !row.checked;
|
row.checked = !row.checked;
|
||||||
@@ -366,7 +372,7 @@ onBeforeUnmount(() => {
|
|||||||
{{ t('autoRefresh') }}
|
{{ t('autoRefresh') }}
|
||||||
</template>
|
</template>
|
||||||
</n-switch>
|
</n-switch>
|
||||||
<n-button @click="refresh" type="primary" tertiary>
|
<n-button @click="backFirstPageAndRefresh" type="primary" tertiary>
|
||||||
{{ t('refresh') }}
|
{{ t('refresh') }}
|
||||||
</n-button>
|
</n-button>
|
||||||
</n-space>
|
</n-space>
|
||||||
@@ -476,7 +482,7 @@ onBeforeUnmount(() => {
|
|||||||
{{ t('autoRefresh') }}
|
{{ t('autoRefresh') }}
|
||||||
</template>
|
</template>
|
||||||
</n-switch>
|
</n-switch>
|
||||||
<n-button @click="refresh" tertiary size="small" type="primary">
|
<n-button @click="backFirstPageAndRefresh" tertiary size="small" type="primary">
|
||||||
{{ t('refresh') }}
|
{{ t('refresh') }}
|
||||||
</n-button>
|
</n-button>
|
||||||
</n-space>
|
</n-space>
|
||||||
|
|||||||
@@ -72,6 +72,8 @@ export const useGlobalState = createGlobalState(
|
|||||||
const globalTabplacement = useStorage('globalTabplacement', 'top');
|
const globalTabplacement = useStorage('globalTabplacement', 'top');
|
||||||
const useSideMargin = useStorage('useSideMargin', true);
|
const useSideMargin = useStorage('useSideMargin', true);
|
||||||
const useUTCDate = useStorage('useUTCDate', false);
|
const useUTCDate = useStorage('useUTCDate', false);
|
||||||
|
const autoRefresh = useStorage('autoRefresh', false);
|
||||||
|
const configAutoRefreshInterval = useStorage("configAutoRefreshInterval", 60);
|
||||||
const userOpenSettings = ref({
|
const userOpenSettings = ref({
|
||||||
fetched: false,
|
fetched: false,
|
||||||
enable: false,
|
enable: false,
|
||||||
@@ -130,6 +132,8 @@ export const useGlobalState = createGlobalState(
|
|||||||
globalTabplacement,
|
globalTabplacement,
|
||||||
useSideMargin,
|
useSideMargin,
|
||||||
useUTCDate,
|
useUTCDate,
|
||||||
|
autoRefresh,
|
||||||
|
configAutoRefreshInterval,
|
||||||
telegramApp,
|
telegramApp,
|
||||||
isTelegram,
|
isTelegram,
|
||||||
showAdminPage,
|
showAdminPage,
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import { useIsMobile } from '../../utils/composables'
|
|||||||
import { useGlobalState } from '../../store'
|
import { useGlobalState } from '../../store'
|
||||||
|
|
||||||
const {
|
const {
|
||||||
mailboxSplitSize, useIframeShowMail, preferShowTextMail,
|
mailboxSplitSize, useIframeShowMail, preferShowTextMail, configAutoRefreshInterval,
|
||||||
globalTabplacement, useSideMargin, useUTCDate
|
globalTabplacement, useSideMargin, useUTCDate
|
||||||
} = useGlobalState()
|
} = useGlobalState()
|
||||||
const isMobile = useIsMobile()
|
const isMobile = useIsMobile()
|
||||||
@@ -23,6 +23,7 @@ const { t } = useI18n({
|
|||||||
right: 'right',
|
right: 'right',
|
||||||
bottom: 'bottom',
|
bottom: 'bottom',
|
||||||
useUTCDate: 'Use UTC Date',
|
useUTCDate: 'Use UTC Date',
|
||||||
|
autoRefreshInterval: 'Auto Refresh Interval(Sec)',
|
||||||
},
|
},
|
||||||
zh: {
|
zh: {
|
||||||
mailboxSplitSize: '邮箱界面分栏大小',
|
mailboxSplitSize: '邮箱界面分栏大小',
|
||||||
@@ -35,6 +36,7 @@ const { t } = useI18n({
|
|||||||
right: '右侧',
|
right: '右侧',
|
||||||
bottom: '底部',
|
bottom: '底部',
|
||||||
useUTCDate: '使用 UTC 时间',
|
useUTCDate: '使用 UTC 时间',
|
||||||
|
autoRefreshInterval: '自动刷新间隔(秒)',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -50,6 +52,11 @@ const { t } = useI18n({
|
|||||||
0.75: '0.75'
|
0.75: '0.75'
|
||||||
}" />
|
}" />
|
||||||
</n-form-item-row>
|
</n-form-item-row>
|
||||||
|
<n-form-item-row :label="t('autoRefreshInterval')">
|
||||||
|
<n-slider v-model:value="configAutoRefreshInterval" :min="30" :max="300" :step="1" :marks="{
|
||||||
|
60: '60', 120: '120', 180: '180', 240: '240'
|
||||||
|
}" />
|
||||||
|
</n-form-item-row>
|
||||||
<n-form-item-row :label="t('preferShowTextMail')">
|
<n-form-item-row :label="t('preferShowTextMail')">
|
||||||
<n-switch v-model:value="preferShowTextMail" :round="false" />
|
<n-switch v-model:value="preferShowTextMail" :round="false" />
|
||||||
</n-form-item-row>
|
</n-form-item-row>
|
||||||
|
|||||||
Reference in New Issue
Block a user