Browse Source

fix(configprovider): v4 移除字体图标相关功能 #2165 (#2166)

* fix(configprovider): v4 移除字体图标相关功能 #2165

* fix(configprovider): 修改 Taro 下 tag 属性类型与默认值
eiinu 2 years ago
parent
commit
09290a0061

+ 0 - 2
src/packages/__VUE/configprovider/doc.en-US.md

@@ -181,5 +181,3 @@ Here are all the base variables:
 | theme      | Theme style, set to `dark` to enable dark mode, take effect globally | string | -       |
 | theme-vars | Customized theme variable                     | object | -       |
 | tag        | HTML Tag of root element                                             | string | `div`     |
-| font-class-name | Custom icon font base class name                                     | String | `nutui-iconfont` |
-| class-prefix    | Custom icon class name prefix for using custom icons                 | String | `nut-icon`       |

+ 0 - 2
src/packages/__VUE/configprovider/doc.md

@@ -197,5 +197,3 @@ app.use(ConfigProvider);
 | theme      | 主题风格,设置为 `dark` 来开启深色模式,全局生效 | string | -      |
 | theme-vars | 自定义主题变量                        | object | -      |
 | tag        | 根节点对应的 HTML 标签名                         | string | `div`    |
-| font-class-name | 自定义 icon 字体基础类名                           | String | `nutui-iconfont` |
-| class-prefix    | 自定义 icon 类名前缀,用于使用自定义图标              | String | `nut-icon`       |

+ 0 - 2
src/packages/__VUE/configprovider/doc.taro.md

@@ -197,5 +197,3 @@ page, :root {
 | theme      | 主题风格,设置为 `dark` 来开启深色模式,全局生效 | string | -      |
 | theme-vars | 自定义主题变量                   | object | -      |
 | tag        | 根节点对应的小程序标签名                         | string | `view`    |
-| font-class-name | 自定义 icon 字体基础类名                           | String | `nutui-iconfont` |
-| class-prefix    | 自定义 icon 类名前缀,用于使用自定义图标              | String | `nut-icon`       |

+ 3 - 39
src/packages/__VUE/configprovider/index.taro.vue

@@ -1,15 +1,12 @@
 <script lang="ts">
 import { createComponent } from '@/packages/utils/create';
-import { h, PropType, VNode } from 'vue';
-import { isObject } from '@/packages/utils/util';
+import { h, PropType } from 'vue';
 const { componentName, create } = createComponent('config-provider');
 export default create({
   props: {
     theme: { type: String, default: '' },
-    themeVars: { type: Object, default: () => {} },
-    tag: { type: String as PropType<keyof HTMLElementTagNameMap>, default: 'div' },
-    classPrefix: { type: String, default: 'nut-icon' },
-    fontClassName: { type: String, default: 'nutui-iconfont' }
+    themeVars: { type: Object, default: {} },
+    tag: { type: String, default: 'view' }
   },
   setup(props: any, { slots }: any) {
     const kebabCase = (str: string): string => {
@@ -61,41 +58,8 @@ export default create({
       return cssVars;
     };
 
-    // 覆盖默认插槽的属性
-    const overDefaultSlotProp = (vnodes: VNode[]) => {
-      if (!vnodes) {
-        return;
-      }
-      vnodes.forEach((vnode: VNode) => {
-        let type = vnode.type;
-        type = (type as any).name || type;
-        if (!vnode.props) {
-          vnode.props = {};
-        }
-        if (type == 'nut-icon') {
-          vnode.props['fontClassName'] = vnode.props['font-class-name'] || props.fontClassName;
-          vnode.props['classPrefix'] = vnode.props['class-prefix'] || props.classPrefix;
-        }
-
-        if (Array.isArray(vnode.children) && vnode.children?.length) {
-          overDefaultSlotProp(vnode.children as VNode[]);
-        } else if (isObject(vnode.children) && Object.keys(vnode.children)) {
-          let children = vnode.children as any;
-          for (const key in children) {
-            if (key === '_') {
-              break;
-            }
-
-            const childrenVNode = children[key]?.();
-            overDefaultSlotProp(childrenVNode);
-            children[key] = () => childrenVNode;
-          }
-        }
-      });
-    };
     return () => {
       const defaultSlots = slots.default?.();
-      overDefaultSlotProp(defaultSlots);
       return h(
         props.tag,
         {

+ 2 - 36
src/packages/__VUE/configprovider/index.vue

@@ -1,12 +1,11 @@
 <script lang="ts">
 import { createComponent } from '@/packages/utils/create';
-import { h, PropType, VNode } from 'vue';
-import { isObject } from '@/packages/utils/util';
+import { h, PropType } from 'vue';
 const { componentName, create } = createComponent('config-provider');
 export default create({
   props: {
     theme: { type: String, default: '' },
-    themeVars: { type: Object, default: () => {} },
+    themeVars: { type: Object, default: {} },
     tag: { type: String as PropType<keyof HTMLElementTagNameMap>, default: 'div' }
   },
   setup(props: any, { slots }: any) {
@@ -61,41 +60,8 @@ export default create({
       return cssVars;
     };
 
-    // 覆盖默认插槽的属性
-    const overDefaultSlotProp = (vnodes: VNode[]) => {
-      if (!vnodes) {
-        return;
-      }
-      vnodes.forEach((vnode: VNode) => {
-        let type = vnode.type;
-        type = (type as any).name || type;
-        if (!vnode.props) {
-          vnode.props = {};
-        }
-        if (type == 'nut-icon') {
-          vnode.props['fontClassName'] = vnode.props['font-class-name'] || props.fontClassName;
-          vnode.props['classPrefix'] = vnode.props['class-prefix'] || props.classPrefix;
-        }
-
-        if (Array.isArray(vnode.children) && vnode.children?.length) {
-          overDefaultSlotProp(vnode.children as VNode[]);
-        } else if (isObject(vnode.children) && Object.keys(vnode.children)) {
-          let children = vnode.children as any;
-          for (const key in children) {
-            if (key === '_') {
-              break;
-            }
-
-            const childrenVNode = children[key]?.();
-            overDefaultSlotProp(childrenVNode);
-            children[key] = () => childrenVNode;
-          }
-        }
-      });
-    };
     return () => {
       const defaultSlots = slots.default?.();
-      overDefaultSlotProp(defaultSlots);
       return h(
         props.tag,
         {