数据逻辑处理

v1.4.0
于肖磊 2025-08-05 18:30:50 +08:00
parent 2833dd5b3c
commit d517730cca
1 changed files with 13 additions and 10 deletions

View File

@ -23,7 +23,7 @@ import { Settings, AppMain } from './components/index';
import defaultSettings from './components/main/index';
import defaultConfigSetting from '@/config/setting';
import defaultConfigConst from '@/config/const/index';
import { cloneDeep, isEmpty, omit } from 'lodash';
import { clone, cloneDeep, isEmpty, omit } from 'lodash';
import DiyAPI, { diyData, headerAndFooter, diyConfig } from '@/api/diy';
import CommonAPI from '@/api/common';
import { commonStore } from '@/store';
@ -277,8 +277,9 @@ const save_formmat_form_data = (data: diy_data_item, close: boolean = false, is_
//
const all_type = ['hot_zone', 'custom', 'img_magic', 'goods_magic', 'goods_list', 'article_list', 'nav_group', 'video', 'carousel'];
//
const new_data_list = [item.com_data.content.home_data, ...item.com_data.content.tabs_list];
const new_data_list = cloneDeep([item.com_data.content.home_data, ...item.com_data.content.tabs_list]);
//
let clone_data_list: any = [];
new_data_list.forEach((item1: any) => {
if (['goods-list', 'article-list'].includes(item1.magic_type)) {
//
@ -287,16 +288,18 @@ const save_formmat_form_data = (data: diy_data_item, close: boolean = false, is_
//
custom_data_processing(item1[item1.magic_type].content);
}
item1 = Object.keys(item1)
.filter(key => !all_type.filter((item2: string) => item2 !== item1.magic_type).includes(key))
.reduce((acc: Record<string, any>, key: string) => {
acc[key] = item1[key];
return acc;
}, {});
clone_data_list.push(
Object.keys(item1)
.filter(key => !(all_type.filter((item2: string) => !isEmpty(item1.magic_type) ? (item2 !== item1.magic_type) : item2).includes(key)))
.reduce((acc: Record<string, any>, key: string) => {
acc[key] = item1[key];
return acc;
}, {})
);
});
//
item.com_data.content.home_data = new_data_list.length > 0 ? new_data_list[0] : null;
item.com_data.content.tabs_list = new_data_list.slice(1, new_data_list.length);
item.com_data.content.home_data = clone_data_list.length > 0 ? clone_data_list[0] : null;
item.com_data.content.tabs_list = clone_data_list.slice(1, clone_data_list.length);
}
return {
...item,