feat(admin): configure model providers from database

This commit is contained in:
Jesse_Chen
2026-08-07 20:03:20 +08:00
parent d63f10dcc2
commit 3089316d2e
31 changed files with 871 additions and 1430 deletions
+4 -21
View File
@@ -2,7 +2,6 @@
import {
ApiOutlined,
ArrowLeftOutlined,
AuditOutlined,
ControlOutlined,
CreditCardOutlined,
@@ -17,10 +16,9 @@ import {
UserOutlined,
} from "@ant-design/icons";
import { Authenticated, Refine } from "@refinedev/core";
import { ErrorComponent, ThemedLayout, ThemedSider, useNotificationProvider } from "@refinedev/antd";
import { ErrorComponent, ThemedLayout, useNotificationProvider } from "@refinedev/antd";
import routerProvider from "@refinedev/nextjs-router";
import { App as AntdApp, ConfigProvider, Menu, Spin, theme } from "antd";
import Link from "next/link";
import { App as AntdApp, ConfigProvider, Spin, theme } from "antd";
import type { ReactNode } from "react";
import {
@@ -29,26 +27,11 @@ import {
adminDataProvider,
} from "@/lib/admin/providers";
function AdminSider() {
return (
<ThemedSider
render={({ items, collapsed }) => (
<>
{items}
<Menu.Item key="return-to-chat" icon={<ArrowLeftOutlined />} title="返回对话">
<Link href="/" aria-label="返回对话">{collapsed ? null : "返回对话"}</Link>
</Menu.Item>
</>
)}
/>
);
}
export function AdminApp({ children }: { children: ReactNode }) {
const notificationProvider = useNotificationProvider();
return (
<div className="admin-app-shell">
<ConfigProvider theme={{ algorithm: theme.darkAlgorithm, token: { colorPrimary: "#c8a96b" } }}>
<ConfigProvider componentSize="large" theme={{ algorithm: theme.darkAlgorithm, token: { colorPrimary: "#c8a96b" } }}>
<AntdApp>
<Refine
routerProvider={routerProvider}
@@ -83,7 +66,7 @@ export function AdminApp({ children }: { children: ReactNode }) {
key="admin-authenticated"
loading={<div className="admin-loading"><Spin size="large" /><span>正在验证后台权限</span></div>}
>
<ThemedLayout Sider={AdminSider}>{children}</ThemedLayout>
<ThemedLayout>{children}</ThemedLayout>
</Authenticated>
</Refine>
</AntdApp>