add auto refresh for contest rank.
This commit is contained in:
@@ -19,6 +19,17 @@ const total = ref(0)
|
|||||||
const data = ref<ContestRank[]>([])
|
const data = ref<ContestRank[]>([])
|
||||||
const chart = ref<ContestRank[]>([])
|
const chart = ref<ContestRank[]>([])
|
||||||
const problems = ref<ProblemFiltered[]>([])
|
const problems = ref<ProblemFiltered[]>([])
|
||||||
|
const [autoRefresh] = useToggle()
|
||||||
|
const { resume, pause } = useIntervalFn(
|
||||||
|
() => {
|
||||||
|
query.page = 1
|
||||||
|
listRanks()
|
||||||
|
},
|
||||||
|
10000,
|
||||||
|
{
|
||||||
|
immediate: false,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
const query = reactive({
|
const query = reactive({
|
||||||
limit: 50,
|
limit: 50,
|
||||||
@@ -168,6 +179,7 @@ watch(
|
|||||||
listRanks()
|
listRanks()
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
watch(autoRefresh, (checked) => (checked ? resume() : pause()))
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
listRanks()
|
listRanks()
|
||||||
@@ -183,11 +195,18 @@ onMounted(() => {
|
|||||||
:columns="columns"
|
:columns="columns"
|
||||||
:data="data"
|
:data="data"
|
||||||
/>
|
/>
|
||||||
<Pagination
|
<n-space justify="end" align="center">
|
||||||
:total="total"
|
<n-form label-placement="left" inline :show-feedback="false">
|
||||||
v-model:page="query.page"
|
<n-form-item label="开启自动刷新">
|
||||||
v-model:limit="query.limit"
|
<n-switch v-model:value="autoRefresh" />
|
||||||
/>
|
</n-form-item>
|
||||||
|
</n-form>
|
||||||
|
<Pagination
|
||||||
|
:total="total"
|
||||||
|
v-model:page="query.page"
|
||||||
|
v-model:limit="query.limit"
|
||||||
|
/>
|
||||||
|
</n-space>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style scoped></style>
|
<style scoped></style>
|
||||||
|
|||||||
Reference in New Issue
Block a user