cx-chat 0.0.2 → 0.0.4
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 +68257 -0
- package/dist/cx-chat.umd.js +492 -0
- package/package.json +27 -3
- 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,67 +0,0 @@
|
|
|
1
|
-
import clsx from 'clsx'
|
|
2
|
-
import { ReactNode } from 'react'
|
|
3
|
-
import { useTranslation } from 'react-i18next'
|
|
4
|
-
import { CxTooltip } from '@cx-ui'
|
|
5
|
-
|
|
6
|
-
export type DetailLinkProps = {
|
|
7
|
-
/** 显示的文本内容 */
|
|
8
|
-
text: string
|
|
9
|
-
/** 点击事件 */
|
|
10
|
-
onClick?: () => void
|
|
11
|
-
/** 额外的渲染内容(如徽章、图标等) */
|
|
12
|
-
extra?: ReactNode
|
|
13
|
-
/** 自定义类名 */
|
|
14
|
-
className?: string
|
|
15
|
-
/** 是否禁用 */
|
|
16
|
-
disabled?: boolean
|
|
17
|
-
/** tooltip 提示文本,默认为"查看" */
|
|
18
|
-
title?: string
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* 表格中可点击跳转详情的链接组件
|
|
23
|
-
*
|
|
24
|
-
* @example
|
|
25
|
-
* // 基础用法
|
|
26
|
-
* <DetailLink text={record.name} onClick={() => handleDetail(record)} />
|
|
27
|
-
*
|
|
28
|
-
* @example
|
|
29
|
-
* // 带额外内容(如徽章)
|
|
30
|
-
* <DetailLink
|
|
31
|
-
* text={record.name}
|
|
32
|
-
* onClick={() => handleDetail(record)}
|
|
33
|
-
* extra={<span className="ml-2 px-2 py-0.5 text-xs bg-blue-100 text-blue-700 rounded-full">系统</span>}
|
|
34
|
-
* />
|
|
35
|
-
*/
|
|
36
|
-
export function DetailLink({
|
|
37
|
-
text,
|
|
38
|
-
onClick,
|
|
39
|
-
extra,
|
|
40
|
-
className,
|
|
41
|
-
disabled = false,
|
|
42
|
-
title,
|
|
43
|
-
}: DetailLinkProps) {
|
|
44
|
-
const { t } = useTranslation()
|
|
45
|
-
const tooltipTitle = title ?? t('common.view')
|
|
46
|
-
|
|
47
|
-
return (
|
|
48
|
-
<CxTooltip title={tooltipTitle}>
|
|
49
|
-
<button
|
|
50
|
-
type="button"
|
|
51
|
-
className={clsx(
|
|
52
|
-
'max-w-full cursor-pointer truncate text-blue-600 hover:underline dark:text-blue-400',
|
|
53
|
-
disabled && 'cursor-not-allowed opacity-50 hover:no-underline',
|
|
54
|
-
className,
|
|
55
|
-
)}
|
|
56
|
-
disabled={disabled}
|
|
57
|
-
onClick={disabled ? undefined : onClick}>
|
|
58
|
-
<span className="inline-flex items-center gap-1">
|
|
59
|
-
<span className="truncate">{text}</span>
|
|
60
|
-
{extra}
|
|
61
|
-
</span>
|
|
62
|
-
</button>
|
|
63
|
-
</CxTooltip>
|
|
64
|
-
)
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
DetailLink.displayName = 'DetailLink'
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
import {Component} from 'react';
|
|
2
|
-
import type {ErrorInfo, ReactNode} from 'react';
|
|
3
|
-
import {AlertTriangle, RefreshCcw} from 'lucide-react';
|
|
4
|
-
|
|
5
|
-
interface Props {
|
|
6
|
-
children?: ReactNode;
|
|
7
|
-
fallback?: ReactNode;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
interface State {
|
|
11
|
-
hasError: boolean;
|
|
12
|
-
error: Error | null;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
class ErrorBoundary extends Component<Props, State> {
|
|
16
|
-
public state: State = {
|
|
17
|
-
hasError: false,
|
|
18
|
-
error: null,
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
public static getDerivedStateFromError(error: Error): State {
|
|
22
|
-
return {hasError: true, error};
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
public componentDidCatch(error: Error, errorInfo: ErrorInfo) {
|
|
26
|
-
console.error('------- 全局错误边界捕获到错误 -------');
|
|
27
|
-
console.error('错误:', error);
|
|
28
|
-
console.error('组件堆栈:', errorInfo.componentStack);
|
|
29
|
-
console.error('----------------------------------------');
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
public handleReload = () => {
|
|
33
|
-
window.location.reload();
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
public render() {
|
|
37
|
-
if (this.state.hasError) {
|
|
38
|
-
if (this.props.fallback) {
|
|
39
|
-
return this.props.fallback;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
return (
|
|
43
|
-
<div className="min-h-screen bg-gray-50 dark:bg-gray-900 flex flex-col items-center justify-center p-4">
|
|
44
|
-
<div
|
|
45
|
-
className="max-w-md w-full bg-white dark:bg-gray-800 rounded-xl shadow-lg p-8 text-center border border-gray-200 dark:border-gray-700">
|
|
46
|
-
<div
|
|
47
|
-
className="w-16 h-16 bg-red-100 dark:bg-red-900/30 rounded-full flex items-center justify-center mx-auto mb-6">
|
|
48
|
-
<AlertTriangle className="w-8 h-8 text-red-600 dark:text-red-400"/>
|
|
49
|
-
</div>
|
|
50
|
-
<h1 className="text-2xl font-bold text-gray-900 dark:text-white mb-2">
|
|
51
|
-
出错了
|
|
52
|
-
</h1>
|
|
53
|
-
<p className="text-gray-500 dark:text-gray-400 mb-6">
|
|
54
|
-
应用程序遇到意外错误。请尝试重新加载页面。
|
|
55
|
-
</p>
|
|
56
|
-
|
|
57
|
-
{this.state.error && (
|
|
58
|
-
<div
|
|
59
|
-
className="mb-6 p-4 bg-gray-100 dark:bg-gray-900 rounded-lg text-left overflow-auto max-h-32 text-xs font-mono text-red-500">
|
|
60
|
-
{this.state.error.toString()}
|
|
61
|
-
</div>
|
|
62
|
-
)}
|
|
63
|
-
|
|
64
|
-
<button
|
|
65
|
-
onClick={this.handleReload}
|
|
66
|
-
className="inline-flex items-center gap-2 px-6 py-2.5 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors font-medium shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 dark:focus:ring-offset-gray-800"
|
|
67
|
-
>
|
|
68
|
-
<RefreshCcw size={18}/>
|
|
69
|
-
重新加载应用
|
|
70
|
-
</button>
|
|
71
|
-
|
|
72
|
-
<div className="mt-8 pt-6 border-t border-gray-200 dark:border-gray-700 w-full">
|
|
73
|
-
<p className="text-sm text-gray-500 mb-3">
|
|
74
|
-
如果重新加载无法解决问题,请尝试重置应用程序。
|
|
75
|
-
<br/>
|
|
76
|
-
<span className="text-xs text-orange-500">
|
|
77
|
-
(这将清除您的本地会话和设置)
|
|
78
|
-
</span>
|
|
79
|
-
</p>
|
|
80
|
-
<button
|
|
81
|
-
onClick={() => {
|
|
82
|
-
localStorage.clear();
|
|
83
|
-
window.location.reload();
|
|
84
|
-
}}
|
|
85
|
-
className="text-sm text-red-600 hover:text-red-700 underline underline-offset-4"
|
|
86
|
-
>
|
|
87
|
-
重置应用并清除缓存
|
|
88
|
-
</button>
|
|
89
|
-
</div>
|
|
90
|
-
</div>
|
|
91
|
-
</div>
|
|
92
|
-
);
|
|
93
|
-
}
|
|
94
|
-
return this.props.children;
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
export default ErrorBoundary;
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
import { useUserPreferences } from '@/hooks/useUserPreferences';
|
|
2
|
-
import { setStore } from '@/utils/storage';
|
|
3
|
-
import { Check, Globe } from 'lucide-react';
|
|
4
|
-
import React, { useEffect, useRef, useState } from 'react';
|
|
5
|
-
import { useTranslation } from 'react-i18next';
|
|
6
|
-
|
|
7
|
-
const languages = [
|
|
8
|
-
{ code: 'zh', name: '简体中文', nativeName: '简体中文', displayCode: '中' },
|
|
9
|
-
{ code: 'en', name: 'English', nativeName: 'English', displayCode: 'EN' },
|
|
10
|
-
];
|
|
11
|
-
|
|
12
|
-
interface LanguageSwitcherProps {
|
|
13
|
-
direction?: 'up' | 'down';
|
|
14
|
-
/** 是否在按钮上显示当前语言代码(如 EN / ZH) */
|
|
15
|
-
showCode?: boolean;
|
|
16
|
-
/** 仅本地切换语言:不调用保存语言接口(用于登录页等未登录场景) */
|
|
17
|
-
localOnly?: boolean;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const LanguageSwitcher: React.FC<LanguageSwitcherProps> = ({ direction = 'up', showCode = false, localOnly = false }) => {
|
|
21
|
-
const { i18n } = useTranslation();
|
|
22
|
-
const [isOpen, setIsOpen] = useState(false);
|
|
23
|
-
const dropdownRef = useRef<HTMLDivElement>(null);
|
|
24
|
-
const { saveLanguage } = useUserPreferences();
|
|
25
|
-
|
|
26
|
-
useEffect(() => {
|
|
27
|
-
const handleClickOutside = (event: MouseEvent) => {
|
|
28
|
-
if (dropdownRef.current && !dropdownRef.current.contains(event.target as Node)) {
|
|
29
|
-
setIsOpen(false);
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
if (isOpen) {
|
|
34
|
-
document.addEventListener('mousedown', handleClickOutside);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
return () => {
|
|
38
|
-
document.removeEventListener('mousedown', handleClickOutside);
|
|
39
|
-
};
|
|
40
|
-
}, [isOpen]);
|
|
41
|
-
|
|
42
|
-
const currentCode = String(i18n.language || '').toLowerCase().startsWith('zh') ? 'zh' : 'en';
|
|
43
|
-
const currentLanguage = languages.find(lang => lang.code === currentCode) || languages[0];
|
|
44
|
-
|
|
45
|
-
const handleLanguageChange = (langCode: string) => {
|
|
46
|
-
i18n.changeLanguage(langCode);
|
|
47
|
-
if (localOnly) {
|
|
48
|
-
// localStorage.setItem('i18nextLng', langCode);
|
|
49
|
-
setStore('i18nextLng', langCode);
|
|
50
|
-
} else {
|
|
51
|
-
saveLanguage(langCode); // Save to server
|
|
52
|
-
}
|
|
53
|
-
setIsOpen(false);
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
return (
|
|
57
|
-
<div className="relative" ref={dropdownRef}>
|
|
58
|
-
<button
|
|
59
|
-
onClick={() => setIsOpen(!isOpen)}
|
|
60
|
-
className={`p-2 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors text-gray-500 dark:text-gray-400${showCode ? ' flex items-center gap-1' : ''}`}
|
|
61
|
-
title={currentLanguage.nativeName}
|
|
62
|
-
>
|
|
63
|
-
<Globe size={20} />
|
|
64
|
-
{showCode && (
|
|
65
|
-
<span className="text-[11px] font-bold tracking-wide w-4 text-center">{currentLanguage.displayCode}</span>
|
|
66
|
-
)}
|
|
67
|
-
<span className="sr-only">Switch Language</span>
|
|
68
|
-
</button>
|
|
69
|
-
|
|
70
|
-
{isOpen && (
|
|
71
|
-
<div className={`absolute right-0 w-48 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-lg py-1 z-50 ${direction === 'up' ? 'bottom-full mb-2' : 'top-full mt-2'
|
|
72
|
-
}`}>
|
|
73
|
-
{languages.map((lang) => (
|
|
74
|
-
<button
|
|
75
|
-
key={lang.code}
|
|
76
|
-
onClick={() => handleLanguageChange(lang.code)}
|
|
77
|
-
className="w-full flex items-center justify-between px-4 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors"
|
|
78
|
-
>
|
|
79
|
-
<span>{lang.nativeName}</span>
|
|
80
|
-
{currentCode === lang.code && (
|
|
81
|
-
<Check size={16} className="text-blue-600 dark:text-blue-400" />
|
|
82
|
-
)}
|
|
83
|
-
</button>
|
|
84
|
-
))}
|
|
85
|
-
</div>
|
|
86
|
-
)}
|
|
87
|
-
</div>
|
|
88
|
-
);
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
export default LanguageSwitcher;
|
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
import clsx from 'clsx'
|
|
3
|
-
|
|
4
|
-
import type { ListRenderContext } from '@/components/table-view/components/table-view.types'
|
|
5
|
-
|
|
6
|
-
export function getRecordKey(record: any, rowKey: string): string | number {
|
|
7
|
-
const v = record?.[rowKey] ?? record?._id
|
|
8
|
-
if (v === undefined || v === null) {
|
|
9
|
-
return `__idx_${JSON.stringify(record).slice(0, 80)}`
|
|
10
|
-
}
|
|
11
|
-
return v
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export function keysEqual(a: string | number, b: string | number) {
|
|
15
|
-
return String(a) === String(b)
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export type LiteTableBaseProps = Pick<
|
|
19
|
-
ListRenderContext,
|
|
20
|
-
'columns' | 'renderCell' | 'tableData' | 't'
|
|
21
|
-
>
|
|
22
|
-
|
|
23
|
-
export type LiteTableProps = LiteTableBaseProps & {
|
|
24
|
-
/** 行主键字段,默认 `id` */
|
|
25
|
-
rowKey?: string
|
|
26
|
-
onRowClick?: (record: any, index: number) => void
|
|
27
|
-
rowClassName?: (record: any, index: number) => string
|
|
28
|
-
/** 包裹 table 的横向滚动容器 */
|
|
29
|
-
className?: string
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/** 从列表渲染上下文中取出 LiteTable 所需字段(忽略 `tree` 等) */
|
|
33
|
-
export function pickLiteTableProps(ctx: ListRenderContext): LiteTableBaseProps {
|
|
34
|
-
return {
|
|
35
|
-
columns: ctx.columns,
|
|
36
|
-
renderCell: ctx.renderCell,
|
|
37
|
-
tableData: ctx.tableData,
|
|
38
|
-
t: ctx.t,
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
function columnAlignClass(align: string | undefined): string {
|
|
43
|
-
if (align === 'center') return 'text-center'
|
|
44
|
-
if (align === 'right') return 'text-right'
|
|
45
|
-
if (align === 'left') return 'text-left'
|
|
46
|
-
return ''
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/** 与 antd Table 列约定一致:number 视为 px */
|
|
50
|
-
function columnWidthStyle(col: {
|
|
51
|
-
width?: number | string
|
|
52
|
-
}): React.CSSProperties | undefined {
|
|
53
|
-
const w = col.width
|
|
54
|
-
if (w === undefined || w === null || w === '') return undefined
|
|
55
|
-
return { width: typeof w === 'number' ? `${w}px` : w }
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* 轻量表格(原生 table):
|
|
60
|
-
* - 适合简单展示
|
|
61
|
-
* - 不依赖 antd Table
|
|
62
|
-
*/
|
|
63
|
-
export default function LiteTable(props: LiteTableProps) {
|
|
64
|
-
const {
|
|
65
|
-
className,
|
|
66
|
-
columns,
|
|
67
|
-
onRowClick,
|
|
68
|
-
renderCell,
|
|
69
|
-
rowClassName,
|
|
70
|
-
rowKey = 'id',
|
|
71
|
-
tableData,
|
|
72
|
-
t,
|
|
73
|
-
} = props
|
|
74
|
-
|
|
75
|
-
return (
|
|
76
|
-
<div className={clsx('overflow-x-auto', className)}>
|
|
77
|
-
<table className="w-full table-fixed text-left text-sm">
|
|
78
|
-
<thead className="bg-gray-50 dark:bg-gray-700/50 text-gray-500 dark:text-gray-400">
|
|
79
|
-
<tr>
|
|
80
|
-
{columns.map((col: any, index: number) => (
|
|
81
|
-
<th
|
|
82
|
-
key={(col.key as string) ?? col.dataIndex ?? index}
|
|
83
|
-
style={columnWidthStyle(col)}
|
|
84
|
-
className={clsx(
|
|
85
|
-
'px-3 py-4 font-medium',
|
|
86
|
-
columnAlignClass(col.headerAlign ?? col.align ?? 'left'),
|
|
87
|
-
)}>
|
|
88
|
-
{typeof col.title === 'string'
|
|
89
|
-
? t(col.title as any)
|
|
90
|
-
: ((col.title as React.ReactNode) ?? '')}
|
|
91
|
-
</th>
|
|
92
|
-
))}
|
|
93
|
-
</tr>
|
|
94
|
-
</thead>
|
|
95
|
-
<tbody className="divide-y divide-gray-200 dark:divide-gray-700">
|
|
96
|
-
{tableData.map((record: any, rowIndex: number) => (
|
|
97
|
-
<tr
|
|
98
|
-
key={String(getRecordKey(record, rowKey))}
|
|
99
|
-
role={onRowClick ? 'button' : undefined}
|
|
100
|
-
tabIndex={onRowClick ? 0 : undefined}
|
|
101
|
-
onClick={onRowClick ? () => onRowClick(record, rowIndex) : undefined}
|
|
102
|
-
onKeyDown={
|
|
103
|
-
onRowClick
|
|
104
|
-
? (e) => {
|
|
105
|
-
if (e.key === 'Enter' || e.key === ' ') {
|
|
106
|
-
e.preventDefault()
|
|
107
|
-
onRowClick(record, rowIndex)
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
: undefined
|
|
111
|
-
}
|
|
112
|
-
className={clsx(
|
|
113
|
-
'transition-colors hover:bg-gray-50 dark:hover:bg-gray-700/50',
|
|
114
|
-
onRowClick && 'cursor-pointer',
|
|
115
|
-
rowClassName?.(record, rowIndex),
|
|
116
|
-
)}>
|
|
117
|
-
{columns.map((col: any, colIndex: number) => (
|
|
118
|
-
<td
|
|
119
|
-
key={(col.key as string) ?? col.dataIndex ?? colIndex}
|
|
120
|
-
style={columnWidthStyle(col)}
|
|
121
|
-
className={clsx(
|
|
122
|
-
'px-3 py-4 text-gray-900 dark:text-white',
|
|
123
|
-
columnAlignClass(col.align),
|
|
124
|
-
)}>
|
|
125
|
-
{renderCell(col, record, rowIndex)}
|
|
126
|
-
</td>
|
|
127
|
-
))}
|
|
128
|
-
</tr>
|
|
129
|
-
))}
|
|
130
|
-
</tbody>
|
|
131
|
-
</table>
|
|
132
|
-
</div>
|
|
133
|
-
)
|
|
134
|
-
}
|
|
135
|
-
|
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
import { useEffect, useRef } from 'react'
|
|
2
|
-
import { useTranslation } from 'react-i18next'
|
|
3
|
-
import { cn } from '@/utils/cn'
|
|
4
|
-
import ReactMarkdown from 'react-markdown'
|
|
5
|
-
import remarkGfm from 'remark-gfm'
|
|
6
|
-
|
|
7
|
-
type Props = {
|
|
8
|
-
value?: string
|
|
9
|
-
onChange?: (next: string) => void
|
|
10
|
-
/** 挂最外层;作为 Form.Item 唯一直接子节点时用这里写高度,勿再外包 div(会接不到 value/onChange) */
|
|
11
|
-
className?: string
|
|
12
|
-
id?: string
|
|
13
|
-
disabled?: boolean
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
/** 左侧 Markdown 源码、右侧实时预览(与滚动大致同步) */
|
|
17
|
-
export function MdEditor({ value, onChange, className, id, disabled }: Props) {
|
|
18
|
-
const { t } = useTranslation()
|
|
19
|
-
const sourceRef = useRef<HTMLTextAreaElement | null>(null)
|
|
20
|
-
const previewRef = useRef<HTMLDivElement | null>(null)
|
|
21
|
-
const activeRef = useRef<0 | 1 | 2>(0)
|
|
22
|
-
const ignoreNextRef = useRef<{ source: boolean; preview: boolean }>({
|
|
23
|
-
source: false,
|
|
24
|
-
preview: false,
|
|
25
|
-
})
|
|
26
|
-
const rafRef = useRef<number | null>(null)
|
|
27
|
-
const releaseTimerRef = useRef<number | null>(null)
|
|
28
|
-
|
|
29
|
-
const scheduleRelease = () => {
|
|
30
|
-
if (releaseTimerRef.current != null) window.clearTimeout(releaseTimerRef.current)
|
|
31
|
-
releaseTimerRef.current = window.setTimeout(() => {
|
|
32
|
-
activeRef.current = 0
|
|
33
|
-
}, 120)
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const syncScroll = (from: 1 | 2) => {
|
|
37
|
-
const sourceEl = sourceRef.current
|
|
38
|
-
const previewEl = previewRef.current
|
|
39
|
-
if (!sourceEl || !previewEl) return
|
|
40
|
-
activeRef.current = from
|
|
41
|
-
scheduleRelease()
|
|
42
|
-
|
|
43
|
-
if (rafRef.current != null) cancelAnimationFrame(rafRef.current)
|
|
44
|
-
rafRef.current = requestAnimationFrame(() => {
|
|
45
|
-
if (from === 1) {
|
|
46
|
-
ignoreNextRef.current.preview = true
|
|
47
|
-
const maxFrom = sourceEl.scrollHeight - sourceEl.clientHeight
|
|
48
|
-
const maxTo = previewEl.scrollHeight - previewEl.clientHeight
|
|
49
|
-
const ratio = maxFrom > 0 ? sourceEl.scrollTop / maxFrom : 0
|
|
50
|
-
previewEl.scrollTop = maxTo > 0 ? ratio * maxTo : 0
|
|
51
|
-
return
|
|
52
|
-
}
|
|
53
|
-
ignoreNextRef.current.source = true
|
|
54
|
-
const maxFrom = previewEl.scrollHeight - previewEl.clientHeight
|
|
55
|
-
const maxTo = sourceEl.scrollHeight - sourceEl.clientHeight
|
|
56
|
-
const ratio = maxFrom > 0 ? previewEl.scrollTop / maxFrom : 0
|
|
57
|
-
sourceEl.scrollTop = maxTo > 0 ? ratio * maxTo : 0
|
|
58
|
-
})
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
useEffect(() => {
|
|
62
|
-
return () => {
|
|
63
|
-
if (rafRef.current != null) cancelAnimationFrame(rafRef.current)
|
|
64
|
-
if (releaseTimerRef.current != null) window.clearTimeout(releaseTimerRef.current)
|
|
65
|
-
}
|
|
66
|
-
}, [])
|
|
67
|
-
|
|
68
|
-
return (
|
|
69
|
-
<div
|
|
70
|
-
id={id}
|
|
71
|
-
className={cn('flex h-full w-full min-h-0 gap-4 overflow-hidden', className)}
|
|
72
|
-
>
|
|
73
|
-
<div className="flex h-full min-h-0 flex-1 flex-col overflow-hidden rounded-xl border border-gray-200 bg-white shadow-sm dark:border-gray-700 dark:bg-gray-800">
|
|
74
|
-
<div className="flex min-h-[44px] shrink-0 items-center border-b border-gray-200 bg-gray-50 px-3 py-2.5 dark:border-gray-700 dark:bg-gray-700/50">
|
|
75
|
-
<h3 className="line-clamp-1 py-0.5 text-xs font-semibold uppercase tracking-wider text-gray-700 dark:text-gray-300">
|
|
76
|
-
{t('common.md_editor.editor_source')}
|
|
77
|
-
</h3>
|
|
78
|
-
</div>
|
|
79
|
-
<div className="min-h-0 flex-1 overflow-hidden">
|
|
80
|
-
<textarea
|
|
81
|
-
ref={sourceRef}
|
|
82
|
-
className="h-full w-full min-h-0 resize-none overflow-auto border-0 bg-transparent p-3 font-mono text-sm text-gray-900 outline-none dark:text-gray-100"
|
|
83
|
-
placeholder={t('common.md_editor.raw_text_placeholder')}
|
|
84
|
-
value={value ?? ''}
|
|
85
|
-
disabled={disabled}
|
|
86
|
-
onChange={(e) => onChange?.(e.target.value)}
|
|
87
|
-
onScroll={() => {
|
|
88
|
-
if (ignoreNextRef.current.source) {
|
|
89
|
-
ignoreNextRef.current.source = false
|
|
90
|
-
return
|
|
91
|
-
}
|
|
92
|
-
if (activeRef.current === 0 || activeRef.current === 1) syncScroll(1)
|
|
93
|
-
}}
|
|
94
|
-
/>
|
|
95
|
-
</div>
|
|
96
|
-
</div>
|
|
97
|
-
|
|
98
|
-
<div className="flex h-full min-h-0 flex-1 flex-col overflow-hidden rounded-xl border border-gray-200 bg-white shadow-sm dark:border-gray-700 dark:bg-gray-800">
|
|
99
|
-
<div className="flex min-h-[44px] shrink-0 items-center border-b border-gray-200 bg-gray-50 px-3 py-2.5 dark:border-gray-700 dark:bg-gray-700/50">
|
|
100
|
-
<h3 className="line-clamp-1 py-0.5 text-xs font-semibold uppercase tracking-wider text-gray-700 dark:text-gray-300">
|
|
101
|
-
{t('common.md_editor.editor_preview')}
|
|
102
|
-
</h3>
|
|
103
|
-
</div>
|
|
104
|
-
<div
|
|
105
|
-
ref={previewRef}
|
|
106
|
-
className="prose prose-sm max-w-none min-h-0 flex-1 overflow-auto p-3 text-gray-900 dark:prose-invert dark:text-gray-100"
|
|
107
|
-
onScroll={() => {
|
|
108
|
-
if (ignoreNextRef.current.preview) {
|
|
109
|
-
ignoreNextRef.current.preview = false
|
|
110
|
-
return
|
|
111
|
-
}
|
|
112
|
-
if (activeRef.current === 0 || activeRef.current === 2) syncScroll(2)
|
|
113
|
-
}}
|
|
114
|
-
>
|
|
115
|
-
{(value ?? '').trim() ? (
|
|
116
|
-
<ReactMarkdown remarkPlugins={[remarkGfm]}>{value ?? ''}</ReactMarkdown>
|
|
117
|
-
) : (
|
|
118
|
-
<span className="not-prose text-sm text-gray-400">
|
|
119
|
-
{t('common.md_editor.preview_empty')}
|
|
120
|
-
</span>
|
|
121
|
-
)}
|
|
122
|
-
</div>
|
|
123
|
-
</div>
|
|
124
|
-
</div>
|
|
125
|
-
)
|
|
126
|
-
}
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
import { AlertTriangle, X } from 'lucide-react'
|
|
3
|
-
import { useTranslation } from 'react-i18next'
|
|
4
|
-
|
|
5
|
-
import { CxButton, CxButtonCancel, CxButtonIcon } from '@cx-ui'
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* 基于 `ui/ConfirmDialog` 的克隆:交互与 props 一致;底部与关闭使用 `CxButton`。
|
|
9
|
-
* `ui/ConfirmDialog.tsx` 保持不动作参考;需要本实现时在页面中改 import 指向本文件即可。
|
|
10
|
-
*/
|
|
11
|
-
interface ConfirmDialogProps {
|
|
12
|
-
isOpen: boolean
|
|
13
|
-
onClose: () => void
|
|
14
|
-
onConfirm: () => void
|
|
15
|
-
title: string
|
|
16
|
-
message: string
|
|
17
|
-
/** 遮罩层额外 class(如嵌套在 antd Modal 内时用 `z-[2000]` 盖住主弹窗) */
|
|
18
|
-
overlayClassName?: string
|
|
19
|
-
confirmText?: string
|
|
20
|
-
cancelText?: string
|
|
21
|
-
/** 为 true 时隐藏取消按钮(结果提示场景只需要一个按钮) */
|
|
22
|
-
hideCancel?: boolean
|
|
23
|
-
/** 为 true 时交换主/次按钮顺序 */
|
|
24
|
-
swapButtons?: boolean
|
|
25
|
-
danger?: boolean
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
const ConfirmDialog: React.FC<ConfirmDialogProps> = ({
|
|
29
|
-
isOpen,
|
|
30
|
-
onClose,
|
|
31
|
-
onConfirm,
|
|
32
|
-
title,
|
|
33
|
-
message,
|
|
34
|
-
overlayClassName,
|
|
35
|
-
confirmText,
|
|
36
|
-
cancelText,
|
|
37
|
-
hideCancel = false,
|
|
38
|
-
swapButtons = false,
|
|
39
|
-
danger = false,
|
|
40
|
-
}) => {
|
|
41
|
-
const { t } = useTranslation()
|
|
42
|
-
|
|
43
|
-
if (!isOpen) return null
|
|
44
|
-
|
|
45
|
-
const overlayClass = ['fixed inset-0 bg-black/50 flex items-center justify-center p-4 z-50', overlayClassName]
|
|
46
|
-
.filter(Boolean)
|
|
47
|
-
.join(' ')
|
|
48
|
-
|
|
49
|
-
const confirmButton = danger ? (
|
|
50
|
-
<CxButton color="danger" variant="solid" onClick={onConfirm}>
|
|
51
|
-
{confirmText || t('common.confirm')}
|
|
52
|
-
</CxButton>
|
|
53
|
-
) : (
|
|
54
|
-
<CxButton type="primary" onClick={onConfirm}>
|
|
55
|
-
{confirmText || t('common.confirm')}
|
|
56
|
-
</CxButton>
|
|
57
|
-
)
|
|
58
|
-
|
|
59
|
-
const cancelButton = hideCancel ? null : (
|
|
60
|
-
<CxButtonCancel onClick={onClose}>
|
|
61
|
-
{cancelText || t('common.cancel')}
|
|
62
|
-
</CxButtonCancel>
|
|
63
|
-
)
|
|
64
|
-
|
|
65
|
-
return (
|
|
66
|
-
<div className={overlayClass}>
|
|
67
|
-
<div className="bg-white dark:bg-gray-800 rounded-xl shadow-2xl max-w-md w-full">
|
|
68
|
-
<div className="p-6">
|
|
69
|
-
<div className="flex items-start gap-4">
|
|
70
|
-
{danger && (
|
|
71
|
-
<div className="flex-shrink-0 w-10 h-10 bg-red-100 dark:bg-red-900/30 rounded-full flex items-center justify-center">
|
|
72
|
-
<AlertTriangle
|
|
73
|
-
size={20}
|
|
74
|
-
className="text-red-600 dark:text-red-400"
|
|
75
|
-
/>
|
|
76
|
-
</div>
|
|
77
|
-
)}
|
|
78
|
-
<div className="flex-1 min-w-0">
|
|
79
|
-
<h3 className="text-lg font-semibold text-gray-900 dark:text-white mb-2">
|
|
80
|
-
{title}
|
|
81
|
-
</h3>
|
|
82
|
-
<p className="text-sm text-gray-600 dark:text-gray-400 whitespace-pre-line max-h-[45vh] overflow-auto pr-1">
|
|
83
|
-
{message}
|
|
84
|
-
</p>
|
|
85
|
-
</div>
|
|
86
|
-
<CxButtonIcon
|
|
87
|
-
type="default"
|
|
88
|
-
icon={<X size={20} />}
|
|
89
|
-
onClick={onClose}
|
|
90
|
-
title={t('common.close')}
|
|
91
|
-
className="text-gray-400 hover:text-gray-600 dark:hover:text-gray-200"
|
|
92
|
-
/>
|
|
93
|
-
</div>
|
|
94
|
-
</div>
|
|
95
|
-
<div className="px-6 py-4 bg-gray-50 dark:bg-gray-700/50 rounded-b-xl flex justify-end gap-3">
|
|
96
|
-
{swapButtons ? (
|
|
97
|
-
<>
|
|
98
|
-
{confirmButton}
|
|
99
|
-
{cancelButton}
|
|
100
|
-
</>
|
|
101
|
-
) : (
|
|
102
|
-
<>
|
|
103
|
-
{cancelButton}
|
|
104
|
-
{confirmButton}
|
|
105
|
-
</>
|
|
106
|
-
)}
|
|
107
|
-
</div>
|
|
108
|
-
</div>
|
|
109
|
-
</div>
|
|
110
|
-
)
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
export default ConfirmDialog
|