From 901a0f22bb260e912008d4da479c6779287a1a88 Mon Sep 17 00:00:00 2001 From: Katherine Date: Wed, 19 Mar 2025 18:29:31 +0800 Subject: [PATCH] refactor: add secondary confirmation prompt for Clear Cache (#6505) --- packages/core/client/src/locale/zh-CN.json | 1 + .../plugin-client/src/client/ClearCache.tsx | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/packages/core/client/src/locale/zh-CN.json b/packages/core/client/src/locale/zh-CN.json index c568bf4ed0d..9aa45fc3bb9 100644 --- a/packages/core/client/src/locale/zh-CN.json +++ b/packages/core/client/src/locale/zh-CN.json @@ -837,6 +837,7 @@ "The will interrupt service, it may take a few seconds to restart. Are you sure to continue?": "重启将会中断当前服务,这个过程可能需要一点时间,确定要继续吗?", "Restart": "重启", "Clear cache": "清除缓存", + "Are you sure you want to clear cache ?": "你确定你想清除缓存吗", "Duplicate": "复制", "Duplicating": "复制中", "Duplicate mode": "复制方式", diff --git a/packages/plugins/@nocobase/plugin-client/src/client/ClearCache.tsx b/packages/plugins/@nocobase/plugin-client/src/client/ClearCache.tsx index 08c768e075d..1f8e9162881 100644 --- a/packages/plugins/@nocobase/plugin-client/src/client/ClearCache.tsx +++ b/packages/plugins/@nocobase/plugin-client/src/client/ClearCache.tsx @@ -10,17 +10,29 @@ import React from 'react'; import { useTranslation } from 'react-i18next'; import { useAPIClient, SchemaSettingsItem } from '@nocobase/client'; +import { App } from 'antd'; export const ClearCache = () => { const { t } = useTranslation(); const api = useAPIClient(); + const { modal } = App.useApp(); return ( { - await api.resource('app').clearCache(); - window.location.reload(); + modal.confirm({ + title: t('Clear cache'), + content: t('Are you sure you want to clear cache ?'), + okText: t('Clear'), + okButtonProps: { + danger: true, + }, + onOk: async () => { + await api.resource('app').clearCache(); + window.location.reload(); + }, + }); }} > {t('Clear cache')}