From c743d66b8e5856e880d759635b5d05a5ede23db7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=A2=AB=E9=9B=A8=E6=B0=B4=E8=BF=87=E6=BB=A4=E7=9A=84?= =?UTF-8?q?=E7=A9=BA=E6=B0=94-Rain?= <958414905@qq.com> Date: Mon, 31 Jul 2023 13:14:20 +0800 Subject: [PATCH] chore: only dev env can throw errors (#2355) --- .../theme-editor/src/client/hooks/useThemeSettings.tsx | 7 +++++-- .../client/utils/changeAlgorithmFromStringToFunction.tsx | 5 ++--- packages/plugins/theme-editor/src/server/plugin.ts | 3 +-- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/packages/plugins/theme-editor/src/client/hooks/useThemeSettings.tsx b/packages/plugins/theme-editor/src/client/hooks/useThemeSettings.tsx index 914d8864b..f4fb2d26e 100644 --- a/packages/plugins/theme-editor/src/client/hooks/useThemeSettings.tsx +++ b/packages/plugins/theme-editor/src/client/hooks/useThemeSettings.tsx @@ -68,8 +68,11 @@ function Label() { return null; } - if (!systemSettings) { - error('Please check if provide `SystemSettingsProvider` in your app.'); + if (process.env.NODE_ENV !== 'production' && !currentUser) { + throw new Error('Please check if provide `CurrentUserProvider` in your app.'); + } + + if (process.env.NODE_ENV !== 'production' && !systemSettings) { throw new Error('Please check if provide `SystemSettingsProvider` in your app.'); } diff --git a/packages/plugins/theme-editor/src/client/utils/changeAlgorithmFromStringToFunction.tsx b/packages/plugins/theme-editor/src/client/utils/changeAlgorithmFromStringToFunction.tsx index c4c2cef1e..f4d04762f 100644 --- a/packages/plugins/theme-editor/src/client/utils/changeAlgorithmFromStringToFunction.tsx +++ b/packages/plugins/theme-editor/src/client/utils/changeAlgorithmFromStringToFunction.tsx @@ -1,4 +1,3 @@ -import { isString } from '@nocobase/utils'; import { theme } from 'antd'; import _ from 'lodash'; import { ThemeItem } from '../../types'; @@ -9,12 +8,12 @@ import { ThemeItem } from '../../types'; */ export function changeAlgorithmFromStringToFunction(themeConfig: ThemeItem) { themeConfig = _.cloneDeep(themeConfig); - if (isString(themeConfig.config.algorithm)) { + if (_.isString(themeConfig.config.algorithm)) { themeConfig.config.algorithm = theme[themeConfig.config.algorithm]; } if (Array.isArray(themeConfig.config.algorithm)) { themeConfig.config.algorithm = themeConfig.config.algorithm.map((item) => { - if (isString(item)) { + if (_.isString(item)) { return theme[item]; } return item; diff --git a/packages/plugins/theme-editor/src/server/plugin.ts b/packages/plugins/theme-editor/src/server/plugin.ts index d5945a3c9..a2d1399e0 100644 --- a/packages/plugins/theme-editor/src/server/plugin.ts +++ b/packages/plugins/theme-editor/src/server/plugin.ts @@ -1,9 +1,8 @@ -import { Collection } from '@nocobase/database'; import { InstallOptions, Plugin } from '@nocobase/server'; import { antd, compact, compactDark, dark } from './builtinThemes'; export class ThemeEditorPlugin extends Plugin { - theme: Collection; + theme: any; afterAdd() {}