Browse Source

Merge remote-tracking branch 'upstream/main' into refactor/typed-supported-languages

# Conflicts:
#	playground/src/views/demos/features/vue-query/concurrency-caching.vue
pull/8297/head
Dream 23 hours ago
parent
commit
bc483dcd33
  1. 26
      playground/src/views/demos/features/vue-query/concurrency-caching.vue

26
playground/src/views/demos/features/vue-query/concurrency-caching.vue

@ -1,36 +1,32 @@
<script lang="ts" setup>
import type { Recordable } from '@vben/types';
import { useQuery, useQueryClient } from '@tanstack/vue-query';
import { queryOptions, useQuery, useQueryClient } from '@tanstack/vue-query';
import { useVbenForm } from '#/adapter/form';
import { getMenuList } from '#/api';
const queryKey = ['demo', 'api', 'options'];
const count = 4;
//
const staleTime = 1000 * 60 * 5;
const queryClient = useQueryClient();
const { dataUpdatedAt } = useQuery({
// useQuery fetchQuery
const menuQueryOptions = queryOptions({
//
queryFn: getMenuList,
queryKey,
// always
refetchOnMount: 'always',
queryKey: ['demo', 'api', 'options'],
staleTime,
});
// fetchQuery
//
const queryClient = useQueryClient();
const { dataUpdatedAt } = useQuery(menuQueryOptions);
async function fetchOptions() {
// fetchQuery queryKey
// 退 rejection
try {
return await queryClient.fetchQuery({
queryFn: getMenuList,
queryKey,
staleTime,
});
return await queryClient.fetchQuery(menuQueryOptions);
} catch (error) {
console.error('Failed to fetch menu options:', error);
return [];

Loading…
Cancel
Save