@gadmin2n/schematics 0.0.64 → 0.0.66
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/dist/lib/application/files/gadmin2-game-angle-demo/.dockerignore +2 -2
- package/dist/lib/application/files/gadmin2-game-angle-demo/Dockerfile +40 -26
- package/dist/lib/application/files/gadmin2-game-angle-demo/Jenkinsfile +30 -4
- package/dist/lib/application/files/gadmin2-game-angle-demo/config/prisma/example.prisma +33 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/config/prisma/system.prisma +170 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/config/ui/Event.ts +70 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/config/ui/Game.ts +6 -6
- package/dist/lib/application/files/gadmin2-game-angle-demo/config/ui/ITActivityDay.ts +70 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/config/ui/Log.ts +2 -2
- package/dist/lib/application/files/gadmin2-game-angle-demo/config/ui/Role.ts +2 -2
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/.env +20 -9
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/.env.local +1 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/.eslintrc.js +1 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/.prettierignore +1 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/README.md +2 -18
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/gadmin-cli.json +1 -1
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/migrate-between-pg-schemas.js +1232 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/package.json +65 -38
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/prisma/.generator.prisma +4 -3
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/prisma.config.ts +16 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/seed/games.ts +1 -71
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/seed/index.ts +17 -21
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/seed/permissions.ts +278 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/seed/seedDataMngtPages.ts +258 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/seed/users.ts +7 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/alias.config.ts +7 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/app.controller.ts +151 -11
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/app.module.ts +29 -13
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/app.service.ts +151 -12
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/lib/auth.guard.ts +87 -41
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/lib/http-cache.interceptor.ts +21 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/lib/logger.ts +19 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/lib/safe-log.util.ts +176 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/lib/{yufuid.ts → taihu.ts} +49 -34
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/lib/tracing.ts +174 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/lib/trim.pipe.ts +51 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/lib/utils.ts +91 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/lib/woaAuth.ts +25 -12
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/main.ts +22 -12
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/audit/audit.controller.spec.ts +20 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/audit/audit.controller.ts +190 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/audit/audit.module.ts +10 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/audit/audit.service.spec.ts +338 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/audit/audit.service.ts +83 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/game/game.controller.spec.ts +20 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/game/game.controller.ts +188 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/game/game.module.ts +10 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/game/game.service.spec.ts +18 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/game/game.service.ts +83 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/page/page.controller.spec.ts +20 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/page/page.controller.ts +250 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/page/page.module.ts +10 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/page/page.service.spec.ts +18 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/page/page.service.ts +1051 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/pageResource/pageResource.controller.spec.ts +20 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/pageResource/pageResource.controller.ts +196 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/pageResource/pageResource.module.ts +13 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/pageResource/pageResource.service.spec.ts +18 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/pageResource/pageResource.service.ts +219 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/resource/resource.controller.spec.ts +20 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/resource/resource.controller.ts +196 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/resource/resource.module.ts +10 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/resource/resource.service.spec.ts +18 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/resource/resource.service.ts +199 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/role/role.controller.spec.ts +20 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/role/role.controller.ts +210 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/role/role.module.ts +12 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/role/role.service.spec.ts +18 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/role/role.service.ts +849 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/role/roles-refresher.service.ts +133 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/rolePages/rolePages.controller.spec.ts +20 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/rolePages/rolePages.controller.ts +196 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/rolePages/rolePages.module.ts +10 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/rolePages/rolePages.service.spec.ts +18 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/rolePages/rolePages.service.ts +201 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/roleResource/roleResource.controller.spec.ts +20 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/roleResource/roleResource.controller.ts +196 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/roleResource/roleResource.module.ts +10 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/roleResource/roleResource.service.spec.ts +18 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/roleResource/roleResource.service.ts +216 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/user/user.controller.spec.ts +20 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/user/user.controller.ts +198 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/user/user.module.ts +10 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/user/user.service.spec.ts +18 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/src/modules/user/user.service.ts +104 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/start-prod.sh +130 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/tsconfig.json +18 -3
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/index.html +19 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/package.json +34 -42
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/postcss.config.cjs +6 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/App.tsx +111 -185
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/auditLogProvider.ts +5 -5
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/authProvider.ts +2 -2
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/components/SqlModal.tsx +419 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/components/contexts/business/index.tsx +1 -1
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/components/contexts/color-mode/index.tsx +49 -51
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/components/custom-avatar.tsx +38 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/components/index.ts +4 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/components/layout/{header/index.tsx → header.tsx} +22 -31
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/components/layout/index.ts +3 -1
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/components/layout/layout.tsx +32 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/components/layout/logo.tsx +19 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/components/layout/sider.tsx +331 -166
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/components/layout/title.tsx +61 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/components/pagination-total.tsx +21 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/components/tags/index.ts +1 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/components/tags/role-tag.tsx +44 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/components/text.tsx +74 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/config/http.ts +28 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/config/routeRegistry.tsx +258 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/constants/layout.ts +16 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/enums/audit-log.enum.ts +13 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/enums/index.ts +1 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/helpers/get-name-initials.ts +8 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/helpers/get-random-color.ts +27 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/helpers/http.ts +87 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/helpers/index.tsx +6 -1
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/helpers/login.ts +22 -59
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/helpers/utils.tsx +5 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/hooks/useDynamicResources.tsx +211 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/hooks/useFetchData.ts +33 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/hooks/useRoles.ts +30 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/hooks/useUserPageAccess.ts +339 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/i18n.ts +8 -4
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/index.tsx +3 -11
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/{public → src}/locales/en/common.json +1 -1
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/{public → src}/locales/zh_CN/common.json +1 -1
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/audit/components/action-cell.css +3 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/audit/components/action-cell.tsx +134 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/audit/create.tsx +113 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/audit/edit.tsx +122 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/audit/index.ts +8 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/audit/index.tsx +6 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/audit/list.tsx +213 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/audit/show.tsx +61 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/page/Components/AssignRolesModal.tsx +168 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/page/Components/CreatePageModal.tsx +42 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/page/Components/EditPageModal.tsx +42 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/page/Components/PageDetailDrawer.tsx +101 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/page/Components/PageFormModal.tsx +731 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/page/hooks/usePageManagement.ts +36 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/page/index.ts +1 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/page/list.tsx +1215 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/page/queries.ts +17 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/page/types.ts +45 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/permissionReadme/index.tsx +1089 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/resource/Components/CreateModal.tsx +25 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/resource/Components/EditModal.tsx +28 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/resource/Components/ResourceDetailDrawer.tsx +160 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/resource/Components/modal.tsx +202 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/resource/index.ts +2 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/resource/list.tsx +212 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/resource/queries.ts +10 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/resource/types.ts +9 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/role/Components/CreateModal.tsx +30 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/role/Components/EditModal.tsx +47 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/role/Components/RoleDetailDrawer.tsx +56 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/role/Components/modal.tsx +302 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/role/hooks/useRolePage.ts +35 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/role/index.ts +1 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/role/list.tsx +431 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/role/queries.ts +8 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/role/types.ts +8 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/user/components/create-modal.tsx +17 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/user/components/edit-modal.tsx +19 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/user/components/form-modal.tsx +188 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/user/components/index.ts +5 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/user/components/role-tag.tsx +48 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/user/components/show-drawer.tsx +140 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/user/index.ts +1 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/user/list.tsx +372 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/user/queries.ts +14 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/styles/antd.css +132 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/styles/fc.css +58 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/styles/index.css +128 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/styles/show-drawer.module.css +18 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/styles/show-page.module.css +21 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/types/audit-log.ts +1 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/types/index.ts +3 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/types/role.ts +7 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/types/user.ts +1 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/vite-env.d.ts +1 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/tsconfig.json +5 -4
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/vite.config.ts +31 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/yarn.lock +8321 -0
- package/package.json +1 -1
- package/dist/lib/application/files/gadmin2-game-angle-demo/config/prisma/sample.prisma +0 -65
- package/dist/lib/application/files/gadmin2-game-angle-demo/config/ui/Source.ts +0 -76
- package/dist/lib/application/files/gadmin2-game-angle-demo/config/ui/Tasklog.ts +0 -76
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/seed/roles.ts +0 -4
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/craco.config.js +0 -27
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/public/index.html +0 -53
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/components/layout/styles.ts +0 -10
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/helpers/utils.ts +0 -76
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/react-app-env.d.ts +0 -1
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/reportWebVitals.ts +0 -15
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/styles/antd.less +0 -79
- /package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/components/VanillaJSONEditor/{index.js → index.jsx} +0 -0
|
@@ -0,0 +1,419 @@
|
|
|
1
|
+
import React, { useState } from "react";
|
|
2
|
+
import { Modal, Button, Typography, message, Tooltip } from "antd";
|
|
3
|
+
import { CopyOutlined, CheckOutlined } from "@ant-design/icons";
|
|
4
|
+
|
|
5
|
+
const { Text } = Typography;
|
|
6
|
+
|
|
7
|
+
interface SqlModalProps {
|
|
8
|
+
open: boolean;
|
|
9
|
+
onClose: () => void;
|
|
10
|
+
title: string;
|
|
11
|
+
sql: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export const SqlModal: React.FC<SqlModalProps> = ({ open, onClose, title, sql }) => {
|
|
15
|
+
const [copied, setCopied] = useState(false);
|
|
16
|
+
|
|
17
|
+
const handleCopy = () => {
|
|
18
|
+
navigator.clipboard.writeText(sql).then(() => {
|
|
19
|
+
setCopied(true);
|
|
20
|
+
message.success("SQL copied to clipboard");
|
|
21
|
+
setTimeout(() => setCopied(false), 2000);
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
<Modal
|
|
27
|
+
title={title}
|
|
28
|
+
open={open}
|
|
29
|
+
onCancel={onClose}
|
|
30
|
+
width={720}
|
|
31
|
+
footer={[
|
|
32
|
+
<Tooltip key="copy" title={copied ? "Copied!" : "Copy SQL"}>
|
|
33
|
+
<Button
|
|
34
|
+
icon={copied ? <CheckOutlined /> : <CopyOutlined />}
|
|
35
|
+
type="primary"
|
|
36
|
+
onClick={handleCopy}
|
|
37
|
+
>
|
|
38
|
+
{copied ? "Copied!" : "Copy SQL"}
|
|
39
|
+
</Button>
|
|
40
|
+
</Tooltip>,
|
|
41
|
+
<Button key="close" onClick={onClose}>
|
|
42
|
+
Close
|
|
43
|
+
</Button>,
|
|
44
|
+
]}
|
|
45
|
+
>
|
|
46
|
+
<pre
|
|
47
|
+
style={{
|
|
48
|
+
background: "#1e1e1e",
|
|
49
|
+
color: "#d4d4d4",
|
|
50
|
+
padding: "16px",
|
|
51
|
+
borderRadius: "6px",
|
|
52
|
+
overflowX: "auto",
|
|
53
|
+
overflowY: "auto",
|
|
54
|
+
maxHeight: "500px",
|
|
55
|
+
fontSize: "12px",
|
|
56
|
+
lineHeight: "1.6",
|
|
57
|
+
whiteSpace: "pre-wrap",
|
|
58
|
+
wordBreak: "break-word",
|
|
59
|
+
fontFamily: "'Fira Code', 'Cascadia Code', 'Consolas', 'Monaco', monospace",
|
|
60
|
+
}}
|
|
61
|
+
>
|
|
62
|
+
<Text
|
|
63
|
+
style={{
|
|
64
|
+
color: "inherit",
|
|
65
|
+
fontSize: "inherit",
|
|
66
|
+
fontFamily: "inherit",
|
|
67
|
+
}}
|
|
68
|
+
>
|
|
69
|
+
{sql}
|
|
70
|
+
</Text>
|
|
71
|
+
</pre>
|
|
72
|
+
</Modal>
|
|
73
|
+
);
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
// ─── SQL Generators ────────────────────────────────────────────────────────────
|
|
77
|
+
|
|
78
|
+
function escapeStr(val: string | null | undefined): string {
|
|
79
|
+
if (val == null) return "NULL";
|
|
80
|
+
return `'${String(val).replace(/'/g, "''")}'`;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function jsonArr(val: string | null | undefined): string {
|
|
84
|
+
// roles is stored as a JSON-encoded array string in the DB, e.g. '["GUEST","PRODUCT"]'
|
|
85
|
+
if (val == null) return "'{}'";
|
|
86
|
+
return `'${String(val).replace(/'/g, "''")}'`;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Generate an INSERT for t_admin_audit_log.
|
|
91
|
+
* authorId / authorName come from the currently logged-in user passed by the caller.
|
|
92
|
+
*/
|
|
93
|
+
function auditInsert(opts: {
|
|
94
|
+
action: string;
|
|
95
|
+
resource: string;
|
|
96
|
+
resourceId: string;
|
|
97
|
+
data: string; // JSON string of the record
|
|
98
|
+
creator?: string | null;
|
|
99
|
+
authorId?: string | null;
|
|
100
|
+
authorName?: string | null;
|
|
101
|
+
}): string {
|
|
102
|
+
const dataJson = escapeStr(opts.data);
|
|
103
|
+
const authorId = opts.authorId ?? "<author_id>";
|
|
104
|
+
const authorName = opts.authorName ?? "<author_name>";
|
|
105
|
+
return `INSERT INTO public.t_admin_audit_log (creator, "authorId", "authorName", action, resource, "resourceId", data, "previousData")
|
|
106
|
+
VALUES (
|
|
107
|
+
${escapeStr(authorId)},
|
|
108
|
+
${escapeStr(authorId)},
|
|
109
|
+
${escapeStr(authorName)},
|
|
110
|
+
${escapeStr(opts.action)},
|
|
111
|
+
${escapeStr(opts.resource)},
|
|
112
|
+
${escapeStr(opts.resourceId)},
|
|
113
|
+
${dataJson},
|
|
114
|
+
NULL
|
|
115
|
+
);`;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Generate INSERT SQL for a User record.
|
|
120
|
+
* Table: t_admin_user_role
|
|
121
|
+
*/
|
|
122
|
+
export function generateUserSql(user: {
|
|
123
|
+
userid: string;
|
|
124
|
+
username?: string | null;
|
|
125
|
+
roles?: string | null;
|
|
126
|
+
isApiKey?: boolean;
|
|
127
|
+
apiKey?: string | null;
|
|
128
|
+
description?: string | null;
|
|
129
|
+
isActive?: boolean;
|
|
130
|
+
creator?: string | null;
|
|
131
|
+
}, operator?: { authorId?: string | null; authorName?: string | null }): string {
|
|
132
|
+
const rolesValue = user.roles ?? "[]";
|
|
133
|
+
const isApiKey = user.isApiKey ? "true" : "false";
|
|
134
|
+
const isActive = user.isActive !== false ? "true" : "false";
|
|
135
|
+
|
|
136
|
+
const userDataJson = JSON.stringify({
|
|
137
|
+
userid: user.userid,
|
|
138
|
+
username: user.username ?? null,
|
|
139
|
+
roles: rolesValue,
|
|
140
|
+
isApiKey: user.isApiKey ?? false,
|
|
141
|
+
description: user.description ?? null,
|
|
142
|
+
isActive: user.isActive !== false,
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
const mainSql = `-- Insert User: ${user.userid}
|
|
146
|
+
INSERT INTO public.t_admin_user_role (userid, username, roles, "isApiKey", "apiKey", description, "isActive", creator, "createdAt", "updatedAt")
|
|
147
|
+
VALUES (
|
|
148
|
+
${escapeStr(user.userid)},
|
|
149
|
+
${escapeStr(user.username)},
|
|
150
|
+
${jsonArr(rolesValue)},
|
|
151
|
+
${isApiKey},
|
|
152
|
+
${user.apiKey ? escapeStr(user.apiKey) : "NULL"},
|
|
153
|
+
${escapeStr(user.description)},
|
|
154
|
+
${isActive},
|
|
155
|
+
${escapeStr(user.creator)},
|
|
156
|
+
NOW(),
|
|
157
|
+
NOW()
|
|
158
|
+
)
|
|
159
|
+
ON CONFLICT (userid) DO UPDATE SET
|
|
160
|
+
username = EXCLUDED.username,
|
|
161
|
+
roles = EXCLUDED.roles,
|
|
162
|
+
"isApiKey" = EXCLUDED."isApiKey",
|
|
163
|
+
"apiKey" = EXCLUDED."apiKey",
|
|
164
|
+
description = EXCLUDED.description,
|
|
165
|
+
"isActive" = EXCLUDED."isActive",
|
|
166
|
+
"updatedAt" = NOW();`;
|
|
167
|
+
|
|
168
|
+
return [
|
|
169
|
+
mainSql,
|
|
170
|
+
"",
|
|
171
|
+
auditInsert({ action: "create", resource: "user", resourceId: user.userid, data: userDataJson, creator: user.creator, ...operator }),
|
|
172
|
+
].join("\n");
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Generate INSERT SQL for a Resource record.
|
|
177
|
+
* Table: t_resource
|
|
178
|
+
*/
|
|
179
|
+
export function generateResourceSql(resource: {
|
|
180
|
+
code: string;
|
|
181
|
+
name: string;
|
|
182
|
+
description?: string | null;
|
|
183
|
+
isCommonResource?: boolean;
|
|
184
|
+
creator?: string | null;
|
|
185
|
+
}, operator?: { authorId?: string | null; authorName?: string | null }): string {
|
|
186
|
+
const isCommon = resource.isCommonResource ? "true" : "false";
|
|
187
|
+
|
|
188
|
+
const resourceDataJson = JSON.stringify({
|
|
189
|
+
code: resource.code,
|
|
190
|
+
name: resource.name,
|
|
191
|
+
description: resource.description ?? null,
|
|
192
|
+
isCommonResource: resource.isCommonResource ?? false,
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
const mainSql = `-- Insert Resource: ${resource.code}
|
|
196
|
+
INSERT INTO public.t_resource (code, name, description, is_common_resource, creator, "createdAt", "updatedAt")
|
|
197
|
+
VALUES (
|
|
198
|
+
${escapeStr(resource.code)},
|
|
199
|
+
${escapeStr(resource.name)},
|
|
200
|
+
${escapeStr(resource.description)},
|
|
201
|
+
${isCommon},
|
|
202
|
+
${escapeStr(resource.creator)},
|
|
203
|
+
NOW(),
|
|
204
|
+
NOW()
|
|
205
|
+
)
|
|
206
|
+
ON CONFLICT (code) DO UPDATE SET
|
|
207
|
+
name = EXCLUDED.name,
|
|
208
|
+
description = EXCLUDED.description,
|
|
209
|
+
is_common_resource = EXCLUDED.is_common_resource,
|
|
210
|
+
"updatedAt" = NOW();`;
|
|
211
|
+
|
|
212
|
+
return [
|
|
213
|
+
mainSql,
|
|
214
|
+
"",
|
|
215
|
+
auditInsert({ action: "create", resource: "resource", resourceId: resource.code, data: resourceDataJson, creator: resource.creator, ...operator }),
|
|
216
|
+
].join("\n");
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* Generate INSERT SQL for a Role record, including its page assignments and
|
|
221
|
+
* the resulting role_resource entries.
|
|
222
|
+
*
|
|
223
|
+
* rolePages: list of { pageId, pageName }
|
|
224
|
+
* roleResources: list of { resourceCode, resourceName, actions: string[] }
|
|
225
|
+
*/
|
|
226
|
+
export function generateRoleSql(
|
|
227
|
+
role: {
|
|
228
|
+
name: string;
|
|
229
|
+
description?: string | null;
|
|
230
|
+
creator?: string | null;
|
|
231
|
+
},
|
|
232
|
+
rolePages: Array<{ pageId: number; pageName: string; pageCode: string }>,
|
|
233
|
+
roleResources: Array<{ resourceCode: string; resourceName: string; actions: string[] }>,
|
|
234
|
+
operator?: { authorId?: string | null; authorName?: string | null },
|
|
235
|
+
): string {
|
|
236
|
+
const lines: string[] = [];
|
|
237
|
+
|
|
238
|
+
// 1. Role
|
|
239
|
+
lines.push(`-- ════════════════════════════════════════════════════════`);
|
|
240
|
+
lines.push(`-- Role: ${role.name}`);
|
|
241
|
+
lines.push(`-- ════════════════════════════════════════════════════════`);
|
|
242
|
+
lines.push(`INSERT INTO public.t_role (name, description, creator, "createdAt", "updatedAt")`);
|
|
243
|
+
lines.push(`VALUES (`);
|
|
244
|
+
lines.push(` ${escapeStr(role.name)},`);
|
|
245
|
+
lines.push(` ${escapeStr(role.description)},`);
|
|
246
|
+
lines.push(` ${escapeStr(role.creator)},`);
|
|
247
|
+
lines.push(` NOW(),`);
|
|
248
|
+
lines.push(` NOW()`);
|
|
249
|
+
lines.push(`)`);
|
|
250
|
+
lines.push(`ON CONFLICT (name) DO UPDATE SET`);
|
|
251
|
+
lines.push(` description = EXCLUDED.description,`);
|
|
252
|
+
lines.push(` "updatedAt" = NOW();`);
|
|
253
|
+
|
|
254
|
+
// 2. Role-page associations
|
|
255
|
+
if (rolePages.length > 0) {
|
|
256
|
+
lines.push(``);
|
|
257
|
+
lines.push(`-- Role-Page Associations for "${role.name}"`);
|
|
258
|
+
lines.push(`-- Pages: ${rolePages.map(p => p.pageName).join(", ")}`);
|
|
259
|
+
|
|
260
|
+
for (const rp of rolePages) {
|
|
261
|
+
lines.push(``);
|
|
262
|
+
lines.push(`INSERT INTO public.t_role_pages (role_id, page_id, "created_at", "updated_at")`);
|
|
263
|
+
lines.push(`SELECT r.id, p.id, NOW(), NOW()`);
|
|
264
|
+
lines.push(`FROM public.t_role r, public.t_page p`);
|
|
265
|
+
lines.push(`WHERE r.name = ${escapeStr(role.name)}`);
|
|
266
|
+
lines.push(` AND p.code = ${escapeStr(rp.pageCode)} -- ${rp.pageName}`);
|
|
267
|
+
lines.push(`ON CONFLICT (role_id, page_id) DO NOTHING;`);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
// 3. Role-resource associations
|
|
272
|
+
if (roleResources.length > 0) {
|
|
273
|
+
lines.push(``);
|
|
274
|
+
lines.push(`-- Role-Resource Permissions for "${role.name}"`);
|
|
275
|
+
|
|
276
|
+
for (const rr of roleResources) {
|
|
277
|
+
const actionsJson = JSON.stringify(rr.actions);
|
|
278
|
+
lines.push(``);
|
|
279
|
+
lines.push(`INSERT INTO public.t_role_resource (role_id, resource_id, actions, "created_at", "updated_at")`);
|
|
280
|
+
lines.push(`SELECT r.id, res.id, '${actionsJson}'::jsonb, NOW(), NOW()`);
|
|
281
|
+
lines.push(`FROM public.t_role r, public.t_resource res`);
|
|
282
|
+
lines.push(`WHERE r.name = ${escapeStr(role.name)}`);
|
|
283
|
+
lines.push(` AND res.code = ${escapeStr(rr.resourceCode)} -- ${rr.resourceName}`);
|
|
284
|
+
lines.push(`ON CONFLICT (role_id, resource_id) DO UPDATE SET`);
|
|
285
|
+
lines.push(` actions = EXCLUDED.actions,`);
|
|
286
|
+
lines.push(` "updated_at" = NOW();`);
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
// 4. Audit log
|
|
291
|
+
const roleDataJson = JSON.stringify({
|
|
292
|
+
name: role.name,
|
|
293
|
+
description: role.description ?? null,
|
|
294
|
+
});
|
|
295
|
+
lines.push(``);
|
|
296
|
+
lines.push(auditInsert({ action: "create", resource: "role", resourceId: role.name, data: roleDataJson, creator: role.creator, ...operator }));
|
|
297
|
+
|
|
298
|
+
return lines.join("\n");
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
/**
|
|
302
|
+
* Generate INSERT SQL for a Page and (optionally) its children.
|
|
303
|
+
*
|
|
304
|
+
* When called on a parent page, pass all child pages in `children`.
|
|
305
|
+
* Each page includes its pageResources (resource assignments).
|
|
306
|
+
*
|
|
307
|
+
* pageResources: list of { resourceCode, resourceName, actions }
|
|
308
|
+
*/
|
|
309
|
+
export function generatePageSql(
|
|
310
|
+
page: {
|
|
311
|
+
id: number;
|
|
312
|
+
code: string;
|
|
313
|
+
name: string;
|
|
314
|
+
path?: string | null;
|
|
315
|
+
description?: string | null;
|
|
316
|
+
zhName?: string | null;
|
|
317
|
+
enName?: string | null;
|
|
318
|
+
sortOrder?: number | null;
|
|
319
|
+
parentId?: number | null;
|
|
320
|
+
/** code of the parent page — used to generate a portable subquery instead of a raw numeric ID */
|
|
321
|
+
parentCode?: string | null;
|
|
322
|
+
isVirtual?: boolean;
|
|
323
|
+
creator?: string | null;
|
|
324
|
+
},
|
|
325
|
+
pageResources: Array<{ resourceCode: string; resourceName: string; actions: string[] }>,
|
|
326
|
+
children: Array<{
|
|
327
|
+
page: typeof page;
|
|
328
|
+
pageResources: Array<{ resourceCode: string; resourceName: string; actions: string[] }>;
|
|
329
|
+
}>,
|
|
330
|
+
operator?: { authorId?: string | null; authorName?: string | null },
|
|
331
|
+
): string {
|
|
332
|
+
const lines: string[] = [];
|
|
333
|
+
|
|
334
|
+
const renderPageInsert = (
|
|
335
|
+
p: typeof page,
|
|
336
|
+
res: Array<{ resourceCode: string; resourceName: string; actions: string[] }>,
|
|
337
|
+
parentRef: string | null,
|
|
338
|
+
) => {
|
|
339
|
+
lines.push(`-- ────────────────────────────────────────────────────────`);
|
|
340
|
+
lines.push(`-- Page: ${p.name} (code: ${p.code})`);
|
|
341
|
+
lines.push(`-- ────────────────────────────────────────────────────────`);
|
|
342
|
+
lines.push(`INSERT INTO public.t_page (`);
|
|
343
|
+
lines.push(` code, name, path, description, zh_name, en_name, sort_order, parent_id, "isVirtual", creator, created_at, updated_at`);
|
|
344
|
+
lines.push(`)`);
|
|
345
|
+
lines.push(`VALUES (`);
|
|
346
|
+
lines.push(` ${escapeStr(p.code)},`);
|
|
347
|
+
lines.push(` ${escapeStr(p.name)},`);
|
|
348
|
+
lines.push(` ${escapeStr(p.path)},`);
|
|
349
|
+
lines.push(` ${escapeStr(p.description)},`);
|
|
350
|
+
lines.push(` ${escapeStr(p.zhName)},`);
|
|
351
|
+
lines.push(` ${escapeStr(p.enName)},`);
|
|
352
|
+
lines.push(` ${p.sortOrder != null ? p.sortOrder : "NULL"},`);
|
|
353
|
+
if (parentRef) {
|
|
354
|
+
lines.push(` (${parentRef}), -- parent_id resolved by code`);
|
|
355
|
+
} else {
|
|
356
|
+
lines.push(` NULL,`);
|
|
357
|
+
}
|
|
358
|
+
lines.push(` ${p.isVirtual ? "true" : "false"},`);
|
|
359
|
+
lines.push(` ${escapeStr(p.creator)},`);
|
|
360
|
+
lines.push(` NOW(),`);
|
|
361
|
+
lines.push(` NOW()`);
|
|
362
|
+
lines.push(`)`);
|
|
363
|
+
lines.push(`ON CONFLICT (code) DO UPDATE SET`);
|
|
364
|
+
lines.push(` name = EXCLUDED.name,`);
|
|
365
|
+
lines.push(` path = EXCLUDED.path,`);
|
|
366
|
+
lines.push(` description = EXCLUDED.description,`);
|
|
367
|
+
lines.push(` zh_name = EXCLUDED.zh_name,`);
|
|
368
|
+
lines.push(` en_name = EXCLUDED.en_name,`);
|
|
369
|
+
lines.push(` sort_order = EXCLUDED.sort_order,`);
|
|
370
|
+
lines.push(` parent_id = EXCLUDED.parent_id,`);
|
|
371
|
+
lines.push(` updated_at = NOW();`);
|
|
372
|
+
|
|
373
|
+
if (res.length > 0) {
|
|
374
|
+
lines.push(``);
|
|
375
|
+
lines.push(`-- Page-Resource Associations for "${p.name}"`);
|
|
376
|
+
for (const pr of res) {
|
|
377
|
+
const actionsJson = JSON.stringify(pr.actions);
|
|
378
|
+
lines.push(``);
|
|
379
|
+
lines.push(`INSERT INTO public.t_page_resource (page_id, resource_id, actions, "created_at", "updated_at")`);
|
|
380
|
+
lines.push(`SELECT pg.id, res.id, '${actionsJson}'::jsonb, NOW(), NOW()`);
|
|
381
|
+
lines.push(`FROM public.t_page pg, public.t_resource res`);
|
|
382
|
+
lines.push(`WHERE pg.code = ${escapeStr(p.code)}`);
|
|
383
|
+
lines.push(` AND res.code = ${escapeStr(pr.resourceCode)} -- ${pr.resourceName}`);
|
|
384
|
+
lines.push(`ON CONFLICT (page_id, resource_id) DO UPDATE SET`);
|
|
385
|
+
lines.push(` actions = EXCLUDED.actions,`);
|
|
386
|
+
lines.push(` "updated_at" = NOW();`);
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
// Audit log for this page
|
|
391
|
+
const pageDataJson = JSON.stringify({
|
|
392
|
+
code: p.code,
|
|
393
|
+
name: p.name,
|
|
394
|
+
path: p.path ?? null,
|
|
395
|
+
description: p.description ?? null,
|
|
396
|
+
zhName: p.zhName ?? null,
|
|
397
|
+
enName: p.enName ?? null,
|
|
398
|
+
sortOrder: p.sortOrder ?? null,
|
|
399
|
+
isVirtual: p.isVirtual ?? false,
|
|
400
|
+
});
|
|
401
|
+
lines.push(``);
|
|
402
|
+
lines.push(auditInsert({ action: "create", resource: "page", resourceId: p.code, data: pageDataJson, creator: p.creator, ...operator }));
|
|
403
|
+
};
|
|
404
|
+
|
|
405
|
+
// Parent page — if it has a parentCode, resolve parent_id dynamically by code
|
|
406
|
+
const rootParentRef = page.parentCode
|
|
407
|
+
? `SELECT id FROM public.t_page WHERE code = ${escapeStr(page.parentCode)}`
|
|
408
|
+
: null;
|
|
409
|
+
renderPageInsert(page, pageResources, rootParentRef);
|
|
410
|
+
|
|
411
|
+
// Children
|
|
412
|
+
for (const child of children) {
|
|
413
|
+
lines.push(``);
|
|
414
|
+
const parentRef = `SELECT id FROM public.t_page WHERE code = ${escapeStr(page.code)}`;
|
|
415
|
+
renderPageInsert(child.page, child.pageResources, parentRef);
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
return lines.join("\n");
|
|
419
|
+
}
|
|
@@ -1,60 +1,58 @@
|
|
|
1
1
|
import { RefineThemes } from "@refinedev/antd";
|
|
2
|
-
import { ConfigProvider
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
import { ConfigProvider } from "antd";
|
|
3
|
+
import type { ThemeConfig } from "antd";
|
|
4
|
+
import { PropsWithChildren } from "react";
|
|
5
|
+
|
|
6
|
+
const themeConfig: ThemeConfig = {
|
|
7
|
+
...RefineThemes.Blue,
|
|
8
|
+
token: {
|
|
9
|
+
...RefineThemes.Blue.token,
|
|
10
|
+
colorPrimary: "#1677FF",
|
|
11
|
+
colorError: "#fa541c",
|
|
12
|
+
colorPrimaryText: "rgba(0, 0, 0, 0.85)",
|
|
13
|
+
colorTextSecondary: "rgba(0, 0, 0, 0.65)",
|
|
14
|
+
colorTextTertiary: "rgba(0, 0, 0, 0.45)",
|
|
15
|
+
colorBgContainer: "#F7F8F9",
|
|
16
|
+
colorBgLayout: "#F0F2F5",
|
|
17
|
+
colorBorderBg: "#E8E9EA",
|
|
18
|
+
borderRadius: 6,
|
|
19
|
+
fontFamily:
|
|
20
|
+
"-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji'",
|
|
21
|
+
},
|
|
22
|
+
components: {
|
|
23
|
+
Typography: {
|
|
24
|
+
colorText: "rgba(0, 0, 0, 0.85)",
|
|
25
|
+
colorTextDescription: "rgba(0, 0, 0, 0.65)",
|
|
26
|
+
colorTextDisabled: "rgba(0, 0, 0, 0.45)",
|
|
27
|
+
},
|
|
28
|
+
Card: {
|
|
29
|
+
colorBgContainer: "#FFFFFF",
|
|
30
|
+
headerBg: "#FAFAFA",
|
|
31
|
+
},
|
|
32
|
+
Table: {
|
|
33
|
+
colorBgContainer: "#fff",
|
|
34
|
+
},
|
|
35
|
+
Input: {
|
|
36
|
+
colorBgContainer: "#fff",
|
|
37
|
+
},
|
|
38
|
+
InputNumber: {
|
|
39
|
+
colorBgContainer: "#fff",
|
|
40
|
+
},
|
|
41
|
+
Select: {
|
|
42
|
+
colorBgContainer: "#fff",
|
|
43
|
+
},
|
|
44
|
+
Form: {
|
|
45
|
+
labelFontSize: 14,
|
|
46
|
+
},
|
|
47
|
+
},
|
|
8
48
|
};
|
|
9
49
|
|
|
10
|
-
export const ColorModeContext = createContext<ColorModeContextType>(
|
|
11
|
-
{} as ColorModeContextType
|
|
12
|
-
);
|
|
13
|
-
|
|
14
50
|
export const ColorModeContextProvider: React.FC<PropsWithChildren> = ({
|
|
15
51
|
children,
|
|
16
52
|
}) => {
|
|
17
|
-
// 优先默认使用light模式
|
|
18
|
-
const colorModeFromLocalStorage = localStorage.getItem("colorMode") || "light";
|
|
19
|
-
const isSystemPreferenceDark = window?.matchMedia(
|
|
20
|
-
"(prefers-color-scheme: dark)"
|
|
21
|
-
).matches;
|
|
22
|
-
|
|
23
|
-
const systemPreference = isSystemPreferenceDark ? "dark" : "light";
|
|
24
|
-
const [mode, setMode] = useState(
|
|
25
|
-
colorModeFromLocalStorage || systemPreference
|
|
26
|
-
);
|
|
27
|
-
|
|
28
|
-
useEffect(() => {
|
|
29
|
-
window.localStorage.setItem("colorMode", mode);
|
|
30
|
-
}, [mode]);
|
|
31
|
-
|
|
32
|
-
const setColorMode = () => {
|
|
33
|
-
if (mode === "light") {
|
|
34
|
-
setMode("dark");
|
|
35
|
-
} else {
|
|
36
|
-
setMode("light");
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
const { darkAlgorithm, defaultAlgorithm } = theme;
|
|
41
|
-
|
|
42
53
|
return (
|
|
43
|
-
<
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
mode,
|
|
47
|
-
}}
|
|
48
|
-
>
|
|
49
|
-
<ConfigProvider
|
|
50
|
-
// you can change the theme colors here. example: ...RefineThemes.Magenta,
|
|
51
|
-
theme={{
|
|
52
|
-
...RefineThemes.Blue,
|
|
53
|
-
algorithm: mode === "light" ? defaultAlgorithm : darkAlgorithm,
|
|
54
|
-
}}
|
|
55
|
-
>
|
|
56
|
-
{children}
|
|
57
|
-
</ConfigProvider>
|
|
58
|
-
</ColorModeContext.Provider>
|
|
54
|
+
<ConfigProvider theme={themeConfig}>
|
|
55
|
+
{children}
|
|
56
|
+
</ConfigProvider>
|
|
59
57
|
);
|
|
60
58
|
};
|
package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/components/custom-avatar.tsx
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import React, { memo } from "react";
|
|
2
|
+
|
|
3
|
+
import type { AvatarProps } from "antd";
|
|
4
|
+
import { Avatar as AntdAvatar } from "antd";
|
|
5
|
+
|
|
6
|
+
import { getNameInitials, getRandomColorFromString } from "helpers";
|
|
7
|
+
|
|
8
|
+
type Props = AvatarProps & {
|
|
9
|
+
name?: string;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const CustomAvatarComponent: React.FC<Props> = ({ name = "", style, ...rest }) => {
|
|
13
|
+
return (
|
|
14
|
+
<AntdAvatar
|
|
15
|
+
alt={name}
|
|
16
|
+
size="small"
|
|
17
|
+
style={{
|
|
18
|
+
backgroundColor: rest?.src
|
|
19
|
+
? "transparent"
|
|
20
|
+
: getRandomColorFromString(name),
|
|
21
|
+
display: "flex",
|
|
22
|
+
alignItems: "center",
|
|
23
|
+
border: "none",
|
|
24
|
+
...style,
|
|
25
|
+
}}
|
|
26
|
+
{...rest}
|
|
27
|
+
>
|
|
28
|
+
{getNameInitials(name)}
|
|
29
|
+
</AntdAvatar>
|
|
30
|
+
);
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export const CustomAvatar = memo(
|
|
34
|
+
CustomAvatarComponent,
|
|
35
|
+
(prevProps, nextProps) => {
|
|
36
|
+
return prevProps.name === nextProps.name && prevProps.src === nextProps.src;
|
|
37
|
+
},
|
|
38
|
+
);
|
|
@@ -1,20 +1,18 @@
|
|
|
1
1
|
import { useGetLocale, useSetLocale, useGetIdentity } from "@refinedev/core";
|
|
2
2
|
import {
|
|
3
|
-
Layout
|
|
3
|
+
Layout,
|
|
4
4
|
Space,
|
|
5
5
|
Button,
|
|
6
6
|
Dropdown,
|
|
7
7
|
Avatar,
|
|
8
8
|
Typography,
|
|
9
9
|
theme,
|
|
10
|
-
Switch,
|
|
11
10
|
Select,
|
|
12
11
|
Tooltip,
|
|
13
12
|
} from "antd";
|
|
14
|
-
import
|
|
13
|
+
import { DownOutlined, RobotOutlined } from "@ant-design/icons";
|
|
15
14
|
import { useTranslation } from "react-i18next";
|
|
16
15
|
import { useContext } from "react";
|
|
17
|
-
import { ColorModeContext } from "components/contexts/color-mode";
|
|
18
16
|
import { BusinessContext } from "components/contexts/business";
|
|
19
17
|
import { useAgent } from "components/agentPanel";
|
|
20
18
|
import type { MenuProps } from "antd";
|
|
@@ -25,11 +23,10 @@ type IUser = {
|
|
|
25
23
|
avatar: string;
|
|
26
24
|
};
|
|
27
25
|
|
|
28
|
-
const { DownOutlined, RobotOutlined } = Icons;
|
|
29
26
|
const { Text } = Typography;
|
|
30
27
|
const { useToken } = theme;
|
|
31
28
|
|
|
32
|
-
const isDev =
|
|
29
|
+
const isDev = import.meta.env.DEV;
|
|
33
30
|
|
|
34
31
|
export const Header: React.FC = () => {
|
|
35
32
|
const { i18n } = useTranslation();
|
|
@@ -37,7 +34,6 @@ export const Header: React.FC = () => {
|
|
|
37
34
|
const changeLanguage = useSetLocale();
|
|
38
35
|
const { token } = useToken();
|
|
39
36
|
const { data: user } = useGetIdentity<IUser>();
|
|
40
|
-
const { mode, setMode } = useContext(ColorModeContext);
|
|
41
37
|
const { business, setBusiness, businessList } = useContext(BusinessContext);
|
|
42
38
|
const agent = useAgent();
|
|
43
39
|
const openAgentPanel = agent?.open;
|
|
@@ -58,17 +54,20 @@ export const Header: React.FC = () => {
|
|
|
58
54
|
onClick: ({ key: lang }) => changeLanguage(lang),
|
|
59
55
|
};
|
|
60
56
|
|
|
57
|
+
const headerStyles: React.CSSProperties = {
|
|
58
|
+
backgroundColor: token.colorBgElevated,
|
|
59
|
+
display: "flex",
|
|
60
|
+
justifyContent: "flex-end",
|
|
61
|
+
alignItems: "center",
|
|
62
|
+
padding: "0px 24px",
|
|
63
|
+
height: "64px",
|
|
64
|
+
position: "sticky",
|
|
65
|
+
top: 0,
|
|
66
|
+
zIndex: 999,
|
|
67
|
+
};
|
|
68
|
+
|
|
61
69
|
return (
|
|
62
|
-
<
|
|
63
|
-
style={{
|
|
64
|
-
backgroundColor: token.colorBgElevated,
|
|
65
|
-
display: "flex",
|
|
66
|
-
justifyContent: "flex-end",
|
|
67
|
-
alignItems: "center",
|
|
68
|
-
padding: "0px 24px",
|
|
69
|
-
height: "64px",
|
|
70
|
-
}}
|
|
71
|
-
>
|
|
70
|
+
<Layout.Header style={headerStyles}>
|
|
72
71
|
{isDev && (
|
|
73
72
|
<Tooltip title="AI Agent (Dev Only)">
|
|
74
73
|
<Button
|
|
@@ -83,7 +82,7 @@ export const Header: React.FC = () => {
|
|
|
83
82
|
showSearch
|
|
84
83
|
defaultValue={business.gameId}
|
|
85
84
|
style={{ width: 160 }}
|
|
86
|
-
|
|
85
|
+
variant="borderless"
|
|
87
86
|
options={[
|
|
88
87
|
...businessList.map((item) => ({
|
|
89
88
|
label: item.gameName,
|
|
@@ -94,7 +93,7 @@ export const Header: React.FC = () => {
|
|
|
94
93
|
options: [{ value: "-1", label: "All games" }],
|
|
95
94
|
},
|
|
96
95
|
]}
|
|
97
|
-
optionFilterProp="label"
|
|
96
|
+
optionFilterProp="label"
|
|
98
97
|
onChange={(gameId) => {
|
|
99
98
|
const gameInfo =
|
|
100
99
|
gameId === "-1"
|
|
@@ -113,18 +112,10 @@ export const Header: React.FC = () => {
|
|
|
113
112
|
</Space>
|
|
114
113
|
</Button>
|
|
115
114
|
</Dropdown>
|
|
116
|
-
<Space>
|
|
117
|
-
<
|
|
118
|
-
|
|
119
|
-
unCheckedChildren="🔆"
|
|
120
|
-
onChange={() => setMode(mode === "light" ? "dark" : "light")}
|
|
121
|
-
defaultChecked={mode === "dark"}
|
|
122
|
-
/>
|
|
123
|
-
<Space style={{ marginLeft: "8px" }} size="middle">
|
|
124
|
-
{user?.name && <Text strong>{user.name}</Text>}
|
|
125
|
-
{user?.avatar && <Avatar src={user?.avatar} alt={user?.name} />}
|
|
126
|
-
</Space>
|
|
115
|
+
<Space style={{ marginLeft: "8px" }} size="middle">
|
|
116
|
+
{user?.name && <Text strong>{user.name}</Text>}
|
|
117
|
+
{user?.avatar && <Avatar src={user?.avatar} alt={user?.name} />}
|
|
127
118
|
</Space>
|
|
128
|
-
</
|
|
119
|
+
</Layout.Header>
|
|
129
120
|
);
|
|
130
121
|
};
|