Skip to content

Commit

Permalink
impr: 代码优化
Browse files Browse the repository at this point in the history
  • Loading branch information
JackySoft authored and jianbing.chen committed Dec 18, 2024
1 parent 4b3023a commit 6021da2
Show file tree
Hide file tree
Showing 70 changed files with 17 additions and 97 deletions.
6 changes: 3 additions & 3 deletions packages/editor/src/config/components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ const components = [
},
{
type: 'FormItems',
title: '表单组件',
title: '表单录入',
data: [
{
icon: '',
Expand Down Expand Up @@ -330,7 +330,7 @@ const components = [
},
{
type: 'Basic',
title: '基础组件',
title: '数据展示',
data: [
{
icon: '',
Expand Down Expand Up @@ -381,7 +381,7 @@ const components = [
},
{
type: 'Other',
title: '地图',
title: '其它',
data: [
{
icon: '',
Expand Down
1 change: 0 additions & 1 deletion packages/materials/Basic/Avatar/index.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/materials/Basic/CountDown/index.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/materials/Basic/Icon/index.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/materials/Basic/Image/index.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/materials/Basic/Link/index.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/materials/Basic/QRCode/index.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/materials/Basic/Statistic/index.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/materials/Basic/Text/index.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/materials/Basic/Title/index.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/materials/Container/Card/index.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/materials/Container/Div/index.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/materials/Container/Flex/index.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/materials/Container/Form/index.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/materials/EChart/BarChart/index.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/materials/EChart/ColumnChart/index.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/materials/EChart/LineChart/index.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/materials/EChart/PieChart/index.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/materials/EChart/Progress/index.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/materials/EChart/RingProgress/index.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/materials/EChart/TinyColumn/index.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/materials/EChart/TinyLine/index.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/materials/FeedBack/Drawer/index.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/materials/FeedBack/Empty/index.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/materials/FeedBack/Modal/index.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/materials/FeedBack/Result/index.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/materials/FormItems/Cascader/index.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/materials/FormItems/CheckBox/index.tsx

This file was deleted.

1 change: 0 additions & 1 deletion packages/materials/FormItems/DatePicker/index.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/materials/FormItems/DatePickerRange/index.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/materials/FormItems/EditTable/index.tsx

This file was deleted.

1 change: 0 additions & 1 deletion packages/materials/FormItems/FormItem/index.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/materials/FormItems/FormList/index.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/materials/FormItems/Input/index.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/materials/FormItems/InputNumber/index.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/materials/FormItems/InputOTP/index.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/materials/FormItems/InputPassword/index.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/materials/FormItems/Radio/index.tsx

This file was deleted.

1 change: 0 additions & 1 deletion packages/materials/FormItems/RichText/index.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/materials/FormItems/Segmented/index.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/materials/FormItems/Select/index.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/materials/FormItems/Slider/index.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/materials/FormItems/StaticItem/index.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/materials/FormItems/Switch/index.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/materials/FormItems/TextArea/index.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/materials/FormItems/TimePicker/index.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/materials/FormItems/TimePickerRange/index.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/materials/FormItems/TreeSelect/index.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/materials/FormItems/Upload/index.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/materials/Functional/Button/index.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/materials/Functional/Descriptions/index.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/materials/Functional/FileUpload/index.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/materials/Functional/List/index.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/materials/Functional/Steps/index.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/materials/Functional/Tab/index.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/materials/Functional/Tabs/index.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/materials/IFrame/index.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/materials/Layout/Col/index.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/materials/Layout/Divider/index.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/materials/Layout/Row/index.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/materials/Layout/Space/index.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/materials/Map/BMap/index.ts

This file was deleted.

19 changes: 2 additions & 17 deletions packages/materials/MarsRender/MarsRender.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,22 +64,7 @@ export const Material = memo(({ item }: { item: ComItemType }) => {
return Comp;
});
} else if (Components[item.type as keyof typeof Components]) {
const Comp = lazy(() => {
let res = Components[item.type as keyof typeof Components]().then((mod: any) => {
if (mod[item.type]) {
cachedComponents[item.type] = mod[item.type];
return Promise.resolve({
default: mod[item.type],
get [Symbol.toStringTag]() {
return 'Module';
},
});
} else {
return Promise.reject();
}
});
return res;
});
const Comp = lazy(Components[item.type as keyof typeof Components]);
setComponent(Comp);
}
setConfig(elementsMap[item.id].config);
Expand Down Expand Up @@ -181,7 +166,7 @@ export const Material = memo(({ item }: { item: ComItemType }) => {
);
} else {
return (
<Suspense fallback={<div>加载中</div>}>
<Suspense fallback={<antd.Spin size="default"></antd.Spin>}>
<Component
className={['mars-component']} // 暂时还没用,日后可能会用
id={item.id}
Expand Down
File renamed without changes.
File renamed without changes.
1 change: 0 additions & 1 deletion packages/materials/Page/index.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/materials/Scene/GridForm/index.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/materials/Scene/MarsTable/index.tsx

This file was deleted.

1 change: 0 additions & 1 deletion packages/materials/Scene/SearchForm/index.ts

This file was deleted.

24 changes: 12 additions & 12 deletions packages/materials/index.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
const modules1 = import.meta.glob('./[A-Z][a-zA-Z]+/index.ts(x)?');
const modules2 = import.meta.glob('./[A-Z][a-zA-Z]+/*/index.ts(x)?');
const exportModule: any = {};
const modules = {
...modules1,
...modules2,
};
const componentMap: { [key: string]: any } = {};

/**
* 按需加载组件
*/
const modules: { [key: string]: () => Promise<any> } = import.meta.glob('./[a-zA-Z]+/**');

let regex = /\/([a-z]+)\/index/i;
for (const path in modules) {
const componentName = path.match(regex);
if (componentName?.[1]) {
exportModule[componentName[1]] = modules[path];
const [type, name] = path.split('/').slice(-2);
if (type === 'MarsRender') continue;
if (type === name.split('.')?.[0]) {
componentMap[type] = modules[path];
}
}
export const module = exportModule;

export const module = componentMap;

0 comments on commit 6021da2

Please sign in to comment.