perf: 获取更多模板

main
Lei OT 1 day ago
parent 98aec9b037
commit 7193b62821

@ -11,6 +11,9 @@ import dayjs from 'dayjs';
*/ */
export const fetchTemplates = async (params) => { export const fetchTemplates = async (params) => {
const data = await fetchJSON(`${API_HOST}/listtemplates`, params); const data = await fetchJSON(`${API_HOST}/listtemplates`, params);
const leftPageCnt = Math.ceil( data?.result?.total/100 || 0)-1;
const leftData = await Promise.all(Array.from({ length: leftPageCnt }, (_, i) => fetchJSON(`${API_HOST}/listtemplates`, {...params, page: i+2})));
const leftItems = leftData.map(item => item.result.items).flat();
const topName = [ const topName = [
'agent_intro_with_update_v1', 'agent_intro_with_update_v1',
'online_inquiry_received', 'online_inquiry_received',
@ -68,7 +71,7 @@ export const fetchTemplates = async (params) => {
'one_day_before_ending_the_trip_by_customer_relations', 'one_day_before_ending_the_trip_by_customer_relations',
'network_troubleshooting', 'network_troubleshooting',
] ]
const canUseTemplates = (data?.result?.items || []) const canUseTemplates = (data?.result?.items || []).concat(leftItems)
.filter((_t) => _t.status === 'APPROVED' && !['say_hello_from_trip_advisor', 'free_style_7', 'free_style_1', 'free_style_2'].includes(_t.name)) .filter((_t) => _t.status === 'APPROVED' && !['say_hello_from_trip_advisor', 'free_style_7', 'free_style_1', 'free_style_2'].includes(_t.name))
.map((ele, i) => ({ .map((ele, i) => ({
...ele, ...ele,

Loading…
Cancel
Save