mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-07-01 18:52:20 +08:00
chore: adjust import & export warnings (#4060)
* chore: adjust import & export warnings * fix: add limit * chore: adjust warnings
This commit is contained in:
parent
04f3daa5ba
commit
9b0c22fda9
@ -10,6 +10,7 @@ import lodash from 'lodash';
|
||||
import { saveAs } from 'file-saver';
|
||||
import { App } from 'antd';
|
||||
import { useExportTranslation } from './locale';
|
||||
import React from 'react';
|
||||
|
||||
export const useExportAction = () => {
|
||||
const { service, resource } = useBlockRequestContext();
|
||||
@ -24,7 +25,16 @@ export const useExportAction = () => {
|
||||
async onClick() {
|
||||
const confirmed = await modal.confirm({
|
||||
title: t('Export'),
|
||||
content: t('Export warning'),
|
||||
content: (
|
||||
<>
|
||||
{t('Export warning')}
|
||||
<br />{' '}
|
||||
<a href="https://docs-cn.nocobase.com/handbook/action-export-pro" target="_blank" rel="noreferrer">
|
||||
Action: Export records pro
|
||||
</a>
|
||||
</>
|
||||
),
|
||||
okText: t('Start export'),
|
||||
});
|
||||
if (!confirmed) {
|
||||
return;
|
@ -1,3 +1,4 @@
|
||||
{
|
||||
"Export warning": "Only a small amount of data can be exported (preferably within 1000 rows), and a large amount of data will cause the system to freeze. Please use the Action: Export records pro plugin for large data exports."
|
||||
"Export warning": "You can export up to 200 rows of data at a time, any excess will be ignored. If you need to export a large amount of data at once, please use the Action: Export records pro plugin.",
|
||||
"Start export": "Start export"
|
||||
}
|
||||
|
@ -1,3 +1,4 @@
|
||||
{
|
||||
"Export warning": "仅支持少量数据导出(最好1000行以内),大量数据会导致系统卡住。请通过 Action: Export records pro 插件实现大量数据导出。"
|
||||
"Export warning": "每次最多导出 200 行数据,超出的将被忽略。 如果需要一次导出大量数据,请使用 Action: Export records pro 插件。",
|
||||
"Start export": "开始导出"
|
||||
}
|
||||
|
@ -20,6 +20,7 @@ export async function exportXlsx(ctx: Context, next: Next) {
|
||||
appends,
|
||||
except,
|
||||
sort,
|
||||
limit: 200,
|
||||
context: ctx,
|
||||
});
|
||||
const collectionFields = columns.map((col) => collection.fields.get(col.dataIndex[0]));
|
||||
|
@ -12,6 +12,8 @@ import {
|
||||
import React from 'react';
|
||||
import { NAMESPACE } from './constants';
|
||||
import { useFields } from './useFields';
|
||||
import { Alert } from 'antd';
|
||||
import { useImportTranslation } from './locale';
|
||||
|
||||
const findSchema = (schema: Schema, key: string, action: string) => {
|
||||
return schema.reduceProperties((buf, s) => {
|
||||
@ -46,6 +48,25 @@ const initImportSettings = (fields) => {
|
||||
return { importColumns, explain: '' };
|
||||
};
|
||||
|
||||
export const ImportWarning = () => {
|
||||
const { t } = useImportTranslation();
|
||||
return (
|
||||
<Alert
|
||||
type="warning"
|
||||
style={{ marginBottom: '10px' }}
|
||||
message={
|
||||
<>
|
||||
{t('Import warning')}
|
||||
<br />
|
||||
<a href="https://docs-cn.nocobase.com/handbook/action-import-pro" target="_blank" rel="noreferrer">
|
||||
Action: Import records pro
|
||||
</a>
|
||||
</>
|
||||
}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
export const ImportActionInitializer = () => {
|
||||
const itemConfig = useSchemaInitializerItem();
|
||||
const { insert } = useSchemaInitializer();
|
||||
@ -87,18 +108,7 @@ export const ImportActionInitializer = () => {
|
||||
properties: {
|
||||
warning: {
|
||||
type: 'void',
|
||||
'x-component': 'Markdown.Void',
|
||||
'x-editable': false,
|
||||
'x-component-props': {
|
||||
style: {
|
||||
padding: `var(--paddingContentVerticalSM)`,
|
||||
backgroundColor: `var(--colorWarningBg)`,
|
||||
border: `1px solid var(--colorWarningBorder)`,
|
||||
color: `var(--colorText)`,
|
||||
marginBottom: `var(--marginSM)`,
|
||||
},
|
||||
content: `{{ t("Import warning", {ns: "${NAMESPACE}" }) }}`,
|
||||
},
|
||||
'x-component': 'ImportWarning',
|
||||
},
|
||||
download: {
|
||||
type: 'void',
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { SchemaComponentOptions } from '@nocobase/client';
|
||||
import React, { useState } from 'react';
|
||||
import { createPortal } from 'react-dom';
|
||||
import { ImportActionInitializer, ImportDesigner } from '.';
|
||||
import { ImportActionInitializer, ImportDesigner, ImportWarning } from '.';
|
||||
import { ImportContext } from './context';
|
||||
import { ImportModal, ImportStatus } from './ImportModal';
|
||||
import { useDownloadXlsxTemplateAction, useImportStartAction } from './useImportAction';
|
||||
@ -11,7 +11,7 @@ export const ImportPluginProvider = (props: any) => {
|
||||
const { uploadValidator, beforeUploadHandler, validateUpload } = useShared();
|
||||
return (
|
||||
<SchemaComponentOptions
|
||||
components={{ ImportActionInitializer, ImportDesigner }}
|
||||
components={{ ImportActionInitializer, ImportDesigner, ImportWarning }}
|
||||
scope={{
|
||||
uploadValidator,
|
||||
validateUpload,
|
||||
|
@ -1,2 +1,7 @@
|
||||
// export { default as enUS } from './en-US';
|
||||
// export { default as zhCN } from './zh-CN';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
export const NAMESPACE = 'import';
|
||||
|
||||
export function useImportTranslation() {
|
||||
return useTranslation([NAMESPACE, 'client'], { nsMode: 'fallback' });
|
||||
}
|
||||
|
@ -9,7 +9,7 @@
|
||||
"Step 1: Download template": "Step 1: Download template",
|
||||
"Step 2: Upload Excel": "Step 2: Upload Excel",
|
||||
"Download tip": "- Download the template and fill in the data according to the format \r\n - Import only the first worksheet \r\n - Support single import of up to 1,000 rows of data \r\n - Do not change the header of the template to prevent import failure",
|
||||
"Import warning": "Only a small amount of data can be imported (preferably within 1000 rows), and a large amount of data will cause the system to freeze. Please use the Action: Import records pro plugin for large data imports.",
|
||||
"Import warning": "You can import up to 200 rows of data at a time, any excess will be ignored. If you need to import a large amount of data at once, please use the Action: Export records pro plugin.",
|
||||
"Upload placeholder": "Drag and drop the file here or click to upload, file size should not exceed 30M",
|
||||
"Excel data importing": "Excel data importing",
|
||||
"Import done, total success have {{successCount}} , total failure have {{failureCount}}": "Import is complete, with a total of {{successCount}} successful and {{failureCount}} failed",
|
||||
|
@ -9,7 +9,7 @@
|
||||
"Step 1: Download template": "1.下载模板",
|
||||
"Step 2: Upload Excel": "2.上传完善后的表格",
|
||||
"Download tip": "- 下载模板后,按格式填写数据\r\n - 只导入第一张工作表\r\n - 支持单次导入不超过1000行数据\r\n - 请勿改模板表头,防止导入失败",
|
||||
"Import warning": "仅支持少量数据导入(最好1000行以内),大量数据会导致系统卡住。请通过 Action: Import records pro 插件实现大量数据导入。",
|
||||
"Import warning": "每次最多导入 200 行数据,超出的将被忽略。 如果需要一次导入大量数据,请使用 Action: Import records pro 插件。",
|
||||
"Upload placeholder": "将文件拖曳到此处或点击上传,文件大小不超过10M",
|
||||
"Excel data importing": "数据导入中,请勿关闭窗口",
|
||||
"Import done, total success have {{successCount}} , total failure have {{failureCount}}": "导入完成,共导入成功{{successCount}}条数据,共导入失败{{failureCount}}条数据",
|
||||
|
@ -5,7 +5,7 @@ import xlsx from 'node-xlsx';
|
||||
import XLSX from 'xlsx';
|
||||
import { namespace } from '../../';
|
||||
|
||||
const IMPORT_LIMIT_COUNT = 10000;
|
||||
const IMPORT_LIMIT_COUNT = 200;
|
||||
|
||||
class Importer {
|
||||
repository: Repository;
|
||||
@ -26,6 +26,7 @@ class Importer {
|
||||
getRows() {
|
||||
const workbook = XLSX.read(this.context.file.buffer, {
|
||||
type: 'buffer',
|
||||
sheetRows: IMPORT_LIMIT_COUNT,
|
||||
// cellDates: true,
|
||||
// raw: false,
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user