From 4055f40eb08f8f514d44c8715c471c4338f19c09 Mon Sep 17 00:00:00 2001 From: Treecat Date: Wed, 8 Mar 2023 11:04:10 +0800 Subject: [PATCH] =?UTF-8?q?KERNEL-14316=20fix:=20config=20=E6=89=BE?= =?UTF-8?q?=E4=B8=8D=E5=88=B0=E4=BE=9D=E8=B5=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 3 ++ src/core/platform/web/config.js | 89 +++++++++++++++++++-------------- 2 files changed, 55 insertions(+), 37 deletions(-) diff --git a/package.json b/package.json index 3c642bb2b..7b56d27f1 100644 --- a/package.json +++ b/package.json @@ -4,6 +4,9 @@ "description": "fineui", "main": "dist/fineui_without_conflict.min.js", "module": "dist/esm/index.js", + "sideEffects": [ + "dist/esm/core/**" + ], "types": "dist/lib/index.d.ts", "bin": { "fui-cli": "./bin/cli/cli.js" diff --git a/src/core/platform/web/config.js b/src/core/platform/web/config.js index 6b75cb0f4..c9e24139c 100644 --- a/src/core/platform/web/config.js +++ b/src/core/platform/web/config.js @@ -3,6 +3,21 @@ import { Providers } from "../../5.inject"; import { Plugin } from "../../6.plugin"; import { isSupportCss3, isIE, getIEVersion } from "../../platform/web"; import { HorizontalAlign, VerticalAlign } from "../../constant"; +import { FlexCenterLayout, FlexHorizontalLayout, VerticalLayout, + FlexVerticalLayout, TdLayout, InlineLayout, TableAdaptLayout, + FloatHorizontalFillLayout, ResponsiveInlineLayout, + InlineCenterAdaptLayout, FlexVerticalCenterAdapt, + InlineVerticalAdaptLayout, HorizontalAutoLayout, + TableAdaptLayout, FlexHorizontalCenter, + InlineHorizontalAdaptLayout, TableLayout, + AutoVerticalTapeLayout, VTapeLayout, + HorizontalFillLayout, VerticalFillLayout, + FlexLeftRightVerticalAdaptLayout, ResponsiveFlexWrapperHorizontalLayout, + FlexWrapperHorizontalLayout, ResponsiveFlexHorizontalLayout, + FlexWrapperVerticalLayout +} from "@/core/wrapper/layout/index"; +import { SystemProvider } from "@/core/system"; + // 工程配置 // 注册布局 @@ -54,25 +69,25 @@ configWidget("bi.horizontal", ob => { // return extend({}, ob, {type: "bi.table_adapt"}); // } if (supportFlex) { - return extend({}, ob, { type: "bi.flex_horizontal" }); + return extend({}, ob, { type: FlexHorizontalLayout.xtype }); } return extend({ scrollx: true, - }, ob, { type: "bi.inline" }); + }, ob, { type: InlineLayout.xtype }); }); configWidget("bi.vertical", ob => { if (ob.horizontalAlign === HorizontalAlign.Left || ob.horizontalAlign === HorizontalAlign.Right) { if (isSupportFlex()) { - return extend({}, ob, { type: "bi.flex_vertical" }); + return extend({}, ob, { type: FlexVerticalLayout.xtype }); } return extend({}, ob, { horizontalAlign: HorizontalAlign.Stretch, - type: "bi.vertical", + type: VerticalLayout.xtype, items: map(ob.items, (i, item) => { return { - type: "bi.inline", + type: InlineLayout.xtype, horizontalAlign: ob.horizontalAlign, items: [item], }; @@ -83,7 +98,7 @@ configWidget("bi.vertical", ob => { if (isSupportFlex()) { return extend({ horizontalAlign: HorizontalAlign.Stretch, - }, ob, { type: "bi.flex_vertical" }); + }, ob, { type: FlexVerticalLayout.xtype }); } } @@ -113,15 +128,15 @@ configWidget("bi.inline", ob => { if ((ob.scrollable !== true && ob.scrollx !== true) || ob.horizontalAlign === HorizontalAlign.Stretch) { return extend({ verticalAlign: VerticalAlign.Top, - }, ob, { type: "bi.horizontal_float_fill" }); + }, ob, { type: FloatHorizontalFillLayout.xtype }); } return extend({ horizontalAlign: HorizontalAlign.Stretch, - }, ob, { type: "bi.table_adapt" }); + }, ob, { type: TableAdaptLayout.xtype }); } - if (Providers.getProvider("bi.provider.system").getResponsiveMode()) { - return extend({}, ob, { type: "bi.responsive_inline" }); + if (Providers.getProvider(SystemProvider.xtype).getResponsiveMode()) { + return extend({}, ob, { type: ResponsiveInlineLayout.xtype }); } return ob; @@ -131,10 +146,10 @@ configWidget("bi.center_adapt", ob => { // var isAdapt = !ob.horizontalAlign || ob.horizontalAlign === HorizontalAlign.Center || ob.horizontalAlign === HorizontalAlign.Stretch; // if (!isAdapt || justOneItem) { if (supportFlex) { - return extend({}, ob, { type: "bi.flex_center_adapt" }); + return extend({}, ob, { type: FlexCenterLayout.xtype }); } - return extend({}, ob, { type: "bi.inline_center_adapt" }); + return extend({}, ob, { type: InlineCenterAdaptLayout.xtype }); // } // return ob; }); @@ -143,10 +158,10 @@ configWidget("bi.vertical_adapt", ob => { // var isAdapt = ob.horizontalAlign === HorizontalAlign.Center || ob.horizontalAlign === HorizontalAlign.Stretch; // if (!isAdapt || justOneItem) { if (supportFlex) { - return extend({}, ob, { type: "bi.flex_vertical_center_adapt" }); + return extend({}, ob, { type: FlexVerticalCenterAdapt.xtype }); } - return extend({}, ob, { type: "bi.inline_vertical_adapt" }); + return extend({}, ob, { type: InlineVerticalAdaptLayout.xtype }); // } // return ob; }); @@ -156,7 +171,7 @@ configWidget("bi.horizontal_adapt", ob => { const isAdapt = !ob.horizontalAlign || ob.horizontalAlign === HorizontalAlign.Center || ob.horizontalAlign === HorizontalAlign.Stretch; const verticalAlignTop = !ob.verticalAlign || ob.verticalAlign === VerticalAlign.TOP; if (verticalAlignTop && justOneItem) { - return extend({}, ob, { type: "bi.horizontal_auto" }); + return extend({}, ob, { type: HorizontalAutoLayout.xtype }); } const supportFlex = isSupportFlex(); // 在横向自适应场景下我们需要使用table的自适应撑出滚动条的特性(flex处理不了这种情况) @@ -164,26 +179,26 @@ configWidget("bi.horizontal_adapt", ob => { if (isAdapt) { return extend({ horizontalAlign: HorizontalAlign.Center, - }, ob, { type: "bi.table_adapt" }); + }, ob, { type: TableAdaptLayout.xtype }); } if (supportFlex) { return extend({ horizontalAlign: HorizontalAlign.Center, scrollx: false, - }, ob, { type: "bi.flex_horizontal" }); + }, ob, { type: FlexHorizontalLayout.xtype }); } return extend({ horizontalAlign: HorizontalAlign.Center, - }, ob, { type: "bi.table_adapt" }); + }, ob, { type: TableAdaptLayout.xtype }); }); configWidget("bi.horizontal_float", ob => { if (isSupportFlex()) { - return extend({}, ob, { type: "bi.flex_horizontal_adapt" }); + return extend({}, ob, { type: FlexHorizontalCenter.xtype }); } if (ob.items && ob.items.length <= 1) { - return extend({}, ob, { type: "bi.inline_horizontal_adapt" }); + return extend({}, ob, { type: InlineHorizontalAdaptLayout.xtype }); } return ob; @@ -195,17 +210,17 @@ configWidget("bi.horizontal_fill", ob => { horizontalAlign: HorizontalAlign.Stretch, verticalAlign: VerticalAlign.Stretch, scrollx: false, - }, ob, { type: "bi.flex_horizontal" }); + }, ob, { type: FlexHorizontalLayout.xtype }); } if ((ob.horizontalAlign && ob.horizontalAlign !== HorizontalAlign.Stretch) || (ob.scrollable === true || ob.scrollx === true)) { // 宽度不受限,要用table布局 return extend({ horizontalAlign: HorizontalAlign.Stretch, verticalAlign: VerticalAlign.Stretch, - }, ob, { type: "bi.table_adapt" }); + }, ob, { type: TableLayout.xtype }); } - return extend({}, ob, { type: "bi.horizontal_float_fill" }); + return extend({}, ob, { type: FloatHorizontalFillLayout.xtype }); }); configWidget("bi.vertical_fill", ob => { if (isSupportFlex()) { @@ -213,12 +228,12 @@ configWidget("bi.vertical_fill", ob => { horizontalAlign: HorizontalAlign.Stretch, verticalAlign: VerticalAlign.Stretch, scrolly: false, - }, ob, { type: "bi.flex_vertical" }); + }, ob, { type: FlexVerticalLayout }); } if (ob.scrollable === true || ob.scrollx === true || ob.scrolly === true) { // 有滚动条,降级到table布局处理 return extend({}, ob, { - type: "bi.td", + type: TdLayout.xtype, items: map(ob.items, (i, item) => [item]), }); } @@ -236,19 +251,19 @@ configWidget("bi.vertical_fill", ob => { } if (hasAuto) { // 有自动高的时候 - return extend({}, ob, { type: "bi.vtape_auto" }); + return extend({}, ob, { type: AutoVerticalTapeLayout.xtype }); } - return extend({}, ob, { type: "bi.vtape" }); + return extend({}, ob, { type: VTapeLayout.xtype }); }); configWidget("bi.horizontal_sticky", ob => { if (!isSupportSticky) { - return extend({ scrollx: true }, ob, { type: "bi.horizontal_fill" }); + return extend({ scrollx: true }, ob, { type: HorizontalFillLayout.xtype }); } }); configWidget("bi.vertical_sticky", ob => { if (!isSupportSticky) { - return extend({ scrolly: true }, ob, { type: "bi.vertical_fill" }); + return extend({ scrolly: true }, ob, { type: VerticalFillLayout.xtype }); } }); @@ -256,7 +271,7 @@ configWidget("bi.left_right_vertical_adapt", ob => { if (isSupportFlex()) { // IE下其实也是可以使用flex布局的,只要排除掉出现滚动条的情况 // if (!isIE() || (ob.scrollable !== true && ob.scrolly !== true)) { - return extend({}, ob, { type: "bi.flex_left_right_vertical_adapt" }); + return extend({}, ob, { type: FlexLeftRightVerticalAdaptLayout.xtype }); // } } @@ -265,28 +280,28 @@ configWidget("bi.left_right_vertical_adapt", ob => { configWidget("bi.flex_horizontal", ob => { if (ob.scrollable === true || ob.scrollx === true || ob.scrolly === true) { if (ob.hgap > 0 || ob.lgap > 0 || ob.rgap > 0) { - if (Providers.getProvider("bi.provider.system").getResponsiveMode()) { - return extend({}, ob, { type: "bi.responsive_flex_scrollable_horizontal" }); + if (Providers.getProvider(SystemProvider.xtype).getResponsiveMode()) { + return extend({}, ob, { type: ResponsiveFlexWrapperHorizontalLayout.xtype }); } - return extend({}, ob, { type: "bi.flex_scrollable_horizontal" }); + return extend({}, ob, { type: FlexWrapperHorizontalLayout.xtype }); } } - if (Providers.getProvider("bi.provider.system").getResponsiveMode()) { - return extend({}, ob, { type: "bi.responsive_flex_horizontal" }); + if (Providers.getProvider(SystemProvider.xtype).getResponsiveMode()) { + return extend({}, ob, { type: ResponsiveFlexHorizontalLayout.xtype }); } }); configWidget("bi.flex_vertical", ob => { if (ob.scrollable === true || ob.scrollx === true || ob.scrolly === true) { if (ob.hgap > 0 || ob.lgap > 0 || ob.rgap > 0) { - return extend({}, ob, { type: "bi.flex_scrollable_vertical" }); + return extend({}, ob, { type: FlexWrapperVerticalLayout.xtype }); } } }); configWidget("bi.table", ob => { if (!isSupportGrid()) { - return extend({}, ob, { type: "bi.td" }); + return extend({}, ob, { type: TdLayout.xtype }); } return ob;