From fee811d9503f21e6e0593d8c94a5f37ac4fa6ed2 Mon Sep 17 00:00:00 2001 From: RanMaoting <62940878+RanMaoting@users.noreply.github.com> Date: Wed, 2 Jul 2025 19:58:48 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BC=98=E5=8C=96=E7=BB=84=E4=BB=B6?= =?UTF-8?q?=E6=96=B9=E6=B3=95=E9=80=8F=E4=BC=A0=E5=B9=B6=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E8=A1=A8=E5=8D=95=E5=BC=B9=E7=AA=97=E7=A4=BA=E4=BE=8B=20(#6443?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/web-antd/src/adapter/component/index.ts | 27 +++---- apps/web-ele/src/adapter/component/index.ts | 27 +++---- apps/web-naive/src/adapter/component/index.ts | 27 +++---- apps/web-naive/src/views/demos/form/basic.vue | 12 +++- apps/web-naive/src/views/demos/form/modal.vue | 71 +++++++++++++++++++ playground/src/adapter/component/index.ts | 36 +++++----- pnpm-lock.yaml | 8 --- 7 files changed, 131 insertions(+), 77 deletions(-) create mode 100644 apps/web-naive/src/views/demos/form/modal.vue diff --git a/apps/web-antd/src/adapter/component/index.ts b/apps/web-antd/src/adapter/component/index.ts index d452d5210..786a93dae 100644 --- a/apps/web-antd/src/adapter/component/index.ts +++ b/apps/web-antd/src/adapter/component/index.ts @@ -8,13 +8,7 @@ import type { Component } from 'vue'; import type { BaseFormComponentType } from '@vben/common-ui'; import type { Recordable } from '@vben/types'; -import { - defineAsyncComponent, - defineComponent, - getCurrentInstance, - h, - ref, -} from 'vue'; +import { defineAsyncComponent, defineComponent, h, ref } from 'vue'; import { ApiComponent, globalShareState, IconPicker } from '@vben/common-ui'; import { $t } from '@vben/locales'; @@ -82,16 +76,15 @@ const withDefaultPlaceholder = ( $t(`ui.placeholder.${type}`); // 透传组件暴露的方法 const innerRef = ref(); - const publicApi: Recordable = {}; - expose(publicApi); - const instance = getCurrentInstance(); - instance?.proxy?.$nextTick(() => { - for (const key in innerRef.value) { - if (typeof innerRef.value[key] === 'function') { - publicApi[key] = innerRef.value[key]; - } - } - }); + expose( + new Proxy( + {}, + { + get: (_target, key) => innerRef.value?.[key], + has: (_target, key) => key in (innerRef.value || {}), + }, + ), + ); return () => h( component, diff --git a/apps/web-ele/src/adapter/component/index.ts b/apps/web-ele/src/adapter/component/index.ts index e2f533cf5..79a463602 100644 --- a/apps/web-ele/src/adapter/component/index.ts +++ b/apps/web-ele/src/adapter/component/index.ts @@ -8,13 +8,7 @@ import type { Component } from 'vue'; import type { BaseFormComponentType } from '@vben/common-ui'; import type { Recordable } from '@vben/types'; -import { - defineAsyncComponent, - defineComponent, - getCurrentInstance, - h, - ref, -} from 'vue'; +import { defineAsyncComponent, defineComponent, h, ref } from 'vue'; import { ApiComponent, globalShareState, IconPicker } from '@vben/common-ui'; import { $t } from '@vben/locales'; @@ -139,16 +133,15 @@ const withDefaultPlaceholder = ( $t(`ui.placeholder.${type}`); // 透传组件暴露的方法 const innerRef = ref(); - const publicApi: Recordable = {}; - expose(publicApi); - const instance = getCurrentInstance(); - instance?.proxy?.$nextTick(() => { - for (const key in innerRef.value) { - if (typeof innerRef.value[key] === 'function') { - publicApi[key] = innerRef.value[key]; - } - } - }); + expose( + new Proxy( + {}, + { + get: (_target, key) => innerRef.value?.[key], + has: (_target, key) => key in (innerRef.value || {}), + }, + ), + ); return () => h( component, diff --git a/apps/web-naive/src/adapter/component/index.ts b/apps/web-naive/src/adapter/component/index.ts index 7ff115331..f9df20273 100644 --- a/apps/web-naive/src/adapter/component/index.ts +++ b/apps/web-naive/src/adapter/component/index.ts @@ -8,13 +8,7 @@ import type { Component } from 'vue'; import type { BaseFormComponentType } from '@vben/common-ui'; import type { Recordable } from '@vben/types'; -import { - defineAsyncComponent, - defineComponent, - getCurrentInstance, - h, - ref, -} from 'vue'; +import { defineAsyncComponent, defineComponent, h, ref } from 'vue'; import { ApiComponent, globalShareState, IconPicker } from '@vben/common-ui'; import { $t } from '@vben/locales'; @@ -85,16 +79,15 @@ const withDefaultPlaceholder = ( $t(`ui.placeholder.${type}`); // 透传组件暴露的方法 const innerRef = ref(); - const publicApi: Recordable = {}; - expose(publicApi); - const instance = getCurrentInstance(); - instance?.proxy?.$nextTick(() => { - for (const key in innerRef.value) { - if (typeof innerRef.value[key] === 'function') { - publicApi[key] = innerRef.value[key]; - } - } - }); + expose( + new Proxy( + {}, + { + get: (_target, key) => innerRef.value?.[key], + has: (_target, key) => key in (innerRef.value || {}), + }, + ), + ); return () => h( component, diff --git a/apps/web-naive/src/views/demos/form/basic.vue b/apps/web-naive/src/views/demos/form/basic.vue index fe26624cc..60702a11e 100644 --- a/apps/web-naive/src/views/demos/form/basic.vue +++ b/apps/web-naive/src/views/demos/form/basic.vue @@ -1,11 +1,13 @@ diff --git a/apps/web-naive/src/views/demos/form/modal.vue b/apps/web-naive/src/views/demos/form/modal.vue new file mode 100644 index 000000000..52e23542d --- /dev/null +++ b/apps/web-naive/src/views/demos/form/modal.vue @@ -0,0 +1,71 @@ + + diff --git a/playground/src/adapter/component/index.ts b/playground/src/adapter/component/index.ts index f32569a6c..094d4fc4b 100644 --- a/playground/src/adapter/component/index.ts +++ b/playground/src/adapter/component/index.ts @@ -8,13 +8,7 @@ import type { Component } from 'vue'; import type { BaseFormComponentType } from '@vben/common-ui'; import type { Recordable } from '@vben/types'; -import { - defineAsyncComponent, - defineComponent, - getCurrentInstance, - h, - ref, -} from 'vue'; +import { defineAsyncComponent, defineComponent, h, ref } from 'vue'; import { ApiComponent, globalShareState, IconPicker } from '@vben/common-ui'; import { $t } from '@vben/locales'; @@ -82,16 +76,24 @@ const withDefaultPlaceholder = ( $t(`ui.placeholder.${type}`); // 透传组件暴露的方法 const innerRef = ref(); - const publicApi: Recordable = {}; - expose(publicApi); - const instance = getCurrentInstance(); - instance?.proxy?.$nextTick(() => { - for (const key in innerRef.value) { - if (typeof innerRef.value[key] === 'function') { - publicApi[key] = innerRef.value[key]; - } - } - }); + // const publicApi: Recordable = {}; + expose( + new Proxy( + {}, + { + get: (_target, key) => innerRef.value?.[key], + has: (_target, key) => key in (innerRef.value || {}), + }, + ), + ); + // const instance = getCurrentInstance(); + // instance?.proxy?.$nextTick(() => { + // for (const key in innerRef.value) { + // if (typeof innerRef.value[key] === 'function') { + // publicApi[key] = innerRef.value[key]; + // } + // } + // }); return () => h( component, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 148013e82..4d9080759 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1470,9 +1470,6 @@ importers: vue: specifier: ^3.5.17 version: 3.5.17(typescript@5.8.3) - vue-sonner: - specifier: ^2.0.1 - version: 2.0.1 packages/@core/ui-kit/tabs-ui: dependencies: @@ -11258,9 +11255,6 @@ packages: peerDependencies: vue: ^3.5.17 - vue-sonner@2.0.1: - resolution: {integrity: sha512-sn4vjCRzRcnMaxaLa9aNSyZQi6S+gshiea5Lc3eqpkj0ES9LH8ljg+WJCkxefr28V4PZ9xkUXBIWpxGfQxstIg==} - vue-tippy@6.7.1: resolution: {integrity: sha512-gdHbBV5/Vc8gH87hQHLA7TN1K4BlLco3MAPrTb70ZYGXxx+55rAU4a4mt0fIoP+gB3etu1khUZ6c29Br1n0CiA==} peerDependencies: @@ -22068,8 +22062,6 @@ snapshots: '@vue/devtools-api': 6.6.4 vue: 3.5.17(typescript@5.8.3) - vue-sonner@2.0.1: {} - vue-tippy@6.7.1(vue@3.5.17(typescript@5.8.3)): dependencies: tippy.js: 6.3.7