Commit 9c4fe581 by chenwq

优化活码详情获取逻辑,确保编辑时展示最新的群池和门店配置

1 parent 894b821b
......@@ -7,6 +7,7 @@
import { usedcarClient } from '../core/client';
import type { UsedcarParams } from '../core/types';
/**
* 一客一码分页列表
*/
......@@ -52,9 +53,13 @@ export function deleteLiveCode<T = unknown>(data: UsedcarParams = {}) {
/**
* 一客一群 - 活码配置详情
*/
export function getLiveCodeDetail<T = unknown>(data: UsedcarParams = {}) {
return usedcarClient.post<T>('/liveCode/details', data);
}
export const getLiveCodeDetail = Object.assign(
<T = unknown>(data: UsedcarParams = {}) => usedcarClient.post<T>('/liveCode/details', data),
{
// 编辑群池时需读取最新详情,不使用子应用默认的30秒查询缓存。
queryOptions: { staleTime: 0, refetchOnMount: 'always' as const },
},
);
/** 模块单例出口,与 dashboardApi 同一调用面;实现与上方具名函数完全同源。 */
export const liveCodeApi = {
......
......@@ -2,7 +2,7 @@ import { useEffect, useMemo, useState } from 'react';
import { useQuery } from '@tanstack/react-query';
import { UAlert, UButton, UCard, UForm, UInput, UModal, UResult, useUMessage } from '@uj/ui';
import { CombiForm, DataTable, PageShell, type FieldSchema } from '@/components';
import { liveCodeApi } from '@/api';
import { getLiveCodeDetail, liveCodeApi } from '@/api';
import { useAccess } from '@/access';
import { UC } from '@/permissions/codes';
import { errorDetail } from '@/utils/error';
......@@ -133,9 +133,7 @@ export default function GroupCodeEditor({ params }: Props) {
const detail = useQuery({
queryKey: ['live-code-detail', params?.id],
enabled: editing && Boolean(params?.id),
// 活码编辑必须展示服务端最新的群池和门店配置;不沿用子应用默认的 30 秒缓存。
staleTime: 0,
refetchOnMount: 'always',
...getLiveCodeDetail.queryOptions,
queryFn: () => liveCodeApi.getLiveCodeDetail<Detail>({ id: params?.id }),
});
useEffect(() => {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!