@nocobase/portal-template-default 1.0.9 → 1.0.11
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/.env.example +5 -0
- package/.github/workflows/publish.yml +106 -0
- package/.gitignore +33 -0
- package/AGENTS.md +19 -0
- package/README.MD +61 -180
- package/dist/assets/{LineDraw-C0m1GONT.js → LineDraw-iG-ADes-.js} +1 -1
- package/dist/assets/{SymbolDraw-CCospe5G.js → SymbolDraw-DXoSw1tM.js} +1 -1
- package/dist/assets/VisualMapping-C_ee4Eht.js +1 -0
- package/dist/assets/auth-method-demo-DaOCuvsq.js +1 -0
- package/dist/assets/auto-login-provider-5Uxza9Ms.js +2 -0
- package/dist/assets/auto-login-provider-DyaPGK2D.js +1 -0
- package/dist/assets/auto-redirect-provider-CfwRvYOI.js +1 -0
- package/dist/assets/auto-redirect-provider-Cr3jmYts.js +1 -0
- package/dist/assets/auto-redirect-provider-QkJQRBbG.js +1 -0
- package/dist/assets/calendar-DjDRfD5t.js +1 -0
- package/dist/assets/card-DuQBOS6A.js +1 -0
- package/dist/assets/cas-sign-in-button-CyqG1QME.js +1 -0
- package/dist/assets/components-D-ptYjX_.js +20 -0
- package/dist/assets/configuration-gate-C08mkkiX.js +1 -0
- package/dist/assets/{createClipPathFromCoordSys-uEftn1Mq.js → createClipPathFromCoordSys-wj34-b1B.js} +1 -1
- package/dist/assets/createSeriesDataSimply-D0A6SAVQ.js +1 -0
- package/dist/assets/customGraphicKeyframeAnimation-DWrhrHL_.js +3 -0
- package/dist/assets/demo-BYWHeKUe.js +1 -0
- package/dist/assets/demo-CPWoNtx8.js +1 -0
- package/dist/assets/demo-CyvJk5zV.js +1 -0
- package/dist/assets/demo-D4OiKplc.js +1 -0
- package/dist/assets/demo-DBueJg0m.js +1 -0
- package/dist/assets/demo-DkIhyiRK.js +1 -0
- package/dist/assets/demo-tpTjO0sC.js +1 -0
- package/dist/assets/dingtalk-sign-in-button-DSWsSruv.js +1 -0
- package/dist/assets/echarts-preview-DxHNfq1C.js +1 -0
- package/dist/assets/{echarts-runtime-CEgJbv68.js → echarts-runtime-D8kXn6ME.js} +3 -3
- package/dist/assets/{echarts-runtime-advanced-Buhm2BHz.js → echarts-runtime-advanced-QY8v95qK.js} +1 -1
- package/dist/assets/{echarts-runtime-common-DLAdBAIa.js → echarts-runtime-common-D-yqAK-r.js} +1 -1
- package/dist/assets/{echarts-runtime-components-ypnyLkYx.js → echarts-runtime-components-P4-i8jPU.js} +1 -1
- package/dist/assets/{echarts-runtime-hierarchy-ClStquCF.js → echarts-runtime-hierarchy-ByQZ-DbP.js} +1 -1
- package/dist/assets/floating-BFVEyPEp.js +15 -0
- package/dist/assets/index-BgCbGDMc.js +43 -0
- package/dist/assets/index-Btk35Nx-.js +23 -0
- package/dist/assets/index-CwNxd66J.js +1 -0
- package/dist/assets/index-MB-jfQld.js +686 -0
- package/dist/assets/index-NH3aqqQz.css +1 -0
- package/dist/assets/index-gFtCXH3o.js +58 -0
- package/dist/assets/index-um5hdKdZ.js +23 -0
- package/dist/assets/{labelHelper-C137W5gU.js → labelHelper-DQqRy3a_.js} +1 -1
- package/dist/assets/ldap-sign-in-form--6Gt3yGq.js +1 -0
- package/dist/assets/oidc-sign-in-button-CQdRcR_p.js +1 -0
- package/dist/assets/{page-context-Cxx11gzg.js → page-context-CnQ4GYM7.js} +10 -10
- package/dist/assets/prompt-card-B2RS4nt2.js +1 -0
- package/dist/assets/prompt-output-DZHRM2ft.js +1 -0
- package/dist/assets/saml-sign-in-button-BHL5a0JV.js +1 -0
- package/dist/assets/{sectorHelper-Fqgz3uEk.js → sectorHelper-DN_Vv6OL.js} +1 -1
- package/dist/assets/shortcut-C5x5LQWU.js +47 -0
- package/dist/assets/sms-sign-in-form-DTX9GV2I.js +1 -0
- package/dist/assets/{static.browser-CfQQzERe.js → static.browser-jI1psK0d.js} +8 -8
- package/dist/assets/{switch-DrxImI8F.js → switch-CRL8PmRI.js} +1 -1
- package/dist/assets/{tool-cards-BGfsY8JF.js → tool-cards-DFttLAfo.js} +6 -7
- package/dist/assets/use-authenticator-sign-in-CRGjzXju.js +1 -0
- package/dist/assets/use-dingtalk-sign-in-8WYzJ2jf.js +1 -0
- package/dist/assets/use-wecom-sign-in-C9j8wfCD.js +1 -0
- package/dist/assets/wecom-sign-in-button-mIS1zGSU.js +1 -0
- package/dist/index.html +2 -2
- package/dist/index.raw.html +5 -2
- package/package.json +3 -5
- package/scripts/build-html.mjs +12 -0
- package/src/App.css +2 -0
- package/src/App.tsx +35 -186
- package/src/app/development.tsx +154 -0
- package/src/app/extension.ts +5 -0
- package/src/app/extensions.tsx +18 -4
- package/src/app/routes.tsx +65 -0
- package/src/components/access-control/acl-bootstrap.tsx +11 -3
- package/src/components/access-control/acl-gate.tsx +7 -6
- package/src/components/access-control/can-access.tsx +17 -0
- package/src/components/access-control/navigate-to-accessible-resource.tsx +8 -3
- package/src/components/app-shell/sidebar.tsx +21 -5
- package/src/components/auth/auto-redirect-provider.tsx +2 -1
- package/src/extensions/nocobase-acl/README.md +74 -0
- package/{registry → src/extensions}/nocobase-acl/components/acl-boundary.tsx +22 -25
- package/{registry → src/extensions}/nocobase-acl/components/role-switcher.tsx +26 -23
- package/src/extensions/nocobase-acl/demo/acl-preview-provider.tsx +81 -0
- package/{registry → src/extensions}/nocobase-acl/demo/boundary-api.tsx +58 -0
- package/{registry → src/extensions}/nocobase-acl/demo/index.tsx +243 -105
- package/{registry → src/extensions}/nocobase-acl/demo/prompt-generator.tsx +3 -1
- package/src/extensions/nocobase-acl/extension.tsx +73 -0
- package/{registry → src/extensions}/nocobase-ai/README.md +21 -5
- package/{registry → src/extensions}/nocobase-ai/components/chat/chat-composer.tsx +3 -1
- package/{registry → src/extensions}/nocobase-ai/components/chat/chat-messages.tsx +38 -3
- package/{registry → src/extensions}/nocobase-ai/components/chat/tool-call-card.tsx +1 -9
- package/{registry → src/extensions}/nocobase-ai/components/index.ts +5 -0
- package/src/extensions/nocobase-ai/components/surfaces/chat-dialog.tsx +17 -0
- package/src/extensions/nocobase-ai/components/surfaces/chat-side-panel.tsx +35 -0
- package/src/extensions/nocobase-ai/components/surfaces/chat-surface.tsx +108 -0
- package/{registry → src/extensions}/nocobase-ai/components/triggers/ai-chat-floating-trigger.tsx +2 -2
- package/{registry → src/extensions}/nocobase-ai/demo/configuration-gate.tsx +4 -1
- package/{registry → src/extensions}/nocobase-ai/demo/container-showcase.tsx +2 -2
- package/{registry → src/extensions}/nocobase-ai/demo/floating.tsx +45 -15
- package/{registry → src/extensions}/nocobase-ai/demo/index.tsx +116 -74
- package/{registry → src/extensions}/nocobase-ai/demo/prompt-generator.tsx +3 -3
- package/{registry → src/extensions}/nocobase-ai/demo/tool-cards.tsx +2 -3
- package/src/extensions/nocobase-ai/extension.tsx +160 -0
- package/{registry → src/extensions}/nocobase-ai/global-ai-chat.tsx +12 -28
- package/{registry → src/extensions}/nocobase-ai/providers/ai-provider.tsx +14 -1
- package/{registry → src/extensions}/nocobase-ai/providers/chat-context.tsx +1 -0
- package/{registry → src/extensions}/nocobase-ai/providers/chat-provider.tsx +29 -8
- package/{registry → src/extensions}/nocobase-ai/providers/use-chat-attachments.ts +6 -1
- package/{registry → src/extensions}/nocobase-ai/providers/use-chat-work-context.ts +4 -1
- package/{registry → src/extensions}/nocobase-route-surfaces/README.md +2 -1
- package/{registry → src/extensions}/nocobase-route-surfaces/demo/index.tsx +33 -7
- package/{registry → src/extensions}/nocobase-route-surfaces/demo/scenarios.ts +20 -14
- package/{registry → src/extensions}/nocobase-route-surfaces/extension.tsx +55 -52
- package/src/{pages/users → extensions/nocobase-users-example}/create.tsx +4 -4
- package/src/{pages/users → extensions/nocobase-users-example}/edit.tsx +5 -9
- package/src/extensions/nocobase-users-example/extension.tsx +109 -0
- package/src/{pages/users → extensions/nocobase-users-example}/form-context.ts +11 -9
- package/src/extensions/nocobase-users-example/layout.tsx +16 -0
- package/src/{pages/users → extensions/nocobase-users-example}/list.tsx +1 -1
- package/src/extensions/nocobase-users-example/locales/en-US.ts +77 -0
- package/src/extensions/nocobase-users-example/locales/index.ts +8 -0
- package/src/extensions/nocobase-users-example/locales/zh-CN.ts +73 -0
- package/src/extensions/nocobase-users-example/optional-ai.ts +67 -0
- package/src/{pages/users → extensions/nocobase-users-example}/role-detail.tsx +4 -15
- package/src/{pages/users → extensions/nocobase-users-example}/routes.ts +1 -4
- package/src/extensions/nocobase-users-example/show.tsx +266 -0
- package/src/lib/nocobase/acl/context.ts +32 -0
- package/src/lib/nocobase/acl/evaluator.ts +186 -0
- package/src/lib/nocobase/acl/hooks.ts +40 -0
- package/src/lib/nocobase/acl/index.ts +4 -1
- package/src/lib/nocobase/acl/menu.ts +6 -6
- package/src/lib/nocobase/acl/record-permissions.ts +37 -7
- package/src/lib/nocobase/acl/store-provider.tsx +14 -0
- package/src/lib/nocobase/acl/store.ts +92 -86
- package/src/lib/nocobase/acl/types.ts +52 -32
- package/src/lib/nocobase/auth-session.ts +128 -0
- package/src/lib/nocobase/client.ts +48 -50
- package/src/locales/en-US.ts +0 -78
- package/src/locales/index.ts +2 -7
- package/src/locales/zh-CN.ts +0 -74
- package/src/providers/access-control.ts +43 -8
- package/src/providers/auth-callback.ts +1 -0
- package/src/providers/auth.ts +24 -26
- package/src/providers/constants.ts +0 -4
- package/src/providers/data.ts +14 -26
- package/src/providers/runtime-config.ts +40 -0
- package/src/vite-env.d.ts +9 -0
- package/tests/auth-session-regression.mjs +101 -0
- package/tsconfig.json +2 -1
- package/vite.config.ts +9 -1
- package/dist/assets/VisualMapping-Cbv1v7Cd.js +0 -1
- package/dist/assets/ai-employee-shortcut-B253WWow.js +0 -1
- package/dist/assets/calendar-B3dXXyIv.js +0 -1
- package/dist/assets/chat-inline-xpQ9iq4p.js +0 -1
- package/dist/assets/chat-side-panel-layout-BVWsp5rr.js +0 -1
- package/dist/assets/components-ChhJaNRc.js +0 -20
- package/dist/assets/configuration-gate-Dwdq_lxf.js +0 -1
- package/dist/assets/createSeriesDataSimply-CI7l7Ufv.js +0 -1
- package/dist/assets/customGraphicKeyframeAnimation-DE3jSfMd.js +0 -3
- package/dist/assets/echarts-preview-C-cNUtJF.js +0 -1
- package/dist/assets/floating-BarTmn-b.js +0 -13
- package/dist/assets/index-BJIcYTdc.js +0 -53
- package/dist/assets/index-C6xNKxpg.js +0 -656
- package/dist/assets/index-D4JQi1TM.js +0 -54
- package/dist/assets/index-YA7-AUO8.css +0 -1
- package/dist/assets/index-g8zWVpP9.js +0 -23
- package/dist/assets/prompt-card-BsYMW_rq.js +0 -1
- package/dist/assets/shortcut-xtghDP63.js +0 -47
- package/registry/nocobase-acl/README.md +0 -19
- package/registry/nocobase-acl/extension.tsx +0 -71
- package/registry/nocobase-acl/tests/acl-regression.mjs +0 -314
- package/registry/nocobase-ai/components/surfaces/chat-dialog.tsx +0 -31
- package/registry/nocobase-ai/components/surfaces/chat-side-panel.tsx +0 -74
- package/registry/nocobase-ai/extension.tsx +0 -158
- package/registry/nocobase-ai/tests/business-report-regression.mjs +0 -70
- package/registry/nocobase-ai/tests/form-filler-regression.mjs +0 -129
- package/registry/nocobase-ai/tests/frontend-tool-regression.mjs +0 -128
- package/registry/nocobase-ai/tests/page-context-regression.mjs +0 -48
- package/registry/nocobase-ai/tests/stream-regression.mjs +0 -207
- package/registry/nocobase-auth-cas/README.md +0 -6
- package/registry/nocobase-auth-cas/cas-sign-in-button.tsx +0 -41
- package/registry/nocobase-auth-cas/demo.tsx +0 -20
- package/registry/nocobase-auth-cas/extension.tsx +0 -46
- package/registry/nocobase-auth-cas/index.ts +0 -1
- package/registry/nocobase-auth-cas/use-cas-sign-in.ts +0 -29
- package/registry/nocobase-auth-dingtalk/README.md +0 -7
- package/registry/nocobase-auth-dingtalk/auto-login-provider.tsx +0 -154
- package/registry/nocobase-auth-dingtalk/demo.tsx +0 -23
- package/registry/nocobase-auth-dingtalk/dingtalk-sign-in-button.tsx +0 -45
- package/registry/nocobase-auth-dingtalk/extension.tsx +0 -55
- package/registry/nocobase-auth-dingtalk/index.ts +0 -4
- package/registry/nocobase-auth-dingtalk/use-dingtalk-sign-in.ts +0 -64
- package/registry/nocobase-auth-ldap/README.md +0 -6
- package/registry/nocobase-auth-ldap/demo.tsx +0 -21
- package/registry/nocobase-auth-ldap/extension.tsx +0 -46
- package/registry/nocobase-auth-ldap/index.ts +0 -1
- package/registry/nocobase-auth-ldap/ldap-sign-in-form.tsx +0 -69
- package/registry/nocobase-auth-ldap/use-ldap-sign-in.ts +0 -5
- package/registry/nocobase-auth-oidc/README.md +0 -11
- package/registry/nocobase-auth-oidc/auto-redirect-provider.tsx +0 -13
- package/registry/nocobase-auth-oidc/demo.tsx +0 -20
- package/registry/nocobase-auth-oidc/extension.tsx +0 -51
- package/registry/nocobase-auth-oidc/index.ts +0 -1
- package/registry/nocobase-auth-oidc/oidc-sign-in-button.tsx +0 -44
- package/registry/nocobase-auth-oidc/use-oidc-sign-in.ts +0 -58
- package/registry/nocobase-auth-saml/README.md +0 -6
- package/registry/nocobase-auth-saml/auto-redirect-provider.tsx +0 -13
- package/registry/nocobase-auth-saml/demo.tsx +0 -20
- package/registry/nocobase-auth-saml/extension.tsx +0 -51
- package/registry/nocobase-auth-saml/index.ts +0 -1
- package/registry/nocobase-auth-saml/saml-sign-in-button.tsx +0 -43
- package/registry/nocobase-auth-saml/use-saml-sign-in.ts +0 -51
- package/registry/nocobase-auth-sms/README.md +0 -7
- package/registry/nocobase-auth-sms/demo.tsx +0 -25
- package/registry/nocobase-auth-sms/extension.tsx +0 -46
- package/registry/nocobase-auth-sms/index.ts +0 -1
- package/registry/nocobase-auth-sms/sms-sign-in-form.tsx +0 -107
- package/registry/nocobase-auth-sms/use-sms-sign-in.ts +0 -88
- package/registry/nocobase-auth-wecom/README.md +0 -6
- package/registry/nocobase-auth-wecom/auto-login-provider.tsx +0 -21
- package/registry/nocobase-auth-wecom/demo.tsx +0 -23
- package/registry/nocobase-auth-wecom/extension.tsx +0 -49
- package/registry/nocobase-auth-wecom/index.ts +0 -1
- package/registry/nocobase-auth-wecom/use-wecom-sign-in.ts +0 -62
- package/registry/nocobase-auth-wecom/wecom-sign-in-button.tsx +0 -70
- package/registry/nocobase-i18n/README.md +0 -44
- package/registry/nocobase-i18n/components/index.ts +0 -1
- package/registry/nocobase-i18n/components/language-switcher.tsx +0 -138
- package/registry/nocobase-i18n/demo/index.tsx +0 -209
- package/registry/nocobase-i18n/demo/prompt-generator.tsx +0 -132
- package/registry/nocobase-i18n/extension.tsx +0 -45
- package/registry/nocobase-i18n/index.ts +0 -7
- package/registry/nocobase-i18n/locales/en-US.ts +0 -39
- package/registry/nocobase-i18n/locales/index.ts +0 -8
- package/registry/nocobase-i18n/locales/zh-CN.ts +0 -35
- package/registry/nocobase-i18n/provider.tsx +0 -44
- package/registry/nocobase-i18n/server-resources.ts +0 -166
- package/registry/nocobase-i18n/tests/i18n-regression.mjs +0 -51
- package/registry.config.json +0 -302
- package/scripts/registry.mjs +0 -164
- package/src/components/access-control/resource-access-guard.tsx +0 -21
- package/src/components/access-control/use-acl-runtime.ts +0 -28
- package/src/lib/nocobase/acl/action.ts +0 -147
- package/src/pages/users/layout.tsx +0 -15
- package/src/pages/users/show.tsx +0 -278
- /package/{registry → src/extensions}/nocobase-acl/components/index.ts +0 -0
- /package/{registry → src/extensions}/nocobase-acl/components/role-options.ts +0 -0
- /package/{registry → src/extensions}/nocobase-acl/demo/components.tsx +0 -0
- /package/{registry → src/extensions}/nocobase-acl/demo/lazy-route.tsx +0 -0
- /package/{registry → src/extensions}/nocobase-acl/demo/role-switcher-prompt-generator.tsx +0 -0
- /package/{registry → src/extensions}/nocobase-acl/demo/scenario-section.tsx +0 -0
- /package/{registry → src/extensions}/nocobase-acl/index.ts +0 -0
- /package/{registry → src/extensions}/nocobase-ai/adapters/react-hook-form.ts +0 -0
- /package/{registry → src/extensions}/nocobase-ai/assets/nocobase-ai-chat.svg +0 -0
- /package/{registry → src/extensions}/nocobase-ai/components/ai-root-provider.tsx +0 -0
- /package/{registry → src/extensions}/nocobase-ai/components/chat/ai-employee-avatar.tsx +0 -0
- /package/{registry → src/extensions}/nocobase-ai/components/chat/chat-attachment.tsx +0 -0
- /package/{registry → src/extensions}/nocobase-ai/components/chat/chat-compact.tsx +0 -0
- /package/{registry → src/extensions}/nocobase-ai/components/chat/chat-empty-state.tsx +0 -0
- /package/{registry → src/extensions}/nocobase-ai/components/chat/chat-header.tsx +0 -0
- /package/{registry → src/extensions}/nocobase-ai/components/chat/chat-history-dialog.tsx +0 -0
- /package/{registry → src/extensions}/nocobase-ai/components/chat/chat-message.tsx +0 -0
- /package/{registry → src/extensions}/nocobase-ai/components/chat/chat-window.tsx +0 -0
- /package/{registry → src/extensions}/nocobase-ai/components/chat/conversation-list.tsx +0 -0
- /package/{registry → src/extensions}/nocobase-ai/components/chat/markdown-message.tsx +0 -0
- /package/{registry → src/extensions}/nocobase-ai/components/chat/model-select-options.tsx +0 -0
- /package/{registry → src/extensions}/nocobase-ai/components/chat/reasoning-panel.tsx +0 -0
- /package/{registry → src/extensions}/nocobase-ai/components/chat/sub-agent-conversation.tsx +0 -0
- /package/{registry → src/extensions}/nocobase-ai/components/chat/user-prompt-editor.tsx +0 -0
- /package/{registry → src/extensions}/nocobase-ai/components/chat/work-context-chip.tsx +0 -0
- /package/{registry → src/extensions}/nocobase-ai/components/page-elements/ai-form.tsx +0 -0
- /package/{registry → src/extensions}/nocobase-ai/components/page-elements/page-element-provider.tsx +0 -0
- /package/{registry → src/extensions}/nocobase-ai/components/surfaces/chat-inline.tsx +0 -0
- /package/{registry → src/extensions}/nocobase-ai/components/surfaces/chat-page.tsx +0 -0
- /package/{registry → src/extensions}/nocobase-ai/components/surfaces/chat-side-panel-layout.tsx +0 -0
- /package/{registry → src/extensions}/nocobase-ai/components/surfaces/chat-surface-actions.tsx +0 -0
- /package/{registry → src/extensions}/nocobase-ai/components/tools/builtin-tool-renderers.tsx +0 -0
- /package/{registry → src/extensions}/nocobase-ai/components/tools/business-report-dialog.tsx +0 -0
- /package/{registry → src/extensions}/nocobase-ai/components/tools/business-report-renderer.tsx +0 -0
- /package/{registry → src/extensions}/nocobase-ai/components/tools/business-report-utils.tsx +0 -0
- /package/{registry → src/extensions}/nocobase-ai/components/tools/chart-renderer.tsx +0 -0
- /package/{registry → src/extensions}/nocobase-ai/components/tools/echarts-preview.tsx +0 -0
- /package/{registry → src/extensions}/nocobase-ai/components/tools/echarts-runtime-advanced.ts +0 -0
- /package/{registry → src/extensions}/nocobase-ai/components/tools/echarts-runtime-common.ts +0 -0
- /package/{registry → src/extensions}/nocobase-ai/components/tools/echarts-runtime-components.ts +0 -0
- /package/{registry → src/extensions}/nocobase-ai/components/tools/echarts-runtime-hierarchy.ts +0 -0
- /package/{registry → src/extensions}/nocobase-ai/components/tools/echarts-runtime.ts +0 -0
- /package/{registry → src/extensions}/nocobase-ai/components/tools/sub-agent-renderer.tsx +0 -0
- /package/{registry → src/extensions}/nocobase-ai/components/tools/suggestions-renderer.tsx +0 -0
- /package/{registry → src/extensions}/nocobase-ai/components/tools/tool-renderer-provider.tsx +0 -0
- /package/{registry → src/extensions}/nocobase-ai/components/tools/tool-renderer-utils.ts +0 -0
- /package/{registry → src/extensions}/nocobase-ai/components/tools/workflow-renderer.tsx +0 -0
- /package/{registry → src/extensions}/nocobase-ai/components/triggers/ai-employee-shortcut.tsx +0 -0
- /package/{registry → src/extensions}/nocobase-ai/demo/interaction-showcase.tsx +0 -0
- /package/{registry → src/extensions}/nocobase-ai/demo/page-context-prompt-generator.tsx +0 -0
- /package/{registry → src/extensions}/nocobase-ai/demo/page-context.tsx +0 -0
- /package/{registry → src/extensions}/nocobase-ai/demo/page-element-showcase.tsx +0 -0
- /package/{registry → src/extensions}/nocobase-ai/demo/prompt-card.tsx +0 -0
- /package/{registry → src/extensions}/nocobase-ai/demo/shortcut.tsx +0 -0
- /package/{registry → src/extensions}/nocobase-ai/index.ts +0 -0
- /package/{registry → src/extensions}/nocobase-ai/providers/avatars.ts +0 -0
- /package/{registry → src/extensions}/nocobase-ai/providers/chat-controller.ts +0 -0
- /package/{registry → src/extensions}/nocobase-ai/providers/chat-message-utils.ts +0 -0
- /package/{registry → src/extensions}/nocobase-ai/providers/chat-reducer.ts +0 -0
- /package/{registry → src/extensions}/nocobase-ai/providers/chat-task-utils.ts +0 -0
- /package/{registry → src/extensions}/nocobase-ai/providers/chat-transport.ts +0 -0
- /package/{registry → src/extensions}/nocobase-ai/providers/form-registry.tsx +0 -0
- /package/{registry → src/extensions}/nocobase-ai/providers/frontend-tool-registry.tsx +0 -0
- /package/{registry → src/extensions}/nocobase-ai/providers/index.ts +0 -0
- /package/{registry → src/extensions}/nocobase-ai/providers/model.ts +0 -0
- /package/{registry → src/extensions}/nocobase-ai/providers/page-context.tsx +0 -0
- /package/{registry → src/extensions}/nocobase-ai/providers/stream-coalescer.ts +0 -0
- /package/{registry → src/extensions}/nocobase-ai/providers/stream-event-utils.ts +0 -0
- /package/{registry → src/extensions}/nocobase-ai/providers/stream-parser.ts +0 -0
- /package/{registry → src/extensions}/nocobase-ai/providers/sub-agent-stream.ts +0 -0
- /package/{registry → src/extensions}/nocobase-ai/providers/types.ts +0 -0
- /package/{registry → src/extensions}/nocobase-ai/providers/ui-message-stream.ts +0 -0
- /package/{registry → src/extensions}/nocobase-ai/providers/use-automatic-tool-approval.ts +0 -0
- /package/{registry → src/extensions}/nocobase-ai/providers/use-chat-message-actions.ts +0 -0
- /package/{registry → src/extensions}/nocobase-ai/providers/use-chat-runtime.ts +0 -0
- /package/{registry → src/extensions}/nocobase-ai/providers/use-conversation-catalog.ts +0 -0
- /package/{registry → src/extensions}/nocobase-ai/providers/use-conversation-history.ts +0 -0
- /package/{registry → src/extensions}/nocobase-ai/services/index.ts +0 -0
- /package/{registry → src/extensions}/nocobase-ai/services/nocobase-ai-service.ts +0 -0
- /package/{registry → src/extensions}/nocobase-ai/services/types.ts +0 -0
- /package/{registry → src/extensions}/nocobase-route-surfaces/demo/lazy-route.tsx +0 -0
- /package/{registry → src/extensions}/nocobase-route-surfaces/demo/prompt-generator.tsx +0 -0
- /package/{registry → src/extensions}/nocobase-route-surfaces/index.ts +0 -0
- /package/{registry → src/extensions}/nocobase-route-surfaces/route-dialog.tsx +0 -0
- /package/{registry → src/extensions}/nocobase-route-surfaces/route-drawer.tsx +0 -0
- /package/{registry → src/extensions}/nocobase-route-surfaces/route-page.tsx +0 -0
- /package/{registry → src/extensions}/nocobase-route-surfaces/route-surface-context.ts +0 -0
- /package/{registry → src/extensions}/nocobase-route-surfaces/use-refine-unsaved-changes.tsx +0 -0
- /package/{registry → src/extensions}/nocobase-route-surfaces/use-route-surface-close.ts +0 -0
- /package/{registry → src/extensions}/nocobase-route-surfaces/use-route-surface-state.ts +0 -0
- /package/src/{pages/users → extensions/nocobase-users-example}/form-fields.tsx +0 -0
- /package/src/{pages/users → extensions/nocobase-users-example}/index.ts +0 -0
- /package/src/{pages/users → extensions/nocobase-users-example}/role-badges.tsx +0 -0
- /package/src/{pages/users → extensions/nocobase-users-example}/role-utils.ts +0 -0
- /package/src/{pages/users → extensions/nocobase-users-example}/types.ts +0 -0
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { lazy } from "react";
|
|
2
|
-
import { Smartphone } from "lucide-react";
|
|
3
|
-
import { Route } from "react-router";
|
|
4
|
-
|
|
5
|
-
import type { AppExtension } from "@/app/extension";
|
|
6
|
-
import { AuthDemoRoute } from "@/components/auth/demo";
|
|
7
|
-
|
|
8
|
-
const SmsSignInForm = lazy(() => import("./sms-sign-in-form"));
|
|
9
|
-
const SmsAuthDemoPage = lazy(() =>
|
|
10
|
-
import("./demo").then((module) => ({ default: module.SmsAuthDemoPage }))
|
|
11
|
-
);
|
|
12
|
-
|
|
13
|
-
const smsAuthExtension: AppExtension = {
|
|
14
|
-
id: "nocobase-auth-sms",
|
|
15
|
-
resources: [
|
|
16
|
-
{
|
|
17
|
-
name: "auth-sms-demo",
|
|
18
|
-
list: "/auth/sms",
|
|
19
|
-
meta: {
|
|
20
|
-
parent: "auth-components",
|
|
21
|
-
label: "SMS",
|
|
22
|
-
icon: <Smartphone />,
|
|
23
|
-
acl: { type: "authenticated" },
|
|
24
|
-
},
|
|
25
|
-
},
|
|
26
|
-
],
|
|
27
|
-
routes: (
|
|
28
|
-
<Route
|
|
29
|
-
path="/auth/sms"
|
|
30
|
-
element={
|
|
31
|
-
<AuthDemoRoute>
|
|
32
|
-
<SmsAuthDemoPage />
|
|
33
|
-
</AuthDemoRoute>
|
|
34
|
-
}
|
|
35
|
-
/>
|
|
36
|
-
),
|
|
37
|
-
authAdapters: [
|
|
38
|
-
{
|
|
39
|
-
authType: "SMS",
|
|
40
|
-
placement: "form",
|
|
41
|
-
Component: SmsSignInForm,
|
|
42
|
-
},
|
|
43
|
-
],
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
export default smsAuthExtension;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { useSmsSignIn } from "./use-sms-sign-in";
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
import { useState } from "react";
|
|
2
|
-
|
|
3
|
-
import type { AuthenticatorComponentProps } from "@/components/auth/types";
|
|
4
|
-
import {
|
|
5
|
-
Alert,
|
|
6
|
-
AlertDescription,
|
|
7
|
-
AlertTitle,
|
|
8
|
-
} from "@/components/ui/alert";
|
|
9
|
-
import { Button } from "@/components/ui/button";
|
|
10
|
-
import { Input } from "@/components/ui/input";
|
|
11
|
-
import { Label } from "@/components/ui/label";
|
|
12
|
-
|
|
13
|
-
import { useSmsSignIn } from "./use-sms-sign-in";
|
|
14
|
-
|
|
15
|
-
export default function SmsSignInForm({
|
|
16
|
-
authenticator,
|
|
17
|
-
onSendCode,
|
|
18
|
-
onSignIn,
|
|
19
|
-
}: AuthenticatorComponentProps & {
|
|
20
|
-
onSendCode?: (phone: string) => void;
|
|
21
|
-
onSignIn?: (values: { phone: string; code: string }) => void;
|
|
22
|
-
}) {
|
|
23
|
-
const [phone, setPhone] = useState("");
|
|
24
|
-
const [code, setCode] = useState("");
|
|
25
|
-
const sms = useSmsSignIn(authenticator);
|
|
26
|
-
const autoSignup = authenticator.options?.autoSignup === true;
|
|
27
|
-
|
|
28
|
-
return (
|
|
29
|
-
<form
|
|
30
|
-
className="space-y-5"
|
|
31
|
-
onSubmit={(event) => {
|
|
32
|
-
event.preventDefault();
|
|
33
|
-
if (onSignIn) {
|
|
34
|
-
onSignIn({ phone, code });
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
|
-
void sms.signIn(phone, code);
|
|
38
|
-
}}
|
|
39
|
-
>
|
|
40
|
-
{sms.error && (
|
|
41
|
-
<Alert variant="destructive">
|
|
42
|
-
<AlertTitle>SMS sign-in failed</AlertTitle>
|
|
43
|
-
<AlertDescription>{sms.error.message}</AlertDescription>
|
|
44
|
-
</Alert>
|
|
45
|
-
)}
|
|
46
|
-
<div className="space-y-2">
|
|
47
|
-
<Label htmlFor={`${authenticator.name}-phone`}>Phone</Label>
|
|
48
|
-
<Input
|
|
49
|
-
id={`${authenticator.name}-phone`}
|
|
50
|
-
type="tel"
|
|
51
|
-
value={phone}
|
|
52
|
-
onChange={(event) => setPhone(event.target.value)}
|
|
53
|
-
autoComplete="tel"
|
|
54
|
-
required
|
|
55
|
-
/>
|
|
56
|
-
</div>
|
|
57
|
-
<div className="space-y-2">
|
|
58
|
-
<Label htmlFor={`${authenticator.name}-code`}>
|
|
59
|
-
Verification code
|
|
60
|
-
</Label>
|
|
61
|
-
<div className="grid grid-cols-[minmax(0,1fr)_auto] gap-2">
|
|
62
|
-
<Input
|
|
63
|
-
id={`${authenticator.name}-code`}
|
|
64
|
-
inputMode="numeric"
|
|
65
|
-
value={code}
|
|
66
|
-
onChange={(event) => setCode(event.target.value)}
|
|
67
|
-
autoComplete="one-time-code"
|
|
68
|
-
required
|
|
69
|
-
/>
|
|
70
|
-
<Button
|
|
71
|
-
type="button"
|
|
72
|
-
variant="outline"
|
|
73
|
-
disabled={
|
|
74
|
-
(!onSendCode && (sms.isSendingCode || sms.retryAfter > 0)) ||
|
|
75
|
-
!phone
|
|
76
|
-
}
|
|
77
|
-
onClick={() => {
|
|
78
|
-
if (onSendCode) {
|
|
79
|
-
onSendCode(phone);
|
|
80
|
-
return;
|
|
81
|
-
}
|
|
82
|
-
void sms.sendCode(phone).catch(() => undefined);
|
|
83
|
-
}}
|
|
84
|
-
>
|
|
85
|
-
{!onSendCode && sms.isSendingCode
|
|
86
|
-
? "Sending…"
|
|
87
|
-
: !onSendCode && sms.retryAfter > 0
|
|
88
|
-
? `Retry in ${sms.retryAfter}s`
|
|
89
|
-
: "Send code"}
|
|
90
|
-
</Button>
|
|
91
|
-
</div>
|
|
92
|
-
</div>
|
|
93
|
-
<Button
|
|
94
|
-
type="submit"
|
|
95
|
-
className="w-full"
|
|
96
|
-
disabled={!onSignIn && sms.isSigningIn}
|
|
97
|
-
>
|
|
98
|
-
{!onSignIn && sms.isSigningIn ? "Signing in…" : "Sign in"}
|
|
99
|
-
</Button>
|
|
100
|
-
{autoSignup && (
|
|
101
|
-
<p className="text-xs leading-5 text-muted-foreground">
|
|
102
|
-
An account will be created automatically if this phone number is new.
|
|
103
|
-
</p>
|
|
104
|
-
)}
|
|
105
|
-
</form>
|
|
106
|
-
);
|
|
107
|
-
}
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import { useCallback, useEffect, useMemo, useState } from "react";
|
|
2
|
-
|
|
3
|
-
import { useAuthenticatorSignIn } from "@/components/auth";
|
|
4
|
-
import type { Authenticator } from "@/components/auth/types";
|
|
5
|
-
import { nocobaseClient } from "@/lib/nocobase/client";
|
|
6
|
-
|
|
7
|
-
type SmsCodeResponse = {
|
|
8
|
-
expiresAt?: string;
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
export function useSmsSignIn(authenticator: Authenticator) {
|
|
12
|
-
const auth = useAuthenticatorSignIn(authenticator.name);
|
|
13
|
-
const [isSendingCode, setIsSendingCode] = useState(false);
|
|
14
|
-
const [sendError, setSendError] = useState<Error>();
|
|
15
|
-
const [expiresAt, setExpiresAt] = useState<number>();
|
|
16
|
-
const [now, setNow] = useState(Date.now());
|
|
17
|
-
const verifier =
|
|
18
|
-
typeof authenticator.options?.verifier === "string"
|
|
19
|
-
? authenticator.options.verifier
|
|
20
|
-
: "";
|
|
21
|
-
|
|
22
|
-
useEffect(() => {
|
|
23
|
-
if (!expiresAt || expiresAt <= Date.now()) return;
|
|
24
|
-
const timer = window.setInterval(() => setNow(Date.now()), 1_000);
|
|
25
|
-
return () => window.clearInterval(timer);
|
|
26
|
-
}, [expiresAt]);
|
|
27
|
-
|
|
28
|
-
const retryAfter = useMemo(
|
|
29
|
-
() =>
|
|
30
|
-
expiresAt ? Math.max(0, Math.ceil((expiresAt - now) / 1_000)) : 0,
|
|
31
|
-
[expiresAt, now]
|
|
32
|
-
);
|
|
33
|
-
|
|
34
|
-
const sendCode = useCallback(
|
|
35
|
-
async (phone: string) => {
|
|
36
|
-
if (!phone) throw new Error("Enter a phone number first.");
|
|
37
|
-
if (!verifier) {
|
|
38
|
-
throw new Error("The SMS verifier is not configured.");
|
|
39
|
-
}
|
|
40
|
-
if (retryAfter > 0) return;
|
|
41
|
-
|
|
42
|
-
setSendError(undefined);
|
|
43
|
-
setIsSendingCode(true);
|
|
44
|
-
try {
|
|
45
|
-
const result = await nocobaseClient.action<SmsCodeResponse>(
|
|
46
|
-
"smsOTP",
|
|
47
|
-
"publicCreate",
|
|
48
|
-
{
|
|
49
|
-
method: "POST",
|
|
50
|
-
authenticator: null,
|
|
51
|
-
includeRole: false,
|
|
52
|
-
withAclMeta: false,
|
|
53
|
-
body: {
|
|
54
|
-
action: "auth:signIn",
|
|
55
|
-
verifier,
|
|
56
|
-
uuid: phone,
|
|
57
|
-
},
|
|
58
|
-
}
|
|
59
|
-
);
|
|
60
|
-
const nextExpiry = result?.expiresAt
|
|
61
|
-
? Date.parse(result.expiresAt)
|
|
62
|
-
: Date.now() + 60_000;
|
|
63
|
-
setNow(Date.now());
|
|
64
|
-
setExpiresAt(nextExpiry);
|
|
65
|
-
} catch (cause) {
|
|
66
|
-
const error =
|
|
67
|
-
cause instanceof Error
|
|
68
|
-
? cause
|
|
69
|
-
: new Error("Unable to send the verification code.");
|
|
70
|
-
setSendError(error);
|
|
71
|
-
throw error;
|
|
72
|
-
} finally {
|
|
73
|
-
setIsSendingCode(false);
|
|
74
|
-
}
|
|
75
|
-
},
|
|
76
|
-
[retryAfter, verifier]
|
|
77
|
-
);
|
|
78
|
-
|
|
79
|
-
return {
|
|
80
|
-
sendCode,
|
|
81
|
-
signIn: (phone: string, code: string) =>
|
|
82
|
-
auth.signIn({ uuid: phone, code }),
|
|
83
|
-
isSendingCode,
|
|
84
|
-
isSigningIn: auth.isPending,
|
|
85
|
-
retryAfter,
|
|
86
|
-
error: sendError ?? auth.error,
|
|
87
|
-
};
|
|
88
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import type { PropsWithChildren } from "react";
|
|
2
|
-
|
|
3
|
-
import { AuthAutoRedirectProvider } from "@/components/auth";
|
|
4
|
-
|
|
5
|
-
import { isWecomBrowser } from "./use-wecom-sign-in";
|
|
6
|
-
|
|
7
|
-
export default function WecomAutoLoginProvider({
|
|
8
|
-
children,
|
|
9
|
-
}: PropsWithChildren) {
|
|
10
|
-
const insideWecom = isWecomBrowser();
|
|
11
|
-
return (
|
|
12
|
-
<AuthAutoRedirectProvider
|
|
13
|
-
resource="wecom"
|
|
14
|
-
action="checkLogin"
|
|
15
|
-
enabled={insideWecom}
|
|
16
|
-
query={{ isWeComBrowser: insideWecom }}
|
|
17
|
-
>
|
|
18
|
-
{children}
|
|
19
|
-
</AuthAutoRedirectProvider>
|
|
20
|
-
);
|
|
21
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { AuthMethodDemo } from "@/components/auth/demo";
|
|
2
|
-
import WecomSignInButton from "./wecom-sign-in-button";
|
|
3
|
-
|
|
4
|
-
const authenticator = {
|
|
5
|
-
name: "company-wecom",
|
|
6
|
-
authType: "wecom",
|
|
7
|
-
title: "Sign in via WeCom",
|
|
8
|
-
options: {
|
|
9
|
-
btnTooltip: "Use the account associated with your company directory.",
|
|
10
|
-
},
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
export function WecomAuthDemoPage() {
|
|
14
|
-
return (
|
|
15
|
-
<AuthMethodDemo
|
|
16
|
-
authType="wecom"
|
|
17
|
-
methodName="WeCom"
|
|
18
|
-
description="Provide a WeCom sign-in button and support automatic login when the application is opened inside WeCom."
|
|
19
|
-
>
|
|
20
|
-
<WecomSignInButton authenticator={authenticator} onSignIn={() => {}} />
|
|
21
|
-
</AuthMethodDemo>
|
|
22
|
-
);
|
|
23
|
-
}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { lazy } from "react";
|
|
2
|
-
import { Building2 } from "lucide-react";
|
|
3
|
-
import { Route } from "react-router";
|
|
4
|
-
|
|
5
|
-
import type { AppExtension } from "@/app/extension";
|
|
6
|
-
import { AuthDemoRoute } from "@/components/auth/demo";
|
|
7
|
-
|
|
8
|
-
const WecomSignInButton = lazy(() => import("./wecom-sign-in-button"));
|
|
9
|
-
const WecomAutoLoginProvider = lazy(() => import("./auto-login-provider"));
|
|
10
|
-
const WecomAuthDemoPage = lazy(() =>
|
|
11
|
-
import("./demo").then((module) => ({ default: module.WecomAuthDemoPage }))
|
|
12
|
-
);
|
|
13
|
-
|
|
14
|
-
const wecomAuthExtension: AppExtension = {
|
|
15
|
-
id: "nocobase-auth-wecom",
|
|
16
|
-
AuthRuntimeProvider: WecomAutoLoginProvider,
|
|
17
|
-
authRuntimePriority: 10,
|
|
18
|
-
resources: [
|
|
19
|
-
{
|
|
20
|
-
name: "auth-wecom-demo",
|
|
21
|
-
list: "/auth/wecom",
|
|
22
|
-
meta: {
|
|
23
|
-
parent: "auth-components",
|
|
24
|
-
label: "WeCom",
|
|
25
|
-
icon: <Building2 />,
|
|
26
|
-
acl: { type: "authenticated" },
|
|
27
|
-
},
|
|
28
|
-
},
|
|
29
|
-
],
|
|
30
|
-
routes: (
|
|
31
|
-
<Route
|
|
32
|
-
path="/auth/wecom"
|
|
33
|
-
element={
|
|
34
|
-
<AuthDemoRoute>
|
|
35
|
-
<WecomAuthDemoPage />
|
|
36
|
-
</AuthDemoRoute>
|
|
37
|
-
}
|
|
38
|
-
/>
|
|
39
|
-
),
|
|
40
|
-
authAdapters: [
|
|
41
|
-
{
|
|
42
|
-
authType: "wecom",
|
|
43
|
-
placement: "button",
|
|
44
|
-
Component: WecomSignInButton,
|
|
45
|
-
},
|
|
46
|
-
],
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
export default wecomAuthExtension;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { isWecomBrowser, useWecomSignIn } from "./use-wecom-sign-in";
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { useCallback, useMemo, useState } from "react";
|
|
2
|
-
import { useSearchParams } from "react-router";
|
|
3
|
-
|
|
4
|
-
import type { Authenticator } from "@/components/auth/types";
|
|
5
|
-
import { nocobaseClient } from "@/lib/nocobase/client";
|
|
6
|
-
|
|
7
|
-
type WecomAuthUrlResponse = {
|
|
8
|
-
url?: string;
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
export function isWecomBrowser() {
|
|
12
|
-
return (
|
|
13
|
-
typeof navigator !== "undefined" &&
|
|
14
|
-
navigator.userAgent.toLowerCase().includes("wxwork")
|
|
15
|
-
);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export function useWecomSignIn(authenticator: Authenticator) {
|
|
19
|
-
const [searchParams] = useSearchParams();
|
|
20
|
-
const [isPending, setIsPending] = useState(false);
|
|
21
|
-
const [error, setError] = useState<Error>();
|
|
22
|
-
const callbackError = useMemo(() => {
|
|
23
|
-
if (searchParams.get("authenticator") !== authenticator.name) {
|
|
24
|
-
return undefined;
|
|
25
|
-
}
|
|
26
|
-
const message = searchParams.get("errorMsg");
|
|
27
|
-
return message ? new Error(message) : undefined;
|
|
28
|
-
}, [authenticator.name, searchParams]);
|
|
29
|
-
|
|
30
|
-
const signIn = useCallback(async () => {
|
|
31
|
-
setError(undefined);
|
|
32
|
-
setIsPending(true);
|
|
33
|
-
try {
|
|
34
|
-
const redirect =
|
|
35
|
-
searchParams.get("to") || searchParams.get("redirect") || "/";
|
|
36
|
-
const result = await nocobaseClient.action<WecomAuthUrlResponse>(
|
|
37
|
-
"wecom",
|
|
38
|
-
"getAuthUrl",
|
|
39
|
-
{
|
|
40
|
-
method: "POST",
|
|
41
|
-
authenticator: authenticator.name,
|
|
42
|
-
includeRole: false,
|
|
43
|
-
withAclMeta: false,
|
|
44
|
-
body: { redirect, isWeComBrowser: isWecomBrowser() },
|
|
45
|
-
}
|
|
46
|
-
);
|
|
47
|
-
if (!result?.url) {
|
|
48
|
-
throw new Error("NocoBase did not return a WeCom authorization URL.");
|
|
49
|
-
}
|
|
50
|
-
window.location.replace(nocobaseClient.resolveUrl(result.url));
|
|
51
|
-
} catch (cause) {
|
|
52
|
-
setError(
|
|
53
|
-
cause instanceof Error
|
|
54
|
-
? cause
|
|
55
|
-
: new Error("Unable to start WeCom sign-in.")
|
|
56
|
-
);
|
|
57
|
-
setIsPending(false);
|
|
58
|
-
}
|
|
59
|
-
}, [authenticator.name, searchParams]);
|
|
60
|
-
|
|
61
|
-
return { signIn, isPending, error: error ?? callbackError };
|
|
62
|
-
}
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import { Building2 } from "lucide-react";
|
|
2
|
-
|
|
3
|
-
import type { AuthenticatorComponentProps } from "@/components/auth/types";
|
|
4
|
-
import {
|
|
5
|
-
Alert,
|
|
6
|
-
AlertDescription,
|
|
7
|
-
AlertTitle,
|
|
8
|
-
} from "@/components/ui/alert";
|
|
9
|
-
import { Button } from "@/components/ui/button";
|
|
10
|
-
import {
|
|
11
|
-
Tooltip,
|
|
12
|
-
TooltipContent,
|
|
13
|
-
TooltipTrigger,
|
|
14
|
-
} from "@/components/ui/tooltip";
|
|
15
|
-
import { resolveTranslatableText } from "@/lib/i18n";
|
|
16
|
-
|
|
17
|
-
import { useWecomSignIn } from "./use-wecom-sign-in";
|
|
18
|
-
|
|
19
|
-
function plainText(value: unknown) {
|
|
20
|
-
return typeof value === "string"
|
|
21
|
-
? value.replace(/<[^>]+>/g, " ").replace(/\s+/g, " ").trim()
|
|
22
|
-
: "";
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export default function WecomSignInButton({
|
|
26
|
-
authenticator,
|
|
27
|
-
onSignIn,
|
|
28
|
-
}: AuthenticatorComponentProps & { onSignIn?: () => void }) {
|
|
29
|
-
const { signIn, isPending, error } = useWecomSignIn(authenticator);
|
|
30
|
-
const tooltip = plainText(authenticator.options?.btnTooltip);
|
|
31
|
-
const button = (
|
|
32
|
-
<Button
|
|
33
|
-
type="button"
|
|
34
|
-
variant="outline"
|
|
35
|
-
className="w-full"
|
|
36
|
-
disabled={!onSignIn && isPending}
|
|
37
|
-
onClick={onSignIn ?? signIn}
|
|
38
|
-
>
|
|
39
|
-
<Building2 />
|
|
40
|
-
{!onSignIn && isPending
|
|
41
|
-
? "Redirecting…"
|
|
42
|
-
: resolveTranslatableText(
|
|
43
|
-
authenticator.title ||
|
|
44
|
-
authenticator.authTypeTitle ||
|
|
45
|
-
"Sign in via WeCom"
|
|
46
|
-
)}
|
|
47
|
-
</Button>
|
|
48
|
-
);
|
|
49
|
-
|
|
50
|
-
return (
|
|
51
|
-
<div className="space-y-3">
|
|
52
|
-
{error && (
|
|
53
|
-
<Alert variant="destructive">
|
|
54
|
-
<AlertTitle>WeCom sign-in failed</AlertTitle>
|
|
55
|
-
<AlertDescription>{error.message}</AlertDescription>
|
|
56
|
-
</Alert>
|
|
57
|
-
)}
|
|
58
|
-
{tooltip ? (
|
|
59
|
-
<Tooltip>
|
|
60
|
-
<TooltipTrigger render={button} />
|
|
61
|
-
<TooltipContent side="right" className="max-w-xs">
|
|
62
|
-
{tooltip}
|
|
63
|
-
</TooltipContent>
|
|
64
|
-
</Tooltip>
|
|
65
|
-
) : (
|
|
66
|
-
button
|
|
67
|
-
)}
|
|
68
|
-
</div>
|
|
69
|
-
);
|
|
70
|
-
}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
# NocoBase i18n
|
|
2
|
-
|
|
3
|
-
Optional NocoBase server-language integration and language controls for the
|
|
4
|
-
NocoBase Admin Starter.
|
|
5
|
-
|
|
6
|
-
The Starter owns the Refine i18n provider, local i18next runtime, application
|
|
7
|
-
resources, locale selection, and the shared `systemSettings:get` bootstrap.
|
|
8
|
-
This Registry reuses those foundations and adds only the NocoBase-specific
|
|
9
|
-
remote capabilities:
|
|
10
|
-
|
|
11
|
-
- load registered dynamic namespaces from `app:getLang`;
|
|
12
|
-
- persist a signed-in user's selected language through `users:updateLang`;
|
|
13
|
-
- expose reusable page and user-menu language switchers;
|
|
14
|
-
- provide an integrated Demo and Prompt generator.
|
|
15
|
-
|
|
16
|
-
When this Registry is not installed, the Starter still uses the system default
|
|
17
|
-
language and all local translations normally. It does not request
|
|
18
|
-
`app:getLang`. When installed, the Registry reads the already-cached system
|
|
19
|
-
settings and requests only registered server namespaces. `lm-collections` is
|
|
20
|
-
registered by default for collection and field metadata.
|
|
21
|
-
|
|
22
|
-
Application-owned React translations belong in `src/locales`, outside the
|
|
23
|
-
installed Registry directory:
|
|
24
|
-
|
|
25
|
-
```ts
|
|
26
|
-
import { registerLocaleResources } from "@/providers/i18n";
|
|
27
|
-
|
|
28
|
-
registerLocaleResources("my-feature", {
|
|
29
|
-
"en-US": { title: "Orders" },
|
|
30
|
-
"zh-CN": { title: "订单" },
|
|
31
|
-
});
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
Other installed components can opt into another server-generated namespace:
|
|
35
|
-
|
|
36
|
-
```ts
|
|
37
|
-
import { registerServerResourceNamespace } from "@/extensions/nocobase-i18n";
|
|
38
|
-
|
|
39
|
-
registerServerResourceNamespace("my-dynamic-namespace");
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
Namespaces registered after startup are loaded incrementally. Existing exact
|
|
43
|
-
NocoBase expressions such as `{{t("Orders")}}` remain supported by the
|
|
44
|
-
Starter's translation compatibility helper.
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./language-switcher";
|
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
import { useGetLocale, useSetLocale, useTranslate } from "@refinedev/core";
|
|
2
|
-
import { Languages, Loader2 } from "lucide-react";
|
|
3
|
-
import { useState, type ReactNode } from "react";
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
DropdownMenuRadioGroup,
|
|
7
|
-
DropdownMenuRadioItem,
|
|
8
|
-
DropdownMenuSeparator,
|
|
9
|
-
DropdownMenuSub,
|
|
10
|
-
DropdownMenuSubContent,
|
|
11
|
-
DropdownMenuSubTrigger,
|
|
12
|
-
} from "@/components/ui/dropdown-menu";
|
|
13
|
-
import {
|
|
14
|
-
Select,
|
|
15
|
-
SelectContent,
|
|
16
|
-
SelectItem,
|
|
17
|
-
SelectTrigger,
|
|
18
|
-
SelectValue,
|
|
19
|
-
} from "@/components/ui/select";
|
|
20
|
-
import { cn } from "@/lib/utils";
|
|
21
|
-
import { useEnabledLocales } from "@/providers/i18n";
|
|
22
|
-
|
|
23
|
-
export type LanguageSwitcherProps = {
|
|
24
|
-
className?: string;
|
|
25
|
-
label?: ReactNode | false;
|
|
26
|
-
triggerClassName?: string;
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
export function LanguageSwitcher({
|
|
30
|
-
className,
|
|
31
|
-
label,
|
|
32
|
-
triggerClassName,
|
|
33
|
-
}: LanguageSwitcherProps) {
|
|
34
|
-
const translate = useTranslate();
|
|
35
|
-
const getLocale = useGetLocale();
|
|
36
|
-
const setLocale = useSetLocale();
|
|
37
|
-
const locales = useEnabledLocales();
|
|
38
|
-
const currentLocale = getLocale();
|
|
39
|
-
const [switching, setSwitching] = useState(false);
|
|
40
|
-
const [error, setError] = useState<string>();
|
|
41
|
-
const resolvedLabel =
|
|
42
|
-
typeof label === "undefined"
|
|
43
|
-
? translate("language.label", { ns: "nocobase-i18n" }, "Language")
|
|
44
|
-
: label;
|
|
45
|
-
|
|
46
|
-
if (locales.length < 2) return null;
|
|
47
|
-
|
|
48
|
-
const currentDefinition =
|
|
49
|
-
locales.find(({ locale }) => locale === currentLocale) ?? locales[0];
|
|
50
|
-
|
|
51
|
-
return (
|
|
52
|
-
<div className={cn("space-y-2", className)}>
|
|
53
|
-
{resolvedLabel === false ? null : (
|
|
54
|
-
<p className="text-xs font-medium text-muted-foreground">
|
|
55
|
-
{resolvedLabel}
|
|
56
|
-
</p>
|
|
57
|
-
)}
|
|
58
|
-
<Select
|
|
59
|
-
value={currentLocale}
|
|
60
|
-
disabled={switching}
|
|
61
|
-
onValueChange={(value) => {
|
|
62
|
-
if (!value || value === currentLocale) return;
|
|
63
|
-
setSwitching(true);
|
|
64
|
-
setError(undefined);
|
|
65
|
-
Promise.resolve(setLocale(value)).catch((reason) => {
|
|
66
|
-
setError(
|
|
67
|
-
reason instanceof Error
|
|
68
|
-
? reason.message
|
|
69
|
-
: translate(
|
|
70
|
-
"language.switchError",
|
|
71
|
-
{ ns: "nocobase-i18n" },
|
|
72
|
-
"Unable to switch language."
|
|
73
|
-
)
|
|
74
|
-
);
|
|
75
|
-
setSwitching(false);
|
|
76
|
-
});
|
|
77
|
-
}}
|
|
78
|
-
>
|
|
79
|
-
<SelectTrigger
|
|
80
|
-
className={cn("w-full min-w-52", triggerClassName)}
|
|
81
|
-
aria-label={String(resolvedLabel || "Language")}
|
|
82
|
-
>
|
|
83
|
-
{switching ? <Loader2 className="animate-spin" /> : <Languages />}
|
|
84
|
-
<SelectValue>{currentDefinition?.label ?? currentLocale}</SelectValue>
|
|
85
|
-
</SelectTrigger>
|
|
86
|
-
<SelectContent>
|
|
87
|
-
{locales.map((definition) => (
|
|
88
|
-
<SelectItem key={definition.locale} value={definition.locale}>
|
|
89
|
-
{definition.label}
|
|
90
|
-
</SelectItem>
|
|
91
|
-
))}
|
|
92
|
-
</SelectContent>
|
|
93
|
-
</Select>
|
|
94
|
-
{error ? <p className="text-xs text-destructive">{error}</p> : null}
|
|
95
|
-
</div>
|
|
96
|
-
);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
export function LanguageUserMenuItems() {
|
|
100
|
-
const translate = useTranslate();
|
|
101
|
-
const getLocale = useGetLocale();
|
|
102
|
-
const setLocale = useSetLocale();
|
|
103
|
-
const locales = useEnabledLocales();
|
|
104
|
-
const currentLocale = getLocale();
|
|
105
|
-
|
|
106
|
-
if (locales.length < 2) return null;
|
|
107
|
-
|
|
108
|
-
return (
|
|
109
|
-
<>
|
|
110
|
-
<DropdownMenuSeparator />
|
|
111
|
-
<DropdownMenuSub>
|
|
112
|
-
<DropdownMenuSubTrigger className="min-h-9 gap-2 px-2 text-muted-foreground focus:text-foreground">
|
|
113
|
-
<Languages />
|
|
114
|
-
<span>
|
|
115
|
-
{translate("language.label", { ns: "nocobase-i18n" }, "Language")}
|
|
116
|
-
</span>
|
|
117
|
-
</DropdownMenuSubTrigger>
|
|
118
|
-
<DropdownMenuSubContent className="min-w-44">
|
|
119
|
-
<DropdownMenuRadioGroup
|
|
120
|
-
value={currentLocale}
|
|
121
|
-
onValueChange={(value) => {
|
|
122
|
-
if (value && value !== currentLocale) void setLocale(value);
|
|
123
|
-
}}
|
|
124
|
-
>
|
|
125
|
-
{locales.map((definition) => (
|
|
126
|
-
<DropdownMenuRadioItem
|
|
127
|
-
key={definition.locale}
|
|
128
|
-
value={definition.locale}
|
|
129
|
-
>
|
|
130
|
-
{definition.label}
|
|
131
|
-
</DropdownMenuRadioItem>
|
|
132
|
-
))}
|
|
133
|
-
</DropdownMenuRadioGroup>
|
|
134
|
-
</DropdownMenuSubContent>
|
|
135
|
-
</DropdownMenuSub>
|
|
136
|
-
</>
|
|
137
|
-
);
|
|
138
|
-
}
|