From 213e7d80e87e7913afc87299961df772aae662c2 Mon Sep 17 00:00:00 2001 From: chilingling <26962197+chilingling@users.noreply.github.com> Date: Wed, 8 Nov 2023 01:16:28 -0800 Subject: [PATCH] fix(toolbars): disable toolbar btn when page is empty (#70) * fix(toolbars): disable toolbar btn when page is empty * fix(toolbar): disable preview when page is empty --- packages/controller/src/useLayout.js | 28 +++++++++++++-------- packages/toolbars/generate-vue/src/Main.vue | 10 +++++++- packages/toolbars/preview/src/Main.vue | 15 ++++++++--- packages/toolbars/refresh/src/Main.vue | 6 ++++- packages/toolbars/setting/src/Main.vue | 19 +++++++++++--- 5 files changed, 58 insertions(+), 20 deletions(-) diff --git a/packages/controller/src/useLayout.js b/packages/controller/src/useLayout.js index 9e3973ef4..368b77129 100644 --- a/packages/controller/src/useLayout.js +++ b/packages/controller/src/useLayout.js @@ -1,16 +1,19 @@ /** -* Copyright (c) 2023 - present TinyEngine Authors. -* Copyright (c) 2023 - present Huawei Cloud Computing Technologies Co., Ltd. -* -* Use of this source code is governed by an MIT-style license. -* -* THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, -* BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR -* A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS. -* -*/ + * Copyright (c) 2023 - present TinyEngine Authors. + * Copyright (c) 2023 - present Huawei Cloud Computing Technologies Co., Ltd. + * + * Use of this source code is governed by an MIT-style license. + * + * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, + * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR + * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS. + * + */ import { reactive, nextTick } from 'vue' +import { constants } from '@opentiny/tiny-engine-utils' + +const { PAGE_STATUS } = constants const PLUGIN_NAME = { Materials: 'Materials', @@ -111,6 +114,8 @@ const getDimension = () => layoutState.dimension const getPluginState = () => layoutState.plugins +const isEmptyPage = () => layoutState.pageStatus?.state === PAGE_STATUS.Empty + export default () => { return { PLUGIN_NAME, @@ -124,6 +129,7 @@ export default () => { registerPluginApi, getPluginApi, getPluginState, - pluginState + pluginState, + isEmptyPage } } diff --git a/packages/toolbars/generate-vue/src/Main.vue b/packages/toolbars/generate-vue/src/Main.vue index 2c1fc2bbf..8644d8568 100644 --- a/packages/toolbars/generate-vue/src/Main.vue +++ b/packages/toolbars/generate-vue/src/Main.vue @@ -23,7 +23,7 @@