cx-chat 0.0.1 → 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 -264
- /package/{public → dist}/favicon.ico +0 -0
- /package/{public → dist}/vite.svg +0 -0
|
@@ -1,291 +0,0 @@
|
|
|
1
|
-
import { getImgAPI, uploadFileAPI } from '@/api/upload'
|
|
2
|
-
import { DeleteOutlined, EyeOutlined, PlusOutlined } from '@ant-design/icons'
|
|
3
|
-
import { CxModal, useCxModal } from '@cx-ui'
|
|
4
|
-
import aesUtil from '@utils/aesUtil'
|
|
5
|
-
import type { UploadFile, UploadProps } from 'antd'
|
|
6
|
-
import { Button, Upload, message } from 'antd'
|
|
7
|
-
import type { RcFile } from 'antd/es/upload'
|
|
8
|
-
import React, { useEffect, useState } from 'react'
|
|
9
|
-
|
|
10
|
-
// 回显图片缓存:避免同一 address 重复请求 getImg(开发环境 StrictMode 下尤为明显)
|
|
11
|
-
const IMG_OBJECT_URL_CACHE = new Map<string, string>()
|
|
12
|
-
const IMG_OBJECT_URL_PENDING = new Map<string, Promise<string>>()
|
|
13
|
-
|
|
14
|
-
const isPreviewableUrl = (url: unknown) => {
|
|
15
|
-
if (url == null) return false
|
|
16
|
-
const str = String(url)
|
|
17
|
-
return /^https?:\/\//i.test(str) || /^data:/i.test(str) || /^blob:/i.test(str)
|
|
18
|
-
}
|
|
19
|
-
export type UploadImgProps = {
|
|
20
|
-
/** 回显用的地址集合(编辑态传入),例如 ['addr1','addr2'] */
|
|
21
|
-
value?: string[]
|
|
22
|
-
/** 上传成功后的回调:直接回传上传后的 fileList(antd UploadFile[])。 */
|
|
23
|
-
onUploaded?: (fileList: UploadFile[]) => void
|
|
24
|
-
/** 是否公开图片:影响上传参数与回显取图接口,默认 false */
|
|
25
|
-
isPublic?: boolean
|
|
26
|
-
/** 最大图片大小(KB),默认 5120KB(5MB) */
|
|
27
|
-
maxSizeKB?: number
|
|
28
|
-
/** 接受的文件类型,默认 image/* */
|
|
29
|
-
accept?: string
|
|
30
|
-
/** 是否禁用 */
|
|
31
|
-
disabled?: boolean
|
|
32
|
-
/** 上传列表样式,默认 picture-card */
|
|
33
|
-
listType?: UploadProps['listType']
|
|
34
|
-
/** 允许上传的最大个数,默认 1 */
|
|
35
|
-
maxCount?: number
|
|
36
|
-
/** 缩略图尺寸(px),默认 104 */
|
|
37
|
-
thumbSize?: number
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/** 图片上传组件:上传到固定地址 uploadImageUrl,内部处理大小校验/失败提示;成功后回调文件 address 给上级。 */
|
|
41
|
-
const UploadImg: React.FC<UploadImgProps> = ({
|
|
42
|
-
value,
|
|
43
|
-
onUploaded,
|
|
44
|
-
isPublic = false,
|
|
45
|
-
maxSizeKB = 5 * 1024,
|
|
46
|
-
accept = 'image/*',
|
|
47
|
-
disabled = false,
|
|
48
|
-
listType = 'picture-card',
|
|
49
|
-
maxCount = 1,
|
|
50
|
-
thumbSize = 104,
|
|
51
|
-
}) => {
|
|
52
|
-
const [uploadFileList, setUploadFileList] = useState<UploadFile[]>([])
|
|
53
|
-
const [previewTitle, setPreviewTitle] = useState('')
|
|
54
|
-
const [previewUrl, setPreviewUrl] = useState('')
|
|
55
|
-
const previewModal = useCxModal()
|
|
56
|
-
|
|
57
|
-
useEffect(() => {
|
|
58
|
-
let cancelled = false
|
|
59
|
-
|
|
60
|
-
const run = async () => {
|
|
61
|
-
const list = Array.isArray(value) ? value : []
|
|
62
|
-
if (list.length === 0) {
|
|
63
|
-
setUploadFileList([])
|
|
64
|
-
return
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
const next = await Promise.all(
|
|
68
|
-
list.map(async (address) => {
|
|
69
|
-
try {
|
|
70
|
-
const cacheKey = `${isPublic ? 1 : 0}:${String(address)}`
|
|
71
|
-
const cachedUrl = IMG_OBJECT_URL_CACHE.get(cacheKey)
|
|
72
|
-
if (cachedUrl) {
|
|
73
|
-
return {
|
|
74
|
-
uid: address,
|
|
75
|
-
name: 'image.png',
|
|
76
|
-
status: 'done',
|
|
77
|
-
url: cachedUrl,
|
|
78
|
-
} as UploadFile
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
const pending = IMG_OBJECT_URL_PENDING.get(cacheKey)
|
|
82
|
-
const urlPromise =
|
|
83
|
-
pending ??
|
|
84
|
-
(async () => {
|
|
85
|
-
const blob: any = await getImgAPI({ isPublic, url: aesUtil.encrypt(address) })
|
|
86
|
-
const url = blob ? URL.createObjectURL(blob) : ''
|
|
87
|
-
if (url) IMG_OBJECT_URL_CACHE.set(cacheKey, url)
|
|
88
|
-
return url
|
|
89
|
-
})()
|
|
90
|
-
|
|
91
|
-
if (!pending) IMG_OBJECT_URL_PENDING.set(cacheKey, urlPromise)
|
|
92
|
-
const url = await urlPromise
|
|
93
|
-
IMG_OBJECT_URL_PENDING.delete(cacheKey)
|
|
94
|
-
return {
|
|
95
|
-
uid: address,
|
|
96
|
-
name: 'image.png',
|
|
97
|
-
status: 'done',
|
|
98
|
-
url,
|
|
99
|
-
} as UploadFile
|
|
100
|
-
} catch {
|
|
101
|
-
return {
|
|
102
|
-
uid: address,
|
|
103
|
-
name: 'image.png',
|
|
104
|
-
status: 'done',
|
|
105
|
-
url: '',
|
|
106
|
-
} as UploadFile
|
|
107
|
-
}
|
|
108
|
-
})
|
|
109
|
-
)
|
|
110
|
-
|
|
111
|
-
if (cancelled) return
|
|
112
|
-
setUploadFileList(next)
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
void run()
|
|
116
|
-
return () => {
|
|
117
|
-
cancelled = true
|
|
118
|
-
}
|
|
119
|
-
}, [value, isPublic])
|
|
120
|
-
|
|
121
|
-
/** 自定义上传:调用 uploadFileAPI,拦截器已统一解密。 */
|
|
122
|
-
const customUpload: UploadProps['customRequest'] = async (options) => {
|
|
123
|
-
const { file, onSuccess, onError } = options
|
|
124
|
-
|
|
125
|
-
try {
|
|
126
|
-
const response: any = await uploadFileAPI({
|
|
127
|
-
file: file as RcFile,
|
|
128
|
-
isPublic,
|
|
129
|
-
})
|
|
130
|
-
|
|
131
|
-
// 拦截器返回 { code: 200, data: {...} },需取 data 字段
|
|
132
|
-
const respData: any = response.data || response
|
|
133
|
-
|
|
134
|
-
if (respData && typeof respData === 'object') {
|
|
135
|
-
respData.uid = respData.uid ?? respData.id ?? (file as any).uid
|
|
136
|
-
// address 可能只是 key,不一定是可直接访问的预览 URL
|
|
137
|
-
if (isPreviewableUrl(respData.address)) {
|
|
138
|
-
respData.url = respData.address
|
|
139
|
-
} else {
|
|
140
|
-
const origin = file as File
|
|
141
|
-
respData.url = origin ? URL.createObjectURL(origin) : ''
|
|
142
|
-
}
|
|
143
|
-
respData.status = 'done'
|
|
144
|
-
respData.name = respData.name || 'image.png'
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
setUploadFileList((prev) => {
|
|
148
|
-
// 移除 uploading 阶段的那一项,避免残留 loading 卡片
|
|
149
|
-
const uploadingUid = (file as any).uid
|
|
150
|
-
const filtered = (prev || []).filter((x: any) => x && x.uid !== uploadingUid)
|
|
151
|
-
const next = [...filtered, respData as any]
|
|
152
|
-
onUploaded?.(next as any)
|
|
153
|
-
return next as any
|
|
154
|
-
})
|
|
155
|
-
|
|
156
|
-
onSuccess?.(respData)
|
|
157
|
-
} catch (error: any) {
|
|
158
|
-
message.error('上传失败,请重试')
|
|
159
|
-
onError?.(error)
|
|
160
|
-
|
|
161
|
-
setUploadFileList((prev) => {
|
|
162
|
-
const uploadingUid = (file as any).uid
|
|
163
|
-
return (prev || []).filter((x: any) => x && x.uid !== uploadingUid)
|
|
164
|
-
})
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
/** 上传前校验图片大小:最大不超过 5MB(默认 5120KB)。 */
|
|
169
|
-
const beforeUpload: UploadProps['beforeUpload'] = (file) => {
|
|
170
|
-
const sizeLimit = Math.max(1, Number(maxSizeKB || 0)) * 1024
|
|
171
|
-
if (file.size > sizeLimit) {
|
|
172
|
-
const maxMB = (Number(maxSizeKB || 0) / 1024).toFixed(0)
|
|
173
|
-
message.error(`图片不能超过 ${maxMB}MB`)
|
|
174
|
-
return false
|
|
175
|
-
}
|
|
176
|
-
return true
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
/** 移除文件:从列表中移除并同步到上级。 */
|
|
180
|
-
const handleRemove: UploadProps['onRemove'] = (file) => {
|
|
181
|
-
const removeUid = file.uid
|
|
182
|
-
const next = uploadFileList.filter((x: any) => x && x.uid !== removeUid)
|
|
183
|
-
setUploadFileList(next)
|
|
184
|
-
onUploaded?.(next)
|
|
185
|
-
return true
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
/** 预览图片:组件内用 CxModal 放大查看。 */
|
|
189
|
-
const handlePreview: UploadProps['onPreview'] = (file) => {
|
|
190
|
-
const url = (file as any)?.url
|
|
191
|
-
if (!url) return
|
|
192
|
-
setPreviewTitle(file.name || '')
|
|
193
|
-
setPreviewUrl(`${url}`)
|
|
194
|
-
previewModal.open({ opeType: 'detail' })
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
return (
|
|
198
|
-
<>
|
|
199
|
-
{/* 自定义渲染图片列表 */}
|
|
200
|
-
{uploadFileList.length > 0 && (
|
|
201
|
-
<div style={{ display: 'flex', flexWrap: 'wrap', gap: 8 }}>
|
|
202
|
-
{uploadFileList.map((file) => {
|
|
203
|
-
const thumbUrl = file.url || ''
|
|
204
|
-
return (
|
|
205
|
-
<div
|
|
206
|
-
key={file.uid}
|
|
207
|
-
style={{
|
|
208
|
-
width: thumbSize,
|
|
209
|
-
height: thumbSize,
|
|
210
|
-
border: '1px solid rgba(5,5,5,0.06)',
|
|
211
|
-
borderRadius: 6,
|
|
212
|
-
position: 'relative',
|
|
213
|
-
overflow: 'hidden',
|
|
214
|
-
}}
|
|
215
|
-
>
|
|
216
|
-
{/* eslint-disable-next-line @next/next/no-img-element */}
|
|
217
|
-
<img
|
|
218
|
-
src={thumbUrl}
|
|
219
|
-
alt={file.name}
|
|
220
|
-
style={{
|
|
221
|
-
width: '100%',
|
|
222
|
-
height: '100%',
|
|
223
|
-
objectFit: 'cover',
|
|
224
|
-
display: 'block',
|
|
225
|
-
}}
|
|
226
|
-
onClick={() => handlePreview(file)}
|
|
227
|
-
/>
|
|
228
|
-
{!disabled && (
|
|
229
|
-
<div
|
|
230
|
-
style={{
|
|
231
|
-
position: 'absolute',
|
|
232
|
-
inset: 0,
|
|
233
|
-
background: 'rgba(0,0,0,0.45)',
|
|
234
|
-
display: 'flex',
|
|
235
|
-
alignItems: 'center',
|
|
236
|
-
justifyContent: 'center',
|
|
237
|
-
gap: 10,
|
|
238
|
-
opacity: 0,
|
|
239
|
-
transition: 'opacity 0.2s',
|
|
240
|
-
}}
|
|
241
|
-
className="cx-upload-img-mask"
|
|
242
|
-
onMouseEnter={(e) => {
|
|
243
|
-
e.currentTarget.style.opacity = '1'
|
|
244
|
-
}}
|
|
245
|
-
onMouseLeave={(e) => {
|
|
246
|
-
e.currentTarget.style.opacity = '0'
|
|
247
|
-
}}
|
|
248
|
-
>
|
|
249
|
-
<Button type="text" icon={<EyeOutlined />} onClick={() => handlePreview(file)} />
|
|
250
|
-
<Button type="text" icon={<DeleteOutlined />} onClick={() => handleRemove(file)} />
|
|
251
|
-
</div>
|
|
252
|
-
)}
|
|
253
|
-
</div>
|
|
254
|
-
)
|
|
255
|
-
})}
|
|
256
|
-
</div>
|
|
257
|
-
)}
|
|
258
|
-
|
|
259
|
-
{/* Upload 组件仅负责上传,不显示文件列表 */}
|
|
260
|
-
{uploadFileList.length < maxCount && (
|
|
261
|
-
<Upload
|
|
262
|
-
accept={accept}
|
|
263
|
-
listType="picture-card"
|
|
264
|
-
maxCount={maxCount}
|
|
265
|
-
multiple={Number(maxCount || 1) > 1}
|
|
266
|
-
disabled={disabled}
|
|
267
|
-
fileList={[]}
|
|
268
|
-
beforeUpload={beforeUpload}
|
|
269
|
-
customRequest={customUpload}
|
|
270
|
-
showUploadList={false}
|
|
271
|
-
>
|
|
272
|
-
<PlusOutlined />
|
|
273
|
-
</Upload>
|
|
274
|
-
)}
|
|
275
|
-
|
|
276
|
-
<CxModal
|
|
277
|
-
isOpen={previewModal.isOpen}
|
|
278
|
-
title={previewTitle}
|
|
279
|
-
onClose={previewModal.close}
|
|
280
|
-
opeType="detail"
|
|
281
|
-
modalConfig={{ width: 900 }}
|
|
282
|
-
>
|
|
283
|
-
{/* eslint-disable-next-line @next/next/no-img-element */}
|
|
284
|
-
<img alt={previewTitle} src={previewUrl} style={{ width: '100%', display: 'block' }} />
|
|
285
|
-
</CxModal>
|
|
286
|
-
</>
|
|
287
|
-
)
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
export default UploadImg
|
|
291
|
-
|
|
@@ -1,216 +0,0 @@
|
|
|
1
|
-
import clsx from 'clsx';
|
|
2
|
-
import { LibraryBig, LogOut, Moon, Settings, Sun } from 'lucide-react';
|
|
3
|
-
import React, { useEffect, useState } from 'react';
|
|
4
|
-
import { useTranslation } from 'react-i18next';
|
|
5
|
-
import { Link } from 'react-router-dom';
|
|
6
|
-
|
|
7
|
-
import LanguageSwitcher from '@/components/common/language-switcher';
|
|
8
|
-
import { CurrentUserAvatar } from '@/components/auth/current-user-avatar';
|
|
9
|
-
import { getStore, setStore } from '@/utils/storage';
|
|
10
|
-
import { useSystemConfig } from '@/config/system'
|
|
11
|
-
import { useUserPreferences } from '../../../hooks/useUserPreferences';
|
|
12
|
-
|
|
13
|
-
type HeaderProps = {
|
|
14
|
-
user: any;
|
|
15
|
-
hasPermission: (permission: string) => boolean;
|
|
16
|
-
headerTitle: React.ReactNode | null;
|
|
17
|
-
isUserMenuOpen: boolean;
|
|
18
|
-
setIsUserMenuOpen: React.Dispatch<React.SetStateAction<boolean>>;
|
|
19
|
-
onLogout: () => void;
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
/** 右上角主文案:优先真实姓名/昵称,再退到账号(手机、邮箱),与权限字段无关 */
|
|
23
|
-
function headerPrimaryLabel(u: any): string {
|
|
24
|
-
if (!u) return 'User';
|
|
25
|
-
const prefer =
|
|
26
|
-
u.name ||
|
|
27
|
-
u.nickname ||
|
|
28
|
-
u.nickName ||
|
|
29
|
-
u.realName ||
|
|
30
|
-
u.real_name ||
|
|
31
|
-
u.display_name ||
|
|
32
|
-
u.userName ||
|
|
33
|
-
u.username;
|
|
34
|
-
const s = typeof prefer === 'string' ? prefer.trim() : '';
|
|
35
|
-
if (s) return s;
|
|
36
|
-
const acct = u.phone || u.phone_number || u.email;
|
|
37
|
-
return acct ? String(acct).trim() : 'User';
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
function headerSubLabel(u: any): string {
|
|
41
|
-
if (!u) return '';
|
|
42
|
-
const mail = typeof u.email === 'string' ? u.email.trim() : '';
|
|
43
|
-
const tel = u.phone || u.phone_number;
|
|
44
|
-
const ts = tel != null ? String(tel).trim() : '';
|
|
45
|
-
if (mail && ts && mail !== ts) return `${mail} · ${ts}`;
|
|
46
|
-
return mail || ts || '';
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
// 语言切换已改为下拉组件(LanguageSwitcher)
|
|
50
|
-
|
|
51
|
-
const Header: React.FC<HeaderProps> = ({
|
|
52
|
-
user,
|
|
53
|
-
hasPermission,
|
|
54
|
-
headerTitle,
|
|
55
|
-
isUserMenuOpen,
|
|
56
|
-
setIsUserMenuOpen,
|
|
57
|
-
onLogout,
|
|
58
|
-
}) => {
|
|
59
|
-
const { t, i18n } = useTranslation();
|
|
60
|
-
const { saveTheme, saveLanguage } = useUserPreferences();
|
|
61
|
-
const { systemLogo: appLogoUrl, systemName: appName } = useSystemConfig()
|
|
62
|
-
const [theme, setTheme] = useState<'light' | 'dark'>(() => {
|
|
63
|
-
// const stored = localStorage.getItem('theme');
|
|
64
|
-
const stored = getStore('theme');
|
|
65
|
-
if (stored === 'dark' || stored === 'light') return stored;
|
|
66
|
-
return window.matchMedia &&
|
|
67
|
-
window.matchMedia('(prefers-color-scheme: dark)').matches
|
|
68
|
-
? 'dark'
|
|
69
|
-
: 'light';
|
|
70
|
-
});
|
|
71
|
-
const userName = headerPrimaryLabel(user);
|
|
72
|
-
const userSub = headerSubLabel(user);
|
|
73
|
-
|
|
74
|
-
useEffect(() => {
|
|
75
|
-
if (theme === 'dark') {
|
|
76
|
-
document.documentElement.classList.add('dark');
|
|
77
|
-
} else {
|
|
78
|
-
document.documentElement.classList.remove('dark');
|
|
79
|
-
}
|
|
80
|
-
setStore('theme', theme);
|
|
81
|
-
// localStorage.setItem('theme', theme);
|
|
82
|
-
}, [theme, saveTheme]);
|
|
83
|
-
|
|
84
|
-
const toggleTheme = (e: React.MouseEvent) => {
|
|
85
|
-
e.stopPropagation();
|
|
86
|
-
const next = theme === 'light' ? 'dark' : 'light';
|
|
87
|
-
setTheme(next);
|
|
88
|
-
void saveTheme(next);
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
// 语言切换改为下拉组件(未来可扩展多语言)
|
|
92
|
-
|
|
93
|
-
return (
|
|
94
|
-
<header className="flex items-center justify-between px-6 py-3 bg-white dark:bg-[#131314] relative border-b border-transparent dark:border-gray-800/50 transition-colors">
|
|
95
|
-
<div className="flex items-center gap-3 relative z-10 min-w-[200px]">
|
|
96
|
-
{appLogoUrl ? (
|
|
97
|
-
<img
|
|
98
|
-
src={appLogoUrl}
|
|
99
|
-
alt={appName}
|
|
100
|
-
className="w-8 h-8 rounded-lg object-cover"
|
|
101
|
-
/>
|
|
102
|
-
) : (
|
|
103
|
-
<div className="w-8 h-8 bg-blue-600 rounded-lg flex items-center justify-center text-white font-bold shrink-0">
|
|
104
|
-
{appName.substring(0, 2).toUpperCase()}
|
|
105
|
-
</div>
|
|
106
|
-
)}
|
|
107
|
-
<span className="font-bold text-xl text-gray-900 dark:text-white whitespace-nowrap hidden md:block">
|
|
108
|
-
{appName}
|
|
109
|
-
</span>
|
|
110
|
-
</div>
|
|
111
|
-
|
|
112
|
-
{headerTitle ? (
|
|
113
|
-
<div className="absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 z-20">
|
|
114
|
-
{typeof headerTitle === 'string' ? (
|
|
115
|
-
<div className="font-semibold text-gray-900 dark:text-white animate-in fade-in slide-in-from-top-2 duration-200 pointer-events-none">
|
|
116
|
-
{headerTitle}
|
|
117
|
-
</div>
|
|
118
|
-
) : (
|
|
119
|
-
headerTitle
|
|
120
|
-
)}
|
|
121
|
-
</div>
|
|
122
|
-
) : null}
|
|
123
|
-
|
|
124
|
-
<div className="relative z-10 flex justify-end min-w-[260px]">
|
|
125
|
-
<div
|
|
126
|
-
className="flex items-center gap-1 mr-2"
|
|
127
|
-
onClick={(e) => e.stopPropagation()}>
|
|
128
|
-
<button
|
|
129
|
-
type="button"
|
|
130
|
-
onClick={toggleTheme}
|
|
131
|
-
className="p-2 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors text-gray-500 dark:text-gray-400"
|
|
132
|
-
title={t('base.settings.theme')}>
|
|
133
|
-
{theme === 'light' ? (
|
|
134
|
-
<Sun size={18} className="text-yellow-500" />
|
|
135
|
-
) : (
|
|
136
|
-
<Moon size={18} className="text-blue-400" />
|
|
137
|
-
)}
|
|
138
|
-
<span className="sr-only">{t('base.settings.theme')}</span>
|
|
139
|
-
</button>
|
|
140
|
-
<LanguageSwitcher direction="down" showCode />
|
|
141
|
-
</div>
|
|
142
|
-
<div
|
|
143
|
-
className={clsx(
|
|
144
|
-
'flex items-center gap-3 cursor-pointer py-1.5 pl-4 pr-3.5 rounded-full border transition-all duration-200',
|
|
145
|
-
isUserMenuOpen
|
|
146
|
-
? 'bg-white dark:bg-gray-800 border-gray-200 dark:border-gray-700 shadow-sm'
|
|
147
|
-
: 'border-transparent hover:bg-gray-100 dark:hover:bg-gray-800',
|
|
148
|
-
)}
|
|
149
|
-
onClick={(e) => {
|
|
150
|
-
e.stopPropagation();
|
|
151
|
-
setIsUserMenuOpen(!isUserMenuOpen);
|
|
152
|
-
}}
|
|
153
|
-
title={t('common.settings')}>
|
|
154
|
-
<div className="hidden md:block text-right">
|
|
155
|
-
<span className="text-sm font-medium text-gray-700 dark:text-gray-200">
|
|
156
|
-
{userName}
|
|
157
|
-
</span>
|
|
158
|
-
</div>
|
|
159
|
-
<CurrentUserAvatar
|
|
160
|
-
alt={userName}
|
|
161
|
-
className="h-8 w-8 shrink-0"
|
|
162
|
-
fallbackTone="brand"
|
|
163
|
-
/>
|
|
164
|
-
</div>
|
|
165
|
-
|
|
166
|
-
{isUserMenuOpen && (
|
|
167
|
-
<div
|
|
168
|
-
className="absolute right-0 top-full mt-2 w-56 bg-white dark:bg-gray-800 rounded-xl shadow-2xl border border-gray-100 dark:border-gray-700 py-2 overflow-hidden animate-fade-in-up"
|
|
169
|
-
onClick={(e) => e.stopPropagation()}>
|
|
170
|
-
<div className="px-4 py-3 border-b border-gray-100 dark:border-gray-700 mb-1">
|
|
171
|
-
<p className="text-sm font-medium text-gray-900 dark:text-white truncate">
|
|
172
|
-
{userName}
|
|
173
|
-
</p>
|
|
174
|
-
{userSub ? (
|
|
175
|
-
<p
|
|
176
|
-
className="text-xs text-gray-500 dark:text-gray-400 truncate"
|
|
177
|
-
title={userSub}>
|
|
178
|
-
{userSub}
|
|
179
|
-
</p>
|
|
180
|
-
) : null}
|
|
181
|
-
</div>
|
|
182
|
-
|
|
183
|
-
<Link
|
|
184
|
-
to="/settings"
|
|
185
|
-
onClick={() => setIsUserMenuOpen(false)}
|
|
186
|
-
className="flex items-center gap-3 px-4 py-2.5 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-700/50 transition-colors">
|
|
187
|
-
<Settings size={16} />
|
|
188
|
-
<span>{t('common.settings')}</span>
|
|
189
|
-
</Link>
|
|
190
|
-
|
|
191
|
-
{hasPermission('system:long-memory:page') && (
|
|
192
|
-
<Link
|
|
193
|
-
to="/memories"
|
|
194
|
-
onClick={() => setIsUserMenuOpen(false)}
|
|
195
|
-
className="flex items-center gap-3 px-4 py-2.5 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-700/50 transition-colors">
|
|
196
|
-
<LibraryBig size={16} />
|
|
197
|
-
<span>{t('common.memory')}</span>
|
|
198
|
-
</Link>
|
|
199
|
-
)}
|
|
200
|
-
|
|
201
|
-
<div className="h-px bg-gray-100 dark:bg-gray-700 my-1" />
|
|
202
|
-
|
|
203
|
-
<button
|
|
204
|
-
onClick={onLogout}
|
|
205
|
-
className="w-full flex items-center gap-3 px-4 py-2.5 text-sm text-red-600 dark:text-red-400 hover:bg-red-50 dark:hover:bg-red-900/10 transition-colors">
|
|
206
|
-
<LogOut size={16} />
|
|
207
|
-
<span>{t('auth.logout')}</span>
|
|
208
|
-
</button>
|
|
209
|
-
</div>
|
|
210
|
-
)}
|
|
211
|
-
</div>
|
|
212
|
-
</header>
|
|
213
|
-
);
|
|
214
|
-
};
|
|
215
|
-
|
|
216
|
-
export default Header;
|