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,657 +0,0 @@
|
|
|
1
|
-
import { changePasswordAPI, updateUserPersonalCenterAPI } from '@/api/system/user';
|
|
2
|
-
import { uploadFileAPI } from '@/api/upload';
|
|
3
|
-
import LanguageSwitcher from '@/components/common/language-switcher';
|
|
4
|
-
import { countryCodes } from '@/constants/countryCodes';
|
|
5
|
-
import { useAuth } from '@/contexts/AuthContext';
|
|
6
|
-
import { useToast } from '@/contexts/ToastContext';
|
|
7
|
-
import { useStickyHeader } from '@/hooks/useStickyHeader';
|
|
8
|
-
import { useUserPreferences } from '@/hooks/useUserPreferences';
|
|
9
|
-
import { request } from '@/http/axios';
|
|
10
|
-
import { getStore, setStore } from '@/utils/storage';
|
|
11
|
-
import { CxButton, CxForm, CxFormItem, CxInput, CxModal, CxSelect } from '@cx-ui';
|
|
12
|
-
import { resolveAvatarUrl } from '@utils/url';
|
|
13
|
-
import { validatePhoneNumber } from '@utils/validation';
|
|
14
|
-
import { Form } from 'antd';
|
|
15
|
-
import { Check, Loader2, Moon, Pencil, Settings as SettingsIcon, Sun, SwatchBook, Trash2, Upload, UserCog, UserLock, X } from 'lucide-react';
|
|
16
|
-
import React, { useEffect, useRef, useState } from 'react';
|
|
17
|
-
import { useTranslation } from 'react-i18next';
|
|
18
|
-
const SettingsPage: React.FC = () => {
|
|
19
|
-
const { user, refreshUser, logout } = useAuth();
|
|
20
|
-
const { t } = useTranslation();
|
|
21
|
-
const { saveTheme } = useUserPreferences();
|
|
22
|
-
// Global UI State
|
|
23
|
-
const [theme, setTheme] = useState<'light' | 'dark'>(() => {
|
|
24
|
-
// const stored = localStorage.getItem('theme');
|
|
25
|
-
const stored = getStore('theme');
|
|
26
|
-
if (stored === 'dark' || stored === 'light') return stored;
|
|
27
|
-
return window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
|
|
28
|
-
});
|
|
29
|
-
const { showToast } = useToast();
|
|
30
|
-
const userName = user?.name || '';
|
|
31
|
-
const userAvatar = user?.avatar || '';
|
|
32
|
-
/** 当前用户手机号:兼容后端返回 phone 为 “+86 138xxx” 或仅号码,以及单独返回 areaCode 的场景。 */
|
|
33
|
-
const userPhoneRaw = (user as any)?.phone ?? '';
|
|
34
|
-
const userAreaCodeRaw =
|
|
35
|
-
(user as any)?.areaCode ??
|
|
36
|
-
(user as any)?.phoneAreaCode ??
|
|
37
|
-
(user as any)?.countryCode ??
|
|
38
|
-
'';
|
|
39
|
-
|
|
40
|
-
/** 将手机号来源拆成区号与号码,兼容历史 “+86 138xxxx” 格式。 */
|
|
41
|
-
const parseAreaCodeAndPhone = (rawAreaCode: unknown, rawPhone: unknown) => {
|
|
42
|
-
const areaFromField = rawAreaCode != null && rawAreaCode !== '' ? String(rawAreaCode).trim() : '';
|
|
43
|
-
const phoneFromField = rawPhone != null && rawPhone !== '' ? String(rawPhone).trim() : '';
|
|
44
|
-
|
|
45
|
-
if (areaFromField) {
|
|
46
|
-
return {
|
|
47
|
-
areaCode: areaFromField,
|
|
48
|
-
phone: phoneFromField,
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
if (!phoneFromField) {
|
|
53
|
-
return { areaCode: '+86', phone: '' };
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
const parts = phoneFromField.split(/\s+/).filter(Boolean);
|
|
57
|
-
if (parts.length > 1 && String(parts[0]).startsWith('+')) {
|
|
58
|
-
return { areaCode: String(parts[0]), phone: parts.slice(1).join(' ') };
|
|
59
|
-
}
|
|
60
|
-
return { areaCode: '+86', phone: phoneFromField };
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
const initialPhoneParts = parseAreaCodeAndPhone(userAreaCodeRaw, userPhoneRaw);
|
|
64
|
-
|
|
65
|
-
// Avatar State
|
|
66
|
-
const [isUploading, setIsUploading] = useState(false);
|
|
67
|
-
const [avatarUrl, setAvatarUrl] = useState(userAvatar);
|
|
68
|
-
const fileInputRef = useRef<HTMLInputElement>(null);
|
|
69
|
-
|
|
70
|
-
// Display Name State
|
|
71
|
-
const [displayName, setDisplayName] = useState(userName);
|
|
72
|
-
const [isEditingName, setIsEditingName] = useState(false);
|
|
73
|
-
const [isSavingName, setIsSavingName] = useState(false);
|
|
74
|
-
|
|
75
|
-
// Phone Number State
|
|
76
|
-
const [isEditingPhone, setIsEditingPhone] = useState(false);
|
|
77
|
-
const [isSavingPhone, setIsSavingPhone] = useState(false);
|
|
78
|
-
const [isPhoneRevealed, setIsPhoneRevealed] = useState(false);
|
|
79
|
-
const [phoneNumber, setPhoneNumber] = useState(() => initialPhoneParts.phone);
|
|
80
|
-
const [countryCode, setCountryCode] = useState(() => initialPhoneParts.areaCode);
|
|
81
|
-
|
|
82
|
-
// Password State
|
|
83
|
-
const [isEditingPassword, setIsEditingPassword] = useState(false);
|
|
84
|
-
const [isSavingPassword, setIsSavingPassword] = useState(false);
|
|
85
|
-
const [passwordForm] = Form.useForm<{
|
|
86
|
-
oldPassword: string;
|
|
87
|
-
newPassword: string;
|
|
88
|
-
confirmPassword: string;
|
|
89
|
-
}>();
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
/** 监听主题变化:同步到 html class 与 localStorage(不在初始化时打接口)。 */
|
|
93
|
-
useEffect(() => {
|
|
94
|
-
if (theme === 'dark') {
|
|
95
|
-
document.documentElement.classList.add('dark');
|
|
96
|
-
} else {
|
|
97
|
-
document.documentElement.classList.remove('dark');
|
|
98
|
-
}
|
|
99
|
-
setStore('theme', theme);
|
|
100
|
-
// localStorage.setItem('theme', theme);
|
|
101
|
-
}, [theme, saveTheme]);
|
|
102
|
-
|
|
103
|
-
/** 切换明暗主题:立即更新 UI,并调用接口持久化到服务端。 */
|
|
104
|
-
const toggleTheme = () => {
|
|
105
|
-
const next = theme === 'light' ? 'dark' : 'light';
|
|
106
|
-
setTheme(next);
|
|
107
|
-
void saveTheme(next);
|
|
108
|
-
};
|
|
109
|
-
|
|
110
|
-
// --- Avatar Logic ---
|
|
111
|
-
/** 更新个人中心头像:调用 updateUserPersonalCenterAPI 写回头像字段,并刷新用户信息。 */
|
|
112
|
-
const updateAvatarByPersonalCenter = async (avatar: any) => {
|
|
113
|
-
const uid = user?.id;
|
|
114
|
-
if (uid === undefined || uid === null || String(uid) === '') {
|
|
115
|
-
showToast(t('base.settings.save_failed'), 'error');
|
|
116
|
-
return;
|
|
117
|
-
}
|
|
118
|
-
await updateUserPersonalCenterAPI({
|
|
119
|
-
id: uid,
|
|
120
|
-
avatar,
|
|
121
|
-
// 与昵称/手机号保存保持一致,避免后端覆盖其它字段
|
|
122
|
-
name: user?.name,
|
|
123
|
-
areaCode: countryCode,
|
|
124
|
-
phone: phoneNumber,
|
|
125
|
-
sex: user?.sex,
|
|
126
|
-
email: user?.email,
|
|
127
|
-
} as any);
|
|
128
|
-
await refreshUser();
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
/** 选择头像文件后上传(走 uploadImageApi),并在成功后刷新当前用户信息。 */
|
|
132
|
-
const handleFileSelect = async (e: React.ChangeEvent<HTMLInputElement>) => {
|
|
133
|
-
const file = e.target.files?.[0];
|
|
134
|
-
if (!file) return;
|
|
135
|
-
|
|
136
|
-
if (file.size > 512 * 1024) {
|
|
137
|
-
showToast(t('base.settings.avatar_too_large'), 'error');
|
|
138
|
-
return;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
try {
|
|
142
|
-
setIsUploading(true);
|
|
143
|
-
const response: any = await uploadFileAPI({ isPublic: true, file });
|
|
144
|
-
const address =
|
|
145
|
-
response?.data?.address ??
|
|
146
|
-
response?.address ??
|
|
147
|
-
response?.data?.data?.address ??
|
|
148
|
-
response?.data?.url ??
|
|
149
|
-
response?.url;
|
|
150
|
-
|
|
151
|
-
if (address) {
|
|
152
|
-
// 将上传得到的文件地址写回用户头像字段
|
|
153
|
-
setAvatarUrl(String(address));
|
|
154
|
-
await updateAvatarByPersonalCenter(address);
|
|
155
|
-
// showToast(t('base.settings.upload_success'), 'success');
|
|
156
|
-
} else {
|
|
157
|
-
// showToast(t('base.settings.upload_failed'), 'error');
|
|
158
|
-
}
|
|
159
|
-
} catch (error: any) {
|
|
160
|
-
console.error('Upload failed:', error);
|
|
161
|
-
const detail = error.response?.data?.detail;
|
|
162
|
-
const errMsg = typeof detail === 'string' ? detail : t('base.settings.upload_failed');
|
|
163
|
-
showToast(errMsg, 'error');
|
|
164
|
-
} finally {
|
|
165
|
-
setIsUploading(false);
|
|
166
|
-
if (fileInputRef.current) fileInputRef.current.value = '';
|
|
167
|
-
}
|
|
168
|
-
};
|
|
169
|
-
|
|
170
|
-
/** 移除头像:将头像字段置空并刷新当前用户信息。 */
|
|
171
|
-
const handleRemoveAvatar = async () => {
|
|
172
|
-
if (!avatarUrl) return;
|
|
173
|
-
setIsUploading(true);
|
|
174
|
-
try {
|
|
175
|
-
await updateAvatarByPersonalCenter(null);
|
|
176
|
-
setAvatarUrl('');
|
|
177
|
-
showToast(t('base.settings.save_success'), 'success');
|
|
178
|
-
} catch (error: any) {
|
|
179
|
-
console.error('Remove avatar failed:', error);
|
|
180
|
-
showToast(error.response?.data?.detail || t('base.settings.save_failed'), 'error');
|
|
181
|
-
} finally {
|
|
182
|
-
setIsUploading(false);
|
|
183
|
-
}
|
|
184
|
-
};
|
|
185
|
-
|
|
186
|
-
// --- Display Name Logic ---
|
|
187
|
-
/** 进入昵称编辑状态:将输入框值重置为当前用户昵称。 */
|
|
188
|
-
const startEditingName = () => {
|
|
189
|
-
setDisplayName(user?.name || '');
|
|
190
|
-
setIsEditingName(true);
|
|
191
|
-
};
|
|
192
|
-
|
|
193
|
-
/** 取消昵称编辑:恢复为当前用户昵称并退出编辑状态。 */
|
|
194
|
-
const cancelEditingName = () => {
|
|
195
|
-
setDisplayName(user?.name || '');
|
|
196
|
-
setIsEditingName(false);
|
|
197
|
-
};
|
|
198
|
-
|
|
199
|
-
/** 保存昵称:调用个人中心更新接口并在成功后刷新用户信息。 */
|
|
200
|
-
const saveName = async () => {
|
|
201
|
-
setIsSavingName(true);
|
|
202
|
-
try {
|
|
203
|
-
const uid = user?.id;
|
|
204
|
-
if (uid === undefined || uid === null || String(uid) === '') {
|
|
205
|
-
showToast(t('base.settings.save_failed'), 'error');
|
|
206
|
-
return;
|
|
207
|
-
}
|
|
208
|
-
await updateUserPersonalCenterAPI({
|
|
209
|
-
id: uid,
|
|
210
|
-
name: displayName,
|
|
211
|
-
areaCode: countryCode,
|
|
212
|
-
phone: phoneNumber,
|
|
213
|
-
sex:user?.sex,
|
|
214
|
-
email:user?.email,
|
|
215
|
-
|
|
216
|
-
});
|
|
217
|
-
showToast(t('base.settings.save_success'), 'success');
|
|
218
|
-
setIsEditingName(false);
|
|
219
|
-
await refreshUser();
|
|
220
|
-
} catch (error: any) {
|
|
221
|
-
console.log(error.response?.data?.detail || t('base.settings.save_failed'));
|
|
222
|
-
} finally {
|
|
223
|
-
setIsSavingName(false);
|
|
224
|
-
}
|
|
225
|
-
};
|
|
226
|
-
|
|
227
|
-
// --- Phone Number Logic ---
|
|
228
|
-
/** 显示/隐藏手机号明文:显示时调用 reveal 接口获取完整手机号。 */
|
|
229
|
-
// const handleRevealPhone = async () => {
|
|
230
|
-
// if (isPhoneRevealed) {
|
|
231
|
-
// setIsPhoneRevealed(false);
|
|
232
|
-
// const parts = parseAreaCodeAndPhone(userAreaCodeRaw, userPhoneRaw);
|
|
233
|
-
// setCountryCode(parts.areaCode);
|
|
234
|
-
// setPhoneNumber(parts.phone);
|
|
235
|
-
// } else {
|
|
236
|
-
// try {
|
|
237
|
-
// const response = await api.post('/users/me/phone/reveal', {}, { _forceEncryption: true } as any);
|
|
238
|
-
// const fullPhone = response.data.phone;
|
|
239
|
-
// const parts = parseAreaCodeAndPhone('', fullPhone);
|
|
240
|
-
// setCountryCode(parts.areaCode);
|
|
241
|
-
// setPhoneNumber(parts.phone);
|
|
242
|
-
// setIsPhoneRevealed(true);
|
|
243
|
-
// } catch (error: any) {
|
|
244
|
-
// console.error('Failed to reveal phone', error);
|
|
245
|
-
// showToast(t('base.settings.reveal_failed'), 'error');
|
|
246
|
-
// }
|
|
247
|
-
// }
|
|
248
|
-
// };
|
|
249
|
-
|
|
250
|
-
/** 开始编辑手机号:若当前是掩码,先尝试 reveal 以便编辑真实号码。 */
|
|
251
|
-
const startEditingPhone = async () => {
|
|
252
|
-
// If masked, try to reveal first so user edits the real number
|
|
253
|
-
if (!isPhoneRevealed && phoneNumber.includes('****')) {
|
|
254
|
-
try {
|
|
255
|
-
const response: any = await request({
|
|
256
|
-
method: 'post',
|
|
257
|
-
url: '/users/me/phone/reveal',
|
|
258
|
-
data: {},
|
|
259
|
-
_forceEncryption: true,
|
|
260
|
-
} as any);
|
|
261
|
-
const fullPhone = response?.phone ?? response?.data?.phone;
|
|
262
|
-
const parts = parseAreaCodeAndPhone('', fullPhone);
|
|
263
|
-
setCountryCode(parts.areaCode);
|
|
264
|
-
setPhoneNumber(parts.phone);
|
|
265
|
-
setIsPhoneRevealed(true);
|
|
266
|
-
} catch (e) {
|
|
267
|
-
// If reveal fails, user starts with masked or empty?
|
|
268
|
-
// Let's clear it to avoid submitting mask
|
|
269
|
-
setPhoneNumber('');
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
setIsEditingPhone(true);
|
|
273
|
-
};
|
|
274
|
-
|
|
275
|
-
/** 取消手机号编辑:退出编辑状态并恢复为用户当前手机号(掩码显示)。 */
|
|
276
|
-
const cancelEditingPhone = () => {
|
|
277
|
-
setIsEditingPhone(false);
|
|
278
|
-
setIsPhoneRevealed(false);
|
|
279
|
-
const parts = parseAreaCodeAndPhone(userAreaCodeRaw, userPhoneRaw);
|
|
280
|
-
setCountryCode(parts.areaCode);
|
|
281
|
-
setPhoneNumber(parts.phone);
|
|
282
|
-
};
|
|
283
|
-
|
|
284
|
-
/** 保存手机号:调用个人中心更新接口。 */
|
|
285
|
-
const savePhone = async () => {
|
|
286
|
-
if (!validatePhoneNumber(countryCode, phoneNumber)) {
|
|
287
|
-
showToast(t('base.settings.invalid_phone_number'), 'error');
|
|
288
|
-
return;
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
const uid = user?.id;
|
|
292
|
-
if (uid === undefined || uid === null || String(uid) === '') {
|
|
293
|
-
showToast(t('base.settings.save_failed'), 'error');
|
|
294
|
-
return;
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
setIsSavingPhone(true);
|
|
298
|
-
try {
|
|
299
|
-
await updateUserPersonalCenterAPI({
|
|
300
|
-
id: uid,
|
|
301
|
-
areaCode: countryCode,
|
|
302
|
-
phone: phoneNumber,
|
|
303
|
-
sex:user?.sex,
|
|
304
|
-
name:user?.name,
|
|
305
|
-
email:user?.email,
|
|
306
|
-
});
|
|
307
|
-
showToast(t('base.settings.save_success'), 'success');
|
|
308
|
-
setIsEditingPhone(false);
|
|
309
|
-
await refreshUser();
|
|
310
|
-
} catch (error: any) {
|
|
311
|
-
const msg =
|
|
312
|
-
(typeof error?.message === 'string' && error.message) ||
|
|
313
|
-
error?.response?.data?.detail ||
|
|
314
|
-
t('base.settings.save_failed');
|
|
315
|
-
console.log(msg);
|
|
316
|
-
} finally {
|
|
317
|
-
setIsSavingPhone(false);
|
|
318
|
-
}
|
|
319
|
-
};
|
|
320
|
-
|
|
321
|
-
// --- Password Logic ---
|
|
322
|
-
/** 开始修改密码:清空新密码输入并打开弹窗。 */
|
|
323
|
-
const startEditingPassword = () => {
|
|
324
|
-
passwordForm.setFieldsValue({
|
|
325
|
-
oldPassword: '',
|
|
326
|
-
newPassword: '',
|
|
327
|
-
confirmPassword: '',
|
|
328
|
-
});
|
|
329
|
-
setIsEditingPassword(true);
|
|
330
|
-
};
|
|
331
|
-
|
|
332
|
-
/** 取消修改密码:清空输入并关闭弹窗。 */
|
|
333
|
-
const cancelEditingPassword = () => {
|
|
334
|
-
passwordForm.resetFields();
|
|
335
|
-
setIsEditingPassword(false);
|
|
336
|
-
};
|
|
337
|
-
|
|
338
|
-
/** 保存新密码:校验表单后调用 changePasswordAPI,成功后强制退出登录。 */
|
|
339
|
-
const savePassword = async () => {
|
|
340
|
-
const values = await passwordForm.validateFields();
|
|
341
|
-
const oldPassword = String(values?.oldPassword || '');
|
|
342
|
-
const newPassword = String(values?.newPassword || '');
|
|
343
|
-
const confirmPassword = String(values?.confirmPassword || '');
|
|
344
|
-
if (newPassword !== confirmPassword) {
|
|
345
|
-
showToast(t('base.settings.password_mismatch'), 'error');
|
|
346
|
-
return;
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
setIsSavingPassword(true);
|
|
350
|
-
try {
|
|
351
|
-
const uid = user?.id;
|
|
352
|
-
if (uid === undefined || uid === null || String(uid) === '') {
|
|
353
|
-
showToast(t('base.settings.save_failed'), 'error');
|
|
354
|
-
return;
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
await changePasswordAPI({
|
|
358
|
-
id: uid,
|
|
359
|
-
oldPassword,
|
|
360
|
-
newPassword,
|
|
361
|
-
confirmPassword,
|
|
362
|
-
} as any);
|
|
363
|
-
|
|
364
|
-
showToast(t('base.settings.save_success'), 'success');
|
|
365
|
-
setIsEditingPassword(false);
|
|
366
|
-
passwordForm.resetFields();
|
|
367
|
-
await logout();
|
|
368
|
-
} catch (error: any) {
|
|
369
|
-
const detail = error?.response?.data?.detail ?? error?.message;
|
|
370
|
-
console.log(t(detail) === detail ? (detail || t('base.settings.save_failed')) : t(detail));
|
|
371
|
-
} finally {
|
|
372
|
-
setIsSavingPassword(false);
|
|
373
|
-
}
|
|
374
|
-
};
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
// Sticky Header
|
|
378
|
-
const titleRef = useStickyHeader(t('base.settings.title'));
|
|
379
|
-
|
|
380
|
-
return (
|
|
381
|
-
<div className="p-6 max-w-3xl mx-auto pb-20">
|
|
382
|
-
{/* Header */}
|
|
383
|
-
<div className="mb-8" ref={titleRef}>
|
|
384
|
-
<h1 className="text-3xl font-bold bg-clip-text text-transparent bg-gradient-to-r from-blue-400 to-purple-500 flex items-center gap-3">
|
|
385
|
-
<SettingsIcon className="text-blue-400" size={32} />
|
|
386
|
-
{t('base.settings.title')}
|
|
387
|
-
</h1>
|
|
388
|
-
<p className="text-gray-400 mt-2">{t('base.settings.description')}</p>
|
|
389
|
-
</div>
|
|
390
|
-
|
|
391
|
-
{/* Profile Information Section */}
|
|
392
|
-
<div className="bg-white dark:bg-gray-800 rounded-xl shadow-sm border border-gray-200 dark:border-gray-700 p-6 mb-6 transition-all hover:shadow-md">
|
|
393
|
-
<h2 className="text-lg font-semibold mb-6 text-gray-900 dark:text-white flex items-center gap-2">
|
|
394
|
-
<UserCog size={20} className="text-gray-400" />
|
|
395
|
-
{t('base.settings.profile')}
|
|
396
|
-
</h2>
|
|
397
|
-
|
|
398
|
-
<div className="space-y-6">
|
|
399
|
-
{/* Avatar Field */}
|
|
400
|
-
<div className="flex flex-col items-center sm:flex-row sm:items-start gap-6">
|
|
401
|
-
<div className="relative group">
|
|
402
|
-
<div
|
|
403
|
-
className="w-24 h-24 rounded-full overflow-hidden bg-gray-100 dark:bg-gray-700 border-4 border-white dark:border-gray-800 shadow-lg cursor-pointer relative transition-transform group-hover:scale-105"
|
|
404
|
-
onClick={() => !isUploading && fileInputRef.current?.click()}
|
|
405
|
-
>
|
|
406
|
-
{avatarUrl ? (
|
|
407
|
-
<img
|
|
408
|
-
src={resolveAvatarUrl(avatarUrl)}
|
|
409
|
-
alt="Avatar"
|
|
410
|
-
className="w-full h-full object-cover"
|
|
411
|
-
onError={(e) => {
|
|
412
|
-
const target = e.target as HTMLImageElement;
|
|
413
|
-
target.style.display = 'none';
|
|
414
|
-
if (target.nextElementSibling) {
|
|
415
|
-
(target.nextElementSibling as HTMLElement).style.display = 'flex';
|
|
416
|
-
}
|
|
417
|
-
}}
|
|
418
|
-
/>
|
|
419
|
-
) : null}
|
|
420
|
-
|
|
421
|
-
<div
|
|
422
|
-
className="w-full h-full bg-gradient-to-br from-blue-500 to-purple-600 flex items-center justify-center text-white font-bold text-4xl"
|
|
423
|
-
style={{ display: avatarUrl ? 'none' : 'flex' }}
|
|
424
|
-
>
|
|
425
|
-
{(user?.name || t('common.user_display_fallback'))[0].toUpperCase()}
|
|
426
|
-
</div>
|
|
427
|
-
|
|
428
|
-
<div className="absolute inset-0 bg-black/50 flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity">
|
|
429
|
-
<Upload size={24} className="text-white" />
|
|
430
|
-
</div>
|
|
431
|
-
{isUploading && (
|
|
432
|
-
<div className="absolute inset-0 bg-black/50 flex items-center justify-center opacity-100">
|
|
433
|
-
<Loader2 size={24} className="text-white animate-spin" />
|
|
434
|
-
</div>
|
|
435
|
-
)}
|
|
436
|
-
</div>
|
|
437
|
-
{avatarUrl && (
|
|
438
|
-
<button
|
|
439
|
-
type="button"
|
|
440
|
-
onClick={(e) => {
|
|
441
|
-
e.stopPropagation();
|
|
442
|
-
handleRemoveAvatar();
|
|
443
|
-
}}
|
|
444
|
-
className="absolute -top-1 -right-1 p-1.5 bg-white dark:bg-gray-800 rounded-full shadow-md border border-gray-200 dark:border-gray-700 text-red-500 hover:text-red-600 hover:bg-gray-50 dark:hover:bg-gray-700 active:scale-90 active:bg-red-50 dark:active:bg-red-900/20 transition-all z-10"
|
|
445
|
-
title={t('base.settings.remove_avatar')}
|
|
446
|
-
>
|
|
447
|
-
<Trash2 size={14} />
|
|
448
|
-
</button>
|
|
449
|
-
)}
|
|
450
|
-
</div>
|
|
451
|
-
<div className="flex-1 text-center sm:text-left pt-2">
|
|
452
|
-
{isEditingName ? (
|
|
453
|
-
<div className="flex items-center gap-2 mb-1 justify-center sm:justify-start">
|
|
454
|
-
<input
|
|
455
|
-
type="text"
|
|
456
|
-
value={displayName}
|
|
457
|
-
onChange={(e) => setDisplayName(e.target.value)}
|
|
458
|
-
className="w-48 px-2 py-1 bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg text-sm text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500/20 focus:border-blue-500 transition-all outline-none"
|
|
459
|
-
autoFocus
|
|
460
|
-
/>
|
|
461
|
-
<button onClick={saveName} disabled={isSavingName} className="p-1.5 bg-blue-50/50 dark:bg-blue-900/20 text-blue-600 dark:text-blue-400 rounded-lg hover:bg-blue-100 dark:hover:bg-blue-900/40 active:scale-90 active:bg-blue-200 dark:active:bg-blue-800/60 transition-all">
|
|
462
|
-
{isSavingName ? <Loader2 size={14} className="animate-spin" /> : <Check size={14} />}
|
|
463
|
-
</button>
|
|
464
|
-
<button onClick={cancelEditingName} disabled={isSavingName} className="p-1.5 bg-gray-100 dark:bg-gray-800 text-gray-500 hover:text-gray-700 dark:hover:text-gray-300 rounded-lg hover:bg-gray-200 active:scale-90 active:bg-gray-300 dark:active:bg-gray-600 transition-all">
|
|
465
|
-
<X size={14} />
|
|
466
|
-
</button>
|
|
467
|
-
</div>
|
|
468
|
-
) : (
|
|
469
|
-
<h3 className="text-lg font-medium text-gray-900 dark:text-white mb-1 flex items-center justify-center sm:justify-start gap-2 group/name">
|
|
470
|
-
{user?.name || t('common.not_set')}
|
|
471
|
-
<button onClick={startEditingName} className="text-gray-400 hover:text-blue-500 active:scale-90 transition-all opacity-100 sm:opacity-0 sm:group-hover/name:opacity-100 p-1">
|
|
472
|
-
<Pencil size={14} />
|
|
473
|
-
</button>
|
|
474
|
-
</h3>
|
|
475
|
-
)}
|
|
476
|
-
<p className="text-gray-500 dark:text-gray-400 text-sm mb-4">{user?.email}</p>
|
|
477
|
-
<div className="inline-block relative">
|
|
478
|
-
<input type="file" ref={fileInputRef} onChange={handleFileSelect} accept="image/*" className="hidden" />
|
|
479
|
-
<button
|
|
480
|
-
onClick={() => fileInputRef.current?.click()}
|
|
481
|
-
className="text-sm text-blue-600 dark:text-blue-400 hover:underline font-medium active:scale-95 transition-transform"
|
|
482
|
-
>
|
|
483
|
-
{t('base.settings.avatar_url_hint')}
|
|
484
|
-
</button>
|
|
485
|
-
</div>
|
|
486
|
-
</div>
|
|
487
|
-
</div>
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
</div>
|
|
491
|
-
</div>
|
|
492
|
-
|
|
493
|
-
{/* Account Security Section */}
|
|
494
|
-
<div className="bg-white dark:bg-gray-800 rounded-xl shadow-sm border border-gray-200 dark:border-gray-700 p-6 mb-6 transition-all hover:shadow-md">
|
|
495
|
-
<h2 className="text-lg font-semibold mb-6 text-gray-900 dark:text-white flex items-center gap-2">
|
|
496
|
-
<UserLock size={20} className="text-gray-400" />
|
|
497
|
-
{t('base.settings.account_security')}
|
|
498
|
-
</h2>
|
|
499
|
-
|
|
500
|
-
<div className="space-y-8">
|
|
501
|
-
{/* Phone Number Field */}
|
|
502
|
-
<div>
|
|
503
|
-
<div className="flex justify-between items-center mb-2">
|
|
504
|
-
<label className="block text-sm font-medium text-gray-700 dark:text-gray-300">{t('base.settings.phone_number')}</label>
|
|
505
|
-
{!isEditingPhone && (
|
|
506
|
-
<button onClick={startEditingPhone} className="text-gray-400 hover:text-blue-500 active:scale-90 transition-all p-1">
|
|
507
|
-
<Pencil size={16} />
|
|
508
|
-
</button>
|
|
509
|
-
)}
|
|
510
|
-
</div>
|
|
511
|
-
|
|
512
|
-
{isEditingPhone ? (
|
|
513
|
-
<div className="flex items-center gap-2">
|
|
514
|
-
<div className="flex relative flex-1">
|
|
515
|
-
<div className="relative">
|
|
516
|
-
<CxSelect
|
|
517
|
-
value={countryCode}
|
|
518
|
-
onChange={(v) => setCountryCode(String(v))}
|
|
519
|
-
options={countryCodes.map((country) => ({
|
|
520
|
-
label: country.dial_code,
|
|
521
|
-
value: country.dial_code,
|
|
522
|
-
}))}
|
|
523
|
-
style={{ width: 96 }}
|
|
524
|
-
/>
|
|
525
|
-
</div>
|
|
526
|
-
<CxInput
|
|
527
|
-
inputMode="tel"
|
|
528
|
-
value={phoneNumber}
|
|
529
|
-
onChange={(e) => setPhoneNumber(e.target.value)}
|
|
530
|
-
className="flex-1"
|
|
531
|
-
placeholder={t('base.settings.phone_placeholder')}
|
|
532
|
-
/>
|
|
533
|
-
</div>
|
|
534
|
-
<button onClick={savePhone} disabled={isSavingPhone} className="p-2.5 bg-blue-50/50 dark:bg-blue-900/20 text-blue-600 dark:text-blue-400 rounded-xl hover:bg-blue-100 dark:hover:bg-blue-900/40 active:scale-90 active:bg-blue-200 dark:active:bg-blue-800/60 transition-all">
|
|
535
|
-
{isSavingPhone ? <Loader2 size={18} className="animate-spin" /> : <Check size={18} />}
|
|
536
|
-
</button>
|
|
537
|
-
<button onClick={cancelEditingPhone} disabled={isSavingPhone} className="p-2.5 bg-gray-100 dark:bg-gray-800 text-gray-500 hover:text-gray-700 dark:hover:text-gray-300 rounded-xl hover:bg-gray-200 active:scale-90 active:bg-gray-300 dark:active:bg-gray-600 transition-all">
|
|
538
|
-
<X size={18} />
|
|
539
|
-
</button>
|
|
540
|
-
</div>
|
|
541
|
-
) : (
|
|
542
|
-
<div className="flex items-center justify-between px-4 py-3 bg-gray-50 dark:bg-gray-900/30 rounded-xl text-gray-900 dark:text-white border border-transparent">
|
|
543
|
-
<span>
|
|
544
|
-
{userPhoneRaw ?
|
|
545
|
-
(isPhoneRevealed ?
|
|
546
|
-
`${countryCode} ${phoneNumber}`
|
|
547
|
-
: userPhoneRaw
|
|
548
|
-
)
|
|
549
|
-
: t('common.not_set')}
|
|
550
|
-
</span>
|
|
551
|
-
{/* <button
|
|
552
|
-
type="button"
|
|
553
|
-
onClick={handleRevealPhone}
|
|
554
|
-
className="text-gray-400 hover:text-blue-500 active:scale-90 transition-all"
|
|
555
|
-
title={isPhoneRevealed ? "Hide" : "Reveal"}
|
|
556
|
-
>
|
|
557
|
-
{isPhoneRevealed ? <EyeOff size={18} /> : <Eye size={18} />}
|
|
558
|
-
</button> */}
|
|
559
|
-
</div>
|
|
560
|
-
)}
|
|
561
|
-
</div>
|
|
562
|
-
|
|
563
|
-
{/* Password Field */}
|
|
564
|
-
<div className="pt-6 border-t border-gray-100 dark:border-gray-700/50">
|
|
565
|
-
<div className="flex justify-between items-center">
|
|
566
|
-
<div>
|
|
567
|
-
<h3 className="text-base font-medium text-gray-800 dark:text-gray-200">{t('base.settings.change_password')}</h3>
|
|
568
|
-
<p className="text-sm text-gray-500 mt-1">{t('base.settings.change_password_desc')}</p>
|
|
569
|
-
</div>
|
|
570
|
-
<CxButton
|
|
571
|
-
type="default"
|
|
572
|
-
onClick={startEditingPassword}
|
|
573
|
-
className="px-4 py-2 text-sm"
|
|
574
|
-
>
|
|
575
|
-
{t('base.settings.change_password')}
|
|
576
|
-
</CxButton>
|
|
577
|
-
</div>
|
|
578
|
-
</div>
|
|
579
|
-
</div>
|
|
580
|
-
</div>
|
|
581
|
-
|
|
582
|
-
{/* Appearance Section */}
|
|
583
|
-
<div className="bg-white dark:bg-gray-800 rounded-xl shadow-sm border border-gray-200 dark:border-gray-700 p-6 mb-6 transition-all hover:shadow-md">
|
|
584
|
-
<h2 className="text-lg font-semibold mb-4 text-gray-900 dark:text-white flex items-center gap-2">
|
|
585
|
-
<SwatchBook size={20} className="text-gray-400" />
|
|
586
|
-
{t('base.settings.appearance')}
|
|
587
|
-
</h2>
|
|
588
|
-
<div className="space-y-4">
|
|
589
|
-
<div className="flex items-center justify-between p-3 bg-gray-50 dark:bg-gray-900/50 rounded-lg">
|
|
590
|
-
<span className="text-gray-700 dark:text-gray-300 font-medium">{t('base.settings.theme')}</span>
|
|
591
|
-
<button
|
|
592
|
-
onClick={toggleTheme}
|
|
593
|
-
className="p-2 rounded-lg bg-white dark:bg-gray-700 shadow-sm hover:bg-gray-50 dark:hover:bg-gray-600 active:scale-90 active:bg-gray-100 dark:active:bg-gray-500 transition-all border border-gray-200 dark:border-gray-600"
|
|
594
|
-
>
|
|
595
|
-
{theme === 'light' ? <Sun size={20} className="text-yellow-500" /> : <Moon size={20} className="text-blue-400" />}
|
|
596
|
-
</button>
|
|
597
|
-
</div>
|
|
598
|
-
<div className="flex items-center justify-between p-3 bg-gray-50 dark:bg-gray-900/50 rounded-lg">
|
|
599
|
-
<span className="text-gray-700 dark:text-gray-300 font-medium">{t('base.settings.language')}</span>
|
|
600
|
-
<LanguageSwitcher />
|
|
601
|
-
</div>
|
|
602
|
-
</div>
|
|
603
|
-
</div>
|
|
604
|
-
|
|
605
|
-
{/* Password Change Modal */}
|
|
606
|
-
<CxModal
|
|
607
|
-
title={t('base.settings.change_password')}
|
|
608
|
-
isOpen={isEditingPassword}
|
|
609
|
-
onClose={cancelEditingPassword}
|
|
610
|
-
opeType="default"
|
|
611
|
-
submitting={isSavingPassword}
|
|
612
|
-
onOk={savePassword}
|
|
613
|
-
modalConfig={{ width: 520 }}
|
|
614
|
-
>
|
|
615
|
-
<CxForm form={passwordForm} layout="vertical">
|
|
616
|
-
<CxFormItem
|
|
617
|
-
label={t('base.settings.current_password')}
|
|
618
|
-
name="oldPassword"
|
|
619
|
-
rules={[{ required: true, message: t('base.settings.current_password_placeholder') }]}
|
|
620
|
-
>
|
|
621
|
-
<CxInput
|
|
622
|
-
type="password"
|
|
623
|
-
className="w-full"
|
|
624
|
-
placeholder={t('base.settings.current_password_placeholder')}
|
|
625
|
-
/>
|
|
626
|
-
</CxFormItem>
|
|
627
|
-
|
|
628
|
-
<CxFormItem
|
|
629
|
-
label={t('base.settings.new_password')}
|
|
630
|
-
name="newPassword"
|
|
631
|
-
rules={[{ required: true, message: t('base.settings.password_required') }]}
|
|
632
|
-
>
|
|
633
|
-
<CxInput
|
|
634
|
-
type="password"
|
|
635
|
-
className="w-full"
|
|
636
|
-
placeholder={t('base.settings.new_password_placeholder')}
|
|
637
|
-
/>
|
|
638
|
-
</CxFormItem>
|
|
639
|
-
|
|
640
|
-
<CxFormItem
|
|
641
|
-
label={t('base.settings.confirm_password')}
|
|
642
|
-
name="confirmPassword"
|
|
643
|
-
rules={[{ required: true, message: t('base.settings.confirm_password_placeholder') }]}
|
|
644
|
-
>
|
|
645
|
-
<CxInput
|
|
646
|
-
type="password"
|
|
647
|
-
className="w-full"
|
|
648
|
-
placeholder={t('base.settings.confirm_password_placeholder')}
|
|
649
|
-
/>
|
|
650
|
-
</CxFormItem>
|
|
651
|
-
</CxForm>
|
|
652
|
-
</CxModal>
|
|
653
|
-
</div>
|
|
654
|
-
);
|
|
655
|
-
};
|
|
656
|
-
|
|
657
|
-
export default SettingsPage;
|