@allbluecn/admin-app 0.3.2 → 0.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/allblue-ui/package.json +6 -0
- package/allblue-ui/src/components/confirm-dialog.tsx +94 -0
- package/allblue-ui/src/components/infinite-scroll-sentinel.tsx +37 -0
- package/allblue-ui/src/components/notion-avatar.tsx +126 -0
- package/allblue-ui/src/components/user-avatar.tsx +82 -0
- package/{src/components → allblue-ui/src}/data-table/data-table-pagination.tsx +14 -5
- package/{src/components → allblue-ui/src}/data-table/data-table.tsx +1 -1
- package/{src/components → allblue-ui/src}/data-table/table-detail-layout.tsx +5 -6
- package/allblue-ui/src/hooks/use-load-more.ts +57 -0
- package/allblue-ui/src/index.ts +31 -0
- package/allblue-ui/src/lib/datetime.ts +226 -0
- package/allblue-ui/src/lib/sanitize.ts +18 -0
- package/allblue-ui/src/lib/utils.ts +1 -0
- package/{src/components → allblue-ui/src}/ui/alert-dialog.tsx +1 -3
- package/{src/components → allblue-ui/src}/ui/checkbox.tsx +0 -1
- package/{src/components → allblue-ui/src}/ui/dialog.tsx +1 -1
- package/{src/components → allblue-ui/src}/ui/dropdown-menu.tsx +0 -2
- package/{src/components → allblue-ui/src}/ui/field.tsx +2 -2
- package/{src/components → allblue-ui/src}/ui/input-group.tsx +3 -4
- package/allblue-ui/src/ui/input.tsx +19 -0
- package/{src/components → allblue-ui/src}/ui/pagination.tsx +1 -1
- package/{src/components → allblue-ui/src}/ui/select.tsx +0 -2
- package/{src/components → allblue-ui/src}/ui/separator.tsx +1 -0
- package/{src/components → allblue-ui/src}/ui/sheet.tsx +1 -2
- package/{src/components → allblue-ui/src}/ui/sidebar.tsx +7 -7
- package/{src/components → allblue-ui/src}/ui/switch.tsx +1 -0
- package/{src/components → allblue-ui/src}/ui/table.tsx +0 -2
- package/{src/components → allblue-ui/src}/ui/toast.tsx +44 -18
- package/{src/components → allblue-ui/src}/ui/tooltip.tsx +1 -0
- package/package.json +21 -18
- package/src/components/admin/admin-user-menu.tsx +4 -4
- package/src/components/admin/developer-log.tsx +16 -32
- package/src/components/ai-memory/memory-facts-panel.tsx +30 -70
- package/src/components/ai-prompts/preview-panel.tsx +1 -1
- package/src/components/ai-prompts/prompt-editor.tsx +8 -9
- package/src/components/ai-prompts/prompt-table.tsx +6 -6
- package/src/components/ai-prompts/section-editor.tsx +3 -3
- package/src/components/ai-prompts/variable-panel.tsx +2 -2
- package/src/components/ai-prompts/version-history.tsx +21 -41
- package/src/components/ai-provider/model-list-editor.tsx +2 -3
- package/src/components/ai-provider/provider-form.tsx +7 -7
- package/src/components/ai-provider/provider-table.tsx +17 -40
- package/src/components/auth/admin-login-form.tsx +7 -7
- package/src/components/auth/icon-input.tsx +2 -2
- package/src/components/auth/password-input.tsx +2 -2
- package/src/components/component/component-form-dialog.tsx +10 -18
- package/src/components/component/component-import-dialog.tsx +6 -6
- package/src/components/component/component-preview.tsx +311 -0
- package/src/components/component/component-table.tsx +3 -3
- package/src/components/dependency/changelog-dialog.tsx +2 -2
- package/src/components/dependency/columns.tsx +3 -3
- package/src/components/dependency/dependency-table.tsx +7 -7
- package/src/components/dependency/edit-dialog.tsx +8 -8
- package/src/components/invitations/invitations-page.tsx +26 -49
- package/src/components/knowledge-public/bookmark-form-dialog.tsx +6 -6
- package/src/components/knowledge-public/compliance-form-dialog.tsx +6 -6
- package/src/components/knowledge-public/legal-form-dialog.tsx +7 -7
- package/src/components/layout/sidebar-02/app-sidebar.tsx +1 -2
- package/src/components/layout/sidebar-02/index.tsx +1 -1
- package/src/components/layout/sidebar-02/nav-main.tsx +2 -3
- package/src/components/layout/sidebar-02/nav-notifications.tsx +3 -3
- package/src/components/market/columns.tsx +4 -4
- package/src/components/market/market-app-form.tsx +6 -7
- package/src/components/market/market-app-list.tsx +14 -29
- package/src/components/monitoring/error-list.tsx +2 -2
- package/src/components/monitoring/metrics-stats.tsx +1 -1
- package/src/components/monitoring/request-log-table.tsx +2 -2
- package/src/components/oauth-providers/provider-page.tsx +20 -38
- package/src/components/permissions/assign-dialog.tsx +135 -0
- package/src/components/permissions/create-role-dialog.tsx +135 -0
- package/src/components/permissions/types.ts +49 -0
- package/src/components/user/columns.tsx +6 -6
- package/src/components/user/settings-activity-log.tsx +7 -7
- package/src/components/user/settings-profile/avatar-uploader.tsx +118 -0
- package/src/components/user/settings-profile/social-links.tsx +63 -0
- package/src/components/user/settings-profile.tsx +26 -125
- package/src/components/user/user-create-dialog.tsx +6 -6
- package/src/components/user/user-detail/error-boundary.tsx +19 -0
- package/src/components/user/user-detail/user-detail-dialogs.tsx +203 -0
- package/src/components/user/user-filters.tsx +4 -4
- package/src/lib/auth/page-gate.ts +28 -0
- package/src/lib/auth.config.ts +25 -9
- package/src/lib/i18n/detect.ts +1 -1
- package/src/lib/loader-serial.ts +14 -0
- package/src/providers/index.tsx +1 -1
- package/src/routeTree.gen.ts +67 -78
- package/src/routes/__root.tsx +4 -4
- package/src/routes/_nav/audit/route.lazy.tsx +1 -2
- package/src/routes/_nav/compliance/route.lazy.tsx +5 -3
- package/src/routes/_nav/components/route.lazy.tsx +14 -34
- package/src/routes/_nav/knowledge-public/bookmarks/route.lazy.tsx +18 -38
- package/src/routes/_nav/knowledge-public/compliance/route.lazy.tsx +18 -38
- package/src/routes/_nav/knowledge-public/legal/route.lazy.tsx +6 -6
- package/src/routes/_nav/licenses/$licenseId/route.lazy.tsx +3 -3
- package/src/routes/_nav/licenses/new/route.lazy.tsx +5 -5
- package/src/routes/_nav/licenses/route.lazy.tsx +1 -1
- package/src/routes/_nav/monitoring/ai-usage/route.lazy.tsx +2 -2
- package/src/routes/_nav/monitoring/errors/route.lazy.tsx +10 -10
- package/src/routes/_nav/monitoring/errors/route.tsx +7 -0
- package/src/routes/_nav/monitoring/health/route.lazy.tsx +13 -15
- package/src/routes/_nav/monitoring/health/route.tsx +14 -0
- package/src/routes/_nav/monitoring/logs/route.lazy.tsx +24 -9
- package/src/routes/_nav/monitoring/logs/route.tsx +13 -0
- package/src/routes/_nav/monitoring/metrics/route.lazy.tsx +12 -14
- package/src/routes/_nav/monitoring/metrics/route.tsx +7 -0
- package/src/routes/_nav/monitoring/overview/route.lazy.tsx +14 -13
- package/src/routes/_nav/monitoring/overview/route.tsx +17 -0
- package/src/routes/_nav/monitoring/route.lazy.tsx +6 -6
- package/src/routes/_nav/monitoring/sentry/route.lazy.tsx +2 -2
- package/src/routes/_nav/permissions/route.lazy.tsx +21 -311
- package/src/routes/_nav/permissions/route.tsx +1 -1
- package/src/routes/_nav/route.tsx +5 -13
- package/src/routes/_nav/sso/route.lazy.tsx +2 -3
- package/src/routes/_nav/users/$userId/route.lazy.tsx +91 -156
- package/src/routes/_nav/users/-components/users-table.tsx +1 -1
- package/src/routes/_nav/users/route.lazy.tsx +1 -1
- package/src/routes/login/route.lazy.tsx +1 -1
- package/src/routes/setup/route.lazy.tsx +2 -2
- package/src/server/__tests__/admin-billing.test.ts +191 -16
- package/src/server/__tests__/compliance.test.ts +44 -7
- package/src/server/__tests__/permissions.test.ts +10 -5
- package/src/server/__tests__/prompt-defaults.test.ts +3 -3
- package/src/server/admin-ai-alerts.ts +2 -1
- package/src/server/admin-ai-usage.ts +2 -1
- package/src/server/ai-memory/store.ts +6 -2
- package/src/server/{serverFns/ai-prompts → ai-prompts}/prompt-defaults.ts +5 -3
- package/src/server/{serverFns/dependency → dependency}/helpers.ts +4 -3
- package/src/server/knowledge-public/github-sync.ts +2 -1
- package/src/server/license-issue.ts +2 -1
- package/src/server/middlewares/auth-rate-limit.ts +117 -0
- package/src/server/observability/health-check.ts +4 -1
- package/src/server/observability/metrics.ts +17 -15
- package/src/server/observability/request-middleware.ts +2 -1
- package/src/server/observability/timing.ts +14 -16
- package/src/server/serverFns/admin-billing.ts +107 -12
- package/src/server/serverFns/ai-memory/list-users.ts +2 -1
- package/src/server/serverFns/ai-prompts/activate.ts +2 -1
- package/src/server/serverFns/ai-prompts/get.ts +3 -2
- package/src/server/serverFns/ai-prompts/list.ts +3 -2
- package/src/server/serverFns/ai-prompts/rollback.ts +3 -1
- package/src/server/serverFns/ai-prompts/save.ts +5 -3
- package/src/server/serverFns/ai-provider/create.ts +4 -1
- package/src/server/serverFns/ai-provider/delete.ts +4 -1
- package/src/server/serverFns/ai-provider/get.ts +4 -1
- package/src/server/serverFns/ai-provider/list.ts +28 -1
- package/src/server/serverFns/ai-provider/seed-from-seed.ts +2 -1
- package/src/server/serverFns/ai-provider/update.ts +4 -1
- package/src/server/serverFns/anyhub/market.ts +8 -1
- package/src/server/serverFns/audit.ts +14 -1
- package/src/server/serverFns/auth/setup.ts +3 -1
- package/src/server/serverFns/compliance.ts +32 -3
- package/src/server/serverFns/components/import.ts +69 -14
- package/src/server/serverFns/components/list.ts +4 -1
- package/src/server/serverFns/components/mutations.ts +9 -1
- package/src/server/serverFns/dependency/list.ts +28 -5
- package/src/server/serverFns/dependency/sync.ts +7 -2
- package/src/server/serverFns/dependency/update.ts +4 -1
- package/src/server/serverFns/developer-log-auto-generate.ts +63 -32
- package/src/server/serverFns/developer-logs.ts +5 -1
- package/src/server/serverFns/invitations.ts +7 -1
- package/src/server/serverFns/knowledge-public/bookmarks/create.ts +2 -1
- package/src/server/serverFns/knowledge-public/bookmarks/delete.ts +2 -1
- package/src/server/serverFns/knowledge-public/bookmarks/detail.ts +2 -1
- package/src/server/serverFns/knowledge-public/bookmarks/list.ts +2 -1
- package/src/server/serverFns/knowledge-public/bookmarks/sync-all-github.ts +2 -1
- package/src/server/serverFns/knowledge-public/bookmarks/update.ts +2 -1
- package/src/server/serverFns/knowledge-public/compliance/create.ts +2 -1
- package/src/server/serverFns/knowledge-public/compliance/delete.ts +2 -1
- package/src/server/serverFns/knowledge-public/compliance/detail.ts +2 -1
- package/src/server/serverFns/knowledge-public/compliance/list.ts +2 -1
- package/src/server/serverFns/knowledge-public/compliance/update.ts +2 -1
- package/src/server/serverFns/knowledge-public/legal/create.ts +2 -1
- package/src/server/serverFns/knowledge-public/legal/delete.ts +2 -1
- package/src/server/serverFns/knowledge-public/legal/detail.ts +2 -1
- package/src/server/serverFns/knowledge-public/legal/list.ts +2 -1
- package/src/server/serverFns/knowledge-public/legal/update.ts +2 -1
- package/src/server/serverFns/licenses.ts +8 -2
- package/src/server/serverFns/monitoring/get-errors.ts +2 -1
- package/src/server/serverFns/monitoring/get-health.ts +2 -1
- package/src/server/serverFns/monitoring/get-metrics.ts +2 -1
- package/src/server/serverFns/monitoring/get-request-logs.ts +2 -1
- package/src/server/serverFns/monitoring/report-error.ts +2 -1
- package/src/server/serverFns/monitoring/reset.ts +2 -1
- package/src/server/serverFns/oauth-providers.ts +4 -1
- package/src/server/serverFns/permissions.ts +18 -11
- package/src/server/serverFns/sentry/config.ts +11 -8
- package/src/server/serverFns/sso-config.ts +17 -2
- package/src/server/serverFns/user/create.ts +6 -1
- package/src/server/serverFns/user/delete.ts +6 -1
- package/src/server/serverFns/user/detail.ts +5 -2
- package/src/server/serverFns/user/list.ts +19 -4
- package/src/server/serverFns/user/reset-password.ts +10 -2
- package/src/server/serverFns/user/update-role.ts +10 -2
- package/src/server/serverFns/user/update-status.ts +10 -2
- package/src/styles/globals.css +4 -0
- package/src/components/ui/input.tsx +0 -19
- /package/{src → allblue-ui/src}/hooks/use-mobile.ts +0 -0
- /package/{src → allblue-ui/src}/lib/avatar.ts +0 -0
- /package/{src/components → allblue-ui/src}/ui/alert.tsx +0 -0
- /package/{src/components → allblue-ui/src}/ui/avatar.tsx +0 -0
- /package/{src/components → allblue-ui/src}/ui/badge.tsx +0 -0
- /package/{src/components → allblue-ui/src}/ui/button.tsx +0 -0
- /package/{src/components → allblue-ui/src}/ui/card.tsx +0 -0
- /package/{src/components → allblue-ui/src}/ui/collapsible.tsx +0 -0
- /package/{src/components → allblue-ui/src}/ui/label.tsx +0 -0
- /package/{src/components → allblue-ui/src}/ui/skeleton.tsx +0 -0
- /package/{src/components → allblue-ui/src}/ui/textarea.tsx +0 -0
- /package/src/routes/{api.auth.$.ts → api/auth/$.ts} +0 -0
- /package/src/routes/{api.sentry-test.ts → api/sentry-test.ts} +0 -0
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
2
|
+
// AllBlue - 理想之海
|
|
3
|
+
// Copyright (C) 2026 AllBlue Contributors
|
|
4
|
+
|
|
5
|
+
import type { ReactElement, ReactNode } from "react"
|
|
6
|
+
import {
|
|
7
|
+
AlertDialog,
|
|
8
|
+
AlertDialogAction,
|
|
9
|
+
AlertDialogCancel,
|
|
10
|
+
AlertDialogContent,
|
|
11
|
+
AlertDialogDescription,
|
|
12
|
+
AlertDialogFooter,
|
|
13
|
+
AlertDialogHeader,
|
|
14
|
+
AlertDialogTitle,
|
|
15
|
+
AlertDialogTrigger,
|
|
16
|
+
} from "../ui/alert-dialog"
|
|
17
|
+
import type { Button } from "../ui/button"
|
|
18
|
+
|
|
19
|
+
export interface ConfirmDialogProps {
|
|
20
|
+
/** 受控 open;不传则由 trigger 非受控驱动 */
|
|
21
|
+
open?: boolean
|
|
22
|
+
onOpenChange?: (open: boolean) => void
|
|
23
|
+
title: ReactNode
|
|
24
|
+
/** 传 null 渲染空描述(保持 aria-describedby 结构),缺省则不渲染 */
|
|
25
|
+
description?: ReactNode
|
|
26
|
+
cancelLabel: ReactNode
|
|
27
|
+
confirmLabel: ReactNode
|
|
28
|
+
/** 确认按钮点击回调;关闭时机由调用方自行控制(与既有内联实现一致,不自动关闭) */
|
|
29
|
+
onConfirm: () => void
|
|
30
|
+
confirmVariant?: React.ComponentProps<typeof Button>["variant"]
|
|
31
|
+
confirmClassName?: string
|
|
32
|
+
confirmDisabled?: boolean
|
|
33
|
+
cancelDisabled?: boolean
|
|
34
|
+
confirmTestId?: string
|
|
35
|
+
contentTestId?: string
|
|
36
|
+
contentClassName?: string
|
|
37
|
+
/** 可选触发器元素(作为 AlertDialogTrigger 的 render 元素) */
|
|
38
|
+
trigger?: ReactElement
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* 通用确认弹窗:收口各处内联的「双 state + 手写 AlertDialog」确认模式。
|
|
43
|
+
* 仅做骨架渲染,onConfirm 的异步/关闭时序完全由调用方决定,保证逐站点行为等价迁移。
|
|
44
|
+
*/
|
|
45
|
+
export function ConfirmDialog({
|
|
46
|
+
open,
|
|
47
|
+
onOpenChange,
|
|
48
|
+
title,
|
|
49
|
+
description,
|
|
50
|
+
cancelLabel,
|
|
51
|
+
confirmLabel,
|
|
52
|
+
onConfirm,
|
|
53
|
+
confirmVariant,
|
|
54
|
+
confirmClassName,
|
|
55
|
+
confirmDisabled,
|
|
56
|
+
cancelDisabled,
|
|
57
|
+
confirmTestId,
|
|
58
|
+
contentTestId,
|
|
59
|
+
contentClassName,
|
|
60
|
+
trigger,
|
|
61
|
+
}: ConfirmDialogProps) {
|
|
62
|
+
const rootProps: { open?: boolean; onOpenChange?: (open: boolean) => void } = {}
|
|
63
|
+
if (open !== undefined) {
|
|
64
|
+
rootProps.open = open
|
|
65
|
+
rootProps.onOpenChange = onOpenChange
|
|
66
|
+
} else if (onOpenChange) {
|
|
67
|
+
rootProps.onOpenChange = onOpenChange
|
|
68
|
+
}
|
|
69
|
+
return (
|
|
70
|
+
<AlertDialog {...rootProps}>
|
|
71
|
+
{trigger ? <AlertDialogTrigger render={trigger} /> : null}
|
|
72
|
+
<AlertDialogContent data-testid={contentTestId} className={contentClassName}>
|
|
73
|
+
<AlertDialogHeader>
|
|
74
|
+
<AlertDialogTitle>{title}</AlertDialogTitle>
|
|
75
|
+
{description !== undefined ? (
|
|
76
|
+
<AlertDialogDescription>{description}</AlertDialogDescription>
|
|
77
|
+
) : null}
|
|
78
|
+
</AlertDialogHeader>
|
|
79
|
+
<AlertDialogFooter>
|
|
80
|
+
<AlertDialogCancel disabled={cancelDisabled}>{cancelLabel}</AlertDialogCancel>
|
|
81
|
+
<AlertDialogAction
|
|
82
|
+
variant={confirmVariant}
|
|
83
|
+
className={confirmClassName}
|
|
84
|
+
disabled={confirmDisabled}
|
|
85
|
+
onClick={onConfirm}
|
|
86
|
+
data-testid={confirmTestId}
|
|
87
|
+
>
|
|
88
|
+
{confirmLabel}
|
|
89
|
+
</AlertDialogAction>
|
|
90
|
+
</AlertDialogFooter>
|
|
91
|
+
</AlertDialogContent>
|
|
92
|
+
</AlertDialog>
|
|
93
|
+
)
|
|
94
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
2
|
+
// AllBlue - 理想之海
|
|
3
|
+
// Copyright (C) 2026 AllBlue Contributors
|
|
4
|
+
|
|
5
|
+
import { useLoadMore } from "../hooks/use-load-more"
|
|
6
|
+
|
|
7
|
+
interface InfiniteScrollSentinelProps {
|
|
8
|
+
onLoadMore: () => void | Promise<void>
|
|
9
|
+
hasMore: boolean
|
|
10
|
+
rootRef?: React.RefObject<HTMLElement | null>
|
|
11
|
+
/** 全部加载完后的提示文案(调用方传入,组件内不做 i18n) */
|
|
12
|
+
loadedAllLabel: string
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* 无限滚动哨兵:滚动到底部附近触发 onLoadMore,展示三点脉冲 loading 与
|
|
17
|
+
* 「已全部加载」提示。加载状态机见 useLoadMore。
|
|
18
|
+
*/
|
|
19
|
+
export function InfiniteScrollSentinel({ onLoadMore, hasMore, rootRef, loadedAllLabel }: InfiniteScrollSentinelProps) {
|
|
20
|
+
const { sentinelRef, loading } = useLoadMore(onLoadMore, hasMore, rootRef)
|
|
21
|
+
|
|
22
|
+
return (
|
|
23
|
+
<div className="flex h-7 items-center justify-center">
|
|
24
|
+
<div ref={sentinelRef} className="h-1" />
|
|
25
|
+
{loading && (
|
|
26
|
+
<div className="flex items-center gap-1">
|
|
27
|
+
<div className="h-1.5 w-1.5 animate-pulse rounded-full bg-primary/60" />
|
|
28
|
+
<div className="h-1.5 w-1.5 animate-pulse rounded-full bg-primary/60 delay-75" />
|
|
29
|
+
<div className="h-1.5 w-1.5 animate-pulse rounded-full bg-primary/60 delay-150" />
|
|
30
|
+
</div>
|
|
31
|
+
)}
|
|
32
|
+
{!loading && !hasMore && (
|
|
33
|
+
<span className="text-xs text-muted-foreground">{loadedAllLabel}</span>
|
|
34
|
+
)}
|
|
35
|
+
</div>
|
|
36
|
+
)
|
|
37
|
+
}
|
|
@@ -0,0 +1,126 @@
|
|
|
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
|
+
|
|
19
|
+
import { useEffect, useState } from "react"
|
|
20
|
+
import type { AvatarConfig, AvatarPart, ShapeType } from "@allbluecn/kernel"
|
|
21
|
+
import { sanitizeSvg } from "../lib/sanitize"
|
|
22
|
+
|
|
23
|
+
const noneParts: AvatarPart[] = ["glasses", "hair", "accessories", "details", "beard"]
|
|
24
|
+
|
|
25
|
+
const partOrder: AvatarPart[] = [
|
|
26
|
+
"face",
|
|
27
|
+
"nose",
|
|
28
|
+
"mouth",
|
|
29
|
+
"eyes",
|
|
30
|
+
"eyebrows",
|
|
31
|
+
"glasses",
|
|
32
|
+
"hair",
|
|
33
|
+
"accessories",
|
|
34
|
+
"details",
|
|
35
|
+
"beard",
|
|
36
|
+
]
|
|
37
|
+
|
|
38
|
+
function getPreviewImagePath(part: AvatarPart, index: number): string {
|
|
39
|
+
return `/avatar/preview/${part}/${index}.svg`
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const SVGFilter = `<defs>
|
|
43
|
+
<filter id="notion-avatar-filter" x="-20%" y="-20%" width="140%" height="140%" filterUnits="objectBoundingBox" primitiveUnits="userSpaceOnUse" color-interpolation-filters="linearRGB">
|
|
44
|
+
<feMorphology operator="dilate" radius="20" in="SourceAlpha" result="morphology"/>
|
|
45
|
+
<feFlood flood-color="#ffffff" flood-opacity="1" result="flood"/>
|
|
46
|
+
<feComposite in="flood" in2="morphology" operator="in" result="composite"/>
|
|
47
|
+
<feMerge result="merge">
|
|
48
|
+
<feMergeNode in="composite" result="mergeNode"/>
|
|
49
|
+
<feMergeNode in="SourceGraphic" result="mergeNode1"/>
|
|
50
|
+
</feMerge>
|
|
51
|
+
</filter>
|
|
52
|
+
</defs>`
|
|
53
|
+
|
|
54
|
+
function extractInnerSvg(svgText: string): string {
|
|
55
|
+
return svgText.replace(/<svg[^>]*>/i, "").replace(/<\/svg>/i, "").trim()
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const shapeStyle: Record<ShapeType, string> = {
|
|
59
|
+
circle: "rounded-full",
|
|
60
|
+
rounded: "rounded-lg",
|
|
61
|
+
square: "rounded-none",
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
type NotionAvatarProps = {
|
|
65
|
+
config: AvatarConfig
|
|
66
|
+
bgColor?: string
|
|
67
|
+
shape?: ShapeType
|
|
68
|
+
className?: string
|
|
69
|
+
style?: React.CSSProperties
|
|
70
|
+
flip?: boolean
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export function NotionAvatar({
|
|
74
|
+
config,
|
|
75
|
+
bgColor = "transparent",
|
|
76
|
+
shape = "circle",
|
|
77
|
+
className,
|
|
78
|
+
style,
|
|
79
|
+
flip = false,
|
|
80
|
+
}: NotionAvatarProps) {
|
|
81
|
+
const [svgContent, setSvgContent] = useState<string>("")
|
|
82
|
+
|
|
83
|
+
useEffect(() => {
|
|
84
|
+
async function buildAvatar() {
|
|
85
|
+
const groups = await Promise.all(
|
|
86
|
+
partOrder.map(async (part) => {
|
|
87
|
+
const index = config[part]
|
|
88
|
+
if (noneParts.includes(part) && index === 0) return ""
|
|
89
|
+
try {
|
|
90
|
+
const res = await fetch(getPreviewImagePath(part, index))
|
|
91
|
+
const svgText = await res.text()
|
|
92
|
+
const inner = extractInnerSvg(svgText)
|
|
93
|
+
return `\n<g id="avatar-${part}"${part === "face" ? ' fill="#ffffff"' : ""}>${inner}</g>`
|
|
94
|
+
} catch {
|
|
95
|
+
return ""
|
|
96
|
+
}
|
|
97
|
+
}),
|
|
98
|
+
)
|
|
99
|
+
const flipAttr = flip ? ' transform="scale(-1,1) translate(-1080, 0)"' : ""
|
|
100
|
+
const avatarSvg = `<svg viewBox="0 0 1080 1080" fill="none" xmlns="http://www.w3.org/2000/svg" style="width:100%;height:100%">${SVGFilter}<g id="avatar"${flipAttr}>${groups.join("")}</g></svg>`
|
|
101
|
+
setSvgContent(avatarSvg)
|
|
102
|
+
}
|
|
103
|
+
buildAvatar()
|
|
104
|
+
}, [config, flip])
|
|
105
|
+
|
|
106
|
+
if (!svgContent) {
|
|
107
|
+
return (
|
|
108
|
+
<div
|
|
109
|
+
className={`${shapeStyle[shape]} overflow-hidden bg-muted animate-pulse ${className ?? ""}`}
|
|
110
|
+
style={{ aspectRatio: "1 / 1", ...style }}
|
|
111
|
+
/>
|
|
112
|
+
)
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
return (
|
|
116
|
+
<div
|
|
117
|
+
className={`${shapeStyle[shape]} ${className ?? ""}`}
|
|
118
|
+
style={{
|
|
119
|
+
backgroundColor: bgColor === "transparent" ? undefined : bgColor,
|
|
120
|
+
aspectRatio: "1 / 1",
|
|
121
|
+
...style,
|
|
122
|
+
}}
|
|
123
|
+
dangerouslySetInnerHTML={{ __html: sanitizeSvg(svgContent) }}
|
|
124
|
+
/>
|
|
125
|
+
)
|
|
126
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
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
|
+
|
|
19
|
+
import { NotionAvatar } from "./notion-avatar"
|
|
20
|
+
import type { AvatarConfig, ShapeType } from "@allbluecn/kernel"
|
|
21
|
+
|
|
22
|
+
type UserAvatarProps = {
|
|
23
|
+
avatarConfig?: AvatarConfig | null
|
|
24
|
+
bgShape?: ShapeType | null
|
|
25
|
+
bgColor?: string | null
|
|
26
|
+
name?: string | null
|
|
27
|
+
imageUrl?: string | null
|
|
28
|
+
className?: string
|
|
29
|
+
size?: "xs" | "sm" | "md" | "lg" | "xl" | "2xl" | "3xl" | "4xl"
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const sizeClasses: Record<string, string> = {
|
|
33
|
+
xs: "w-5 h-5",
|
|
34
|
+
sm: "w-6 h-6",
|
|
35
|
+
md: "w-8 h-8",
|
|
36
|
+
lg: "w-10 h-10",
|
|
37
|
+
xl: "w-12 h-12",
|
|
38
|
+
"2xl": "w-16 h-16",
|
|
39
|
+
"3xl": "w-20 h-20",
|
|
40
|
+
"4xl": "w-24 h-24",
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export function UserAvatar({
|
|
44
|
+
avatarConfig,
|
|
45
|
+
bgShape,
|
|
46
|
+
bgColor,
|
|
47
|
+
name,
|
|
48
|
+
imageUrl,
|
|
49
|
+
className,
|
|
50
|
+
size = "md",
|
|
51
|
+
}: UserAvatarProps) {
|
|
52
|
+
const initial = (name || "U").charAt(0).toUpperCase()
|
|
53
|
+
const shapeClass =
|
|
54
|
+
bgShape === "circle" ? "rounded-full" : bgShape === "square" ? "rounded-none" : "rounded-lg"
|
|
55
|
+
|
|
56
|
+
if (avatarConfig) {
|
|
57
|
+
return (
|
|
58
|
+
<NotionAvatar
|
|
59
|
+
config={avatarConfig}
|
|
60
|
+
shape={bgShape ?? "square"}
|
|
61
|
+
bgColor={bgColor ?? "#fff"}
|
|
62
|
+
className={`${sizeClasses[size]} shrink-0 ${className ?? ""}`}
|
|
63
|
+
/>
|
|
64
|
+
)
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if (imageUrl) {
|
|
68
|
+
return (
|
|
69
|
+
<div className={`relative shrink-0 overflow-hidden ${shapeClass} ${sizeClasses[size]} ${className ?? ""}`}>
|
|
70
|
+
<img src={imageUrl} alt={name || ""} className="h-full w-full object-cover" />
|
|
71
|
+
</div>
|
|
72
|
+
)
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return (
|
|
76
|
+
<div
|
|
77
|
+
className={`flex shrink-0 items-center justify-center ${shapeClass} bg-muted text-xs font-medium ${sizeClasses[size]} ${className ?? ""}`}
|
|
78
|
+
>
|
|
79
|
+
{initial}
|
|
80
|
+
</div>
|
|
81
|
+
)
|
|
82
|
+
}
|
|
@@ -23,13 +23,21 @@ import {
|
|
|
23
23
|
PaginationLink,
|
|
24
24
|
PaginationNext,
|
|
25
25
|
PaginationPrevious,
|
|
26
|
-
} from "
|
|
27
|
-
|
|
26
|
+
} from "../ui/pagination";
|
|
27
|
+
|
|
28
|
+
// i18n 由消费方注入(包内不依赖 @/paraglide),文案与原 admin 实现逐字对应
|
|
29
|
+
export interface DataTablePaginationLabels {
|
|
30
|
+
total: string;
|
|
31
|
+
previous: string;
|
|
32
|
+
next: string;
|
|
33
|
+
}
|
|
34
|
+
|
|
28
35
|
interface DataTablePaginationProps {
|
|
29
36
|
page: number;
|
|
30
37
|
totalPages: number;
|
|
31
38
|
total: number;
|
|
32
39
|
onPageChange: (page: number) => void;
|
|
40
|
+
labels: DataTablePaginationLabels;
|
|
33
41
|
}
|
|
34
42
|
|
|
35
43
|
function getPageNumbers(current: number, total: number): (number | "ellipsis")[] {
|
|
@@ -64,19 +72,20 @@ export function DataTablePagination({
|
|
|
64
72
|
totalPages,
|
|
65
73
|
total,
|
|
66
74
|
onPageChange,
|
|
75
|
+
labels,
|
|
67
76
|
}: DataTablePaginationProps) {
|
|
68
77
|
const pages = getPageNumbers(page, totalPages);
|
|
69
78
|
|
|
70
79
|
return (
|
|
71
80
|
<div className="flex items-center justify-between gap-4 px-2 py-4">
|
|
72
81
|
<div className="text-sm text-muted-foreground whitespace-nowrap shrink-0">
|
|
73
|
-
{
|
|
82
|
+
{labels.total}
|
|
74
83
|
</div>
|
|
75
84
|
<Pagination className="justify-end">
|
|
76
85
|
<PaginationContent>
|
|
77
86
|
<PaginationItem>
|
|
78
87
|
<PaginationPrevious
|
|
79
|
-
text={
|
|
88
|
+
text={labels.previous}
|
|
80
89
|
onClick={() => page > 1 && onPageChange(page - 1)}
|
|
81
90
|
className={page <= 1 ? "pointer-events-none opacity-50" : "cursor-pointer"}
|
|
82
91
|
/>
|
|
@@ -100,7 +109,7 @@ export function DataTablePagination({
|
|
|
100
109
|
)}
|
|
101
110
|
<PaginationItem>
|
|
102
111
|
<PaginationNext
|
|
103
|
-
text={
|
|
112
|
+
text={labels.next}
|
|
104
113
|
onClick={() => page < totalPages && onPageChange(page + 1)}
|
|
105
114
|
className={page >= totalPages ? "pointer-events-none opacity-50" : "cursor-pointer"}
|
|
106
115
|
/>
|
|
@@ -16,14 +16,14 @@
|
|
|
16
16
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
17
17
|
|
|
18
18
|
import { useNavigate } from "@tanstack/react-router";
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import { Skeleton } from "@/components/ui/skeleton";
|
|
19
|
+
import { Button } from "../ui/button";
|
|
20
|
+
import { Skeleton } from "../ui/skeleton";
|
|
22
21
|
import { ArrowLeftIcon } from "lucide-react";
|
|
23
22
|
|
|
24
23
|
interface TableDetailLayoutProps {
|
|
25
24
|
backHref: string;
|
|
26
|
-
|
|
25
|
+
// i18n 由消费方注入(包内不依赖 @/paraglide),原 admin 实现默认回退文案由调用方显式传入
|
|
26
|
+
backLabel: string;
|
|
27
27
|
title: string;
|
|
28
28
|
subtitle?: string;
|
|
29
29
|
avatar?: React.ReactNode;
|
|
@@ -45,7 +45,6 @@ export function TableDetailLayout({
|
|
|
45
45
|
children,
|
|
46
46
|
}: TableDetailLayoutProps) {
|
|
47
47
|
const navigate = useNavigate();
|
|
48
|
-
const resolvedBackLabel = backLabel ?? m.common_common_backToList()
|
|
49
48
|
|
|
50
49
|
if (loading) {
|
|
51
50
|
return (
|
|
@@ -73,7 +72,7 @@ export function TableDetailLayout({
|
|
|
73
72
|
className="gap-1.5 text-muted-foreground hover:text-foreground"
|
|
74
73
|
>
|
|
75
74
|
<ArrowLeftIcon className="h-4 w-4" />
|
|
76
|
-
{
|
|
75
|
+
{backLabel}
|
|
77
76
|
</Button>
|
|
78
77
|
</div>
|
|
79
78
|
<div className="p-6 pt-4 space-y-6">
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
2
|
+
// AllBlue - 理想之海
|
|
3
|
+
// Copyright (C) 2026 AllBlue Contributors
|
|
4
|
+
|
|
5
|
+
import { useEffect, useRef, useState } from "react";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* 无限滚动加载状态机:IntersectionObserver 哨兵 + loading 防重入。
|
|
9
|
+
*
|
|
10
|
+
* 哨兵进入视口且 hasMore 时触发 onLoadMore;返回 Promise 时 resolve 后解除
|
|
11
|
+
* loading,同步返回则由调用方经 hasMore/数据更新间接解除。供
|
|
12
|
+
* InfiniteScrollSentinel 等无限滚动组件复用。
|
|
13
|
+
*/
|
|
14
|
+
export function useLoadMore(
|
|
15
|
+
onLoadMore: () => void | Promise<void>,
|
|
16
|
+
hasMore: boolean,
|
|
17
|
+
rootRef?: React.RefObject<HTMLElement | null>,
|
|
18
|
+
): {
|
|
19
|
+
/** 挂到滚动末端哨兵元素上 */
|
|
20
|
+
sentinelRef: React.RefObject<HTMLDivElement | null>;
|
|
21
|
+
loading: boolean;
|
|
22
|
+
} {
|
|
23
|
+
const sentinelRef = useRef<HTMLDivElement>(null);
|
|
24
|
+
const observerRef = useRef<IntersectionObserver | null>(null);
|
|
25
|
+
const [loading, setLoading] = useState(false);
|
|
26
|
+
const loadingRef = useRef(false);
|
|
27
|
+
|
|
28
|
+
useEffect(() => {
|
|
29
|
+
loadingRef.current = loading;
|
|
30
|
+
}, [loading]);
|
|
31
|
+
|
|
32
|
+
useEffect(() => {
|
|
33
|
+
if (!sentinelRef.current || !hasMore) return;
|
|
34
|
+
|
|
35
|
+
if (observerRef.current) observerRef.current.disconnect();
|
|
36
|
+
|
|
37
|
+
const observer = new IntersectionObserver(
|
|
38
|
+
(entries) => {
|
|
39
|
+
if (entries[0]?.isIntersecting && !loadingRef.current) {
|
|
40
|
+
setLoading(true);
|
|
41
|
+
const result = onLoadMore();
|
|
42
|
+
if (result && typeof (result as Promise<void>).then === "function") {
|
|
43
|
+
(result as Promise<void>).then(() => setLoading(false));
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
{ root: rootRef?.current ?? null, rootMargin: "80px" },
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
observer.observe(sentinelRef.current);
|
|
51
|
+
observerRef.current = observer;
|
|
52
|
+
return () => observer.disconnect();
|
|
53
|
+
// onLoadMore 由调用方保证稳定(多为 useCallback),与原实现一致仅依赖 hasMore/rootRef
|
|
54
|
+
}, [hasMore, rootRef]);
|
|
55
|
+
|
|
56
|
+
return { sentinelRef, loading };
|
|
57
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export * from "./ui/alert"
|
|
2
|
+
export * from "./ui/alert-dialog"
|
|
3
|
+
export * from "./ui/avatar"
|
|
4
|
+
export * from "./ui/badge"
|
|
5
|
+
export * from "./ui/button"
|
|
6
|
+
export * from "./ui/card"
|
|
7
|
+
export * from "./ui/checkbox"
|
|
8
|
+
export * from "./ui/collapsible"
|
|
9
|
+
export * from "./ui/dialog"
|
|
10
|
+
export * from "./ui/dropdown-menu"
|
|
11
|
+
export * from "./ui/field"
|
|
12
|
+
export * from "./ui/input"
|
|
13
|
+
export * from "./ui/input-group"
|
|
14
|
+
export * from "./ui/label"
|
|
15
|
+
export * from "./ui/pagination"
|
|
16
|
+
export * from "./ui/select"
|
|
17
|
+
export * from "./ui/separator"
|
|
18
|
+
export * from "./ui/sheet"
|
|
19
|
+
export * from "./ui/sidebar"
|
|
20
|
+
export * from "./ui/skeleton"
|
|
21
|
+
export * from "./ui/switch"
|
|
22
|
+
export * from "./ui/table"
|
|
23
|
+
export * from "./ui/textarea"
|
|
24
|
+
export * from "./ui/toast"
|
|
25
|
+
export * from "./ui/tooltip"
|
|
26
|
+
export { ConfirmDialog, type ConfirmDialogProps } from "./components/confirm-dialog"
|
|
27
|
+
export { InfiniteScrollSentinel } from "./components/infinite-scroll-sentinel"
|
|
28
|
+
export { useLoadMore } from "./hooks/use-load-more"
|
|
29
|
+
export { useIsMobile } from "./hooks/use-mobile"
|
|
30
|
+
export { getBoringAvatarUrl, getAvatarFallback, type AvatarOptions } from "./lib/avatar"
|
|
31
|
+
export { cn } from "./lib/utils"
|