diff --git a/config/config.ts b/config/config.ts index 7611109..b5384a6 100644 --- a/config/config.ts +++ b/config/config.ts @@ -47,4 +47,5 @@ export default defineConfig({ }, // Fast Refresh 热更新 fastRefresh: {}, + extraBabelPlugins: ['react-activation/babel'], }); diff --git a/config/settings.ts b/config/settings.ts index d6f31f4..1e5be70 100644 --- a/config/settings.ts +++ b/config/settings.ts @@ -10,6 +10,8 @@ export type ProjectSetting = LayoutSettings & { defaultLocal: 'zh-CN' | 'en-US'; // 是否展示水印 waterMark: boolean; + // 是否展示顶部多页签 + multiTab: boolean; storageOptions: { // 缓存key 前缀 namespace: string; @@ -33,6 +35,7 @@ const Settings: ProjectSetting = { historyType: 'hash', defaultLocal: 'zh-CN', waterMark: true, + multiTab: true, storageOptions: { namespace: 'ballcat/', storage: 'local', diff --git a/package.json b/package.json index aeed66a..26fbc12 100644 --- a/package.json +++ b/package.json @@ -49,6 +49,7 @@ "moment": "^2.25.3", "omit.js": "^2.0.2", "react": "^17.0.0", + "react-activation": "^0.9.4", "react-color": "2.19.3", "react-cropper": "2.1.8", "react-dev-inspector": "^1.1.1", diff --git a/src/components/Editor/WangEditor.tsx b/src/components/Editor/WangEditor.tsx index 2929065..4863054 100644 --- a/src/components/Editor/WangEditor.tsx +++ b/src/components/Editor/WangEditor.tsx @@ -24,7 +24,16 @@ export default ({ ); useEffect(() => { - const we = new WangEditor(`#wang-editor-dom`); + let we: WangEditor; + + try { + we = new WangEditor(`#wang-editor-dom`); + } catch (e) { + // 组件缓存时. 从有这个组件的页面切换出去会导致这里不停的报错. 找不到 wang-editor-dom Dom. + // 这里捕获异常就不管了. 切换回来这个组件会重新渲染 + return () => {}; + } + setEditor(we); we.config.onchange = (val: string) => update(val); diff --git a/src/components/Form/FullForm.tsx b/src/components/Form/FullForm.tsx index f3d551f..eab1cce 100644 --- a/src/components/Form/FullForm.tsx +++ b/src/components/Form/FullForm.tsx @@ -5,15 +5,9 @@ import ProForm from '@ant-design/pro-form'; import type { R } from '@/typings'; import I18n from '@/utils/I18nUtils'; import type { FullFormProps } from '.'; +import { defautlTitle } from '.'; import { Button, Card } from 'antd'; -export const defautlTitle = { - read: I18n.text('form.read'), - edit: I18n.text('form.edit'), - create: I18n.text('form.create'), - del: I18n.text('form.del'), -}; - const FullForm = (props: FullFormProps) => { const { formRef: currencyRef, @@ -65,7 +59,7 @@ const FullForm = (props: FullFormProps) => { req?: (body: P) => Promise>, ) => { if (req === undefined) { - I18n.error({ key: 'orm.error.request', params: { title: defautlTitle[st] } }); + I18n.error({ key: 'form.error.request', params: { title: defautlTitle[st] } }); return Promise.resolve(false); } setLoading(true); @@ -121,10 +115,10 @@ const FullForm = (props: FullFormProps) => { ]; }, }} - {...antProps} layout="horizontal" labelCol={labelCol || { sm: { span: 24 }, md: { span: 4 } }} wrapperCol={wrapperCol} + {...antProps} formRef={formRef} onFinish={async (values) => { switch (status) { diff --git a/src/components/Form/ModalForm.tsx b/src/components/Form/ModalForm.tsx index cdcfd35..d595d2f 100644 --- a/src/components/Form/ModalForm.tsx +++ b/src/components/Form/ModalForm.tsx @@ -4,13 +4,7 @@ import type { ProFormInstance } from '@ant-design/pro-form'; import { ModalForm as AntdModalForm } from '@ant-design/pro-form'; import type { R } from '@/typings'; import I18n from '@/utils/I18nUtils'; - -export const defautlTitle = { - read: I18n.text('form.read'), - edit: I18n.text('form.edit'), - create: I18n.text('form.create'), - del: I18n.text('form.del'), -}; +import { defautlTitle } from '.'; const ModalForm = (props: ModalFormProps) => { const { @@ -45,7 +39,7 @@ const ModalForm = (props: ModalFormProps) => { req?: (body: P) => Promise>, ) => { if (req === undefined) { - I18n.error({ key: 'orm.error.request', params: { title: defautlTitle[st] } }); + I18n.error({ key: 'form.error.request', params: { title: defautlTitle[st] } }); return Promise.resolve(false); } @@ -95,13 +89,13 @@ const ModalForm = (props: ModalFormProps) => { return ( - {...antProps} width={width} layout="horizontal" labelCol={labelCol || { sm: { span: 24 }, md: { span: 4 } }} wrapperCol={wrapperCol} - formRef={formRef} title={modalTitle} + {...antProps} + formRef={formRef} visible={visible} onVisibleChange={setVisible} onFinish={async (values) => { diff --git a/src/components/Form/index.ts b/src/components/Form/index.ts index fc05cd0..340dae4 100644 --- a/src/components/Form/index.ts +++ b/src/components/Form/index.ts @@ -4,6 +4,7 @@ import FormDictSelect from './dict/FormDictSelect'; import FormNumber from './FormNumber'; import FormGroup from './FormGroup'; import FormDictCheckbox from './dict/FormDictCheckbox'; +import I18n from '@/utils/I18nUtils'; export * from './typings'; @@ -18,4 +19,10 @@ const Form = { export default Form; -export { ModalForm, FormDictRadio, FormDictSelect, FormNumber }; +const defautlTitle = { + read: I18n.text('form.read'), + edit: I18n.text('form.edit'), + create: I18n.text('form.create'), + del: I18n.text('form.del'), +}; +export { ModalForm, FormDictRadio, FormDictSelect, FormNumber, defautlTitle }; diff --git a/src/components/Inline/index.less b/src/components/Inline/index.less deleted file mode 100644 index 7d5e079..0000000 --- a/src/components/Inline/index.less +++ /dev/null @@ -1,6 +0,0 @@ -.iframe { - box-sizing: border-box; - width: 100%; - height: 100%; - border: 0; -} diff --git a/src/components/Inline/index.tsx b/src/components/Inline/index.tsx index ca11b6d..238df09 100644 --- a/src/components/Inline/index.tsx +++ b/src/components/Inline/index.tsx @@ -1,5 +1,4 @@ import { Component } from 'react'; -import './index.less'; import type { Route } from '@ant-design/pro-layout/lib/typings'; export type InlineMeta = { @@ -25,7 +24,12 @@ class Inline extends Component { render() { const { meta } = this.state; - return