release: bump version to 0.73.0
This commit is contained in:
1 parent
19d5ac0fee
commit
fbecf30513
41 files changed
+2306
-311
No files matched your search
@@ -8,6 +8,7 @@ import {
|
||||
} from '@tanstack/react-table'
|
||||
import { ArrowDown, ArrowUp, ChevronsUpDown } from 'lucide-react'
|
||||
import { useMemo, useState } from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import TableScrollRegion from '../../../components/Scrollbar/TableScrollRegion'
|
||||
import { Button } from '../ui/button'
|
||||
|
||||
@@ -37,11 +38,12 @@ export function DataTable<TData>({
|
||||
getRowClassName,
|
||||
selection,
|
||||
loading = false,
|
||||
emptyText = '暂无数据',
|
||||
emptyText,
|
||||
className = '',
|
||||
footer,
|
||||
onRowClick,
|
||||
}: DataTableProps<TData>) {
|
||||
const { t } = useTranslation()
|
||||
const [sorting, setSorting] = useState<SortingState>([])
|
||||
const memoizedColumns = useMemo(() => columns, [columns])
|
||||
|
||||
@@ -74,7 +76,7 @@ export function DataTable<TData>({
|
||||
<th className="an-data-table__selection-cell">
|
||||
<input
|
||||
type="checkbox"
|
||||
aria-label="选择当前可见数据"
|
||||
aria-label={t('common.selectVisibleRows')}
|
||||
checked={allVisibleSelected}
|
||||
disabled={!visibleSelectableIds.length}
|
||||
ref={(element) => {
|
||||
@@ -114,7 +116,7 @@ export function DataTable<TData>({
|
||||
<td colSpan={columnCount}>
|
||||
<div className="an-data-table__state">
|
||||
<span className="an-spinner" />
|
||||
加载中
|
||||
{t('common.loading')}
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -131,7 +133,7 @@ export function DataTable<TData>({
|
||||
<td className="an-data-table__selection-cell">
|
||||
<input
|
||||
type="checkbox"
|
||||
aria-label={selection.getCheckboxLabel?.(row.original) || '选择行'}
|
||||
aria-label={selection.getCheckboxLabel?.(row.original) || t('common.selectRow')}
|
||||
checked={selection.selectedRowIds.has(row.id)}
|
||||
disabled={selection.isRowSelectable ? !selection.isRowSelectable(row.original) : false}
|
||||
onClick={(event) => event.stopPropagation()}
|
||||
@@ -149,7 +151,7 @@ export function DataTable<TData>({
|
||||
) : (
|
||||
<tr>
|
||||
<td colSpan={columnCount}>
|
||||
<div className="an-data-table__state">{emptyText}</div>
|
||||
<div className="an-data-table__state">{emptyText || t('common.noData')}</div>
|
||||
</td>
|
||||
</tr>
|
||||
)}
|
||||
@@ -173,18 +175,19 @@ export function DataTablePager({
|
||||
total: number
|
||||
onPageChange: (page: number) => void
|
||||
}) {
|
||||
const { t } = useTranslation()
|
||||
const totalPages = Math.max(1, Math.ceil(total / pageSize))
|
||||
return (
|
||||
<div className="an-data-table__pager">
|
||||
<span>
|
||||
第 {page} / {totalPages} 页,共 {total.toLocaleString()} 条
|
||||
{t('common.page', { page, totalPages, total: total.toLocaleString() })}
|
||||
</span>
|
||||
<div className="an-data-table__pager-actions">
|
||||
<Button size="sm" variant="subtle" disabled={page <= 1} onClick={() => onPageChange(page - 1)}>
|
||||
上一页
|
||||
{t('common.previousPage')}
|
||||
</Button>
|
||||
<Button size="sm" variant="subtle" disabled={page >= totalPages} onClick={() => onPageChange(page + 1)}>
|
||||
下一页
|
||||
{t('common.nextPage')}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,18 +1,22 @@
|
||||
import {
|
||||
ChevronDown,
|
||||
Languages,
|
||||
LogOut,
|
||||
Menu,
|
||||
Moon,
|
||||
Monitor,
|
||||
Search,
|
||||
Settings,
|
||||
Sun,
|
||||
X,
|
||||
} from 'lucide-react'
|
||||
import { type FocusEvent, type KeyboardEvent, type ReactNode, useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { Link, useLocation, useNavigate } from 'react-router-dom'
|
||||
import packageJson from '../../../../package.json'
|
||||
import Scrollbar from '../../../components/Scrollbar/Scrollbar'
|
||||
import SegmentedControl from '../../../components/SegmentedControl/SegmentedControl'
|
||||
import { localeOptions, useLocale, type SupportedLocale } from '../../../i18n/locale'
|
||||
import { useAuthStore } from '../../../stores/auth'
|
||||
import { useAdminTheme, type AdminThemeMode } from '../../design/theme'
|
||||
import { cn } from '../../utils'
|
||||
@@ -28,6 +32,8 @@ export function AdminLayout({ children }: { children: ReactNode }) {
|
||||
const location = useLocation()
|
||||
const navigate = useNavigate()
|
||||
const adminSearch = useAdminSearch()
|
||||
const { t } = useTranslation()
|
||||
const { locale, setLocale } = useLocale()
|
||||
const { user, logout } = useAuthStore()
|
||||
const { mode, setMode } = useAdminTheme()
|
||||
const [collapsed, setCollapsed] = useState(false)
|
||||
@@ -35,25 +41,39 @@ export function AdminLayout({ children }: { children: ReactNode }) {
|
||||
const [openKeys, setOpenKeys] = useState<string[]>(cachedOpenKeys)
|
||||
const [searchQuery, setSearchQuery] = useState('')
|
||||
const [searchOpen, setSearchOpen] = useState(false)
|
||||
const [preferencesOpen, setPreferencesOpen] = useState(false)
|
||||
const [highlightedSearchIndex, setHighlightedSearchIndex] = useState(0)
|
||||
const menuViewportRef = useRef<HTMLDivElement>(null)
|
||||
const searchInputRef = useRef<HTMLInputElement>(null)
|
||||
const isSuperAdmin = user?.role === 'super_admin'
|
||||
const username = user?.username || '-'
|
||||
const userInitial = username.trim().charAt(0).toUpperCase() || '?'
|
||||
const preferencesLabel = preferencesOpen ? t('admin.collapsePreferences') : t('admin.expandPreferences')
|
||||
const visibleRoutes = useMemo(() => getVisibleAdminRoutes(isSuperAdmin), [isSuperAdmin])
|
||||
const navGroups = useMemo(() => {
|
||||
return adminRouteGroups.map((group) => ({
|
||||
...group,
|
||||
children: visibleRoutes.filter((route) => route.group === group.key),
|
||||
label: t(group.labelKey),
|
||||
children: visibleRoutes
|
||||
.filter((route) => route.group === group.key)
|
||||
.map((route) => ({ ...route, label: t(route.labelKey) })),
|
||||
})).filter((group) => group.children.length > 0)
|
||||
}, [visibleRoutes])
|
||||
}, [t, visibleRoutes])
|
||||
const selectedKey = location.pathname === '/admin/' ? '/admin' : location.pathname.replace(/\/$/, '')
|
||||
const activeRoute = visibleRoutes.find((route) => route.path === selectedKey)
|
||||
const activeRouteLabel = activeRoute ? t(activeRoute.labelKey) : ''
|
||||
const searchResults = useMemo(() => adminSearch.search(searchQuery), [adminSearch, searchQuery])
|
||||
const themeOptions = useMemo(() => [
|
||||
{ value: 'light' as const, label: '浅色', title: '浅色', icon: <Sun /> },
|
||||
{ value: 'system' as const, label: '系统', title: '跟随系统', icon: <Monitor /> },
|
||||
{ value: 'dark' as const, label: '深色', title: '深色', icon: <Moon /> },
|
||||
], [])
|
||||
{ value: 'light' as const, label: t('common.themeLight'), title: t('common.themeLight'), icon: <Sun /> },
|
||||
{ value: 'system' as const, label: t('common.themeSystem'), title: t('common.themeFollowSystem'), icon: <Monitor /> },
|
||||
{ value: 'dark' as const, label: t('common.themeDark'), title: t('common.themeDark'), icon: <Moon /> },
|
||||
], [t])
|
||||
const languageOptions = useMemo(() => localeOptions.map((option) => ({
|
||||
value: option.value,
|
||||
label: t(option.labelKey),
|
||||
title: t(option.titleKey),
|
||||
icon: <Languages />,
|
||||
})), [t])
|
||||
|
||||
const updateOpenKeys = (nextKeys: string[]) => {
|
||||
cachedOpenKeys = nextKeys
|
||||
@@ -116,15 +136,15 @@ export function AdminLayout({ children }: { children: ReactNode }) {
|
||||
event.stopPropagation()
|
||||
setCollapsed((value) => !value)
|
||||
}}
|
||||
aria-label={collapsed ? '展开菜单' : '折叠菜单'}
|
||||
title={collapsed ? '展开菜单' : '折叠菜单'}
|
||||
title={collapsed ? t('admin.expandMenu') : t('admin.collapseMenu')}
|
||||
aria-label={collapsed ? t('admin.expandMenu') : t('admin.collapseMenu')}
|
||||
>
|
||||
{collapsed ? <Menu size={18} /> : <X size={18} />}
|
||||
</Button>
|
||||
{!collapsed ? (
|
||||
<div className="admin__brand-copy">
|
||||
<span className="admin__brand-text">智能星球</span>
|
||||
<span className="admin__brand-subtitle">控制台</span>
|
||||
<span className="admin__brand-text">{t('admin.brandTitle')}</span>
|
||||
<span className="admin__brand-subtitle">{t('admin.brandSubtitle')}</span>
|
||||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
@@ -186,36 +206,61 @@ export function AdminLayout({ children }: { children: ReactNode }) {
|
||||
|
||||
{!collapsed ? (
|
||||
<div className="admin__account">
|
||||
<div className="admin__account-row">
|
||||
<div>
|
||||
<strong>Hi, {user?.username || '-'}</strong>
|
||||
<div className="admin__account-row admin__account-row--primary">
|
||||
<div className="admin__account-profile">
|
||||
<span className="admin__account-avatar" aria-hidden="true">{userInitial}</span>
|
||||
<div>
|
||||
<strong>{t('admin.greeting', { name: username })}</strong>
|
||||
<span>{t('admin.version')} v{packageJson.version}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div className="admin__account-actions">
|
||||
<Button
|
||||
size="icon"
|
||||
variant="ghost"
|
||||
className={cn('admin__account-preferences', preferencesOpen && 'is-active')}
|
||||
onClick={() => setPreferencesOpen((value) => !value)}
|
||||
title={preferencesLabel}
|
||||
aria-label={preferencesLabel}
|
||||
aria-expanded={preferencesOpen}
|
||||
>
|
||||
<Settings size={15} />
|
||||
</Button>
|
||||
<Button
|
||||
size="icon"
|
||||
variant="ghost"
|
||||
className="admin__account-logout"
|
||||
onClick={() => {
|
||||
logout()
|
||||
navigate('/login')
|
||||
}}
|
||||
title={t('admin.logout')}
|
||||
aria-label={t('admin.logout')}
|
||||
>
|
||||
<LogOut size={15} />
|
||||
</Button>
|
||||
</div>
|
||||
<Button
|
||||
size="icon"
|
||||
variant="ghost"
|
||||
className="admin__account-logout"
|
||||
onClick={() => {
|
||||
logout()
|
||||
navigate('/login')
|
||||
}}
|
||||
aria-label="退出登录"
|
||||
title="退出登录"
|
||||
>
|
||||
<LogOut size={15} />
|
||||
</Button>
|
||||
</div>
|
||||
<div className="admin__account-row">
|
||||
<span>版本号</span>
|
||||
<strong>v{packageJson.version}</strong>
|
||||
<div className={cn('admin__preferences-drawer', preferencesOpen && 'is-open')} aria-hidden={!preferencesOpen}>
|
||||
<div className="admin__preferences-panel">
|
||||
<SegmentedControl<SupportedLocale>
|
||||
ariaLabel={t('admin.languageControl')}
|
||||
className="admin__language-control admin__language-control--sider"
|
||||
options={languageOptions}
|
||||
scale={0.86}
|
||||
value={locale}
|
||||
onChange={setLocale}
|
||||
/>
|
||||
<SegmentedControl<AdminThemeMode>
|
||||
ariaLabel={t('admin.themeControl')}
|
||||
className="admin__theme-control admin__theme-control--sider"
|
||||
options={themeOptions}
|
||||
scale={0.86}
|
||||
value={mode}
|
||||
onChange={setMode}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<SegmentedControl<AdminThemeMode>
|
||||
ariaLabel="控制台主题"
|
||||
className="admin__theme-control admin__theme-control--sider"
|
||||
options={themeOptions}
|
||||
scale={0.72}
|
||||
value={mode}
|
||||
onChange={setMode}
|
||||
/>
|
||||
</div>
|
||||
) : null}
|
||||
</>
|
||||
@@ -250,22 +295,22 @@ export function AdminLayout({ children }: { children: ReactNode }) {
|
||||
{mobileNavOpen ? (
|
||||
<div className="admin__mobile-nav">
|
||||
<div className="admin__mobile-nav-panel">{nav}</div>
|
||||
<button className="admin__mobile-nav-backdrop" type="button" aria-label="关闭导航" onClick={() => setMobileNavOpen(false)} />
|
||||
<button className="admin__mobile-nav-backdrop" type="button" aria-label={t('admin.closeNav')} onClick={() => setMobileNavOpen(false)} />
|
||||
</div>
|
||||
) : null}
|
||||
<main className="admin__content">
|
||||
<header className="admin__topbar">
|
||||
<Button size="icon" variant="ghost" className="admin__mobile-menu" onClick={() => setMobileNavOpen(true)} aria-label="打开导航" title="打开导航">
|
||||
<Button size="icon" variant="ghost" className="admin__mobile-menu" onClick={() => setMobileNavOpen(true)} aria-label={t('admin.openNav')} title={t('admin.openNav')}>
|
||||
<Menu size={18} />
|
||||
</Button>
|
||||
<div className="admin__search" onBlur={handleSearchBlur}>
|
||||
<Search className="admin__search-icon" size={16} />
|
||||
<input
|
||||
ref={searchInputRef}
|
||||
aria-label="搜索功能、配置和文字"
|
||||
aria-label={t('admin.search.label')}
|
||||
autoComplete="off"
|
||||
value={searchQuery}
|
||||
placeholder={activeRoute ? `搜索功能、配置和文字,当前:${activeRoute.label}` : '搜索功能、配置和文字'}
|
||||
placeholder={activeRouteLabel ? `${t('admin.search.placeholder')},${t('admin.search.current', { label: activeRouteLabel })}` : t('admin.search.placeholder')}
|
||||
onChange={(event) => {
|
||||
setSearchQuery(event.target.value)
|
||||
setSearchOpen(true)
|
||||
@@ -275,7 +320,7 @@ export function AdminLayout({ children }: { children: ReactNode }) {
|
||||
onKeyDown={handleSearchKeyDown}
|
||||
/>
|
||||
{searchOpen ? (
|
||||
<div className="admin__search-results" role="listbox" aria-label="Admin 搜索结果">
|
||||
<div className="admin__search-results" role="listbox" aria-label={t('admin.search.results')}>
|
||||
{searchResults.length > 0 ? searchResults.map((target, index) => {
|
||||
const ResultIcon = target.icon || Search
|
||||
return (
|
||||
@@ -297,7 +342,7 @@ export function AdminLayout({ children }: { children: ReactNode }) {
|
||||
</button>
|
||||
)
|
||||
}) : (
|
||||
<div className="admin__search-empty">{adminSearch.loading ? '正在加载搜索索引…' : '没有找到匹配内容'}</div>
|
||||
<div className="admin__search-empty">{adminSearch.loading ? t('admin.search.loading') : t('admin.search.empty')}</div>
|
||||
)}
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import * as DialogPrimitive from '@radix-ui/react-dialog'
|
||||
import { X } from 'lucide-react'
|
||||
import { type ReactNode } from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import Scrollbar from '../../../components/Scrollbar/Scrollbar'
|
||||
import { Button } from './button'
|
||||
|
||||
@@ -15,6 +16,8 @@ interface DialogProps {
|
||||
}
|
||||
|
||||
export function Dialog({ open, onOpenChange, title, description, children, footer, width }: DialogProps) {
|
||||
const { t } = useTranslation()
|
||||
|
||||
return (
|
||||
<DialogPrimitive.Root open={open} onOpenChange={onOpenChange}>
|
||||
<DialogPrimitive.Portal>
|
||||
@@ -30,7 +33,7 @@ export function Dialog({ open, onOpenChange, title, description, children, foote
|
||||
) : null}
|
||||
</div>
|
||||
<DialogPrimitive.Close asChild>
|
||||
<Button size="icon" variant="ghost" aria-label="关闭" title="关闭">
|
||||
<Button size="icon" variant="ghost" aria-label={t('common.close')} title={t('common.close')}>
|
||||
<X size={16} />
|
||||
</Button>
|
||||
</DialogPrimitive.Close>
|
||||
@@ -60,12 +63,16 @@ export function ConfirmDialog({
|
||||
onOpenChange,
|
||||
title,
|
||||
description,
|
||||
confirmLabel = '确认',
|
||||
cancelLabel = '取消',
|
||||
confirmLabel,
|
||||
cancelLabel,
|
||||
danger = false,
|
||||
loading = false,
|
||||
onConfirm,
|
||||
}: ConfirmDialogProps) {
|
||||
const { t } = useTranslation()
|
||||
const resolvedCancelLabel = cancelLabel || t('common.cancel')
|
||||
const resolvedConfirmLabel = confirmLabel || t('common.confirm')
|
||||
|
||||
return (
|
||||
<Dialog
|
||||
open={open}
|
||||
@@ -76,15 +83,15 @@ export function ConfirmDialog({
|
||||
footer={(
|
||||
<>
|
||||
<Button variant="subtle" onClick={() => onOpenChange(false)} disabled={loading}>
|
||||
{cancelLabel}
|
||||
{resolvedCancelLabel}
|
||||
</Button>
|
||||
<Button variant={danger ? 'danger' : 'primary'} onClick={onConfirm} loading={loading}>
|
||||
{confirmLabel}
|
||||
{resolvedConfirmLabel}
|
||||
</Button>
|
||||
</>
|
||||
)}
|
||||
>
|
||||
<span className="sr-only">{description || '请确认本次操作。'}</span>
|
||||
<span className="sr-only">{description || t('common.confirm')}</span>
|
||||
</Dialog>
|
||||
)
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
import * as ToastPrimitive from '@radix-ui/react-toast'
|
||||
import { X } from 'lucide-react'
|
||||
import { createContext, useCallback, useContext, useMemo, useState, type ReactNode } from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
|
||||
type ToastTone = 'default' | 'success' | 'error'
|
||||
|
||||
@@ -18,6 +19,7 @@ interface ToastContextValue {
|
||||
const ToastContext = createContext<ToastContextValue | null>(null)
|
||||
|
||||
export function ToastProvider({ children }: { children: ReactNode }) {
|
||||
const { t } = useTranslation()
|
||||
const [items, setItems] = useState<ToastItem[]>([])
|
||||
|
||||
const toast = useCallback((item: Omit<ToastItem, 'id' | 'tone'> & { tone?: ToastTone }) => {
|
||||
@@ -46,7 +48,7 @@ export function ToastProvider({ children }: { children: ReactNode }) {
|
||||
{item.description}
|
||||
</ToastPrimitive.Description>
|
||||
) : null}
|
||||
<ToastPrimitive.Close className="an-toast__close" aria-label="关闭通知" title="关闭通知">
|
||||
<ToastPrimitive.Close className="an-toast__close" aria-label={t('common.close')} title={t('common.close')}>
|
||||
<X size={14} />
|
||||
</ToastPrimitive.Close>
|
||||
</ToastPrimitive.Root>
|
||||
|
||||
@@ -4,6 +4,7 @@ import axios from 'axios'
|
||||
import { Edit, Plus, Search, Trash2, X } from 'lucide-react'
|
||||
import { useEffect, useMemo, useState } from 'react'
|
||||
import { useForm } from 'react-hook-form'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { z } from 'zod'
|
||||
import { useAuthStore } from '../../stores/auth'
|
||||
import { DataTable } from '../components/data-table/DataTable'
|
||||
@@ -25,28 +26,17 @@ interface User {
|
||||
created_at: string
|
||||
}
|
||||
|
||||
const userSchema = z.object({
|
||||
username: z.string().min(1, '请输入用户名'),
|
||||
email: z.string().email('请输入有效邮箱'),
|
||||
password: z.string().optional(),
|
||||
role: z.string().min(1, '请选择角色'),
|
||||
gatekeeper_groups: z.array(z.string()).optional(),
|
||||
})
|
||||
interface UserFormValues {
|
||||
username: string
|
||||
email: string
|
||||
password?: string
|
||||
role: string
|
||||
gatekeeper_groups?: string[]
|
||||
}
|
||||
|
||||
type UserFormValues = z.infer<typeof userSchema>
|
||||
const roleValues = ['super_admin', 'admin', 'operator', 'viewer'] as const
|
||||
|
||||
const roleOptions = [
|
||||
{ value: 'super_admin', label: '超级管理员' },
|
||||
{ value: 'admin', label: '管理员' },
|
||||
{ value: 'operator', label: '操作员' },
|
||||
{ value: 'viewer', label: '只读用户' },
|
||||
]
|
||||
|
||||
const gatekeeperOptions = [
|
||||
{ value: 'docs_user', label: '文档:用户文档' },
|
||||
{ value: 'docs_developer', label: '文档:开发文档' },
|
||||
{ value: 'docs_admin', label: '文档:管理/运维文档' },
|
||||
]
|
||||
const gatekeeperValues = ['docs_user', 'docs_developer', 'docs_admin'] as const
|
||||
|
||||
function roleTone(role: string) {
|
||||
if (role === 'super_admin') return 'red'
|
||||
@@ -56,15 +46,8 @@ function roleTone(role: string) {
|
||||
return 'default'
|
||||
}
|
||||
|
||||
function roleLabel(role: string) {
|
||||
return roleOptions.find((option) => option.value === role)?.label || role
|
||||
}
|
||||
|
||||
function gatekeeperLabel(group: string) {
|
||||
return gatekeeperOptions.find((option) => option.value === group)?.label || group
|
||||
}
|
||||
|
||||
export default function Users() {
|
||||
const { t } = useTranslation()
|
||||
const { user: currentUser } = useAuthStore()
|
||||
const { toast } = useToast()
|
||||
const [users, setUsers] = useState<User[]>([])
|
||||
@@ -74,6 +57,23 @@ export default function Users() {
|
||||
const [deleteTarget, setDeleteTarget] = useState<User | null>(null)
|
||||
const [searchText, setSearchText] = useState('')
|
||||
const isSuperAdmin = currentUser?.role === 'super_admin'
|
||||
const userSchema = useMemo(() => z.object({
|
||||
username: z.string().min(1, t('auth.username')),
|
||||
email: z.string().email(t('auth.email')),
|
||||
password: z.string().optional(),
|
||||
role: z.string().min(1, t('users.role')),
|
||||
gatekeeper_groups: z.array(z.string()).optional(),
|
||||
}), [t])
|
||||
const roleOptions = useMemo(() => roleValues.map((value) => ({
|
||||
value,
|
||||
label: t(`users.roles.${value}`),
|
||||
})), [t])
|
||||
const gatekeeperOptions = useMemo(() => gatekeeperValues.map((value) => ({
|
||||
value,
|
||||
label: t(`users.gatekeeper.${value}`),
|
||||
})), [t])
|
||||
const roleLabel = (role: string) => roleOptions.find((option) => option.value === role)?.label || role
|
||||
const gatekeeperLabel = (group: string) => gatekeeperOptions.find((option) => option.value === group)?.label || group
|
||||
|
||||
const form = useForm<UserFormValues>({
|
||||
resolver: zodResolver(userSchema),
|
||||
@@ -125,17 +125,17 @@ export default function Users() {
|
||||
if (!isSuperAdmin) delete payload.gatekeeper_groups
|
||||
if (editingUser) {
|
||||
await axios.put(`/api/v1/users/${editingUser.id}`, payload)
|
||||
toast({ tone: 'success', title: '更新成功' })
|
||||
toast({ tone: 'success', title: t('users.updateSuccess') })
|
||||
} else {
|
||||
const createPayload = { ...payload, password: values.password || '' }
|
||||
await axios.post('/api/v1/users', createPayload)
|
||||
toast({ tone: 'success', title: '创建成功' })
|
||||
toast({ tone: 'success', title: t('users.createSuccess') })
|
||||
}
|
||||
setModalVisible(false)
|
||||
void fetchUsers()
|
||||
} catch (error: unknown) {
|
||||
const err = error as { response?: { data?: { detail?: string } } }
|
||||
toast({ tone: 'error', title: '操作失败', description: err.response?.data?.detail || '请稍后重试' })
|
||||
toast({ tone: 'error', title: t('common.operationFailed'), description: err.response?.data?.detail || t('users.retryLater') })
|
||||
}
|
||||
}
|
||||
|
||||
@@ -143,22 +143,22 @@ export default function Users() {
|
||||
if (!deleteTarget) return
|
||||
try {
|
||||
await axios.delete(`/api/v1/users/${deleteTarget.id}`)
|
||||
toast({ tone: 'success', title: '删除成功' })
|
||||
toast({ tone: 'success', title: t('users.deleteSuccess') })
|
||||
setDeleteTarget(null)
|
||||
void fetchUsers()
|
||||
} catch (error: unknown) {
|
||||
const err = error as { response?: { data?: { detail?: string } } }
|
||||
toast({ tone: 'error', title: '删除失败', description: err.response?.data?.detail || '请稍后重试' })
|
||||
toast({ tone: 'error', title: t('users.deleteFailed'), description: err.response?.data?.detail || t('users.retryLater') })
|
||||
}
|
||||
}
|
||||
|
||||
const columns = useMemo<Array<ColumnDef<User>>>(() => [
|
||||
{ accessorKey: 'id', header: 'ID', size: 80 },
|
||||
{ accessorKey: 'username', header: '用户名', size: 180 },
|
||||
{ accessorKey: 'email', header: '邮箱', size: 260 },
|
||||
{ accessorKey: 'username', header: t('auth.username'), size: 180 },
|
||||
{ accessorKey: 'email', header: t('auth.email'), size: 260 },
|
||||
{
|
||||
accessorKey: 'role',
|
||||
header: '角色',
|
||||
header: t('users.role'),
|
||||
size: 140,
|
||||
cell: ({ row }) => <Badge tone={roleTone(row.original.role)} title={row.original.role}>{roleLabel(row.original.role)}</Badge>,
|
||||
},
|
||||
@@ -175,30 +175,30 @@ export default function Users() {
|
||||
<Badge key={group} tone={group === 'docs_admin' ? 'red' : group === 'docs_developer' ? 'blue' : 'green'}>
|
||||
{gatekeeperLabel(group)}
|
||||
</Badge>
|
||||
)) : <Badge tone="slate">未配置</Badge>}
|
||||
)) : <Badge tone="slate">{t('users.unconfigured')}</Badge>}
|
||||
</div>
|
||||
)
|
||||
},
|
||||
},
|
||||
{
|
||||
accessorKey: 'is_active',
|
||||
header: '状态',
|
||||
header: t('users.status'),
|
||||
size: 120,
|
||||
cell: ({ row }) => <Badge tone={row.original.is_active ? 'green' : 'red'}>{row.original.is_active ? '活跃' : '禁用'}</Badge>,
|
||||
cell: ({ row }) => <Badge tone={row.original.is_active ? 'green' : 'red'}>{row.original.is_active ? t('users.active') : t('users.disabled')}</Badge>,
|
||||
},
|
||||
{
|
||||
id: 'actions',
|
||||
header: '操作',
|
||||
header: t('users.actions'),
|
||||
size: 148,
|
||||
enableSorting: false,
|
||||
cell: ({ row }) => (
|
||||
<div className="an-row-actions">
|
||||
<Button size="sm" variant="ghost" onClick={() => handleEdit(row.original)}><Edit size={14} />编辑</Button>
|
||||
<Button size="sm" variant="ghost" className="is-danger" onClick={() => setDeleteTarget(row.original)}><Trash2 size={14} />删除</Button>
|
||||
<Button size="sm" variant="ghost" onClick={() => handleEdit(row.original)}><Edit size={14} />{t('users.edit')}</Button>
|
||||
<Button size="sm" variant="ghost" className="is-danger" onClick={() => setDeleteTarget(row.original)}><Trash2 size={14} />{t('common.delete')}</Button>
|
||||
</div>
|
||||
),
|
||||
},
|
||||
], [])
|
||||
], [gatekeeperOptions, roleOptions, t])
|
||||
|
||||
const filteredUsers = useMemo(() => {
|
||||
const keyword = searchText.trim().toLowerCase()
|
||||
@@ -218,8 +218,8 @@ export default function Users() {
|
||||
<div className="an-page">
|
||||
<div className="an-page__header">
|
||||
<div>
|
||||
<h1>用户管理</h1>
|
||||
<p>维护后台账号、角色与文档权限组。</p>
|
||||
<h1>{t('admin.routes.users')}</h1>
|
||||
<p>{t('users.description')}</p>
|
||||
</div>
|
||||
<div className="an-toolbar">
|
||||
<div className="an-search-box">
|
||||
@@ -227,15 +227,15 @@ export default function Users() {
|
||||
<Input
|
||||
value={searchText}
|
||||
onChange={(event) => setSearchText(event.target.value)}
|
||||
placeholder="搜索用户、邮箱、角色"
|
||||
placeholder={t('users.searchPlaceholder')}
|
||||
/>
|
||||
{searchText ? (
|
||||
<Button size="icon" variant="ghost" onClick={() => setSearchText('')} aria-label="清空搜索" title="清空搜索">
|
||||
<Button size="icon" variant="ghost" onClick={() => setSearchText('')} aria-label={t('users.clearSearch')} title={t('users.clearSearch')}>
|
||||
<X size={14} />
|
||||
</Button>
|
||||
) : null}
|
||||
</div>
|
||||
<Button variant="primary" onClick={handleAdd}><Plus size={16} />添加用户</Button>
|
||||
<Button variant="primary" onClick={handleAdd}><Plus size={16} />{t('users.addUser')}</Button>
|
||||
</div>
|
||||
</div>
|
||||
<div className="an-page__body">
|
||||
@@ -244,40 +244,40 @@ export default function Users() {
|
||||
</div>
|
||||
|
||||
<Dialog
|
||||
title={editingUser ? '编辑用户' : '添加用户'}
|
||||
title={editingUser ? t('users.editUser') : t('users.addUser')}
|
||||
open={modalVisible}
|
||||
onOpenChange={setModalVisible}
|
||||
footer={(
|
||||
<>
|
||||
<Button variant="subtle" onClick={() => setModalVisible(false)}>取消</Button>
|
||||
<Button variant="primary" loading={form.formState.isSubmitting} onClick={form.handleSubmit(handleSubmit)}>提交</Button>
|
||||
<Button variant="subtle" onClick={() => setModalVisible(false)}>{t('common.cancel')}</Button>
|
||||
<Button variant="primary" loading={form.formState.isSubmitting} onClick={form.handleSubmit(handleSubmit)}>{t('users.submit')}</Button>
|
||||
</>
|
||||
)}
|
||||
>
|
||||
<form className="an-form" onSubmit={form.handleSubmit(handleSubmit)}>
|
||||
<label className="an-field">
|
||||
<span>用户名</span>
|
||||
<span>{t('auth.username')}</span>
|
||||
<Input {...form.register('username')} />
|
||||
{form.formState.errors.username ? <em>{form.formState.errors.username.message}</em> : null}
|
||||
</label>
|
||||
<label className="an-field">
|
||||
<span>邮箱</span>
|
||||
<span>{t('auth.email')}</span>
|
||||
<Input {...form.register('email')} />
|
||||
{form.formState.errors.email ? <em>{form.formState.errors.email.message}</em> : null}
|
||||
</label>
|
||||
{!editingUser ? (
|
||||
<label className="an-field">
|
||||
<span>密码</span>
|
||||
<span>{t('auth.password')}</span>
|
||||
<Input type="password" {...form.register('password', { required: true, minLength: 8 })} />
|
||||
{form.formState.errors.password ? <em>密码至少 8 位</em> : null}
|
||||
{form.formState.errors.password ? <em>{t('auth.passwordHint')}</em> : null}
|
||||
</label>
|
||||
) : null}
|
||||
<label className="an-field">
|
||||
<span>角色</span>
|
||||
<span>{t('users.role')}</span>
|
||||
<Select value={form.watch('role')} onValueChange={(value) => form.setValue('role', value)} options={roleOptions} />
|
||||
</label>
|
||||
<div className="an-field">
|
||||
<span>Gatekeeper 权限组</span>
|
||||
<span>{t('users.gatekeeperGroups')}</span>
|
||||
<div className="an-checkbox-list" aria-disabled={!isSuperAdmin}>
|
||||
{gatekeeperOptions.map((option) => (
|
||||
<label key={option.value}>
|
||||
@@ -301,14 +301,14 @@ export default function Users() {
|
||||
</Dialog>
|
||||
|
||||
<ConfirmDialog
|
||||
title="确认删除"
|
||||
title={t('users.confirmDelete')}
|
||||
open={Boolean(deleteTarget)}
|
||||
onOpenChange={(open) => {
|
||||
if (!open) setDeleteTarget(null)
|
||||
}}
|
||||
description={`确定要删除用户 ${deleteTarget?.username || ''} 吗?`}
|
||||
description={t('users.confirmDeleteDescription', { username: deleteTarget?.username || '' })}
|
||||
danger
|
||||
confirmLabel="删除"
|
||||
confirmLabel={t('common.delete')}
|
||||
onConfirm={() => void handleDelete()}
|
||||
/>
|
||||
</AdminLayout>
|
||||
|
||||
@@ -17,6 +17,7 @@ import {
|
||||
export interface AdminRouteItem {
|
||||
path: string
|
||||
label: string
|
||||
labelKey: string
|
||||
group: string
|
||||
icon: LucideIcon
|
||||
keywords: string[]
|
||||
@@ -26,33 +27,34 @@ export interface AdminRouteItem {
|
||||
export interface AdminRouteGroup {
|
||||
key: string
|
||||
label: string
|
||||
labelKey: string
|
||||
icon: LucideIcon
|
||||
}
|
||||
|
||||
export const adminRouteGroups: AdminRouteGroup[] = [
|
||||
{ key: 'overview', label: '总览', icon: CircleGauge },
|
||||
{ key: 'collection', label: '采集与数据', icon: HardDrive },
|
||||
{ key: 'observability', label: '专题观测', icon: AppWindow },
|
||||
{ key: 'alerts', label: '告警与研判', icon: ShieldAlert },
|
||||
{ key: 'ops', label: '运维与配置', icon: Settings },
|
||||
{ key: 'overview', label: '总览', labelKey: 'admin.groups.overview', icon: CircleGauge },
|
||||
{ key: 'collection', label: '采集与数据', labelKey: 'admin.groups.collection', icon: HardDrive },
|
||||
{ key: 'observability', label: '专题观测', labelKey: 'admin.groups.observability', icon: AppWindow },
|
||||
{ key: 'alerts', label: '告警与研判', labelKey: 'admin.groups.alerts', icon: ShieldAlert },
|
||||
{ key: 'ops', label: '运维与配置', labelKey: 'admin.groups.ops', icon: Settings },
|
||||
]
|
||||
|
||||
export const adminRoutes: AdminRouteItem[] = [
|
||||
{ path: '/admin', label: '仪表盘', group: 'overview', icon: CircleGauge, keywords: ['dashboard', '总览', '驾驶舱'] },
|
||||
{ path: '/earth', label: '智能星球', group: 'overview', icon: Globe2, keywords: ['earth', '地球', '智能星球'] },
|
||||
{ path: '/docs', label: '文档', group: 'overview', icon: FileText, keywords: ['docs', '文档', 'manual', '使用手册'] },
|
||||
{ path: '/datasources', label: '数据源', group: 'collection', icon: Database, keywords: ['datasource', '采集', '目录'] },
|
||||
{ path: '/data', label: '采集数据', group: 'collection', icon: AppWindow, keywords: ['data', 'records', '采集数据'] },
|
||||
{ path: '/bgp', label: 'BGP观测', group: 'observability', icon: Network, keywords: ['bgp', '观测', '网络'] },
|
||||
{ path: '/alerts/system', label: '系统告警', group: 'alerts', icon: AlertTriangle, keywords: ['alert', 'system', '告警'] },
|
||||
{ path: '/alerts/bgp', label: 'BGP 告警', group: 'alerts', icon: Network, keywords: ['alert', 'bgp', '风险'] },
|
||||
{ path: '/alerts/situational', label: '态势告警', group: 'alerts', icon: Globe2, keywords: ['situational', '态势', '研判'] },
|
||||
{ path: '/ai', label: 'AI', group: 'ops', icon: Bot, keywords: ['ai', 'provider', 'playground', 'prompt'] },
|
||||
{ path: '/earth-content', label: '智能星球内容', group: 'ops', icon: Globe2, keywords: ['earth', '地球', '智能星球', 'tv', 'boundary', 'brand', 'news', 'rss', '新闻源'] },
|
||||
{ path: '/collection-management', label: '采集管理', group: 'ops', icon: Database, keywords: ['collector', 'mapping', 'custom source'] },
|
||||
{ path: '/logs', label: '系统日志', group: 'ops', icon: FileText, keywords: ['log', '日志', 'tail'], superAdminOnly: true },
|
||||
{ path: '/users', label: '用户管理', group: 'ops', icon: Users, keywords: ['users', 'role', 'gatekeeper'] },
|
||||
{ path: '/settings', label: '系统设置', group: 'ops', icon: Settings, keywords: ['settings', 'smtp', 'security'] },
|
||||
{ path: '/admin', label: '仪表盘', labelKey: 'admin.routes.dashboard', group: 'overview', icon: CircleGauge, keywords: ['dashboard', '总览', '驾驶舱'] },
|
||||
{ path: '/earth', label: '智能星球', labelKey: 'admin.routes.earth', group: 'overview', icon: Globe2, keywords: ['earth', '地球', '智能星球'] },
|
||||
{ path: '/docs', label: '文档', labelKey: 'admin.routes.docs', group: 'overview', icon: FileText, keywords: ['docs', '文档', 'manual', '使用手册'] },
|
||||
{ path: '/datasources', label: '数据源', labelKey: 'admin.routes.datasources', group: 'collection', icon: Database, keywords: ['datasource', '采集', '目录'] },
|
||||
{ path: '/data', label: '采集数据', labelKey: 'admin.routes.data', group: 'collection', icon: AppWindow, keywords: ['data', 'records', '采集数据'] },
|
||||
{ path: '/bgp', label: 'BGP观测', labelKey: 'admin.routes.bgp', group: 'observability', icon: Network, keywords: ['bgp', '观测', '网络'] },
|
||||
{ path: '/alerts/system', label: '系统告警', labelKey: 'admin.routes.systemAlerts', group: 'alerts', icon: AlertTriangle, keywords: ['alert', 'system', '告警'] },
|
||||
{ path: '/alerts/bgp', label: 'BGP 告警', labelKey: 'admin.routes.bgpAlerts', group: 'alerts', icon: Network, keywords: ['alert', 'bgp', '风险'] },
|
||||
{ path: '/alerts/situational', label: '态势告警', labelKey: 'admin.routes.situationalAlerts', group: 'alerts', icon: Globe2, keywords: ['situational', '态势', '研判'] },
|
||||
{ path: '/ai', label: 'AI', labelKey: 'admin.routes.ai', group: 'ops', icon: Bot, keywords: ['ai', 'provider', 'playground', 'prompt'] },
|
||||
{ path: '/earth-content', label: '智能星球内容', labelKey: 'admin.routes.earthContent', group: 'ops', icon: Globe2, keywords: ['earth', '地球', '智能星球', 'tv', 'boundary', 'brand', 'news', 'rss', '新闻源'] },
|
||||
{ path: '/collection-management', label: '采集管理', labelKey: 'admin.routes.collectionManagement', group: 'ops', icon: Database, keywords: ['collector', 'mapping', 'custom source'] },
|
||||
{ path: '/logs', label: '系统日志', labelKey: 'admin.routes.logs', group: 'ops', icon: FileText, keywords: ['log', '日志', 'tail'], superAdminOnly: true },
|
||||
{ path: '/users', label: '用户管理', labelKey: 'admin.routes.users', group: 'ops', icon: Users, keywords: ['users', 'role', 'gatekeeper'] },
|
||||
{ path: '/settings', label: '系统设置', labelKey: 'admin.routes.settings', group: 'ops', icon: Settings, keywords: ['settings', 'smtp', 'security'] },
|
||||
]
|
||||
|
||||
export function getVisibleAdminRoutes(isSuperAdmin: boolean) {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { createContext, useCallback, useContext, useEffect, useMemo, useRef, useState, type ReactNode } from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { useLocation, useNavigate } from 'react-router-dom'
|
||||
import { useAuthStore } from '../../stores/auth'
|
||||
import { buildDynamicAdminTargets, buildStaticAdminTargets, searchAdminTargets } from './indexers'
|
||||
@@ -26,13 +27,14 @@ function targetSearchParams(target: AdminSearchTarget) {
|
||||
export function AdminSearchProvider({ children }: { children: ReactNode }) {
|
||||
const navigate = useNavigate()
|
||||
const location = useLocation()
|
||||
const { i18n } = useTranslation()
|
||||
const { user } = useAuthStore()
|
||||
const isSuperAdmin = user?.role === 'super_admin'
|
||||
const [dynamicTargets, setDynamicTargets] = useState<AdminSearchTarget[]>([])
|
||||
const [loading, setLoading] = useState(false)
|
||||
const loadedRef = useRef(false)
|
||||
const loadingRef = useRef<Promise<void> | null>(null)
|
||||
const staticTargets = useMemo(() => buildStaticAdminTargets(isSuperAdmin), [isSuperAdmin])
|
||||
const staticTargets = useMemo(() => buildStaticAdminTargets(isSuperAdmin), [i18n.language, isSuperAdmin])
|
||||
const targets = useMemo(() => {
|
||||
const byId = new Map<string, AdminSearchTarget>()
|
||||
staticTargets.forEach((target) => byId.set(target.id, target))
|
||||
@@ -44,7 +46,7 @@ export function AdminSearchProvider({ children }: { children: ReactNode }) {
|
||||
loadedRef.current = false
|
||||
loadingRef.current = null
|
||||
setDynamicTargets([])
|
||||
}, [isSuperAdmin])
|
||||
}, [i18n.language, isSuperAdmin])
|
||||
|
||||
const ensureDynamicIndex = useCallback(async (query: string) => {
|
||||
if (query.trim().length < 2 || loadedRef.current) return
|
||||
|
||||
@@ -14,6 +14,7 @@ import {
|
||||
ShieldAlert,
|
||||
Users,
|
||||
} from 'lucide-react'
|
||||
import i18n from '../../i18n'
|
||||
import { adminRoutes, getVisibleAdminRoutes } from '../routes/manifest'
|
||||
import type { AdminSearchTarget } from './types'
|
||||
|
||||
@@ -50,11 +51,68 @@ function targetId(parts: Array<string | undefined>) {
|
||||
return parts.filter(Boolean).join(':')
|
||||
}
|
||||
|
||||
const labelKeys: Record<string, string> = {
|
||||
'AI': 'admin.routes.ai',
|
||||
'BGP观测': 'admin.routes.bgp',
|
||||
'BGP': 'admin.sections.bgpOverview',
|
||||
'BGP 事故': 'admin.sections.alerts',
|
||||
'BGP 告警': 'admin.routes.bgpAlerts',
|
||||
'Playground': 'admin.sections.aiPlayground',
|
||||
'SMTP 邮件': 'admin.sections.smtp',
|
||||
'工具调用': 'admin.sections.aiTools',
|
||||
'提示词': 'admin.sections.aiPrompts',
|
||||
'日志': 'admin.routes.logs',
|
||||
'日志源': 'admin.sections.logsSources',
|
||||
'智能星球内容': 'admin.routes.earthContent',
|
||||
'模型供应商': 'admin.sections.aiIntegrations',
|
||||
'模型预设': 'admin.sections.aiIntegrations',
|
||||
'电视直播': 'admin.sections.tv',
|
||||
'系统告警': 'admin.routes.systemAlerts',
|
||||
'系统显示': 'admin.sections.settingsSystem',
|
||||
'系统设置': 'admin.routes.settings',
|
||||
'采集历史': 'admin.sections.collectionHistory',
|
||||
'采集历史 / 快照': 'admin.sections.collectionHistory',
|
||||
'采集器': 'admin.sections.collectorCredentials',
|
||||
'采集数据': 'admin.routes.data',
|
||||
'采集管理': 'admin.routes.collectionManagement',
|
||||
'采集调度': 'admin.sections.collectors',
|
||||
'数据源': 'admin.routes.datasources',
|
||||
'用户': 'admin.routes.users',
|
||||
'用户管理': 'admin.routes.users',
|
||||
'告警记录': 'admin.sections.alerts',
|
||||
'国界精度': 'admin.sections.earthAssets',
|
||||
'品牌标识': 'admin.sections.earthBrand',
|
||||
'态势告警': 'admin.routes.situationalAlerts',
|
||||
'通知策略': 'admin.sections.notifications',
|
||||
'安全策略': 'admin.sections.security',
|
||||
'新闻源': 'admin.sections.newsSources',
|
||||
'页面': 'admin.search.pageContext',
|
||||
}
|
||||
|
||||
function translateLabel(label: string | undefined): string | undefined {
|
||||
if (!label) return label
|
||||
const key = labelKeys[label]
|
||||
return key ? i18n.t(key) : label
|
||||
}
|
||||
|
||||
function makeTarget(target: Omit<AdminSearchTarget, 'id'> & { id?: string }): AdminSearchTarget {
|
||||
const routeLabel = translateLabel(target.routeLabel) || target.routeLabel
|
||||
const sectionLabel = translateLabel(target.sectionLabel) || target.sectionLabel
|
||||
const label = translateLabel(target.label) || target.label
|
||||
const contextLabel = translateLabel(target.contextLabel) || target.contextLabel
|
||||
|
||||
return {
|
||||
...target,
|
||||
contextLabel,
|
||||
id: target.id || targetId([target.routePath, target.sectionKey, target.groupKey, target.fieldKey, target.label]),
|
||||
label,
|
||||
routeLabel,
|
||||
sectionLabel,
|
||||
terms: Array.from(new Set([
|
||||
label,
|
||||
routeLabel,
|
||||
sectionLabel,
|
||||
contextLabel,
|
||||
target.routeLabel,
|
||||
target.sectionLabel,
|
||||
target.contextLabel,
|
||||
@@ -153,9 +211,9 @@ export function buildStaticAdminTargets(isSuperAdmin: boolean): AdminSearchTarge
|
||||
.filter((route) => visiblePaths.has(route.path))
|
||||
.map((route) => makeTarget({
|
||||
routePath: route.path,
|
||||
routeLabel: route.label,
|
||||
label: route.label,
|
||||
contextLabel: '页面',
|
||||
routeLabel: i18n.t(route.labelKey),
|
||||
label: i18n.t(route.labelKey),
|
||||
contextLabel: i18n.t('admin.search.pageContext'),
|
||||
terms: route.keywords,
|
||||
icon: route.icon,
|
||||
}))
|
||||
|
||||
+167
-11
@@ -1,4 +1,7 @@
|
||||
.admin-theme-root {
|
||||
min-height: 0;
|
||||
height: 100%;
|
||||
overflow: hidden;
|
||||
--an-page-padding: 16px;
|
||||
--an-section-gap: 16px;
|
||||
--an-panel-gap: 12px;
|
||||
@@ -128,7 +131,10 @@ body:has(.admin-theme-root[data-theme='dark']) .an-toast {
|
||||
.admin__sider {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
min-height: 0;
|
||||
min-width: 0;
|
||||
height: 100%;
|
||||
overflow: hidden;
|
||||
background: var(--an-surface);
|
||||
border-right: 1px solid var(--an-border);
|
||||
}
|
||||
@@ -171,8 +177,9 @@ body:has(.admin-theme-root[data-theme='dark']) .an-toast {
|
||||
}
|
||||
|
||||
.admin__nav-scroll {
|
||||
flex: 1;
|
||||
flex: 1 1 auto;
|
||||
min-height: 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.admin__nav {
|
||||
@@ -237,10 +244,12 @@ body:has(.admin-theme-root[data-theme='dark']) .an-toast {
|
||||
}
|
||||
|
||||
.admin__account {
|
||||
flex: 0 0 auto;
|
||||
border-top: 1px solid var(--an-border);
|
||||
padding: 12px;
|
||||
background: color-mix(in srgb, var(--an-bg) 42%, var(--an-surface));
|
||||
display: grid;
|
||||
gap: 9px;
|
||||
gap: 0;
|
||||
}
|
||||
|
||||
.admin__account-row {
|
||||
@@ -251,21 +260,93 @@ body:has(.admin-theme-root[data-theme='dark']) .an-toast {
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.admin__account-row--primary {
|
||||
min-height: 34px;
|
||||
}
|
||||
|
||||
.admin__account-row > div {
|
||||
min-width: 0;
|
||||
display: grid;
|
||||
gap: 2px;
|
||||
}
|
||||
|
||||
.admin__account-profile {
|
||||
display: flex !important;
|
||||
grid-template-columns: none;
|
||||
align-items: center;
|
||||
min-width: 0;
|
||||
flex: 1 1 auto;
|
||||
margin-right: 6px;
|
||||
}
|
||||
|
||||
.admin__account-row .admin__account-profile {
|
||||
gap: 18px;
|
||||
}
|
||||
|
||||
.admin__account-profile > div {
|
||||
min-width: 0;
|
||||
display: grid;
|
||||
gap: 1px;
|
||||
}
|
||||
|
||||
.admin__account-avatar {
|
||||
flex: 0 0 30px;
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
border-radius: 999px;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background: var(--an-accent);
|
||||
color: #ffffff;
|
||||
font-size: 12px;
|
||||
font-weight: 800;
|
||||
box-shadow: 0 6px 16px color-mix(in srgb, var(--an-accent) 22%, transparent);
|
||||
}
|
||||
|
||||
.admin__account-row .admin__account-avatar {
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.admin__account-row strong {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.admin__account-logout {
|
||||
.admin__account-actions {
|
||||
display: flex !important;
|
||||
grid-template-columns: none;
|
||||
align-items: center;
|
||||
justify-content: flex-end;
|
||||
flex: 0 0 auto;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.admin__account-logout,
|
||||
.admin__account-preferences {
|
||||
width: 28px;
|
||||
height: 28px;
|
||||
}
|
||||
|
||||
.admin__account-preferences {
|
||||
color: var(--an-muted);
|
||||
}
|
||||
|
||||
.admin__account-preferences svg {
|
||||
transition: color 0.18s ease, transform 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
|
||||
}
|
||||
|
||||
.admin__account-preferences.is-active {
|
||||
color: var(--an-accent);
|
||||
background: color-mix(in srgb, var(--an-accent) 10%, var(--an-surface));
|
||||
}
|
||||
|
||||
.admin__account-preferences.is-active svg {
|
||||
transform: rotate(90deg);
|
||||
}
|
||||
|
||||
.admin__account-logout {
|
||||
color: var(--an-danger);
|
||||
}
|
||||
|
||||
@@ -277,11 +358,46 @@ body:has(.admin-theme-root[data-theme='dark']) .an-toast {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.admin__preferences-drawer {
|
||||
max-height: 0;
|
||||
overflow: hidden;
|
||||
opacity: 0;
|
||||
visibility: hidden;
|
||||
transform: translateY(-5px);
|
||||
transition:
|
||||
max-height 0.24s ease,
|
||||
opacity 0.18s ease,
|
||||
transform 0.24s ease,
|
||||
visibility 0s linear 0.24s;
|
||||
}
|
||||
|
||||
.admin__preferences-drawer.is-open {
|
||||
max-height: 146px;
|
||||
opacity: 1;
|
||||
visibility: visible;
|
||||
transform: translateY(0);
|
||||
transition:
|
||||
max-height 0.28s ease,
|
||||
opacity 0.18s ease,
|
||||
transform 0.28s ease,
|
||||
visibility 0s;
|
||||
}
|
||||
|
||||
.admin__preferences-panel {
|
||||
margin-top: 12px;
|
||||
padding: 12px 14px;
|
||||
border-top: 1px solid color-mix(in srgb, var(--an-border) 78%, transparent);
|
||||
border-radius: 8px;
|
||||
background: color-mix(in srgb, var(--an-bg) 62%, var(--an-surface));
|
||||
display: grid;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.admin__theme-control--sider {
|
||||
--segmented-control-radius: 8px;
|
||||
--segmented-control-slider-radius: 6px;
|
||||
--segmented-control-button-gap: 0;
|
||||
--segmented-control-icon-size: calc(17px * var(--segmented-control-scale, 1));
|
||||
--segmented-control-icon-size: 13px;
|
||||
}
|
||||
|
||||
.admin__theme-control--sider .segmented-control__button {
|
||||
@@ -309,6 +425,21 @@ body:has(.admin-theme-root[data-theme='dark']) .an-toast {
|
||||
color: #64748b;
|
||||
}
|
||||
|
||||
.admin__language-control--sider {
|
||||
width: 100%;
|
||||
--segmented-control-radius: 8px;
|
||||
--segmented-control-slider-radius: 6px;
|
||||
--segmented-control-button-gap: 0;
|
||||
--segmented-control-font-size: calc(10px * var(--segmented-control-scale, 1));
|
||||
--segmented-control-font-weight: 800;
|
||||
}
|
||||
|
||||
.admin__language-control--sider .segmented-control__button {
|
||||
font-size: calc(10px * var(--segmented-control-scale, 1));
|
||||
font-weight: 800;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.admin__logout {
|
||||
justify-content: center;
|
||||
}
|
||||
@@ -597,9 +728,11 @@ body:has(.admin-theme-root[data-theme='dark']) .an-toast {
|
||||
|
||||
.admin__content {
|
||||
min-width: 0;
|
||||
min-height: 0;
|
||||
height: 100%;
|
||||
display: grid;
|
||||
grid-template-rows: 48px minmax(0, 1fr);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.admin__topbar {
|
||||
@@ -652,6 +785,25 @@ body:has(.admin-theme-root[data-theme='dark']) .an-toast {
|
||||
color: var(--an-muted);
|
||||
}
|
||||
|
||||
.admin__language-control {
|
||||
width: 112px;
|
||||
--segmented-control-radius: 8px;
|
||||
--segmented-control-slider-radius: 6px;
|
||||
--segmented-control-button-gap: 0;
|
||||
}
|
||||
|
||||
.admin__language-control .segmented-control__button {
|
||||
flex-direction: row;
|
||||
}
|
||||
|
||||
.admin__language-control .segmented-control__icon {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.admin__language-control.admin__language-control--sider {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.admin__search-results {
|
||||
position: absolute;
|
||||
top: calc(100% + 6px);
|
||||
@@ -754,6 +906,7 @@ body:has(.admin-theme-root[data-theme='dark']) .an-toast {
|
||||
.admin__content-inner {
|
||||
min-width: 0;
|
||||
min-height: 0;
|
||||
height: 100%;
|
||||
overflow: hidden;
|
||||
padding: var(--an-page-padding);
|
||||
}
|
||||
@@ -1633,7 +1786,7 @@ body:has(.admin-theme-root[data-theme='dark']) .an-toast {
|
||||
color: var(--an-text);
|
||||
padding: 8px 10px;
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1fr) 104px;
|
||||
grid-template-columns: minmax(0, 1fr) max-content;
|
||||
align-items: start;
|
||||
gap: 10px;
|
||||
text-align: left;
|
||||
@@ -1683,19 +1836,22 @@ body:has(.admin-theme-root[data-theme='dark']) .an-toast {
|
||||
}
|
||||
|
||||
.an-hierarchy-group__meta {
|
||||
width: 104px;
|
||||
max-width: 104px;
|
||||
width: max-content;
|
||||
max-width: none;
|
||||
min-width: max-content;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: flex-end;
|
||||
gap: 5px;
|
||||
overflow: hidden;
|
||||
justify-self: end;
|
||||
overflow: visible;
|
||||
}
|
||||
|
||||
.an-hierarchy-group__meta .an-status-pill {
|
||||
flex: 0 0 74px;
|
||||
width: 74px;
|
||||
max-width: 74px;
|
||||
flex: 0 0 auto;
|
||||
width: auto;
|
||||
min-width: max-content;
|
||||
max-width: none;
|
||||
}
|
||||
|
||||
.an-hierarchy-group__meta em {
|
||||
|
||||
Reference in new issue
Block a user