From e0ee5f415ab6dacf1614220d3c098a5bc63b3441 Mon Sep 17 00:00:00 2001 From: "xinxin.wu" Date: Tue, 22 Aug 2023 15:21:31 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E7=B3=BB=E7=BB=9F=E8=AE=BE=E7=BD=AE):=20?= =?UTF-8?q?=E5=85=AC=E5=85=B1=E7=BB=84=E4=BB=B6dialog=E5=B0=81=E8=A3=85?= =?UTF-8?q?=E5=92=8C=E5=BC=82=E6=AD=A5=E5=A4=84=E7=90=86=E5=87=BD=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/pure/ms-dialog/index.vue | 129 ++++++++++++++++++ .../components/pure/ms-dialog/locale/en-US.ts | 5 + .../components/pure/ms-dialog/locale/zh-CN.ts | 5 + frontend/src/hooks/useAsyncFun.ts | 23 ++++ 4 files changed, 162 insertions(+) create mode 100644 frontend/src/components/pure/ms-dialog/index.vue create mode 100644 frontend/src/components/pure/ms-dialog/locale/en-US.ts create mode 100644 frontend/src/components/pure/ms-dialog/locale/zh-CN.ts create mode 100644 frontend/src/hooks/useAsyncFun.ts diff --git a/frontend/src/components/pure/ms-dialog/index.vue b/frontend/src/components/pure/ms-dialog/index.vue new file mode 100644 index 0000000000..096d467ac2 --- /dev/null +++ b/frontend/src/components/pure/ms-dialog/index.vue @@ -0,0 +1,129 @@ + + + + + diff --git a/frontend/src/components/pure/ms-dialog/locale/en-US.ts b/frontend/src/components/pure/ms-dialog/locale/en-US.ts new file mode 100644 index 0000000000..0f3a789c1f --- /dev/null +++ b/frontend/src/components/pure/ms-dialog/locale/en-US.ts @@ -0,0 +1,5 @@ +export default { + 'ms.dialog.cancel': 'Cancel', + 'ms.dialog.ok': 'Confirm', + 'ms.dialog.saveContinue': 'Save & Continue', +}; diff --git a/frontend/src/components/pure/ms-dialog/locale/zh-CN.ts b/frontend/src/components/pure/ms-dialog/locale/zh-CN.ts new file mode 100644 index 0000000000..434c473df6 --- /dev/null +++ b/frontend/src/components/pure/ms-dialog/locale/zh-CN.ts @@ -0,0 +1,5 @@ +export default { + 'ms.dialog.cancel': '取消', + 'ms.dialog.ok': '确认', + 'ms.dialog.saveContinue': '保存并继续添加', +}; diff --git a/frontend/src/hooks/useAsyncFun.ts b/frontend/src/hooks/useAsyncFun.ts new file mode 100644 index 0000000000..b4860725b5 --- /dev/null +++ b/frontend/src/hooks/useAsyncFun.ts @@ -0,0 +1,23 @@ +import { ref } from 'vue'; + +export default function useAsyncHandler() { + const confirmLoading = ref(false); + + async function handleAsyncProcess(reqFun: T): Promise { + confirmLoading.value = true; + try { + await reqFun; + } catch (error) { + console.log(error); + confirmLoading.value = false; + return new Promise(() => {}); + } finally { + confirmLoading.value = false; + } + } + + return { + confirmLoading, + handleAsyncProcess, + }; +}