Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
monorepo
/
venus
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
1
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit cfa18c2b
authored
Mar 10, 2025
by
Netfan
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
fix: improve component repackaging
1 parent
13354955
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
107 additions
and
24 deletions
apps/web-antd/src/adapter/component/index.ts
apps/web-ele/src/adapter/component/index.ts
apps/web-naive/src/adapter/component/index.ts
playground/src/adapter/component/index.ts
apps/web-antd/src/adapter/component/index.ts
View file @
cfa18c2
...
@@ -3,11 +3,12 @@
...
@@ -3,11 +3,12 @@
* 可用于 vben-form、vben-modal、vben-drawer 等组件使用,
* 可用于 vben-form、vben-modal、vben-drawer 等组件使用,
*/
*/
import
type
{
Component
,
SetupContext
}
from
'vue'
;
import
type
{
Component
}
from
'vue'
;
import
type
{
BaseFormComponentType
}
from
'@vben/common-ui'
;
import
type
{
BaseFormComponentType
}
from
'@vben/common-ui'
;
import
type
{
Recordable
}
from
'@vben/types'
;
import
{
h
}
from
'vue'
;
import
{
defineComponent
,
getCurrentInstance
,
h
,
ref
}
from
'vue'
;
import
{
ApiComponent
,
globalShareState
,
IconPicker
}
from
'@vben/common-ui'
;
import
{
ApiComponent
,
globalShareState
,
IconPicker
}
from
'@vben/common-ui'
;
import
{
$t
}
from
'@vben/locales'
;
import
{
$t
}
from
'@vben/locales'
;
...
@@ -41,10 +42,30 @@ const withDefaultPlaceholder = <T extends Component>(
...
@@ -41,10 +42,30 @@ const withDefaultPlaceholder = <T extends Component>(
component
:
T
,
component
:
T
,
type
:
'input'
|
'select'
,
type
:
'input'
|
'select'
,
)
=>
{
)
=>
{
return
(
props
:
any
,
{
attrs
,
slots
}:
Omit
<
SetupContext
,
'expose'
>
)
=>
{
return
defineComponent
({
const
placeholder
=
props
?.
placeholder
||
$t
(
`ui.placeholder.
${
type
}
`
);
inheritAttrs
:
false
,
return
h
(
component
,
{
...
props
,
...
attrs
,
placeholder
},
slots
);
name
:
component
.
name
,
};
setup
:
(
props
:
any
,
{
attrs
,
expose
,
slots
})
=>
{
const
placeholder
=
props
?.
placeholder
||
attrs
?.
placeholder
||
$t
(
`ui.placeholder.
${
type
}
`
);
// 透传组件暴露的方法
const
innerRef
=
ref
();
const
publicApi
:
Recordable
<
any
>
=
{};
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
];
}
}
});
return
()
=>
h
(
component
,
{
...
props
,
...
attrs
,
placeholder
,
ref
:
innerRef
},
slots
);
},
});
};
};
// 这里需要自行根据业务组件库进行适配,需要用到的组件都需要在这里类型说明
// 这里需要自行根据业务组件库进行适配,需要用到的组件都需要在这里类型说明
...
...
apps/web-ele/src/adapter/component/index.ts
View file @
cfa18c2
...
@@ -3,12 +3,12 @@
...
@@ -3,12 +3,12 @@
* 可用于 vben-form、vben-modal、vben-drawer 等组件使用,
* 可用于 vben-form、vben-modal、vben-drawer 等组件使用,
*/
*/
import
type
{
Component
,
SetupContext
}
from
'vue'
;
import
type
{
Component
}
from
'vue'
;
import
type
{
BaseFormComponentType
}
from
'@vben/common-ui'
;
import
type
{
BaseFormComponentType
}
from
'@vben/common-ui'
;
import
type
{
Recordable
}
from
'@vben/types'
;
import
type
{
Recordable
}
from
'@vben/types'
;
import
{
h
}
from
'vue'
;
import
{
defineComponent
,
getCurrentInstance
,
h
,
ref
}
from
'vue'
;
import
{
ApiComponent
,
globalShareState
,
IconPicker
}
from
'@vben/common-ui'
;
import
{
ApiComponent
,
globalShareState
,
IconPicker
}
from
'@vben/common-ui'
;
import
{
$t
}
from
'@vben/locales'
;
import
{
$t
}
from
'@vben/locales'
;
...
@@ -38,10 +38,30 @@ const withDefaultPlaceholder = <T extends Component>(
...
@@ -38,10 +38,30 @@ const withDefaultPlaceholder = <T extends Component>(
component
:
T
,
component
:
T
,
type
:
'input'
|
'select'
,
type
:
'input'
|
'select'
,
)
=>
{
)
=>
{
return
(
props
:
any
,
{
attrs
,
slots
}:
Omit
<
SetupContext
,
'expose'
>
)
=>
{
return
defineComponent
({
const
placeholder
=
props
?.
placeholder
||
$t
(
`ui.placeholder.
${
type
}
`
);
inheritAttrs
:
false
,
return
h
(
component
,
{
...
props
,
...
attrs
,
placeholder
},
slots
);
name
:
component
.
name
,
};
setup
:
(
props
:
any
,
{
attrs
,
expose
,
slots
})
=>
{
const
placeholder
=
props
?.
placeholder
||
attrs
?.
placeholder
||
$t
(
`ui.placeholder.
${
type
}
`
);
// 透传组件暴露的方法
const
innerRef
=
ref
();
const
publicApi
:
Recordable
<
any
>
=
{};
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
];
}
}
});
return
()
=>
h
(
component
,
{
...
props
,
...
attrs
,
placeholder
,
ref
:
innerRef
},
slots
);
},
});
};
};
// 这里需要自行根据业务组件库进行适配,需要用到的组件都需要在这里类型说明
// 这里需要自行根据业务组件库进行适配,需要用到的组件都需要在这里类型说明
...
...
apps/web-naive/src/adapter/component/index.ts
View file @
cfa18c2
...
@@ -3,11 +3,12 @@
...
@@ -3,11 +3,12 @@
* 可用于 vben-form、vben-modal、vben-drawer 等组件使用,
* 可用于 vben-form、vben-modal、vben-drawer 等组件使用,
*/
*/
import
type
{
Component
,
SetupContext
}
from
'vue'
;
import
type
{
Component
}
from
'vue'
;
import
type
{
BaseFormComponentType
}
from
'@vben/common-ui'
;
import
type
{
BaseFormComponentType
}
from
'@vben/common-ui'
;
import
type
{
Recordable
}
from
'@vben/types'
;
import
{
h
}
from
'vue'
;
import
{
defineComponent
,
getCurrentInstance
,
h
,
ref
}
from
'vue'
;
import
{
ApiComponent
,
globalShareState
,
IconPicker
}
from
'@vben/common-ui'
;
import
{
ApiComponent
,
globalShareState
,
IconPicker
}
from
'@vben/common-ui'
;
import
{
$t
}
from
'@vben/locales'
;
import
{
$t
}
from
'@vben/locales'
;
...
@@ -37,10 +38,30 @@ const withDefaultPlaceholder = <T extends Component>(
...
@@ -37,10 +38,30 @@ const withDefaultPlaceholder = <T extends Component>(
component
:
T
,
component
:
T
,
type
:
'input'
|
'select'
,
type
:
'input'
|
'select'
,
)
=>
{
)
=>
{
return
(
props
:
any
,
{
attrs
,
slots
}:
Omit
<
SetupContext
,
'expose'
>
)
=>
{
return
defineComponent
({
const
placeholder
=
props
?.
placeholder
||
$t
(
`ui.placeholder.
${
type
}
`
);
inheritAttrs
:
false
,
return
h
(
component
,
{
...
props
,
...
attrs
,
placeholder
},
slots
);
name
:
component
.
name
,
};
setup
:
(
props
:
any
,
{
attrs
,
expose
,
slots
})
=>
{
const
placeholder
=
props
?.
placeholder
||
attrs
?.
placeholder
||
$t
(
`ui.placeholder.
${
type
}
`
);
// 透传组件暴露的方法
const
innerRef
=
ref
();
const
publicApi
:
Recordable
<
any
>
=
{};
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
];
}
}
});
return
()
=>
h
(
component
,
{
...
props
,
...
attrs
,
placeholder
,
ref
:
innerRef
},
slots
);
},
});
};
};
// 这里需要自行根据业务组件库进行适配,需要用到的组件都需要在这里类型说明
// 这里需要自行根据业务组件库进行适配,需要用到的组件都需要在这里类型说明
...
...
playground/src/adapter/component/index.ts
View file @
cfa18c2
...
@@ -3,11 +3,12 @@
...
@@ -3,11 +3,12 @@
* 可用于 vben-form、vben-modal、vben-drawer 等组件使用,
* 可用于 vben-form、vben-modal、vben-drawer 等组件使用,
*/
*/
import
type
{
Component
,
SetupContext
}
from
'vue'
;
import
type
{
Component
}
from
'vue'
;
import
type
{
BaseFormComponentType
}
from
'@vben/common-ui'
;
import
type
{
BaseFormComponentType
}
from
'@vben/common-ui'
;
import
type
{
Recordable
}
from
'@vben/types'
;
import
{
h
}
from
'vue'
;
import
{
defineComponent
,
getCurrentInstance
,
h
,
ref
}
from
'vue'
;
import
{
ApiComponent
,
globalShareState
,
IconPicker
}
from
'@vben/common-ui'
;
import
{
ApiComponent
,
globalShareState
,
IconPicker
}
from
'@vben/common-ui'
;
import
{
$t
}
from
'@vben/locales'
;
import
{
$t
}
from
'@vben/locales'
;
...
@@ -41,10 +42,30 @@ const withDefaultPlaceholder = <T extends Component>(
...
@@ -41,10 +42,30 @@ const withDefaultPlaceholder = <T extends Component>(
component
:
T
,
component
:
T
,
type
:
'input'
|
'select'
,
type
:
'input'
|
'select'
,
)
=>
{
)
=>
{
return
(
props
:
any
,
{
attrs
,
slots
}:
Omit
<
SetupContext
,
'expose'
>
)
=>
{
return
defineComponent
({
const
placeholder
=
props
?.
placeholder
||
$t
(
`ui.placeholder.
${
type
}
`
);
inheritAttrs
:
false
,
return
h
(
component
,
{
...
props
,
...
attrs
,
placeholder
},
slots
);
name
:
component
.
name
,
};
setup
:
(
props
:
any
,
{
attrs
,
expose
,
slots
})
=>
{
const
placeholder
=
props
?.
placeholder
||
attrs
?.
placeholder
||
$t
(
`ui.placeholder.
${
type
}
`
);
// 透传组件暴露的方法
const
innerRef
=
ref
();
const
publicApi
:
Recordable
<
any
>
=
{};
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
];
}
}
});
return
()
=>
h
(
component
,
{
...
props
,
...
attrs
,
placeholder
,
ref
:
innerRef
},
slots
);
},
});
};
};
// 这里需要自行根据业务组件库进行适配,需要用到的组件都需要在这里类型说明
// 这里需要自行根据业务组件库进行适配,需要用到的组件都需要在这里类型说明
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment