From 44cb311facd2a153401691900bcd3a15bdb37c1a Mon Sep 17 00:00:00 2001 From: Ryan Wang Date: Fri, 29 Dec 2023 15:15:39 +0800 Subject: [PATCH] refactor: visible condition of modal component (#5078) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #### What type of PR is this? /area console /kind improvement /milestone 2.12.x #### What this PR does / why we need it: 重构 UI 的 Modal 组件,支持通过 v-if 控制是否显示(渲染)。 example: ```vue ``` #### Which issue(s) this PR fixes: Fixes #5077 #### Special notes for your reviewer: 测试方式: 1. cd console && pnpm --filter "./packages/components" storybook 2. 测试 Modal 组件在文档中是否工作正常。 3. 启动 Console 或者 UC。 4. 观察以前页面上的弹框是否工作正常。 #### Does this PR introduce a user-facing change? ```release-note 重构 UI 的 Modal 组件,支持通过 v-if 控制是否显示(渲染)。 ``` --- .../src/components/modal/Modal.stories.ts | 11 +++-- .../components/src/components/modal/Modal.vue | 49 ++++++++++++------- 2 files changed, 39 insertions(+), 21 deletions(-) diff --git a/console/packages/components/src/components/modal/Modal.stories.ts b/console/packages/components/src/components/modal/Modal.stories.ts index a18f76a6b..87eb41c78 100644 --- a/console/packages/components/src/components/modal/Modal.stories.ts +++ b/console/packages/components/src/components/modal/Modal.stories.ts @@ -4,6 +4,7 @@ import { VModal } from "."; import { VButton } from "../button"; import { IconArrowLeft, IconArrowRight } from "@/icons/icons"; import { VSpace } from "../space"; +import { ref } from "vue"; const meta: Meta = { title: "Modal", @@ -12,16 +13,20 @@ const meta: Meta = { render: (args) => ({ components: { VModal, VButton, VSpace, IconArrowLeft, IconArrowRight }, setup() { - return { args }; + const modal = ref(); + return { args, modal }; }, template: ` 打开 diff --git a/console/packages/components/src/components/modal/Modal.vue b/console/packages/components/src/components/modal/Modal.vue index 967cca40d..cbccf7aa9 100644 --- a/console/packages/components/src/components/modal/Modal.vue +++ b/console/packages/components/src/components/modal/Modal.vue @@ -1,5 +1,5 @@