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 3c2d325d
authored
Mar 27, 2025
by
Netfan
Committed by
GitHub
Mar 27, 2025
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
perf: improve api-component for using in form (#5796)
1 parent
a77bb8e6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
2 deletions
packages/effects/common-ui/src/components/api-component/api-component.vue
packages/effects/common-ui/src/components/api-component/api-component.vue
View file @
3c2d325
...
...
@@ -84,7 +84,7 @@ const emit = defineEmits<{
const
modelValue
=
defineModel
({
default
:
''
});
const
attrs
=
useAttrs
();
const
innerParams
=
ref
({});
const
refOptions
=
ref
<
OptionsItem
[]
>
([]);
const
loading
=
ref
(
false
);
// 首次是否加载过了
...
...
@@ -175,8 +175,15 @@ async function handleFetchForVisible(visible: boolean) {
}
}
const
params
=
computed
(()
=>
{
return
{
...
props
.
params
,
...
unref
(
innerParams
),
};
});
watch
(
()
=>
props
.
params
,
params
,
(
value
,
oldValue
)
=>
{
if
(
isEqual
(
value
,
oldValue
))
{
return
;
...
...
@@ -189,12 +196,22 @@ watch(
function
emitChange
()
{
emit
(
'optionsChange'
,
unref
(
getOptions
));
}
const
componentRef
=
ref
();
defineExpose
({
/** 获取被包装的组件实例 */
getComponentRef
:
<
T
=
any
,
>
()
=>
componentRef
.
value
as
T
,
/** 更新Api参数 */
updateParam
(
newParams
:
Record
<
string
,
any
>
)
{
innerParams
.
value
=
newParams
;
},
});
</
script
>
<
template
>
<component
:is=
"component"
v-bind=
"bindProps"
:placeholder=
"$attrs.placeholder"
ref=
"componentRef"
>
<template
v-for=
"item in Object.keys($slots)"
#[
item
]="
data
"
>
<slot
:name=
"item"
v-bind=
"data ||
{}">
</slot>
...
...
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