cx-chat 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cx-chat.css +1 -0
- package/dist/cx-chat.es.js +97326 -0
- package/dist/cx-chat.umd.js +734 -0
- package/package.json +21 -1
- package/.cursor/rules/i18n-cn-gloss-comments.mdc +0 -31
- package/.cursor/rules/list-page-view-pageconfig.mdc +0 -32
- package/.cursor/rules/no-over-defensive-programming.mdc +0 -90
- package/.cursor/rules/requirement-description-for-agent.mdc +0 -33
- package/.cursor/rules/use-showToast-not-antd-message.mdc +0 -28
- package/.docker/Dockerfile +0 -7
- package/.env +0 -9
- package/.env.development +0 -7
- package/.env.production +0 -7
- package/.gitlab-ci/docker-build.yaml +0 -28
- package/.gitlab-ci/k8s-deploy-dev-master.yaml +0 -42
- package/.gitlab-ci/npm-build.yaml +0 -17
- package/.gitlab-ci.yml +0 -8
- package/.k8s/0-namespace.yaml +0 -6
- package/.k8s/1-configmap-web.yaml +0 -7
- package/.k8s/1-nginx-conf-dev.yaml +0 -110
- package/.k8s/2-deployment.yaml +0 -27
- package/.k8s/3-service.yaml +0 -16
- package/.k8s/4-ingress-dev.yaml +0 -30
- package/.lingma/rules/use-showToast-not-antd-message.md +0 -34
- package/.nginx/nginx.conf +0 -52
- package/.prettierrc +0 -9
- package/eslint.config.js +0 -32
- package/index.html +0 -13
- package/postcss.config.js +0 -6
- package/src/App.tsx +0 -96
- package/src/_doc/0.docs-overview.md +0 -28
- package/src/_doc/cx-ui/0.docs-overview.md +0 -30
- package/src/_doc/cx-ui/comp.1.cx-ui-overview.md +0 -82
- package/src/_doc/cx-ui/comp.2.cx-modal.md +0 -82
- package/src/_doc/cx-ui/comp.3.cx-button.md +0 -89
- package/src/_doc/cx-ui/comp.4.cx-form.md +0 -72
- package/src/_doc/cx-ui/comp.5.cx-fields.md +0 -76
- package/src/_doc/cx-ui/comp.6.cx-tag.md +0 -57
- package/src/_doc/cx-ui/comp.7.cx-empty-state.md +0 -29
- package/src/_doc/meta/0.docs-overview.md +0 -24
- package/src/_doc/meta/comp.1.enum-runtime.md +0 -33
- package/src/_doc/meta/comp.2.dict-runtime.md +0 -39
- package/src/_doc/router/0.docs-overview.md +0 -14
- package/src/_doc/router/guide.1.menu-component-config.md +0 -181
- package/src/_doc/router/guide.2.router-auto-registration.md +0 -114
- package/src/_doc/table-view/0.docs-overview.md +0 -30
- package/src/_doc/table-view/comp.1.table-view.md +0 -542
- package/src/_doc/table-view/props.1.create-table-view-config.md +0 -193
- package/src/_doc/table-view/props.2.table-view-search-fields.md +0 -106
- package/src/api/_mock/README.md +0 -340
- package/src/api/_mock/api.ts +0 -1642
- package/src/api/_mock/bundle-shim.ts +0 -16
- package/src/api/_mock/handler-shim.ts +0 -6
- package/src/api/_mock/handler.ts +0 -458
- package/src/api/_mock/index.ts +0 -711
- package/src/api/_mock/interceptor.ts +0 -15
- package/src/api/_mock/mod.ts +0 -12
- package/src/api/_mock/utils.ts +0 -65
- package/src/api/base/memory.js +0 -24
- package/src/api/chat.js +0 -210
- package/src/api/common/auth.js +0 -70
- package/src/api/menus/business-rules.js +0 -76
- package/src/api/menus/feedback.js +0 -102
- package/src/api/menus/knowledge.js +0 -159
- package/src/api/menus/model-metadata/manage.js +0 -70
- package/src/api/menus/model-metadata/role.js +0 -50
- package/src/api/menus/model-metadata/training-detail-mock-data.js +0 -569
- package/src/api/menus/model-metadata/training.js +0 -28
- package/src/api/menus/skill.js +0 -40
- package/src/api/system/agent-config.js +0 -16
- package/src/api/system/department.js +0 -94
- package/src/api/system/dict.js +0 -86
- package/src/api/system/menu.js +0 -37
- package/src/api/system/permission.js +0 -26
- package/src/api/system/role.js +0 -34
- package/src/api/system/sys-config.js +0 -16
- package/src/api/system/sys-log.js +0 -17
- package/src/api/system/user.js +0 -75
- package/src/api/upload.js +0 -39
- package/src/assets/react.svg +0 -1
- package/src/components/auth/current-user-avatar.tsx +0 -77
- package/src/components/common/code-view.tsx +0 -149
- package/src/components/common/detail-link.tsx +0 -67
- package/src/components/common/error-boundary.tsx +0 -98
- package/src/components/common/language-switcher.tsx +0 -91
- package/src/components/common/lite-table/index.tsx +0 -135
- package/src/components/common/md-editor.tsx +0 -126
- package/src/components/common/modal/confirm-dialog.tsx +0 -113
- package/src/components/common/modal/dep-user-select-multi.tsx +0 -324
- package/src/components/common/modal/dep-user-select.tsx +0 -249
- package/src/components/common/modal/user-select-multi.tsx +0 -266
- package/src/components/common/pagination.tsx +0 -472
- package/src/components/common/path.tsx +0 -175
- package/src/components/common/system-logo-mark.tsx +0 -48
- package/src/components/cx-ui/button/index.less +0 -208
- package/src/components/cx-ui/button/index.tsx +0 -611
- package/src/components/cx-ui/checkbox/index.tsx +0 -78
- package/src/components/cx-ui/date-picker/index.less +0 -17
- package/src/components/cx-ui/date-picker/index.tsx +0 -193
- package/src/components/cx-ui/drawer/index.tsx +0 -47
- package/src/components/cx-ui/empty-state/index.tsx +0 -20
- package/src/components/cx-ui/floating-shell/CxFloatingShell.tsx +0 -89
- package/src/components/cx-ui/floating-shell/cx-floating-shell.less +0 -283
- package/src/components/cx-ui/floating-shell/has-floating-value.ts +0 -41
- package/src/components/cx-ui/form/CxForm.tsx +0 -15
- package/src/components/cx-ui/form/index.tsx +0 -20
- package/src/components/cx-ui/form-item/index.less +0 -26
- package/src/components/cx-ui/form-item/index.tsx +0 -36
- package/src/components/cx-ui/index.ts +0 -70
- package/src/components/cx-ui/input/auto-complete.tsx +0 -134
- package/src/components/cx-ui/input/index.tsx +0 -259
- package/src/components/cx-ui/input-number/index.jsx +0 -66
- package/src/components/cx-ui/modal/index.jsx +0 -212
- package/src/components/cx-ui/modal/index.less +0 -144
- package/src/components/cx-ui/modal/useCxModal.ts +0 -125
- package/src/components/cx-ui/multi-select/index.jsx +0 -74
- package/src/components/cx-ui/multi-select/index.less +0 -40
- package/src/components/cx-ui/multi-select/index2.tsx +0 -361
- package/src/components/cx-ui/radio/index.tsx +0 -33
- package/src/components/cx-ui/range-picker/index.less +0 -65
- package/src/components/cx-ui/range-picker/index.tsx +0 -219
- package/src/components/cx-ui/select/index.less +0 -34
- package/src/components/cx-ui/select/index.tsx +0 -196
- package/src/components/cx-ui/skeleton/index.tsx +0 -12
- package/src/components/cx-ui/steps/index.tsx +0 -14
- package/src/components/cx-ui/styles/_tokens.less +0 -79
- package/src/components/cx-ui/styles/index.less +0 -246
- package/src/components/cx-ui/switch/index.less +0 -106
- package/src/components/cx-ui/switch/index.tsx +0 -120
- package/src/components/cx-ui/table/index.less +0 -160
- package/src/components/cx-ui/table/index.tsx +0 -152
- package/src/components/cx-ui/tabs/index.less +0 -15
- package/src/components/cx-ui/tabs/index.tsx +0 -34
- package/src/components/cx-ui/tag/index.less +0 -51
- package/src/components/cx-ui/tag/index.tsx +0 -140
- package/src/components/cx-ui/timeline/index.tsx +0 -14
- package/src/components/cx-ui/tooltip/index.tsx +0 -67
- package/src/components/cx-ui/tree/index.tsx +0 -193
- package/src/components/cx-ui/tree-select/index.jsx +0 -91
- package/src/components/cx-ui/tree-select/index.less +0 -27
- package/src/components/cx-ui/upload-file/index.less +0 -223
- package/src/components/cx-ui/upload-file/index.tsx +0 -640
- package/src/components/cx-ui/upload-img/index.tsx +0 -291
- package/src/components/layout/components/Header.tsx +0 -216
- package/src/components/layout/components/Sidebar.tsx +0 -717
- package/src/components/layout/index.tsx +0 -95
- package/src/components/table-view/components/search-area.tsx +0 -411
- package/src/components/table-view/components/table-view-config.tsx +0 -528
- package/src/components/table-view/components/table-view.types.ts +0 -478
- package/src/components/table-view/components/tree-api-normalize.ts +0 -38
- package/src/components/table-view/components/tree-data-annotate.ts +0 -31
- package/src/components/table-view/components/tree-sidebar.tsx +0 -74
- package/src/components/table-view/index.tsx +0 -61
- package/src/components/table-view/list-page-view.tsx +0 -1049
- package/src/components/table-view/select-table-view.tsx +0 -1094
- package/src/components/table-view/styles/select-table-view.less +0 -51
- package/src/config/default-system-name.ts +0 -9
- package/src/config/system.ts +0 -165
- package/src/constants/countryCodes.ts +0 -3
- package/src/contexts/AuthContext.tsx +0 -256
- package/src/contexts/ChatContext.tsx +0 -839
- package/src/contexts/MenuContext.tsx +0 -62
- package/src/contexts/ToastContext.tsx +0 -181
- package/src/hooks/useCopyToClipboard.ts +0 -47
- package/src/hooks/useModalSubmit.ts +0 -104
- package/src/hooks/useRouter.ts +0 -240
- package/src/hooks/useStepForm.ts +0 -46
- package/src/hooks/useStickyHeader.ts +0 -42
- package/src/hooks/useThreadActions.ts +0 -105
- package/src/hooks/useUserPreferences.ts +0 -101
- package/src/http/axios.js +0 -372
- package/src/http/mock.interceptor.ts +0 -9
- package/src/http/obfuscationKey.ts +0 -41
- package/src/i18n.ts +0 -60
- package/src/index.js +0 -1
- package/src/index.less +0 -169
- package/src/locales/en/auth.ts +0 -70
- package/src/locales/en/base/memory.ts +0 -28
- package/src/locales/en/base/settings.ts +0 -41
- package/src/locales/en/chat.ts +0 -40
- package/src/locales/en/common.ts +0 -173
- package/src/locales/en/enum.ts +0 -27
- package/src/locales/en/menus/business-rules.ts +0 -48
- package/src/locales/en/menus/feedback.ts +0 -62
- package/src/locales/en/menus/knowledge.ts +0 -120
- package/src/locales/en/menus/model-metadata/index.ts +0 -10
- package/src/locales/en/menus/model-metadata/manage.ts +0 -151
- package/src/locales/en/menus/model-metadata/role.ts +0 -48
- package/src/locales/en/menus/model-metadata/training.ts +0 -65
- package/src/locales/en/menus/skill.ts +0 -34
- package/src/locales/en/system/agent-config.ts +0 -34
- package/src/locales/en/system/department.ts +0 -68
- package/src/locales/en/system/dict.ts +0 -44
- package/src/locales/en/system/menu.ts +0 -45
- package/src/locales/en/system/permission.ts +0 -89
- package/src/locales/en/system/role.ts +0 -25
- package/src/locales/en/system/sys-config.ts +0 -33
- package/src/locales/en/system/sys-log.ts +0 -38
- package/src/locales/en/system/user.ts +0 -113
- package/src/locales/en.ts +0 -68
- package/src/locales/zh/auth.ts +0 -70
- package/src/locales/zh/base/memory.ts +0 -29
- package/src/locales/zh/base/settings.ts +0 -41
- package/src/locales/zh/chat.ts +0 -47
- package/src/locales/zh/common.ts +0 -178
- package/src/locales/zh/enum.ts +0 -28
- package/src/locales/zh/menus/business-rules.ts +0 -47
- package/src/locales/zh/menus/feedback.ts +0 -62
- package/src/locales/zh/menus/knowledge.ts +0 -117
- package/src/locales/zh/menus/model-metadata/index.ts +0 -10
- package/src/locales/zh/menus/model-metadata/manage.ts +0 -151
- package/src/locales/zh/menus/model-metadata/role.ts +0 -47
- package/src/locales/zh/menus/model-metadata/training.ts +0 -64
- package/src/locales/zh/menus/skill.ts +0 -34
- package/src/locales/zh/system/agent-config.ts +0 -33
- package/src/locales/zh/system/department.ts +0 -69
- package/src/locales/zh/system/dict.ts +0 -44
- package/src/locales/zh/system/menu.ts +0 -47
- package/src/locales/zh/system/permission.ts +0 -94
- package/src/locales/zh/system/role.ts +0 -25
- package/src/locales/zh/system/sys-config.ts +0 -32
- package/src/locales/zh/system/sys-log.ts +0 -38
- package/src/locales/zh/system/user.ts +0 -114
- package/src/locales/zh.ts +0 -67
- package/src/main.tsx +0 -50
- package/src/meta/const/index.ts +0 -40
- package/src/meta/index-dict.ts +0 -56
- package/src/meta/index-enum.ts +0 -95
- package/src/meta/index.ts +0 -14
- package/src/meta/module/dict-data/runtime.ts +0 -199
- package/src/meta/module/dict-data/types.ts +0 -17
- package/src/meta/module/enum-data/runtime.ts +0 -75
- package/src/meta/module/enum-data/types.ts +0 -18
- package/src/router/index.tsx +0 -312
- package/src/styles/AntdThemeProvider.tsx +0 -40
- package/src/styles/antd-theme.ts +0 -20
- package/src/styles/global.less +0 -107
- package/src/styles/variable.less +0 -103
- package/src/types/feedback.ts +0 -43
- package/src/types/index.ts +0 -85
- package/src/types/menu.ts +0 -43
- package/src/utils/aesUtil.ts +0 -123
- package/src/utils/chatUtils.ts +0 -524
- package/src/utils/cn.ts +0 -6
- package/src/utils/crypto.ts +0 -164
- package/src/utils/date.ts +0 -72
- package/src/utils/file-icons.tsx +0 -79
- package/src/utils/index.ts +0 -168
- package/src/utils/markdown-math-plugins.ts +0 -21
- package/src/utils/menuI18n.ts +0 -305
- package/src/utils/menuRouteRegistry.ts +0 -78
- package/src/utils/permission-crud.ts +0 -147
- package/src/utils/routeConfig.ts +0 -350
- package/src/utils/storage.ts +0 -135
- package/src/utils/toastBridge.ts +0 -26
- package/src/utils/url.ts +0 -38
- package/src/utils/validation.ts +0 -16
- package/src/views/auth/auth-code/index.less +0 -169
- package/src/views/auth/auth-code/index.module.less +0 -174
- package/src/views/auth/auth-code/index.tsx +0 -233
- package/src/views/auth/login.tsx +0 -498
- package/src/views/auth/register.tsx +0 -388
- package/src/views/base/memory/index.tsx +0 -136
- package/src/views/base/memory/modal/detail-modal.tsx +0 -89
- package/src/views/base/memory/modal/submit-modal.tsx +0 -134
- package/src/views/base/settings/index.tsx +0 -657
- package/src/views/chat/chat.less +0 -323
- package/src/views/chat/components/chat-input.tsx +0 -298
- package/src/views/chat/components/header-thread-title.tsx +0 -210
- package/src/views/chat/components/message-list/content-answer.tsx +0 -100
- package/src/views/chat/components/message-list/content-question.tsx +0 -18
- package/src/views/chat/components/message-list/index.tsx +0 -520
- package/src/views/chat/components/message-list/message-item.tsx +0 -199
- package/src/views/chat/components/message-list/preparation-demo-items.ts +0 -147
- package/src/views/chat/components/message-list/preparation-steps.tsx +0 -506
- package/src/views/chat/components/message-list/suggestion-list.tsx +0 -36
- package/src/views/chat/components/message-list/thinking-process.tsx +0 -49
- package/src/views/chat/components/message-list/toolbar.tsx +0 -224
- package/src/views/chat/components/message-list/use-message-list-scroll.ts +0 -214
- package/src/views/chat/components/references-knowledge/context.tsx +0 -57
- package/src/views/chat/components/references-knowledge/index.ts +0 -9
- package/src/views/chat/components/references-knowledge/modal/knowledge-detail-drawer.tsx +0 -556
- package/src/views/chat/components/references-knowledge/modal/knowledge-doc-detail-drawer.tsx +0 -529
- package/src/views/chat/components/references-knowledge/panel.tsx +0 -115
- package/src/views/chat/hooks/use-chat-common.ts +0 -19
- package/src/views/chat/index-session.tsx +0 -647
- package/src/views/chat/index.tsx +0 -127
- package/src/views/page-error/401.tsx +0 -56
- package/src/views/page-error/404.tsx +0 -56
- package/src/views/page-menus/business-rules/index.tsx +0 -376
- package/src/views/page-menus/business-rules/modal/detail-modal.tsx +0 -186
- package/src/views/page-menus/business-rules/modal/scope-modal.tsx +0 -272
- package/src/views/page-menus/business-rules/modal/submit-modal.tsx +0 -142
- package/src/views/page-menus/feedback/components/feedback-dataset-list.tsx +0 -471
- package/src/views/page-menus/feedback/index.tsx +0 -166
- package/src/views/page-menus/feedback/modal/export-feedback-modal.tsx +0 -367
- package/src/views/page-menus/knowledge/components/doc-editor-by-type.tsx +0 -32
- package/src/views/page-menus/knowledge/components/doc-editor-type-file.tsx +0 -330
- package/src/views/page-menus/knowledge/detail.tsx +0 -600
- package/src/views/page-menus/knowledge/index.tsx +0 -337
- package/src/views/page-menus/knowledge/modal/detail-modal.tsx +0 -618
- package/src/views/page-menus/knowledge/modal/doc-detail-modal.tsx +0 -550
- package/src/views/page-menus/knowledge/modal/doc-parse.ts +0 -99
- package/src/views/page-menus/knowledge/modal/doc-submit-modal.tsx +0 -349
- package/src/views/page-menus/knowledge/modal/doc-type-picker-modal.tsx +0 -88
- package/src/views/page-menus/knowledge/modal/knowledge-user-select-modal.tsx +0 -283
- package/src/views/page-menus/knowledge/modal/submit-modal.tsx +0 -179
- package/src/views/page-menus/model-metadata/manage/components/metadata-detail-schema-tab.tsx +0 -114
- package/src/views/page-menus/model-metadata/manage/components/step1-basic-info.tsx +0 -232
- package/src/views/page-menus/model-metadata/manage/components/step2-schema.tsx +0 -316
- package/src/views/page-menus/model-metadata/manage/components/step3-permissions.tsx +0 -134
- package/src/views/page-menus/model-metadata/manage/components/step4-documents.tsx +0 -134
- package/src/views/page-menus/model-metadata/manage/components/step5-example-sql.tsx +0 -101
- package/src/views/page-menus/model-metadata/manage/components/submit-add.tsx +0 -338
- package/src/views/page-menus/model-metadata/manage/components/submit-edit.tsx +0 -276
- package/src/views/page-menus/model-metadata/manage/detail.tsx +0 -298
- package/src/views/page-menus/model-metadata/manage/hooks/model-metadata-submit-shared.ts +0 -113
- package/src/views/page-menus/model-metadata/manage/hooks/use-model-metadata-item-state.ts +0 -20
- package/src/views/page-menus/model-metadata/manage/index.tsx +0 -304
- package/src/views/page-menus/model-metadata/manage/modal/components/table-schema.ts +0 -374
- package/src/views/page-menus/model-metadata/manage/modal/components/use-table-detail-tabs.tsx +0 -151
- package/src/views/page-menus/model-metadata/manage/modal/components/use-table-submit-tabs.tsx +0 -423
- package/src/views/page-menus/model-metadata/manage/modal/detail-modal.tsx +0 -218
- package/src/views/page-menus/model-metadata/manage/modal/submit-modal.tsx +0 -261
- package/src/views/page-menus/model-metadata/manage/modal/table-detail-modal.tsx +0 -196
- package/src/views/page-menus/model-metadata/manage/modal/table-submit-modal.tsx +0 -229
- package/src/views/page-menus/model-metadata/manage/submit.tsx +0 -31
- package/src/views/page-menus/model-metadata/role/index.tsx +0 -207
- package/src/views/page-menus/model-metadata/role/modal/detail-modal.tsx +0 -97
- package/src/views/page-menus/model-metadata/role/modal/role-assign-users-modal.tsx +0 -254
- package/src/views/page-menus/model-metadata/role/modal/role-assign-users-panel.tsx +0 -393
- package/src/views/page-menus/model-metadata/role/modal/role-assign-users-utils.ts +0 -120
- package/src/views/page-menus/model-metadata/role/modal/role-permission-assign-panel.tsx +0 -698
- package/src/views/page-menus/model-metadata/role/modal/role-permission-modal.tsx +0 -237
- package/src/views/page-menus/model-metadata/role/modal/submit-modal.tsx +0 -135
- package/src/views/page-menus/model-metadata/training/components/detail-records/index.ts +0 -4
- package/src/views/page-menus/model-metadata/training/components/detail-records/node-card.tsx +0 -72
- package/src/views/page-menus/model-metadata/training/components/detail-records/summary-lines.ts +0 -196
- package/src/views/page-menus/model-metadata/training/components/detail-records/summary-list.tsx +0 -153
- package/src/views/page-menus/model-metadata/training/components/detail-records/timeline.tsx +0 -103
- package/src/views/page-menus/model-metadata/training/components/detail-records/types.ts +0 -82
- package/src/views/page-menus/model-metadata/training/detail.tsx +0 -159
- package/src/views/page-menus/model-metadata/training/index.tsx +0 -236
- package/src/views/page-menus/model-metadata/training/modal/update-detail-modal.tsx +0 -154
- package/src/views/page-menus/skill/index.tsx +0 -201
- package/src/views/page-menus/skill/modal/detail-modal.tsx +0 -156
- package/src/views/page-menus/skill/modal/submit-modal.tsx +0 -214
- package/src/views/page-system/agent-config/index.tsx +0 -370
- package/src/views/page-system/department/departmentFormShared.ts +0 -36
- package/src/views/page-system/department/index.tsx +0 -541
- package/src/views/page-system/department/modal/detail-modal.tsx +0 -94
- package/src/views/page-system/department/modal/member-role-modal.tsx +0 -128
- package/src/views/page-system/department/modal/submit-modal.tsx +0 -265
- package/src/views/page-system/dict/index.tsx +0 -440
- package/src/views/page-system/dict/modal/cate-submit-modal.tsx +0 -315
- package/src/views/page-system/dict/modal/submit-modal.tsx +0 -184
- package/src/views/page-system/logs/components/index.ts +0 -3
- package/src/views/page-system/logs/components/log-message-demo.tsx +0 -30
- package/src/views/page-system/logs/components/log-message-stream.ts +0 -184
- package/src/views/page-system/logs/components/message-list/content-answer.tsx +0 -100
- package/src/views/page-system/logs/components/message-list/content-question.tsx +0 -18
- package/src/views/page-system/logs/components/message-list/index.tsx +0 -515
- package/src/views/page-system/logs/components/message-list/message-item.tsx +0 -193
- package/src/views/page-system/logs/components/message-list/preparation-demo-items.ts +0 -147
- package/src/views/page-system/logs/components/message-list/preparation-steps.tsx +0 -506
- package/src/views/page-system/logs/components/message-list/suggestion-list.tsx +0 -36
- package/src/views/page-system/logs/components/message-list/thinking-process.tsx +0 -49
- package/src/views/page-system/logs/components/message-list/toolbar.tsx +0 -134
- package/src/views/page-system/logs/components/message-list/use-message-list-scroll.ts +0 -214
- package/src/views/page-system/logs/components/message-modal.tsx +0 -239
- package/src/views/page-system/logs/index.tsx +0 -132
- package/src/views/page-system/logs/modal/detail-modal.tsx +0 -157
- package/src/views/page-system/menu/components/menuFormShared.ts +0 -283
- package/src/views/page-system/menu/index.less +0 -12
- package/src/views/page-system/menu/index.tsx +0 -410
- package/src/views/page-system/menu/modal/icon-modal.less +0 -51
- package/src/views/page-system/menu/modal/icon-modal.tsx +0 -87
- package/src/views/page-system/menu/modal/submit-modal.tsx +0 -263
- package/src/views/page-system/permission/index.tsx +0 -562
- package/src/views/page-system/permission/modal/detail-modal.tsx +0 -179
- package/src/views/page-system/permission/modal/submit-modal.less +0 -146
- package/src/views/page-system/permission/modal/submit-modal.tsx +0 -650
- package/src/views/page-system/role/index.tsx +0 -163
- package/src/views/page-system/role/modal/detail-modal.tsx +0 -127
- package/src/views/page-system/role/modal/permission-assign-group-rules.ts +0 -86
- package/src/views/page-system/role/modal/permission-modal.tsx +0 -111
- package/src/views/page-system/role/modal/role-modal-shell-styles.ts +0 -21
- package/src/views/page-system/role/modal/role-permission-assign-panel.tsx +0 -916
- package/src/views/page-system/role/modal/role-permission-assign-shared.ts +0 -1047
- package/src/views/page-system/role/modal/submit-modal.tsx +0 -193
- package/src/views/page-system/sys-config/index.tsx +0 -294
- package/src/views/page-system/user/components/user-role-column.tsx +0 -87
- package/src/views/page-system/user/index.tsx +0 -439
- package/src/views/page-system/user/modal/assign-roles-modal.tsx +0 -389
- package/src/views/page-system/user/modal/detail-modal.tsx +0 -72
- package/src/views/page-system/user/modal/modal-style/submit-modal.less +0 -40
- package/src/views/page-system/user/modal/submit-modal.less +0 -40
- package/src/views/page-system/user/modal/submit-modal.tsx +0 -287
- package/src/views/page-system/user/userFormShared.ts +0 -51
- package/tailwind.config.js +0 -17
- package/tsconfig.app.json +0 -48
- package/tsconfig.json +0 -11
- package/tsconfig.node.json +0 -26
- package/vite.config.ts +0 -272
- /package/{public → dist}/favicon.ico +0 -0
- /package/{public → dist}/vite.svg +0 -0
|
@@ -1,640 +0,0 @@
|
|
|
1
|
-
import { downloadFileAPI, getFileInfoAPI, getImgAPI, uploadFileAPI } from '@/api/upload'
|
|
2
|
-
import { handlerDownload } from '@/utils'
|
|
3
|
-
import { getFileIconAssetByName, getLowerFileExt, renderFileIconAsset } from '@/utils/file-icons'
|
|
4
|
-
import { getStore } from '@/utils/storage'
|
|
5
|
-
import {
|
|
6
|
-
DeleteOutlined,
|
|
7
|
-
DownloadOutlined,
|
|
8
|
-
EyeOutlined,
|
|
9
|
-
InboxOutlined,
|
|
10
|
-
PlusOutlined,
|
|
11
|
-
} from '@ant-design/icons'
|
|
12
|
-
import { CxModal, CxTooltip, useCxModal } from '@cx-ui'
|
|
13
|
-
import aesUtil from '@utils/aesUtil'
|
|
14
|
-
import type { UploadFile, UploadProps } from 'antd'
|
|
15
|
-
import { Button, Image, Upload, message } from 'antd'
|
|
16
|
-
import type { RcFile } from 'antd/es/upload'
|
|
17
|
-
import React, { useEffect, useMemo, useRef, useState } from 'react'
|
|
18
|
-
import { useTranslation } from 'react-i18next'
|
|
19
|
-
import './index.less'
|
|
20
|
-
|
|
21
|
-
// 图片回显缓存:避免同一 address 重复请求 getImg
|
|
22
|
-
const IMG_OBJECT_URL_CACHE = new Map<string, string>()
|
|
23
|
-
const IMG_OBJECT_URL_PENDING = new Map<string, Promise<string>>()
|
|
24
|
-
|
|
25
|
-
const isPreviewableUrl = (url: unknown) => {
|
|
26
|
-
if (url == null) return false
|
|
27
|
-
const str = `${url}`
|
|
28
|
-
return /^https?:\/\//i.test(str) || /^data:/i.test(str) || /^blob:/i.test(str)
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
const normalizeApiData = (raw: any) => {
|
|
33
|
-
if (raw?.data?.data != null) return raw.data.data
|
|
34
|
-
if (raw?.data != null) return raw.data
|
|
35
|
-
return raw
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
const isImageFile = (file: Pick<UploadFile, 'type' | 'name' | 'url'>) => {
|
|
39
|
-
if (file.type && file.type.startsWith('image/')) return true
|
|
40
|
-
const ext = getLowerFileExt(file.name || (file.url ? `${file.url}` : ''))
|
|
41
|
-
return ['png', 'jpg', 'jpeg', 'gif', 'webp', 'bmp', 'svg'].includes(ext)
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
const isAcceptedFile = (file: File, accept: string) => {
|
|
45
|
-
const rule = (accept || '').trim()
|
|
46
|
-
if (!rule || rule === '*') return true
|
|
47
|
-
|
|
48
|
-
const items = rule
|
|
49
|
-
.split(',')
|
|
50
|
-
.map((x) => x.trim())
|
|
51
|
-
.filter(Boolean)
|
|
52
|
-
if (items.length === 0) return true
|
|
53
|
-
|
|
54
|
-
const name = (file.name || '').toLowerCase()
|
|
55
|
-
const type = file.type || ''
|
|
56
|
-
|
|
57
|
-
return items.some((it) => {
|
|
58
|
-
if (it === '*/*') return true
|
|
59
|
-
if (it.endsWith('/*')) {
|
|
60
|
-
const prefix = it.slice(0, it.length - 1)
|
|
61
|
-
return type.startsWith(prefix)
|
|
62
|
-
}
|
|
63
|
-
if (it.startsWith('.')) return name.endsWith(it.toLowerCase())
|
|
64
|
-
return type === it
|
|
65
|
-
})
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
const getThumbUrl = (file: UploadFile) => {
|
|
69
|
-
if (file.url) return `${file.url}`
|
|
70
|
-
const address = (file as any)?.address ? `${(file as any).address}` : ''
|
|
71
|
-
if (isPreviewableUrl(address)) return address
|
|
72
|
-
return ''
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
/** 根据文件后缀返回图标颜色(用于上传组件的文件缩略图)。 */
|
|
76
|
-
const getFileIconColorByExt = (ext?: string) => {
|
|
77
|
-
const e = (ext || '').toLowerCase()
|
|
78
|
-
if (['doc', 'docx'].includes(e)) return '#2b6ff7'
|
|
79
|
-
if (['xls', 'xlsx', 'csv'].includes(e)) return '#17a34a'
|
|
80
|
-
if (['ppt', 'pptx'].includes(e)) return '#f97316'
|
|
81
|
-
if (['pdf'].includes(e)) return '#ef4444'
|
|
82
|
-
if (['txt', 'md', 'log'].includes(e)) return '#64748b'
|
|
83
|
-
if (['zip', 'rar', '7z', 'tar', 'gz'].includes(e)) return '#8b5cf6'
|
|
84
|
-
if (['mp3', 'wav', 'flac', 'aac'].includes(e)) return '#06b6d4'
|
|
85
|
-
if (['mp4', 'mov', 'avi', 'mkv', 'webm'].includes(e)) return '#a855f7'
|
|
86
|
-
return 'rgba(0,0,0,0.45)'
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
const getServerDisplayName = (data: any, fallback?: string) => {
|
|
90
|
-
if (data?.fileName) return `${data.fileName}`
|
|
91
|
-
if (data?.fullName) return `${data.fullName}`
|
|
92
|
-
if (data?.name && data?.suffix) return `${data.name}.${data.suffix}`
|
|
93
|
-
if (data?.name) return `${data.name}`
|
|
94
|
-
return fallback || 'file'
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
export type UploadFileDisplayMode = string
|
|
98
|
-
|
|
99
|
-
export type UploadFileProps = {
|
|
100
|
-
/** 回显用的文件 id 集合(编辑态传入),例如 ['id1','id2'] */
|
|
101
|
-
value?: string[]
|
|
102
|
-
/** 直接设置回显用的 fileList(优先级高于 value 拉取详情) */
|
|
103
|
-
fileList?: UploadFile[]
|
|
104
|
-
/** 上传成功后的回调:直接回传上传后的 fileList(antd UploadFile[])。 */
|
|
105
|
-
onUploaded?: (fileList: UploadFile[]) => void
|
|
106
|
-
/** 是否公开文件:影响上传参数与回显取图接口,默认 false */
|
|
107
|
-
isPublic?: boolean
|
|
108
|
-
/** 最大文件大小(KB),默认 20480KB(20MB) */
|
|
109
|
-
maxSizeKB?: number
|
|
110
|
-
/** 接受的文件类型,默认 * */
|
|
111
|
-
accept?: string
|
|
112
|
-
/** 是否禁用 */
|
|
113
|
-
disabled?: boolean
|
|
114
|
-
/** 允许上传的最大个数,默认 9 */
|
|
115
|
-
maxCount?: number
|
|
116
|
-
/** 是否支持拖拽上传,默认 true;false 时展示按钮上传 */
|
|
117
|
-
draggable?: boolean
|
|
118
|
-
/**
|
|
119
|
-
* 显示方式:
|
|
120
|
-
* - 'file-list':文件列表
|
|
121
|
-
* - 'picture':卡片/缩略图(图片直接展示,其他展示图标)
|
|
122
|
-
* - 'picture+list':上面卡片,下面列表
|
|
123
|
-
*/
|
|
124
|
-
displayMode?: UploadFileDisplayMode
|
|
125
|
-
/** 缩略图尺寸(px),仅 picture / picture+list 生效,默认 104 */
|
|
126
|
-
thumbSize?: number
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
/** 文件上传组件:基于 antd Upload 封装,支持拖拽/按钮、图片预览、文件下载与删除。 */
|
|
130
|
-
const UploadFile: React.FC<UploadFileProps> = ({
|
|
131
|
-
value,
|
|
132
|
-
fileList,
|
|
133
|
-
onUploaded,
|
|
134
|
-
isPublic = false,
|
|
135
|
-
maxSizeKB = 20 * 1024,
|
|
136
|
-
accept = '*',
|
|
137
|
-
disabled = false,
|
|
138
|
-
maxCount = 9,
|
|
139
|
-
draggable = true,
|
|
140
|
-
displayMode = 'file-list',
|
|
141
|
-
thumbSize = 104,
|
|
142
|
-
}) => {
|
|
143
|
-
const { t } = useTranslation()
|
|
144
|
-
const [uploadFileList, setUploadFileList] = useState<UploadFile[]>([])
|
|
145
|
-
const [previewTitle, setPreviewTitle] = useState('')
|
|
146
|
-
const [previewUrl, setPreviewUrl] = useState('')
|
|
147
|
-
const previewModal = useCxModal()
|
|
148
|
-
const nameNodeMapRef = useRef(new Map<string, HTMLDivElement | null>())
|
|
149
|
-
const [nameTooltipOpenMap, setNameTooltipOpenMap] = useState<Record<string, boolean>>({})
|
|
150
|
-
|
|
151
|
-
const isPictureMode = displayMode === 'picture' || displayMode === 'picture+list'
|
|
152
|
-
const listType: UploadProps['listType'] = isPictureMode ? 'picture-card' : 'text'
|
|
153
|
-
|
|
154
|
-
const canUploadMore = uploadFileList.length < maxCount
|
|
155
|
-
const isEmpty = uploadFileList.length === 0
|
|
156
|
-
const hasUploading = uploadFileList.some((f) => f && f.status === 'uploading')
|
|
157
|
-
|
|
158
|
-
const uploadHeaders = useMemo(() => {
|
|
159
|
-
const token = getStore('token')
|
|
160
|
-
return token ? ({ 'token-agent': `${token}` } as any) : undefined
|
|
161
|
-
}, [])
|
|
162
|
-
|
|
163
|
-
useEffect(() => {
|
|
164
|
-
if (Array.isArray(fileList)) {
|
|
165
|
-
setUploadFileList(fileList)
|
|
166
|
-
return
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
let cancelled = false
|
|
170
|
-
|
|
171
|
-
const run = async () => {
|
|
172
|
-
const list = Array.isArray(value) ? value : []
|
|
173
|
-
if (list.length === 0) {
|
|
174
|
-
setUploadFileList([])
|
|
175
|
-
return
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
// fileId:拉取文件详情拿到 fullName/address
|
|
179
|
-
let infos: any[] = []
|
|
180
|
-
try {
|
|
181
|
-
const res = await getFileInfoAPI(list.join(','))
|
|
182
|
-
const data = normalizeApiData(res)
|
|
183
|
-
infos = Array.isArray(data) ? data : data?.list || []
|
|
184
|
-
} catch {
|
|
185
|
-
infos = []
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
const infoMap = new Map<string, any>()
|
|
189
|
-
infos.forEach((x) => {
|
|
190
|
-
const id = x?.id != null ? `${x.id}` : ''
|
|
191
|
-
if (id) infoMap.set(id, x)
|
|
192
|
-
})
|
|
193
|
-
|
|
194
|
-
const next = await Promise.all(
|
|
195
|
-
list.map(async (fileId) => {
|
|
196
|
-
const info = infoMap.get(fileId)
|
|
197
|
-
const address = info?.address ? `${info.address}` : ''
|
|
198
|
-
const name = getServerDisplayName(info, 'file')
|
|
199
|
-
|
|
200
|
-
const base: UploadFile = {
|
|
201
|
-
uid: fileId,
|
|
202
|
-
name,
|
|
203
|
-
status: 'done',
|
|
204
|
-
...(address ? ({ address } as any) : undefined),
|
|
205
|
-
...(isPreviewableUrl(address) ? ({ url: address } as any) : undefined),
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
if (!isPictureMode) return base
|
|
209
|
-
|
|
210
|
-
// picture 模式:仅图片才取 blob 预览(非图片就显示图标)
|
|
211
|
-
if (!isImageFile({ name, url: address })) return base
|
|
212
|
-
if (!address) return base
|
|
213
|
-
|
|
214
|
-
try {
|
|
215
|
-
const cacheKey = `${isPublic ? 1 : 0}:${address}`
|
|
216
|
-
const cachedUrl = IMG_OBJECT_URL_CACHE.get(cacheKey)
|
|
217
|
-
if (cachedUrl) return { ...base, url: cachedUrl }
|
|
218
|
-
|
|
219
|
-
const pending = IMG_OBJECT_URL_PENDING.get(cacheKey)
|
|
220
|
-
const urlPromise =
|
|
221
|
-
pending ??
|
|
222
|
-
(async () => {
|
|
223
|
-
const blob: any = await getImgAPI({ isPublic, url: aesUtil.encrypt(address) })
|
|
224
|
-
const url = blob ? URL.createObjectURL(blob) : ''
|
|
225
|
-
if (url) IMG_OBJECT_URL_CACHE.set(cacheKey, url)
|
|
226
|
-
return url
|
|
227
|
-
})()
|
|
228
|
-
|
|
229
|
-
if (!pending) IMG_OBJECT_URL_PENDING.set(cacheKey, urlPromise)
|
|
230
|
-
const url = await urlPromise
|
|
231
|
-
IMG_OBJECT_URL_PENDING.delete(cacheKey)
|
|
232
|
-
return { ...base, url }
|
|
233
|
-
} catch {
|
|
234
|
-
return base
|
|
235
|
-
}
|
|
236
|
-
})
|
|
237
|
-
)
|
|
238
|
-
|
|
239
|
-
if (cancelled) return
|
|
240
|
-
setUploadFileList(next)
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
void run()
|
|
244
|
-
return () => {
|
|
245
|
-
cancelled = true
|
|
246
|
-
}
|
|
247
|
-
}, [fileList, value, isPublic, isPictureMode])
|
|
248
|
-
|
|
249
|
-
/** 自定义上传:调用 uploadFileAPI,拦截器已统一解密。 */
|
|
250
|
-
const customUpload: UploadProps['customRequest'] = async (options) => {
|
|
251
|
-
const { file, onSuccess, onError } = options
|
|
252
|
-
|
|
253
|
-
try {
|
|
254
|
-
const response: any = await uploadFileAPI({
|
|
255
|
-
file: file as RcFile,
|
|
256
|
-
isPublic,
|
|
257
|
-
})
|
|
258
|
-
|
|
259
|
-
// 拦截器返回 { code: 200, data: {...} },需取 data 字段
|
|
260
|
-
const respData: any = response.data || response
|
|
261
|
-
|
|
262
|
-
if (respData && typeof respData === 'object') {
|
|
263
|
-
respData.uid = respData.uid ?? respData.id ?? (file as any).uid
|
|
264
|
-
respData.status = 'done'
|
|
265
|
-
respData.name = getServerDisplayName(respData, (file as File).name)
|
|
266
|
-
|
|
267
|
-
if (isPreviewableUrl(respData.address)) {
|
|
268
|
-
respData.url = respData.address
|
|
269
|
-
} else {
|
|
270
|
-
const origin = file as File
|
|
271
|
-
const isImg = isImageFile({ name: respData.name, type: origin.type, url: respData.address })
|
|
272
|
-
// 图片才生成 blob url,避免非图片占用内存且无意义
|
|
273
|
-
respData.url = isImg ? URL.createObjectURL(origin) : respData.url
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
setUploadFileList((prev) => {
|
|
278
|
-
const uploadingUid = (file as any).uid
|
|
279
|
-
const filtered = (prev || []).filter((x: any) => x && x.uid !== uploadingUid)
|
|
280
|
-
const next = [...filtered, respData as any]
|
|
281
|
-
onUploaded?.(next as any)
|
|
282
|
-
return next as any
|
|
283
|
-
})
|
|
284
|
-
|
|
285
|
-
onSuccess?.(respData)
|
|
286
|
-
} catch (error: any) {
|
|
287
|
-
message.error('上传失败,请重试')
|
|
288
|
-
onError?.(error)
|
|
289
|
-
|
|
290
|
-
setUploadFileList((prev) => {
|
|
291
|
-
const uploadingUid = (file as any).uid
|
|
292
|
-
return (prev || []).filter((x: any) => x && x.uid !== uploadingUid)
|
|
293
|
-
})
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
/** 上传前校验:文件大小与格式(基于 accept)。 */
|
|
297
|
-
const beforeUpload: UploadProps['beforeUpload'] = (file) => {
|
|
298
|
-
if (file.size > maxSizeKB * 1024) {
|
|
299
|
-
const maxMB = (maxSizeKB / 1024).toFixed(0)
|
|
300
|
-
message.error(`文件不能超过 ${maxMB}MB`)
|
|
301
|
-
return false
|
|
302
|
-
}
|
|
303
|
-
if (!isAcceptedFile(file as any, accept)) {
|
|
304
|
-
message.error('文件格式不支持')
|
|
305
|
-
return false
|
|
306
|
-
}
|
|
307
|
-
return true
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
/** 移除文件:从列表中移除并同步到上级。 */
|
|
311
|
-
const handleRemove: UploadProps['onRemove'] = (file) => {
|
|
312
|
-
const next = uploadFileList.filter((x: any) => x && x.uid !== file.uid)
|
|
313
|
-
setUploadFileList(next)
|
|
314
|
-
onUploaded?.(next)
|
|
315
|
-
return true
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
/** 预览:图片弹框展示;非图片走下载。 */
|
|
319
|
-
const handlePreview = async (file: UploadFile) => {
|
|
320
|
-
const url = file.url ? `${file.url}` : ''
|
|
321
|
-
const address = (file as any)?.address ? `${(file as any).address}` : ''
|
|
322
|
-
|
|
323
|
-
if (!isImageFile(file)) {
|
|
324
|
-
return
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
if (url) {
|
|
328
|
-
setPreviewTitle(file.name || '')
|
|
329
|
-
setPreviewUrl(url)
|
|
330
|
-
previewModal.open({ opeType: 'detail' })
|
|
331
|
-
return
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
if (address) {
|
|
335
|
-
try {
|
|
336
|
-
const cacheKey = `${isPublic ? 1 : 0}:${address}`
|
|
337
|
-
const cachedUrl = IMG_OBJECT_URL_CACHE.get(cacheKey)
|
|
338
|
-
const nextUrl = cachedUrl
|
|
339
|
-
? cachedUrl
|
|
340
|
-
: await (async () => {
|
|
341
|
-
const pending = IMG_OBJECT_URL_PENDING.get(cacheKey)
|
|
342
|
-
const urlPromise =
|
|
343
|
-
pending ??
|
|
344
|
-
(async () => {
|
|
345
|
-
const blob: any = await getImgAPI({ isPublic, url: aesUtil.encrypt(address) })
|
|
346
|
-
const u = blob ? URL.createObjectURL(blob) : ''
|
|
347
|
-
if (u) IMG_OBJECT_URL_CACHE.set(cacheKey, u)
|
|
348
|
-
return u
|
|
349
|
-
})()
|
|
350
|
-
if (!pending) IMG_OBJECT_URL_PENDING.set(cacheKey, urlPromise)
|
|
351
|
-
const u = await urlPromise
|
|
352
|
-
IMG_OBJECT_URL_PENDING.delete(cacheKey)
|
|
353
|
-
return u
|
|
354
|
-
})()
|
|
355
|
-
|
|
356
|
-
if (!nextUrl) return
|
|
357
|
-
setPreviewTitle(file.name || '')
|
|
358
|
-
setPreviewUrl(nextUrl)
|
|
359
|
-
previewModal.open({ opeType: 'detail' })
|
|
360
|
-
} catch {
|
|
361
|
-
message.error('预览失败')
|
|
362
|
-
}
|
|
363
|
-
}
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
/** 下载文件:调用 downloadFileAPI 成功后用 handlerDownload 触发下载。 */
|
|
367
|
-
const handleDownload = async (file: UploadFile) => {
|
|
368
|
-
try {
|
|
369
|
-
const fileId = file.uid
|
|
370
|
-
const blob: any = await downloadFileAPI(fileId)
|
|
371
|
-
handlerDownload(blob, undefined, file.name)
|
|
372
|
-
} catch {
|
|
373
|
-
message.error('下载失败')
|
|
374
|
-
}
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
/** 自定义渲染:picture 模式下对非图片展示文件图标与操作;列表模式增强 hover 操作。 */
|
|
378
|
-
const itemRender: UploadProps['itemRender'] = (originNode, file, _fileList, actions) => {
|
|
379
|
-
if (!isPictureMode) {
|
|
380
|
-
// text 列表:文件名后提供查看(图片)/下载 + 删除
|
|
381
|
-
const isImg = isImageFile(file)
|
|
382
|
-
return (
|
|
383
|
-
<div style={{ display: 'flex', alignItems: 'center', gap: 8, width: '100%' }}>
|
|
384
|
-
<div style={{ flex: 1, minWidth: 0 }}>
|
|
385
|
-
{originNode}
|
|
386
|
-
</div>
|
|
387
|
-
{isImg ? (
|
|
388
|
-
<Button
|
|
389
|
-
type="text"
|
|
390
|
-
size="small"
|
|
391
|
-
icon={<EyeOutlined />}
|
|
392
|
-
onClick={() => void handlePreview(file)}
|
|
393
|
-
/>
|
|
394
|
-
) : (
|
|
395
|
-
<Button
|
|
396
|
-
type="text"
|
|
397
|
-
size="small"
|
|
398
|
-
icon={<DownloadOutlined />}
|
|
399
|
-
onClick={() => void handleDownload(file)}
|
|
400
|
-
/>
|
|
401
|
-
)}
|
|
402
|
-
{!disabled ? (
|
|
403
|
-
<Button
|
|
404
|
-
type="text"
|
|
405
|
-
size="small"
|
|
406
|
-
icon={<DeleteOutlined />}
|
|
407
|
-
onClick={() => actions.remove?.()}
|
|
408
|
-
/>
|
|
409
|
-
) : null}
|
|
410
|
-
</div>
|
|
411
|
-
)
|
|
412
|
-
}
|
|
413
|
-
|
|
414
|
-
// picture 卡片:自渲染(图片/文件都统一尺寸与 hover)
|
|
415
|
-
const isImg = isImageFile(file)
|
|
416
|
-
const thumbUrl = isImg ? getThumbUrl(file) : ''
|
|
417
|
-
const ext = getLowerFileExt(file.name || (file.url ? `${file.url}` : ''))
|
|
418
|
-
const iconColor = getFileIconColorByExt(ext)
|
|
419
|
-
return (
|
|
420
|
-
<div
|
|
421
|
-
className="cx-upload-file-card"
|
|
422
|
-
style={{
|
|
423
|
-
width: thumbSize,
|
|
424
|
-
height: thumbSize,
|
|
425
|
-
border: '1px solid rgba(5,5,5,0.06)',
|
|
426
|
-
borderRadius: 6,
|
|
427
|
-
display: 'flex',
|
|
428
|
-
alignItems: 'center',
|
|
429
|
-
justifyContent: 'center',
|
|
430
|
-
position: 'relative',
|
|
431
|
-
background: '#fff',
|
|
432
|
-
}}
|
|
433
|
-
>
|
|
434
|
-
{isImg ? (
|
|
435
|
-
// eslint-disable-next-line @next/next/no-img-element
|
|
436
|
-
<img
|
|
437
|
-
src={thumbUrl}
|
|
438
|
-
alt={file.name}
|
|
439
|
-
style={{
|
|
440
|
-
width: '100%',
|
|
441
|
-
height: '100%',
|
|
442
|
-
objectFit: 'cover',
|
|
443
|
-
borderRadius: 6,
|
|
444
|
-
display: 'block',
|
|
445
|
-
}}
|
|
446
|
-
onClick={() => void handlePreview(file)}
|
|
447
|
-
/>
|
|
448
|
-
) : (
|
|
449
|
-
<div
|
|
450
|
-
style={{
|
|
451
|
-
fontSize: Math.max(36, Math.floor(thumbSize * 0.52)),
|
|
452
|
-
color: iconColor,
|
|
453
|
-
lineHeight: 1,
|
|
454
|
-
display: 'flex',
|
|
455
|
-
alignItems: 'center',
|
|
456
|
-
justifyContent: 'center',
|
|
457
|
-
}}
|
|
458
|
-
>
|
|
459
|
-
{renderFileIconAsset(getFileIconAssetByName(file.name || (file.url ? `${file.url}` : '')))}
|
|
460
|
-
</div>
|
|
461
|
-
)}
|
|
462
|
-
<div
|
|
463
|
-
style={{
|
|
464
|
-
position: 'absolute',
|
|
465
|
-
inset: 0,
|
|
466
|
-
background: 'rgba(0,0,0,0.45)',
|
|
467
|
-
display: 'flex',
|
|
468
|
-
alignItems: 'center',
|
|
469
|
-
justifyContent: 'center',
|
|
470
|
-
gap: 10,
|
|
471
|
-
borderRadius: 6,
|
|
472
|
-
}}
|
|
473
|
-
className="cx-upload-file-card-mask"
|
|
474
|
-
>
|
|
475
|
-
{isImg ? (
|
|
476
|
-
<Button type="text" icon={<EyeOutlined />} onClick={() => void handlePreview(file)} />
|
|
477
|
-
) : (
|
|
478
|
-
<Button type="text" icon={<DownloadOutlined />} onClick={() => void handleDownload(file)} />
|
|
479
|
-
)}
|
|
480
|
-
{!disabled ? (
|
|
481
|
-
<Button type="text" icon={<DeleteOutlined />} onClick={() => actions.remove?.()} />
|
|
482
|
-
) : null}
|
|
483
|
-
</div>
|
|
484
|
-
</div>
|
|
485
|
-
)
|
|
486
|
-
}
|
|
487
|
-
|
|
488
|
-
const uploadCommonProps: UploadProps = {
|
|
489
|
-
accept,
|
|
490
|
-
listType,
|
|
491
|
-
maxCount,
|
|
492
|
-
multiple: maxCount > 1,
|
|
493
|
-
disabled,
|
|
494
|
-
fileList: uploadFileList,
|
|
495
|
-
beforeUpload,
|
|
496
|
-
customRequest: customUpload,
|
|
497
|
-
onRemove: handleRemove,
|
|
498
|
-
onPreview: (file) => void handlePreview(file),
|
|
499
|
-
itemRender,
|
|
500
|
-
openFileDialogOnClick: true,
|
|
501
|
-
showUploadList: isPictureMode
|
|
502
|
-
? { showPreviewIcon: true, showRemoveIcon: !disabled, showDownloadIcon: false }
|
|
503
|
-
: { showRemoveIcon: !disabled },
|
|
504
|
-
}
|
|
505
|
-
|
|
506
|
-
const uploaderNode = draggable ? (
|
|
507
|
-
<Upload.Dragger {...uploadCommonProps} style={canUploadMore ? undefined : { display: 'none' }}>
|
|
508
|
-
<div style={{ padding: 12 }}>
|
|
509
|
-
<InboxOutlined style={{ fontSize: 28, color: 'rgba(0,0,0,0.35)' }} />
|
|
510
|
-
<div style={{ marginTop: 8, color: 'rgba(0,0,0,0.65)' }}>
|
|
511
|
-
{t('common.upload_drag_title')},{t('common.upload_drag_or_click')}
|
|
512
|
-
</div>
|
|
513
|
-
</div>
|
|
514
|
-
</Upload.Dragger>
|
|
515
|
-
) : (
|
|
516
|
-
<Upload {...uploadCommonProps}>
|
|
517
|
-
{canUploadMore ? (
|
|
518
|
-
<Button icon={<PlusOutlined />} disabled={disabled}>
|
|
519
|
-
上传文件
|
|
520
|
-
</Button>
|
|
521
|
-
) : null}
|
|
522
|
-
</Upload>
|
|
523
|
-
)
|
|
524
|
-
|
|
525
|
-
/** 渲染列表:用于 picture+list 的下方文件列表展示(含下载/删除)。 */
|
|
526
|
-
const renderFileList = () => {
|
|
527
|
-
if (uploadFileList.length === 0) return null
|
|
528
|
-
return (
|
|
529
|
-
<div className="cx-upload-file-list">
|
|
530
|
-
{uploadFileList.map((f) => (
|
|
531
|
-
<div key={f.uid} className="cx-upload-file-list-item">
|
|
532
|
-
<div
|
|
533
|
-
style={{
|
|
534
|
-
fontSize: 20,
|
|
535
|
-
color: getFileIconColorByExt(getLowerFileExt(f.name)),
|
|
536
|
-
lineHeight: 1,
|
|
537
|
-
flex: '0 0 auto',
|
|
538
|
-
}}
|
|
539
|
-
>
|
|
540
|
-
{renderFileIconAsset(getFileIconAssetByName(f.name))}
|
|
541
|
-
</div>
|
|
542
|
-
<CxTooltip
|
|
543
|
-
title={f.name}
|
|
544
|
-
placement="topLeft"
|
|
545
|
-
mouseEnterDelay={0}
|
|
546
|
-
open={!!nameTooltipOpenMap[f.uid]}
|
|
547
|
-
getPopupContainer={(triggerNode) => triggerNode.parentElement ?? document.body}
|
|
548
|
-
>
|
|
549
|
-
<div
|
|
550
|
-
className="cx-upload-file-list-name"
|
|
551
|
-
ref={(el) => {
|
|
552
|
-
nameNodeMapRef.current.set(f.uid, el)
|
|
553
|
-
}}
|
|
554
|
-
onMouseEnter={() => {
|
|
555
|
-
const el = nameNodeMapRef.current.get(f.uid)
|
|
556
|
-
const shouldOpen = !!el && el.scrollWidth > el.clientWidth
|
|
557
|
-
setNameTooltipOpenMap((prev) => (prev[f.uid] === shouldOpen ? prev : { ...prev, [f.uid]: shouldOpen }))
|
|
558
|
-
}}
|
|
559
|
-
onMouseLeave={() => {
|
|
560
|
-
setNameTooltipOpenMap((prev) => (prev[f.uid] ? { ...prev, [f.uid]: false } : prev))
|
|
561
|
-
}}
|
|
562
|
-
>
|
|
563
|
-
{f.name}
|
|
564
|
-
</div>
|
|
565
|
-
</CxTooltip>
|
|
566
|
-
{!disabled ? (
|
|
567
|
-
<div className="cx-upload-file-list-actions">
|
|
568
|
-
{isImageFile(f) ? (
|
|
569
|
-
<Button
|
|
570
|
-
type="text"
|
|
571
|
-
size="small"
|
|
572
|
-
icon={<EyeOutlined />}
|
|
573
|
-
onClick={() => void handlePreview(f)}
|
|
574
|
-
/>
|
|
575
|
-
) : (
|
|
576
|
-
<Button
|
|
577
|
-
type="text"
|
|
578
|
-
size="small"
|
|
579
|
-
icon={<DownloadOutlined />}
|
|
580
|
-
onClick={() => void handleDownload(f)}
|
|
581
|
-
/>
|
|
582
|
-
)}
|
|
583
|
-
<Button
|
|
584
|
-
type="text"
|
|
585
|
-
size="small"
|
|
586
|
-
icon={<DeleteOutlined />}
|
|
587
|
-
onClick={() => void handleRemove(f as any)}
|
|
588
|
-
/>
|
|
589
|
-
</div>
|
|
590
|
-
) : null}
|
|
591
|
-
</div>
|
|
592
|
-
))}
|
|
593
|
-
</div>
|
|
594
|
-
)
|
|
595
|
-
}
|
|
596
|
-
|
|
597
|
-
return (
|
|
598
|
-
<div
|
|
599
|
-
className="cx-upload-file-root"
|
|
600
|
-
style={isEmpty ? undefined : { ['--cx-upload-thumb-size' as any]: `${thumbSize}px` }}
|
|
601
|
-
>
|
|
602
|
-
{displayMode === 'picture+list' ? (
|
|
603
|
-
<div className={`cx-upload-file-picture-list-wrap${isEmpty ? ' is-empty' : ''}`}>
|
|
604
|
-
{/* 空态用 Dragger;关键:uploading 阶段也保持 Dragger,避免组件切换导致上传中断 */}
|
|
605
|
-
{draggable && (isEmpty || hasUploading) ? (
|
|
606
|
-
<Upload.Dragger
|
|
607
|
-
{...uploadCommonProps}
|
|
608
|
-
style={canUploadMore ? { width: '100%' } : { display: 'none' }}
|
|
609
|
-
>
|
|
610
|
-
<div style={{ padding: 12 }}>
|
|
611
|
-
<InboxOutlined style={{ fontSize: 28, color: 'rgba(0,0,0,0.35)' }} />
|
|
612
|
-
<div style={{ marginTop: 8, color: 'rgba(0,0,0,0.65)' }}>
|
|
613
|
-
{t('common.upload_drag_title')},{t('common.upload_drag_or_click')}
|
|
614
|
-
</div>
|
|
615
|
-
</div>
|
|
616
|
-
</Upload.Dragger>
|
|
617
|
-
) : (
|
|
618
|
-
<Upload {...uploadCommonProps}>{canUploadMore ? <PlusOutlined /> : null}</Upload>
|
|
619
|
-
)}
|
|
620
|
-
{renderFileList()}
|
|
621
|
-
</div>
|
|
622
|
-
) : (
|
|
623
|
-
uploaderNode
|
|
624
|
-
)}
|
|
625
|
-
|
|
626
|
-
<CxModal
|
|
627
|
-
isOpen={previewModal.isOpen}
|
|
628
|
-
title={previewTitle}
|
|
629
|
-
onClose={previewModal.close}
|
|
630
|
-
opeType="detail"
|
|
631
|
-
modalConfig={{ width: 900 }}
|
|
632
|
-
>
|
|
633
|
-
<Image alt={previewTitle} src={previewUrl} style={{ width: '100%' }} />
|
|
634
|
-
</CxModal>
|
|
635
|
-
</div>
|
|
636
|
-
)
|
|
637
|
-
}
|
|
638
|
-
|
|
639
|
-
export default UploadFile
|
|
640
|
-
|