From 10effb54e0bf5de2538543a203388cc10691f735 Mon Sep 17 00:00:00 2001 From: ocean-gao Date: Mon, 18 Sep 2023 19:40:30 +0800 Subject: [PATCH] =?UTF-8?q?feat(drawer):=20=E5=A2=9E=E5=8A=A0=E6=93=8D?= =?UTF-8?q?=E4=BD=9C=E6=8C=89=E9=92=AEloading=E5=92=8C=E6=98=AF=E5=90=A6?= =?UTF-8?q?=E5=B1=95=E7=A4=BA=E5=8F=96=E6=B6=88=E7=9A=84=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/drawer/drawer.tsx | 14 +- .../components/drawer/asyncSubmit.vue | 150 ++++++++++++++++++ docs/.vitepress/components/drawer/index.md | 6 + .../components/modal/asyncSubmit.vue | 4 +- 4 files changed, 169 insertions(+), 5 deletions(-) create mode 100644 docs/.vitepress/components/drawer/asyncSubmit.vue diff --git a/components/drawer/drawer.tsx b/components/drawer/drawer.tsx index b21d3f70..051ebfee 100644 --- a/components/drawer/drawer.tsx +++ b/components/drawer/drawer.tsx @@ -53,10 +53,15 @@ export const drawerProps = { type: String, default: '确定', }, + okLoading: Boolean, cancelText: { type: String, default: '取消', }, + showCancel: { + type: Boolean, + default: true, + }, width: { type: [String, Number] as PropType, default: 520, @@ -153,12 +158,15 @@ const Drawer = defineComponent({ class="btn-margin" size="middle" onClick={handleOk} + loading={props.okLoading} > {props.okText} - - {props.cancelText} - + {props.showCancel && ( + + {props.cancelText} + + )} ); } diff --git a/docs/.vitepress/components/drawer/asyncSubmit.vue b/docs/.vitepress/components/drawer/asyncSubmit.vue new file mode 100644 index 00000000..4124d5b8 --- /dev/null +++ b/docs/.vitepress/components/drawer/asyncSubmit.vue @@ -0,0 +1,150 @@ + + + diff --git a/docs/.vitepress/components/drawer/index.md b/docs/.vitepress/components/drawer/index.md index b9efe972..bd39f977 100644 --- a/docs/.vitepress/components/drawer/index.md +++ b/docs/.vitepress/components/drawer/index.md @@ -40,6 +40,12 @@ app.use(FDrawer); --CUSTOMFOOTER +### 异步提交 + +针对抽屉确认提交操作。 + +--ASYNCSUBMIT + --CODE ## Drawer Props diff --git a/docs/.vitepress/components/modal/asyncSubmit.vue b/docs/.vitepress/components/modal/asyncSubmit.vue index dff665df..e27c1223 100644 --- a/docs/.vitepress/components/modal/asyncSubmit.vue +++ b/docs/.vitepress/components/modal/asyncSubmit.vue @@ -65,7 +65,7 @@ function useModal() { const handleCancel = async () => { cancelLoading.value = true; cancelText.value = '3s后自动关闭'; - await sleep(2000); + await sleep(3000); cancelLoading.value = false; show.value = false; await nextTick(); @@ -74,7 +74,7 @@ function useModal() { const handleOk = async () => { okLoading.value = true; okText.value = '2s后自动关闭'; - await sleep(3000); + await sleep(2000); okLoading.value = false; show.value = false; await nextTick();