@allbluecn/admin-app 0.1.0
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/package.json +86 -0
- package/src/client.tsx +31 -0
- package/src/components/admin/admin-user-menu.tsx +90 -0
- package/src/components/admin/developer-log.tsx +356 -0
- package/src/components/ai-provider/model-list-editor.tsx +147 -0
- package/src/components/ai-provider/provider-form.tsx +434 -0
- package/src/components/ai-provider/provider-icon.tsx +43 -0
- package/src/components/ai-provider/provider-logo.tsx +87 -0
- package/src/components/ai-provider/provider-table.tsx +258 -0
- package/src/components/auth/admin-login-form.tsx +214 -0
- package/src/components/auth/auth-brand-panel.tsx +60 -0
- package/src/components/auth/auth-header.tsx +38 -0
- package/src/components/auth/auth-layout.tsx +66 -0
- package/src/components/auth/auth-providers.tsx +34 -0
- package/src/components/auth/icon-input.tsx +46 -0
- package/src/components/auth/oauth-section.tsx +51 -0
- package/src/components/auth/password-input.tsx +67 -0
- package/src/components/common/page-header.tsx +42 -0
- package/src/components/common/placeholder-page.tsx +42 -0
- package/src/components/component/component-form-dialog.tsx +348 -0
- package/src/components/component/component-import-dialog.tsx +235 -0
- package/src/components/component/component-table.tsx +153 -0
- package/src/components/data-table/data-table-pagination.tsx +114 -0
- package/src/components/data-table/data-table.tsx +218 -0
- package/src/components/data-table/table-detail-layout.tsx +99 -0
- package/src/components/dependency/changelog-dialog.tsx +108 -0
- package/src/components/dependency/columns.tsx +232 -0
- package/src/components/dependency/dependency-table.tsx +368 -0
- package/src/components/dependency/edit-dialog.tsx +200 -0
- package/src/components/knowledge-public/bookmark-form-dialog.tsx +215 -0
- package/src/components/knowledge-public/compliance-form-dialog.tsx +308 -0
- package/src/components/knowledge-public/legal-form-dialog.tsx +315 -0
- package/src/components/layout/sidebar-02/app-sidebar.tsx +160 -0
- package/src/components/layout/sidebar-02/index.tsx +33 -0
- package/src/components/layout/sidebar-02/logo.tsx +40 -0
- package/src/components/layout/sidebar-02/nav-main.tsx +153 -0
- package/src/components/layout/sidebar-02/nav-notifications.tsx +78 -0
- package/src/components/layout/sidebar-02/team-switcher.tsx +106 -0
- package/src/components/magicui/animated-theme-toggler.tsx +272 -0
- package/src/components/magicui/rainbow-button.tsx +78 -0
- package/src/components/market/columns.tsx +151 -0
- package/src/components/market/market-app-form.tsx +237 -0
- package/src/components/market/market-app-list.tsx +156 -0
- package/src/components/monitoring/error-list.tsx +143 -0
- package/src/components/monitoring/health-cards.tsx +152 -0
- package/src/components/monitoring/metrics-stats.tsx +184 -0
- package/src/components/monitoring/request-log-table.tsx +179 -0
- package/src/components/providers/theme-toggle.tsx +59 -0
- package/src/components/settings/avatar/avatar-config.ts +46 -0
- package/src/components/ui/alert-dialog.tsx +216 -0
- package/src/components/ui/alert.tsx +76 -0
- package/src/components/ui/avatar.tsx +129 -0
- package/src/components/ui/badge.tsx +66 -0
- package/src/components/ui/button.tsx +84 -0
- package/src/components/ui/card.tsx +120 -0
- package/src/components/ui/checkbox.tsx +50 -0
- package/src/components/ui/collapsible.tsx +50 -0
- package/src/components/ui/dialog.tsx +185 -0
- package/src/components/ui/dropdown-menu.tsx +286 -0
- package/src/components/ui/field.tsx +255 -0
- package/src/components/ui/input-group.tsx +171 -0
- package/src/components/ui/input.tsx +36 -0
- package/src/components/ui/label.tsx +41 -0
- package/src/components/ui/pagination.tsx +146 -0
- package/src/components/ui/select.tsx +209 -0
- package/src/components/ui/separator.tsx +45 -0
- package/src/components/ui/sheet.tsx +164 -0
- package/src/components/ui/sidebar.tsx +719 -0
- package/src/components/ui/skeleton.tsx +30 -0
- package/src/components/ui/sonner.tsx +37 -0
- package/src/components/ui/switch.tsx +48 -0
- package/src/components/ui/table.tsx +133 -0
- package/src/components/ui/textarea.tsx +35 -0
- package/src/components/ui/tooltip.tsx +74 -0
- package/src/components/user/columns.tsx +153 -0
- package/src/components/user/settings-activity-log.tsx +358 -0
- package/src/components/user/settings-profile/constants.ts +42 -0
- package/src/components/user/settings-profile/types.ts +47 -0
- package/src/components/user/settings-profile.tsx +664 -0
- package/src/components/user/user-create-dialog.tsx +137 -0
- package/src/components/user/user-filters.tsx +117 -0
- package/src/hooks/use-mobile.ts +36 -0
- package/src/instrument.client.ts +34 -0
- package/src/lib/anyhub/capabilities.ts +59 -0
- package/src/lib/anyhub/types.ts +43 -0
- package/src/lib/auth-client.ts +83 -0
- package/src/lib/auth-utils.ts +24 -0
- package/src/lib/auth.config.ts +264 -0
- package/src/lib/avatar.ts +41 -0
- package/src/lib/i18n/client.ts +32 -0
- package/src/lib/i18n/config.ts +40 -0
- package/src/lib/i18n/detect.ts +43 -0
- package/src/lib/i18n/locales/en/admin-ai.json +128 -0
- package/src/lib/i18n/locales/en/admin-billing.json +56 -0
- package/src/lib/i18n/locales/en/admin-users.json +88 -0
- package/src/lib/i18n/locales/en/common.json +877 -0
- package/src/lib/i18n/locales/en/enterprise.json +208 -0
- package/src/lib/i18n/locales/zh/admin-ai.json +128 -0
- package/src/lib/i18n/locales/zh/admin-billing.json +56 -0
- package/src/lib/i18n/locales/zh/admin-users.json +88 -0
- package/src/lib/i18n/locales/zh/common.json +877 -0
- package/src/lib/i18n/locales/zh/enterprise.json +208 -0
- package/src/lib/i18n/server.ts +18 -0
- package/src/lib/i18n/types.ts +5 -0
- package/src/lib/monitoring-benchmarks.ts +85 -0
- package/src/lib/monitoring-descriptions.ts +78 -0
- package/src/lib/prisma.ts +18 -0
- package/src/lib/router-context.ts +38 -0
- package/src/lib/session.ts +38 -0
- package/src/lib/utils.ts +23 -0
- package/src/providers/index.tsx +45 -0
- package/src/routeTree.gen.ts +1199 -0
- package/src/router.tsx +51 -0
- package/src/routes/__root.tsx +170 -0
- package/src/routes/_nav/ai-providers/$id/edit/route.lazy.tsx +74 -0
- package/src/routes/_nav/ai-providers/$id/edit/route.tsx +35 -0
- package/src/routes/_nav/ai-providers/index/route.lazy.tsx +33 -0
- package/src/routes/_nav/ai-providers/new/route.lazy.tsx +31 -0
- package/src/routes/_nav/ai-providers/new/route.tsx +20 -0
- package/src/routes/_nav/ai-providers/route.lazy.tsx +26 -0
- package/src/routes/_nav/ai-providers/route.tsx +31 -0
- package/src/routes/_nav/apps/route.lazy.tsx +30 -0
- package/src/routes/_nav/apps/route.tsx +20 -0
- package/src/routes/_nav/audit/route.lazy.tsx +100 -0
- package/src/routes/_nav/audit/route.tsx +25 -0
- package/src/routes/_nav/billing/invoices/route.lazy.tsx +86 -0
- package/src/routes/_nav/billing/invoices/route.tsx +25 -0
- package/src/routes/_nav/billing/route.lazy.tsx +48 -0
- package/src/routes/_nav/billing/route.tsx +27 -0
- package/src/routes/_nav/billing/subscriptions/$subscriptionId/route.lazy.tsx +160 -0
- package/src/routes/_nav/billing/subscriptions/$subscriptionId/route.tsx +25 -0
- package/src/routes/_nav/billing/subscriptions/route.lazy.tsx +113 -0
- package/src/routes/_nav/billing/subscriptions/route.tsx +28 -0
- package/src/routes/_nav/compliance/route.lazy.tsx +184 -0
- package/src/routes/_nav/compliance/route.tsx +25 -0
- package/src/routes/_nav/components/route.lazy.tsx +184 -0
- package/src/routes/_nav/components/route.tsx +40 -0
- package/src/routes/_nav/dashboard/route.lazy.tsx +33 -0
- package/src/routes/_nav/dashboard/route.tsx +20 -0
- package/src/routes/_nav/dependencies/route.lazy.tsx +66 -0
- package/src/routes/_nav/dependencies/route.tsx +32 -0
- package/src/routes/_nav/developer-logs/route.lazy.tsx +6 -0
- package/src/routes/_nav/developer-logs/route.tsx +14 -0
- package/src/routes/_nav/docs/route.lazy.tsx +30 -0
- package/src/routes/_nav/docs/route.tsx +20 -0
- package/src/routes/_nav/knowledge-public/bookmarks/route.lazy.tsx +355 -0
- package/src/routes/_nav/knowledge-public/bookmarks/route.tsx +40 -0
- package/src/routes/_nav/knowledge-public/compliance/route.lazy.tsx +245 -0
- package/src/routes/_nav/knowledge-public/compliance/route.tsx +40 -0
- package/src/routes/_nav/knowledge-public/legal/route.lazy.tsx +242 -0
- package/src/routes/_nav/knowledge-public/legal/route.tsx +40 -0
- package/src/routes/_nav/licenses/$licenseId/route.lazy.tsx +235 -0
- package/src/routes/_nav/licenses/$licenseId/route.tsx +25 -0
- package/src/routes/_nav/licenses/new/route.lazy.tsx +237 -0
- package/src/routes/_nav/licenses/route.lazy.tsx +143 -0
- package/src/routes/_nav/licenses/route.tsx +25 -0
- package/src/routes/_nav/market/route.lazy.tsx +31 -0
- package/src/routes/_nav/market/route.tsx +20 -0
- package/src/routes/_nav/monitoring/ai-usage/route.lazy.tsx +305 -0
- package/src/routes/_nav/monitoring/ai-usage/route.tsx +3 -0
- package/src/routes/_nav/monitoring/errors/route.lazy.tsx +111 -0
- package/src/routes/_nav/monitoring/health/route.lazy.tsx +260 -0
- package/src/routes/_nav/monitoring/logs/route.lazy.tsx +165 -0
- package/src/routes/_nav/monitoring/metrics/route.lazy.tsx +240 -0
- package/src/routes/_nav/monitoring/overview/route.lazy.tsx +138 -0
- package/src/routes/_nav/monitoring/route.lazy.tsx +68 -0
- package/src/routes/_nav/monitoring/route.tsx +20 -0
- package/src/routes/_nav/monitoring/sentry/route.lazy.tsx +399 -0
- package/src/routes/_nav/monitoring/sentry/route.tsx +20 -0
- package/src/routes/_nav/permissions/route.lazy.tsx +504 -0
- package/src/routes/_nav/permissions/route.tsx +26 -0
- package/src/routes/_nav/route.lazy.tsx +31 -0
- package/src/routes/_nav/route.tsx +34 -0
- package/src/routes/_nav/settings/route.lazy.tsx +30 -0
- package/src/routes/_nav/settings/route.tsx +20 -0
- package/src/routes/_nav/sso/route.lazy.tsx +145 -0
- package/src/routes/_nav/sso/route.tsx +25 -0
- package/src/routes/_nav/users/$userId/route.lazy.tsx +432 -0
- package/src/routes/_nav/users/$userId/route.tsx +27 -0
- package/src/routes/_nav/users/-components/users-table.tsx +38 -0
- package/src/routes/_nav/users/route.lazy.tsx +74 -0
- package/src/routes/_nav/users/route.tsx +43 -0
- package/src/routes/api/compliance-download/$jobId.ts +35 -0
- package/src/routes/api/observability/errors.ts +41 -0
- package/src/routes/api/observability/health.ts +30 -0
- package/src/routes/api.auth.$.ts +31 -0
- package/src/routes/api.sentry-test.ts +33 -0
- package/src/routes/index/route.lazy.tsx +22 -0
- package/src/routes/index/route.tsx +24 -0
- package/src/routes/login/route.lazy.tsx +46 -0
- package/src/routes/login/route.tsx +28 -0
- package/src/routes/sentry-tunnel.ts +61 -0
- package/src/routes/setup/route.lazy.tsx +94 -0
- package/src/routes/setup/route.tsx +28 -0
- package/src/server/__tests__/admin-ai-alerts.test.ts +113 -0
- package/src/server/__tests__/licenses-issue.test.ts +98 -0
- package/src/server/admin-ai-alerts.ts +177 -0
- package/src/server/admin-ai-usage.ts +134 -0
- package/src/server/auth-helpers.ts +51 -0
- package/src/server/entitlements.ts +24 -0
- package/src/server/knowledge-public/canonical-id.ts +55 -0
- package/src/server/knowledge-public/github-sync.ts +86 -0
- package/src/server/license-issue.ts +78 -0
- package/src/server/middlewares/request.ts +26 -0
- package/src/server/observability/debug-middleware.ts +39 -0
- package/src/server/observability/error-reporter.ts +99 -0
- package/src/server/observability/health-check.ts +140 -0
- package/src/server/observability/index.ts +33 -0
- package/src/server/observability/logger.ts +49 -0
- package/src/server/observability/metrics.ts +105 -0
- package/src/server/observability/request-middleware.ts +125 -0
- package/src/server/observability/timing.ts +42 -0
- package/src/server/pro-services.ts +32 -0
- package/src/server/serverFns/admin-billing.ts +94 -0
- package/src/server/serverFns/ai-provider/create.ts +92 -0
- package/src/server/serverFns/ai-provider/delete.ts +42 -0
- package/src/server/serverFns/ai-provider/get.ts +35 -0
- package/src/server/serverFns/ai-provider/list.ts +92 -0
- package/src/server/serverFns/ai-provider/update.ts +73 -0
- package/src/server/serverFns/anyhub/market.ts +64 -0
- package/src/server/serverFns/audit.ts +57 -0
- package/src/server/serverFns/auth/session.ts +26 -0
- package/src/server/serverFns/auth/setup.ts +73 -0
- package/src/server/serverFns/compliance.ts +85 -0
- package/src/server/serverFns/components/import.ts +197 -0
- package/src/server/serverFns/components/list.ts +51 -0
- package/src/server/serverFns/components/mutations.ts +84 -0
- package/src/server/serverFns/dependency/helpers.ts +245 -0
- package/src/server/serverFns/dependency/list.ts +127 -0
- package/src/server/serverFns/dependency/sync.ts +123 -0
- package/src/server/serverFns/dependency/update.ts +51 -0
- package/src/server/serverFns/developer-log-auto-generate.ts +176 -0
- package/src/server/serverFns/developer-logs.ts +132 -0
- package/src/server/serverFns/knowledge-public/bookmarks/create.ts +53 -0
- package/src/server/serverFns/knowledge-public/bookmarks/delete.ts +31 -0
- package/src/server/serverFns/knowledge-public/bookmarks/detail.ts +32 -0
- package/src/server/serverFns/knowledge-public/bookmarks/list.ts +66 -0
- package/src/server/serverFns/knowledge-public/bookmarks/sync-all-github.ts +56 -0
- package/src/server/serverFns/knowledge-public/bookmarks/update.ts +50 -0
- package/src/server/serverFns/knowledge-public/compliance/create.ts +58 -0
- package/src/server/serverFns/knowledge-public/compliance/delete.ts +31 -0
- package/src/server/serverFns/knowledge-public/compliance/detail.ts +32 -0
- package/src/server/serverFns/knowledge-public/compliance/list.ts +59 -0
- package/src/server/serverFns/knowledge-public/compliance/update.ts +53 -0
- package/src/server/serverFns/knowledge-public/legal/create.ts +62 -0
- package/src/server/serverFns/knowledge-public/legal/delete.ts +31 -0
- package/src/server/serverFns/knowledge-public/legal/detail.ts +32 -0
- package/src/server/serverFns/knowledge-public/legal/list.ts +60 -0
- package/src/server/serverFns/knowledge-public/legal/update.ts +55 -0
- package/src/server/serverFns/licenses.ts +92 -0
- package/src/server/serverFns/locale.ts +10 -0
- package/src/server/serverFns/monitoring/check-ai-alerts.ts +13 -0
- package/src/server/serverFns/monitoring/get-ai-usage-overview.ts +25 -0
- package/src/server/serverFns/monitoring/get-errors.ts +43 -0
- package/src/server/serverFns/monitoring/get-health-settings.ts +35 -0
- package/src/server/serverFns/monitoring/get-health.ts +55 -0
- package/src/server/serverFns/monitoring/get-metrics.ts +46 -0
- package/src/server/serverFns/monitoring/get-request-logs.ts +66 -0
- package/src/server/serverFns/monitoring/report-error.ts +55 -0
- package/src/server/serverFns/monitoring/reset.ts +70 -0
- package/src/server/serverFns/permissions.ts +214 -0
- package/src/server/serverFns/sentry/config.ts +88 -0
- package/src/server/serverFns/sso-config.ts +83 -0
- package/src/server/serverFns/user/create.ts +40 -0
- package/src/server/serverFns/user/delete.ts +29 -0
- package/src/server/serverFns/user/detail.ts +45 -0
- package/src/server/serverFns/user/list.ts +56 -0
- package/src/server/serverFns/user/reset-password.ts +28 -0
- package/src/server/serverFns/user/update-role.ts +26 -0
- package/src/server/serverFns/user/update-status.ts +26 -0
- package/src/server.ts +27 -0
- package/src/start.ts +85 -0
- package/src/styles/_keyframe-animations.scss +91 -0
- package/src/styles/_variables.scss +296 -0
- package/src/styles/globals.css +200 -0
- package/src/types/start-authjs.d.ts +27 -0
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
2
|
+
// AllBlue - 理想之海
|
|
3
|
+
// Copyright (C) 2026 AllBlue Contributors
|
|
4
|
+
//
|
|
5
|
+
// This program is free software: you can redistribute it and/or modify
|
|
6
|
+
// it under the terms of the GNU Affero General Public License as published by
|
|
7
|
+
// the Free Software Foundation, either version 3 of the License, or
|
|
8
|
+
// (at your option) any later version.
|
|
9
|
+
//
|
|
10
|
+
// This program is distributed in the hope that it will be useful,
|
|
11
|
+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
+
// GNU Affero General Public License for more details.
|
|
14
|
+
//
|
|
15
|
+
// You should have received a copy of the GNU Affero General Public License
|
|
16
|
+
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
17
|
+
|
|
18
|
+
import { Outlet, createLazyFileRoute, useMatches } from '@tanstack/react-router'
|
|
19
|
+
import { useState } from 'react'
|
|
20
|
+
import { useTranslation } from 'react-i18next'
|
|
21
|
+
import { UsersTable } from './-components/users-table'
|
|
22
|
+
import { UserFilters } from '@/components/user/user-filters'
|
|
23
|
+
import { UserCreateDialog } from '@/components/user/user-create-dialog'
|
|
24
|
+
import { Button } from '@/components/ui/button'
|
|
25
|
+
import { PlusIcon } from 'lucide-react'
|
|
26
|
+
|
|
27
|
+
export const Route = createLazyFileRoute('/_nav/users')({
|
|
28
|
+
pendingComponent: () => (
|
|
29
|
+
<div className="flex h-64 items-center justify-center">
|
|
30
|
+
<div className="size-8 animate-spin rounded-full border-2 border-primary border-t-transparent" />
|
|
31
|
+
</div>
|
|
32
|
+
),
|
|
33
|
+
component: UsersLayout,
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
function UsersLayout() {
|
|
37
|
+
const matches = useMatches()
|
|
38
|
+
const lastMatch = matches[matches.length - 1]
|
|
39
|
+
const isIndex = lastMatch?.routeId === '/_nav/users'
|
|
40
|
+
|
|
41
|
+
if (isIndex) {
|
|
42
|
+
return <UsersPage />
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return <Outlet />
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function UsersPage() {
|
|
49
|
+
const { t } = useTranslation('admin-users')
|
|
50
|
+
const { items, total } = Route.useLoaderData()
|
|
51
|
+
const { search, role, status } = Route.useSearch()
|
|
52
|
+
const [createOpen, setCreateOpen] = useState(false)
|
|
53
|
+
|
|
54
|
+
return (
|
|
55
|
+
<div className="space-y-4 p-6">
|
|
56
|
+
<div className="flex items-center justify-between">
|
|
57
|
+
<div>
|
|
58
|
+
<h2 className="text-xl font-bold">{t('page.title')}</h2>
|
|
59
|
+
<p className="text-sm text-muted-foreground">{t('page.total', { total })}</p>
|
|
60
|
+
</div>
|
|
61
|
+
<Button onClick={() => setCreateOpen(true)}>
|
|
62
|
+
<PlusIcon className="mr-1 h-4 w-4" />
|
|
63
|
+
{t('page.createUser')}
|
|
64
|
+
</Button>
|
|
65
|
+
</div>
|
|
66
|
+
|
|
67
|
+
<UserFilters search={search} role={role} status={status} />
|
|
68
|
+
|
|
69
|
+
<UsersTable users={items} />
|
|
70
|
+
|
|
71
|
+
<UserCreateDialog open={createOpen} onOpenChange={setCreateOpen} />
|
|
72
|
+
</div>
|
|
73
|
+
)
|
|
74
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
2
|
+
// AllBlue - 理想之海
|
|
3
|
+
// Copyright (C) 2026 AllBlue Contributors
|
|
4
|
+
//
|
|
5
|
+
// This program is free software: you can redistribute it and/or modify
|
|
6
|
+
// it under the terms of the GNU Affero General Public License as published by
|
|
7
|
+
// the Free Software Foundation, either version 3 of the License, or
|
|
8
|
+
// (at your option) any later version.
|
|
9
|
+
//
|
|
10
|
+
// This program is distributed in the hope that it will be useful,
|
|
11
|
+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
+
// GNU Affero General Public License for more details.
|
|
14
|
+
//
|
|
15
|
+
// You should have received a copy of the GNU Affero General Public License
|
|
16
|
+
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
17
|
+
|
|
18
|
+
import { createFileRoute } from '@tanstack/react-router'
|
|
19
|
+
import { z } from 'zod'
|
|
20
|
+
import { listUsersFn } from '@/server/serverFns/user/list'
|
|
21
|
+
|
|
22
|
+
const userSearchSchema = z.object({
|
|
23
|
+
search: z.string().optional(),
|
|
24
|
+
role: z.string().optional(),
|
|
25
|
+
status: z.string().optional(),
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
export const Route = createFileRoute('/_nav/users')({
|
|
29
|
+
validateSearch: userSearchSchema,
|
|
30
|
+
loaderDeps: ({ search }) => search,
|
|
31
|
+
loader: async ({ deps }) => {
|
|
32
|
+
const result = await listUsersFn({
|
|
33
|
+
data: {
|
|
34
|
+
page: 1,
|
|
35
|
+
pageSize: 50,
|
|
36
|
+
search: deps.search,
|
|
37
|
+
role: deps.role as 'USER' | 'ADMIN' | 'SUPER_ADMIN' | undefined,
|
|
38
|
+
status: deps.status as 'ACTIVE' | 'INACTIVE' | 'BANNED' | undefined,
|
|
39
|
+
},
|
|
40
|
+
})
|
|
41
|
+
return result
|
|
42
|
+
},
|
|
43
|
+
})
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { createFileRoute } from '@tanstack/react-router'
|
|
2
|
+
import { prisma } from '@allbluecn/database'
|
|
3
|
+
import { requireAdmin } from '@/server/auth-helpers'
|
|
4
|
+
|
|
5
|
+
export const Route = createFileRoute('/api/compliance-download/$jobId')({
|
|
6
|
+
server: {
|
|
7
|
+
handlers: {
|
|
8
|
+
GET: async ({ params, request }) => {
|
|
9
|
+
try {
|
|
10
|
+
await requireAdmin()
|
|
11
|
+
} catch {
|
|
12
|
+
return Response.json({ ok: false, message: '无权限访问' }, { status: 403 })
|
|
13
|
+
}
|
|
14
|
+
const job = await prisma.complianceExport.findUnique({
|
|
15
|
+
where: { id: params.jobId },
|
|
16
|
+
})
|
|
17
|
+
if (!job || job.status !== 'completed') {
|
|
18
|
+
return Response.json({ ok: false, message: '任务不存在或未完成' }, { status: 404 })
|
|
19
|
+
}
|
|
20
|
+
if (!job.content) {
|
|
21
|
+
return Response.json({ ok: false, message: '下载内容未生成' }, { status: 404 })
|
|
22
|
+
}
|
|
23
|
+
if (job.expiresAt && job.expiresAt < new Date()) {
|
|
24
|
+
return Response.json({ ok: false, message: '下载已过期' }, { status: 410 })
|
|
25
|
+
}
|
|
26
|
+
return new Response(job.content, {
|
|
27
|
+
headers: {
|
|
28
|
+
'content-type': 'application/json; charset=utf-8',
|
|
29
|
+
'content-disposition': `attachment; filename="allblue-export-${job.id}.json"`,
|
|
30
|
+
},
|
|
31
|
+
})
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
})
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
2
|
+
// AllBlue - 理想之海
|
|
3
|
+
// Copyright (C) 2026 AllBlue Contributors
|
|
4
|
+
//
|
|
5
|
+
// This program is free software: you can redistribute it and/or modify
|
|
6
|
+
// it under the terms of the GNU Affero General Public License as published by
|
|
7
|
+
// the Free Software Foundation, either version 3 of the License, or
|
|
8
|
+
// (at your option) any later version.
|
|
9
|
+
//
|
|
10
|
+
// This program is distributed in the hope that it will be useful,
|
|
11
|
+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
+
// GNU Affero General Public License for more details.
|
|
14
|
+
//
|
|
15
|
+
// You should have received a copy of the GNU Affero General Public License
|
|
16
|
+
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
17
|
+
|
|
18
|
+
import { createFileRoute } from '@tanstack/react-router'
|
|
19
|
+
|
|
20
|
+
export const Route = createFileRoute('/api/observability/errors')({
|
|
21
|
+
server: {
|
|
22
|
+
handlers: {
|
|
23
|
+
GET: async () => {
|
|
24
|
+
const { prisma } = await import('@allbluecn/database')
|
|
25
|
+
const errors = await prisma.monitoringErrorReport.findMany({
|
|
26
|
+
orderBy: { lastSeen: 'desc' },
|
|
27
|
+
take: 50,
|
|
28
|
+
})
|
|
29
|
+
return Response.json({
|
|
30
|
+
errors: errors.map((e) => ({
|
|
31
|
+
id: e.id,
|
|
32
|
+
errorName: e.errorName,
|
|
33
|
+
errorMessage: e.errorMessage,
|
|
34
|
+
count: e.count,
|
|
35
|
+
lastSeen: e.lastSeen.toISOString(),
|
|
36
|
+
})),
|
|
37
|
+
})
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
})
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
2
|
+
// AllBlue - 理想之海
|
|
3
|
+
// Copyright (C) 2026 AllBlue Contributors
|
|
4
|
+
//
|
|
5
|
+
// This program is free software: you can redistribute it and/or modify
|
|
6
|
+
// it under the terms of the GNU Affero General Public License as published by
|
|
7
|
+
// the Free Software Foundation, either version 3 of the License, or
|
|
8
|
+
// (at your option) any later version.
|
|
9
|
+
//
|
|
10
|
+
// This program is distributed in the hope that it will be useful,
|
|
11
|
+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
+
// GNU Affero General Public License for more details.
|
|
14
|
+
//
|
|
15
|
+
// You should have received a copy of the GNU Affero General Public License
|
|
16
|
+
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
17
|
+
|
|
18
|
+
import { createFileRoute } from '@tanstack/react-router'
|
|
19
|
+
import { performHealthCheck } from '@/server/observability'
|
|
20
|
+
|
|
21
|
+
export const Route = createFileRoute('/api/observability/health')({
|
|
22
|
+
server: {
|
|
23
|
+
handlers: {
|
|
24
|
+
GET: async () => {
|
|
25
|
+
const result = await performHealthCheck()
|
|
26
|
+
return Response.json(result)
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
})
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
2
|
+
// AllBlue - 理想之海
|
|
3
|
+
// Copyright (C) 2026 AllBlue Contributors
|
|
4
|
+
//
|
|
5
|
+
// This program is free software: you can redistribute it and/or modify
|
|
6
|
+
// it under the terms of the GNU Affero General Public License as published by
|
|
7
|
+
// the Free Software Foundation, either version 3 of the License, or
|
|
8
|
+
// (at your option) any later version.
|
|
9
|
+
//
|
|
10
|
+
// This program is distributed in the hope that it will be useful,
|
|
11
|
+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
+
// GNU Affero General Public License for more details.
|
|
14
|
+
//
|
|
15
|
+
// You should have received a copy of the GNU Affero General Public License
|
|
16
|
+
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
17
|
+
|
|
18
|
+
import { createFileRoute } from '@tanstack/react-router'
|
|
19
|
+
import { authConfig } from '@/lib/auth.config'
|
|
20
|
+
import { StartAuthJS } from 'start-authjs'
|
|
21
|
+
|
|
22
|
+
const authHandlers = StartAuthJS(authConfig)
|
|
23
|
+
|
|
24
|
+
export const Route = createFileRoute('/api/auth/$')({
|
|
25
|
+
server: {
|
|
26
|
+
handlers: {
|
|
27
|
+
GET: ({ request }) => authHandlers.GET({ request }),
|
|
28
|
+
POST: ({ request }) => authHandlers.POST({ request }),
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
})
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
2
|
+
// AllBlue - 理想之海
|
|
3
|
+
// Copyright (C) 2026 AllBlue Contributors
|
|
4
|
+
//
|
|
5
|
+
// This program is free software: you can redistribute it and/or modify
|
|
6
|
+
// it under the terms of the GNU Affero General Public License as published by
|
|
7
|
+
// the Free Software Foundation, either version 3 of the License, or
|
|
8
|
+
// (at your option) any later version.
|
|
9
|
+
//
|
|
10
|
+
// This program is distributed in the hope that it will be useful,
|
|
11
|
+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
+
// GNU Affero General Public License for more details.
|
|
14
|
+
//
|
|
15
|
+
// You should have received a copy of the GNU Affero General Public License
|
|
16
|
+
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
17
|
+
|
|
18
|
+
import { createFileRoute } from '@tanstack/react-router'
|
|
19
|
+
|
|
20
|
+
export const Route = createFileRoute('/api/sentry-test')({
|
|
21
|
+
server: {
|
|
22
|
+
handlers: {
|
|
23
|
+
GET: () => {
|
|
24
|
+
return new Response(
|
|
25
|
+
JSON.stringify({ message: 'Sentry test endpoint' }),
|
|
26
|
+
{
|
|
27
|
+
headers: { 'Content-Type': 'application/json' },
|
|
28
|
+
},
|
|
29
|
+
)
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
})
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
2
|
+
// AllBlue - 理想之海
|
|
3
|
+
// Copyright (C) 2026 AllBlue Contributors
|
|
4
|
+
//
|
|
5
|
+
// This program is free software: you can redistribute it and/or modify
|
|
6
|
+
// it under the terms of the GNU Affero General Public License as published by
|
|
7
|
+
// the Free Software Foundation, either version 3 of the License, or
|
|
8
|
+
// (at your option) any later version.
|
|
9
|
+
//
|
|
10
|
+
// This program is distributed in the hope that it will be useful,
|
|
11
|
+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
+
// GNU Affero General Public License for more details.
|
|
14
|
+
//
|
|
15
|
+
// You should have received a copy of the GNU Affero General Public License
|
|
16
|
+
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
17
|
+
|
|
18
|
+
import { createLazyFileRoute } from '@tanstack/react-router'
|
|
19
|
+
|
|
20
|
+
export const Route = createLazyFileRoute('/')({
|
|
21
|
+
component: () => null,
|
|
22
|
+
})
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
2
|
+
// AllBlue - 理想之海
|
|
3
|
+
// Copyright (C) 2026 AllBlue Contributors
|
|
4
|
+
//
|
|
5
|
+
// This program is free software: you can redistribute it and/or modify
|
|
6
|
+
// it under the terms of the GNU Affero General Public License as published by
|
|
7
|
+
// the Free Software Foundation, either version 3 of the License, or
|
|
8
|
+
// (at your option) any later version.
|
|
9
|
+
//
|
|
10
|
+
// This program is distributed in the hope that it will be useful,
|
|
11
|
+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
+
// GNU Affero General Public License for more details.
|
|
14
|
+
//
|
|
15
|
+
// You should have received a copy of the GNU Affero General Public License
|
|
16
|
+
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
17
|
+
|
|
18
|
+
import { createFileRoute, redirect } from '@tanstack/react-router'
|
|
19
|
+
|
|
20
|
+
export const Route = createFileRoute('/')({
|
|
21
|
+
beforeLoad: () => {
|
|
22
|
+
throw redirect({ to: '/dashboard', replace: true })
|
|
23
|
+
},
|
|
24
|
+
})
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
2
|
+
// AllBlue - 理想之海
|
|
3
|
+
// Copyright (C) 2026 AllBlue Contributors
|
|
4
|
+
//
|
|
5
|
+
// This program is free software: you can redistribute it and/or modify
|
|
6
|
+
// it under the terms of the GNU Affero General Public License as published by
|
|
7
|
+
// the Free Software Foundation, either version 3 of the License, or
|
|
8
|
+
// (at your option) any later version.
|
|
9
|
+
//
|
|
10
|
+
// This program is distributed in the hope that it will be useful,
|
|
11
|
+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
+
// GNU Affero General Public License for more details.
|
|
14
|
+
//
|
|
15
|
+
// You should have received a copy of the GNU Affero General Public License
|
|
16
|
+
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
17
|
+
|
|
18
|
+
import { createLazyFileRoute } from '@tanstack/react-router'
|
|
19
|
+
import AdminLoginForm from '@/components/auth/admin-login-form'
|
|
20
|
+
import { useSession } from '@/lib/auth-client'
|
|
21
|
+
import type { AvatarConfig, ShapeType } from '@allbluecn/kernel'
|
|
22
|
+
|
|
23
|
+
export const Route = createLazyFileRoute('/login')({
|
|
24
|
+
component: AdminLoginPage,
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
function AdminLoginPage() {
|
|
28
|
+
const context = Route.useRouteContext()
|
|
29
|
+
const ssrSession = context?.session as any
|
|
30
|
+
const { data: clientSession } = useSession()
|
|
31
|
+
const session = clientSession || ssrSession
|
|
32
|
+
const user = session?.user
|
|
33
|
+
? {
|
|
34
|
+
name: session.user.name,
|
|
35
|
+
email: session.user.email,
|
|
36
|
+
avatarConfig: (session.user as any).avatarConfig as AvatarConfig | undefined,
|
|
37
|
+
bgShape: (session.user as any).bgShape as string | undefined,
|
|
38
|
+
bgColor: (session.user as any).bgColor as string | undefined,
|
|
39
|
+
}
|
|
40
|
+
: null
|
|
41
|
+
const role = (session?.user as any)?.role
|
|
42
|
+
const isAdmin = role === 'ADMIN' || role === 'SUPER_ADMIN'
|
|
43
|
+
return (
|
|
44
|
+
<AdminLoginForm user={user} isAdmin={isAdmin} />
|
|
45
|
+
)
|
|
46
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
2
|
+
// AllBlue - 理想之海
|
|
3
|
+
// Copyright (C) 2026 AllBlue Contributors
|
|
4
|
+
//
|
|
5
|
+
// This program is free software: you can redistribute it and/or modify
|
|
6
|
+
// it under the terms of the GNU Affero General Public License as published by
|
|
7
|
+
// the Free Software Foundation, either version 3 of the License, or
|
|
8
|
+
// (at your option) any later version.
|
|
9
|
+
//
|
|
10
|
+
// This program is distributed in the hope that it will be useful,
|
|
11
|
+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
+
// GNU Affero General Public License for more details.
|
|
14
|
+
//
|
|
15
|
+
// You should have received a copy of the GNU Affero General Public License
|
|
16
|
+
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
17
|
+
|
|
18
|
+
import { createFileRoute, redirect } from '@tanstack/react-router'
|
|
19
|
+
import { checkAdminExistsFn } from '@/server/serverFns/auth/setup'
|
|
20
|
+
|
|
21
|
+
export const Route = createFileRoute('/login')({
|
|
22
|
+
beforeLoad: async () => {
|
|
23
|
+
const result = await checkAdminExistsFn().catch(() => null)
|
|
24
|
+
if (!result?.hasAdmin) {
|
|
25
|
+
throw redirect({ to: '/setup' })
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
})
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
2
|
+
// AllBlue - 理想之海
|
|
3
|
+
// Copyright (C) 2026 AllBlue Contributors
|
|
4
|
+
//
|
|
5
|
+
// This program is free software: you can redistribute it and/or modify
|
|
6
|
+
// it under the terms of the GNU Affero General Public License as published by
|
|
7
|
+
// the Free Software Foundation, either version 3 of the License, or
|
|
8
|
+
// (at your option) any later version.
|
|
9
|
+
//
|
|
10
|
+
// This program is distributed in the hope that it will be useful,
|
|
11
|
+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
+
// GNU Affero General Public License for more details.
|
|
14
|
+
//
|
|
15
|
+
// You should have received a copy of the GNU Affero General Public License
|
|
16
|
+
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
17
|
+
|
|
18
|
+
import { createFileRoute } from '@tanstack/react-router'
|
|
19
|
+
|
|
20
|
+
const SENTRY_INGEST = 'https://sentry.io/api/{dsn_key}/envelope/'
|
|
21
|
+
|
|
22
|
+
async function getSentryDsn(): Promise<string | null> {
|
|
23
|
+
const { prisma } = await import('@allbluecn/database')
|
|
24
|
+
const setting = await prisma.systemSetting.findUnique({
|
|
25
|
+
where: { key: 'dsn' },
|
|
26
|
+
})
|
|
27
|
+
return setting?.value || null
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export const Route = createFileRoute('/sentry-tunnel')({
|
|
31
|
+
server: {
|
|
32
|
+
handlers: {
|
|
33
|
+
POST: async ({ request }) => {
|
|
34
|
+
const dsn = await getSentryDsn()
|
|
35
|
+
if (!dsn) {
|
|
36
|
+
return new Response('Sentry not configured', { status: 200 })
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const parsed = new URL(dsn)
|
|
40
|
+
const projectId = parsed.pathname.replace('/', '')
|
|
41
|
+
const ingestUrl = `https://${parsed.hostname}/api/${projectId}/envelope/`
|
|
42
|
+
|
|
43
|
+
const envelope = await request.arrayBuffer()
|
|
44
|
+
|
|
45
|
+
const upstream = await fetch(ingestUrl, {
|
|
46
|
+
method: 'POST',
|
|
47
|
+
headers: {
|
|
48
|
+
'Content-Type': 'application/x-sentry-envelope',
|
|
49
|
+
},
|
|
50
|
+
body: envelope,
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
if (!upstream.ok) {
|
|
54
|
+
return new Response('Upstream error', { status: upstream.status })
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return new Response(null, { status: 204 })
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
})
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
2
|
+
// AllBlue - 理想之海
|
|
3
|
+
// Copyright (C) 2026 AllBlue Contributors
|
|
4
|
+
//
|
|
5
|
+
// This program is free software: you can redistribute it and/or modify
|
|
6
|
+
// it under the terms of the GNU Affero General Public License as published by
|
|
7
|
+
// the Free Software Foundation, either version 3 of the License, or
|
|
8
|
+
// (at your option) any later version.
|
|
9
|
+
//
|
|
10
|
+
// This program is distributed in the hope that it will be useful,
|
|
11
|
+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
+
// GNU Affero General Public License for more details.
|
|
14
|
+
//
|
|
15
|
+
// You should have received a copy of the GNU Affero General Public License
|
|
16
|
+
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
17
|
+
|
|
18
|
+
import { createLazyFileRoute, useNavigate } from '@tanstack/react-router'
|
|
19
|
+
import { useState } from 'react'
|
|
20
|
+
import { useTranslation } from 'react-i18next'
|
|
21
|
+
import { toast } from '@/components/ui/sonner'
|
|
22
|
+
import { Loader2, ShieldCheck, User, Mail, Database } from 'lucide-react'
|
|
23
|
+
import { AuthLayout, AuthLayoutLeft, AuthLayoutRight } from '@/components/auth/auth-layout'
|
|
24
|
+
import { AuthHeader } from '@/components/auth/auth-header'
|
|
25
|
+
import { AuthBrandPanel } from '@/components/auth/auth-brand-panel'
|
|
26
|
+
import { PasswordInput } from '@/components/auth/password-input'
|
|
27
|
+
import { IconInput } from '@/components/auth/icon-input'
|
|
28
|
+
import { Button } from '@/components/ui/button'
|
|
29
|
+
import { setupAdminFn } from '@/server/serverFns/auth/setup'
|
|
30
|
+
|
|
31
|
+
export const Route = createLazyFileRoute('/setup')({
|
|
32
|
+
component: SetupPage,
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
function SetupPage() {
|
|
36
|
+
const { t } = useTranslation('common')
|
|
37
|
+
const navigate = useNavigate()
|
|
38
|
+
const [username, setUsername] = useState('')
|
|
39
|
+
const [email, setEmail] = useState('')
|
|
40
|
+
const [password, setPassword] = useState('')
|
|
41
|
+
const [confirmPassword, setConfirmPassword] = useState('')
|
|
42
|
+
const [loading, setLoading] = useState(false)
|
|
43
|
+
|
|
44
|
+
const setupBrandFeatures = [
|
|
45
|
+
{ icon: ShieldCheck, label: t('setup.brandFeatures.superAdmin.label'), desc: t('setup.brandFeatures.superAdmin.desc') },
|
|
46
|
+
{ icon: Database, label: t('setup.brandFeatures.dataMgmt.label'), desc: t('setup.brandFeatures.dataMgmt.desc') },
|
|
47
|
+
{ icon: User, label: t('setup.brandFeatures.accountSecurity.label'), desc: t('setup.brandFeatures.accountSecurity.desc') },
|
|
48
|
+
]
|
|
49
|
+
|
|
50
|
+
const handleSubmit = async (e: React.FormEvent) => {
|
|
51
|
+
e.preventDefault()
|
|
52
|
+
|
|
53
|
+
if (!username || !email || !password) {
|
|
54
|
+
toast.error(t('setup.validation.fillAllFields'))
|
|
55
|
+
return
|
|
56
|
+
}
|
|
57
|
+
if (password !== confirmPassword) {
|
|
58
|
+
toast.error(t('setup.validation.passwordMismatch'))
|
|
59
|
+
return
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
setLoading(true)
|
|
63
|
+
try {
|
|
64
|
+
await setupAdminFn({ data: { username, email, password } })
|
|
65
|
+
toast.success(t('setup.success'))
|
|
66
|
+
setTimeout(() => navigate({ to: '/login' }), 500)
|
|
67
|
+
} catch (err) {
|
|
68
|
+
toast.error(err instanceof Error ? err.message : t('setup.error'))
|
|
69
|
+
} finally {
|
|
70
|
+
setLoading(false)
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return (
|
|
75
|
+
<AuthLayout>
|
|
76
|
+
<AuthLayoutLeft>
|
|
77
|
+
<AuthHeader title={t('setup.form.title')} subtitle={t('setup.form.subtitle')} />
|
|
78
|
+
<form onSubmit={handleSubmit} className="space-y-6">
|
|
79
|
+
<IconInput icon={User} label={t('setup.form.username.label')} placeholder={t('setup.form.username.placeholder')} value={username} onChange={(e) => setUsername(e.target.value)} />
|
|
80
|
+
<IconInput icon={Mail} label={t('setup.form.email.label')} placeholder={t('setup.form.email.placeholder')} value={email} onChange={(e) => setEmail(e.target.value)} />
|
|
81
|
+
<PasswordInput label={t('setup.form.password.label')} placeholder={t('setup.form.password.placeholder')} value={password} onChange={(e) => setPassword(e.target.value)} />
|
|
82
|
+
<PasswordInput label={t('setup.form.confirmPassword.label')} placeholder={t('setup.form.confirmPassword.placeholder')} value={confirmPassword} onChange={(e) => setConfirmPassword(e.target.value)} />
|
|
83
|
+
<Button type="submit" className="w-full" disabled={loading}>
|
|
84
|
+
{loading && <Loader2 className="mr-2 h-4 w-4 animate-spin" />}
|
|
85
|
+
{loading ? t('setup.form.loading') : t('setup.form.submit')}
|
|
86
|
+
</Button>
|
|
87
|
+
</form>
|
|
88
|
+
</AuthLayoutLeft>
|
|
89
|
+
<AuthLayoutRight>
|
|
90
|
+
<AuthBrandPanel title={t('setup.brand.title')} subtitle={t('setup.brand.subtitle')} features={setupBrandFeatures} />
|
|
91
|
+
</AuthLayoutRight>
|
|
92
|
+
</AuthLayout>
|
|
93
|
+
)
|
|
94
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
2
|
+
// AllBlue - 理想之海
|
|
3
|
+
// Copyright (C) 2026 AllBlue Contributors
|
|
4
|
+
//
|
|
5
|
+
// This program is free software: you can redistribute it and/or modify
|
|
6
|
+
// it under the terms of the GNU Affero General Public License as published by
|
|
7
|
+
// the Free Software Foundation, either version 3 of the License, or
|
|
8
|
+
// (at your option) any later version.
|
|
9
|
+
//
|
|
10
|
+
// This program is distributed in the hope that it will be useful,
|
|
11
|
+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
+
// GNU Affero General Public License for more details.
|
|
14
|
+
//
|
|
15
|
+
// You should have received a copy of the GNU Affero General Public License
|
|
16
|
+
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
17
|
+
|
|
18
|
+
import { createFileRoute, redirect } from '@tanstack/react-router'
|
|
19
|
+
import { checkAdminExistsFn } from '@/server/serverFns/auth/setup'
|
|
20
|
+
|
|
21
|
+
export const Route = createFileRoute('/setup')({
|
|
22
|
+
beforeLoad: async () => {
|
|
23
|
+
const result = await checkAdminExistsFn().catch(() => null)
|
|
24
|
+
if (result?.hasAdmin) {
|
|
25
|
+
throw redirect({ to: '/login' })
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
})
|