@quansitech/antd-admin 1.1.1 → 1.1.2

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.
Files changed (119) hide show
  1. package/dist/components/Column/Cascader.d.ts +3 -0
  2. package/dist/components/Column/Cascader.js +110 -0
  3. package/dist/components/Column/File.d.ts +18 -0
  4. package/dist/components/Column/File.js +176 -0
  5. package/dist/components/Column/Image.d.ts +10 -0
  6. package/dist/components/Column/Image.js +104 -0
  7. package/dist/components/Column/Readonly/Action/Link.d.ts +11 -0
  8. package/dist/components/Column/Readonly/Action/Link.js +114 -0
  9. package/dist/components/Column/Readonly/Action/index.d.ts +4 -0
  10. package/dist/components/Column/Readonly/Action/index.js +3 -0
  11. package/dist/components/Column/Readonly/Action.d.ts +12 -0
  12. package/dist/components/Column/Readonly/Action.js +96 -0
  13. package/dist/components/Column/Readonly/Cascader.d.ts +9 -0
  14. package/dist/components/Column/Readonly/Cascader.js +52 -0
  15. package/dist/components/Column/Readonly/File.d.ts +8 -0
  16. package/dist/components/Column/Readonly/File.js +54 -0
  17. package/dist/components/Column/Readonly/Image.d.ts +3 -0
  18. package/dist/components/Column/Readonly/Image.js +69 -0
  19. package/dist/components/Column/Readonly/Ueditor.d.ts +3 -0
  20. package/dist/components/Column/Readonly/Ueditor.js +24 -0
  21. package/dist/components/Column/Readonly/index.d.ts +8 -0
  22. package/dist/components/Column/Readonly/index.js +7 -0
  23. package/dist/components/Column/Ueditor.d.ts +27 -0
  24. package/dist/components/Column/Ueditor.js +333 -0
  25. package/dist/components/Column/index.d.ts +7 -0
  26. package/dist/components/Column/index.js +6 -0
  27. package/dist/components/Form/Action/Button.d.ts +15 -0
  28. package/dist/components/Form/Action/Button.js +194 -0
  29. package/dist/components/Form/Action/index.d.ts +4 -0
  30. package/dist/components/Form/Action/index.js +3 -0
  31. package/dist/components/Form/Actions.d.ts +6 -0
  32. package/dist/components/Form/Actions.js +48 -0
  33. package/dist/components/Form.d.ts +20 -0
  34. package/dist/components/Form.js +217 -0
  35. package/dist/components/FormContext.d.ts +7 -0
  36. package/dist/components/FormContext.js +2 -0
  37. package/dist/components/Layout/New.d.ts +7 -0
  38. package/dist/components/Layout/New.js +257 -0
  39. package/dist/components/Layout.d.ts +4 -0
  40. package/dist/components/Layout.js +67 -0
  41. package/dist/components/LayoutContext.d.ts +26 -0
  42. package/dist/components/LayoutContext.js +2 -0
  43. package/dist/components/ModalContext.d.ts +8 -0
  44. package/dist/components/ModalContext.js +6 -0
  45. package/dist/components/Table/Action/Button.d.ts +10 -0
  46. package/dist/components/Table/Action/Button.js +166 -0
  47. package/dist/components/Table/Action/StartEditable.d.ts +10 -0
  48. package/dist/components/Table/Action/StartEditable.js +79 -0
  49. package/dist/components/Table/Action/index.d.ts +5 -0
  50. package/dist/components/Table/Action/index.js +4 -0
  51. package/dist/components/Table/ToolbarActions.d.ts +6 -0
  52. package/dist/components/Table/ToolbarActions.js +52 -0
  53. package/dist/components/Table.d.ts +19 -0
  54. package/dist/components/Table.js +322 -0
  55. package/dist/components/TableContext.d.ts +14 -0
  56. package/dist/components/TableContext.js +2 -0
  57. package/dist/components/Tabs.d.ts +15 -0
  58. package/dist/components/Tabs.js +62 -0
  59. package/dist/env.d.ts +1 -0
  60. package/dist/global.d.ts +6 -0
  61. package/dist/index.d.ts +7 -0
  62. package/dist/index.js +7 -0
  63. package/dist/lib/container.d.ts +9 -0
  64. package/dist/lib/container.js +93 -0
  65. package/dist/lib/customRule.d.ts +3 -0
  66. package/dist/lib/customRule.js +7 -0
  67. package/dist/lib/global.d.ts +9 -0
  68. package/dist/lib/global.js +2 -0
  69. package/dist/lib/helpers.d.ts +14 -0
  70. package/dist/lib/helpers.js +183 -0
  71. package/dist/lib/http.d.ts +5 -0
  72. package/dist/lib/http.js +72 -0
  73. package/dist/lib/schemaHandler.d.ts +5 -0
  74. package/dist/lib/schemaHandler.js +133 -0
  75. package/dist/lib/upload.d.ts +20 -0
  76. package/dist/lib/upload.js +215 -0
  77. package/dist/lib/writeExtra.d.ts +1 -0
  78. package/dist/lib/writeExtra.js +28 -0
  79. package/dist/types.d.ts +25 -0
  80. package/package.json +13 -6
  81. package/components/Column/Cascader.tsx +0 -79
  82. package/components/Column/File.tsx +0 -166
  83. package/components/Column/Image.tsx +0 -77
  84. package/components/Column/Readonly/Action/Link.tsx +0 -78
  85. package/components/Column/Readonly/Action.tsx +0 -80
  86. package/components/Column/Readonly/Cascader.tsx +0 -51
  87. package/components/Column/Readonly/File.tsx +0 -53
  88. package/components/Column/Readonly/Image.tsx +0 -39
  89. package/components/Column/Readonly/Ueditor.tsx +0 -18
  90. package/components/Column/Ueditor.tsx +0 -314
  91. package/components/Form/Action/Button.tsx +0 -129
  92. package/components/Form/Actions.tsx +0 -39
  93. package/components/Form.tsx +0 -177
  94. package/components/FormContext.ts +0 -9
  95. package/components/Layout/New.tsx +0 -251
  96. package/components/Layout.tsx +0 -52
  97. package/components/LayoutContext.ts +0 -26
  98. package/components/ModalContext.ts +0 -16
  99. package/components/Table/Action/Button.tsx +0 -89
  100. package/components/Table/Action/StartEditable.tsx +0 -59
  101. package/components/Table/ToolbarActions.tsx +0 -44
  102. package/components/Table.tsx +0 -280
  103. package/components/TableContext.ts +0 -15
  104. package/components/Tabs.tsx +0 -72
  105. package/lib/container.ts +0 -84
  106. package/lib/customRule.ts +0 -10
  107. package/lib/global.ts +0 -11
  108. package/lib/helpers.tsx +0 -149
  109. package/lib/http.ts +0 -74
  110. package/lib/schemaHandler.ts +0 -122
  111. package/lib/upload.ts +0 -177
  112. package/lib/writeExtra.js +0 -31
  113. /package/{components → dist/components}/Column/Readonly/Action/types.d.ts +0 -0
  114. /package/{components → dist/components}/Column/Readonly/types.d.ts +0 -0
  115. /package/{components → dist/components}/Column/types.d.ts +0 -0
  116. /package/{components → dist/components}/Form/Action/types.d.ts +0 -0
  117. /package/{components → dist/components}/Table/Action/types.d.ts +0 -0
  118. /package/{components → dist/components}/Table.scss +0 -0
  119. /package/{components → dist/components}/types.d.ts +0 -0
@@ -1,129 +0,0 @@
1
- import {FormActionType} from "./types";
2
- import {Button, Popconfirm} from "antd";
3
- import {useContext, useEffect, useState} from "react";
4
- import http from "../../../lib/http";
5
- import {FormContext} from "../../FormContext";
6
- import {modalShow, replaceParams, replaceUrl, routerNavigateTo} from "../../../lib/helpers";
7
- import {ModalContext} from "../../ModalContext";
8
- import {TableContext} from "../../TableContext";
9
-
10
- export default function (props: FormActionType & {
11
- props: any,
12
-
13
- // 操作
14
- submit?: boolean | {
15
- confirm?: string
16
- },
17
- request?: RequestOptions,
18
- link?: {
19
- url: string,
20
- }
21
- back?: boolean,
22
- reset?: boolean,
23
- modal?: ModalOptions,
24
- }) {
25
-
26
- const [loading, setLoading] = useState(false)
27
- const formContext = useContext(FormContext)
28
- const tableContext = useContext(TableContext)
29
- const modalContext = useContext(ModalContext)
30
-
31
- const onClick = async () => {
32
- try {
33
- setLoading(true)
34
- const handleAfterAction = async (req?: RequestOptions) => {
35
- if (req?.afterAction?.includes('tableReload')) {
36
- if (modalContext.contexts) {
37
- modalContext.setAfterClose(() => {
38
- modalContext.contexts?.tableContext?.actionRef.reload()
39
- })
40
- }
41
- if (tableContext.actionRef) {
42
- await tableContext.actionRef.reload()
43
- }
44
- }
45
- if (req?.afterAction?.includes('closeModal') && modalContext.inModal) {
46
- modalContext.closeModal()
47
- }
48
- }
49
-
50
- if (props.submit) {
51
- formContext.formRef?.current?.submit()
52
- return
53
- }
54
- if (props.request) {
55
- await http({
56
- method: props.request.method,
57
- url: props.request.url,
58
- headers: props.request.headers || {},
59
- data: replaceParams(props.request.data || {}, {
60
- ...(await formContext.formRef?.current?.getFieldsValue()),
61
- })
62
- })
63
-
64
- await handleAfterAction(props.request)
65
- return
66
- }
67
- if (props.modal) {
68
- await modalShow({
69
- ...props.modal,
70
- content: {
71
- ...props.modal.content,
72
- url: replaceUrl(props.modal.content.url as string, formContext.formRef?.current?.getFieldsValue())
73
- }
74
- })
75
- return
76
- }
77
-
78
- if (props.link) {
79
- routerNavigateTo(replaceUrl(props.link.url, await formContext.formRef?.current?.getFieldsValue()))
80
- return
81
- }
82
- if (props.reset) {
83
- formContext.formRef?.current?.resetFields()
84
- return
85
- }
86
- if (props.back) {
87
- if (modalContext.inModal) {
88
- modalContext.closeModal()
89
- } else {
90
- history.back()
91
- }
92
- return
93
- }
94
- } finally {
95
- setLoading(false)
96
- }
97
- }
98
-
99
- useEffect(() => {
100
- if (props.submit) {
101
- setLoading(props.loading || false)
102
- }
103
- }, [props.loading]);
104
-
105
- const MyButton = ({onClick}: {
106
- onClick?: () => void,
107
- }) => {
108
-
109
- return <>
110
- <Button {...props.props}
111
- onClick={onClick}
112
- loading={loading}
113
- >{props.title}</Button>
114
- </>
115
- }
116
-
117
- const confirm = (typeof props.submit === 'object' ? props.submit.confirm : null)
118
- || props.request?.confirm
119
-
120
- return <>
121
- {
122
- confirm ?
123
- <Popconfirm title={confirm} onConfirm={onClick}>
124
- <MyButton></MyButton>
125
- </Popconfirm>
126
- : <MyButton onClick={onClick}></MyButton>
127
- }
128
- </>
129
- }
@@ -1,39 +0,0 @@
1
- import {FormActionType} from "./Action/types";
2
- import {lazy, useEffect, useState} from "react";
3
- import {ReactComponentLike} from "prop-types";
4
- import {Badge, Space} from "antd";
5
- import container from "../../lib/container";
6
- import {upperFirst} from "es-toolkit";
7
-
8
- export default function (props: {
9
- actions?: FormActionType[]
10
- loading?: boolean
11
- }) {
12
- const [components, setComponents] = useState<{
13
- Component: ReactComponentLike,
14
- props: FormActionType,
15
- }[]>([])
16
-
17
- useEffect(() => {
18
- setComponents(props.actions?.map(a => {
19
- return {
20
- Component: lazy(container.get('Form.Action.' + upperFirst(a.type))),
21
- props: {
22
- ...a,
23
- },
24
- }
25
- }) || [])
26
- }, []);
27
-
28
- return <>
29
- <Space>
30
- {components.map(item => (
31
- item.props.badge ?
32
- <Badge key={item.props.title} count={item.props.badge} style={{zIndex: 100}}>
33
- <item.Component loading={props.loading} {...item.props}></item.Component>
34
- </Badge> :
35
- <item.Component key={item.props.title} loading={props.loading} {...item.props}></item.Component>
36
- ))}
37
- </Space>
38
- </>
39
- }
@@ -1,177 +0,0 @@
1
- import {BetaSchemaForm, ProFormColumnsType, ProFormInstance, ProSkeleton} from "@ant-design/pro-components";
2
- import type {FormSchema} from "@ant-design/pro-form/es/components/SchemaForm/typing";
3
- import React, {lazy, Suspense, useContext, useEffect, useRef, useState} from "react";
4
- import {cloneDeep, upperFirst} from "es-toolkit";
5
- import container from "../lib/container";
6
- import {FormActionType} from "./Form/Action/types";
7
- import Actions from "./Form/Actions";
8
- import {FormContext} from "./FormContext";
9
- import {Col, Row, Spin} from "antd";
10
- import http from "../lib/http";
11
- import customRule from "../lib/customRule";
12
- import {ModalContext} from "./ModalContext";
13
- import {TableContext} from "./TableContext";
14
- import {commonHandler} from "../lib/schemaHandler";
15
- import {Rule} from "antd/es/form";
16
-
17
- type SubmitRequestType = {
18
- url: string,
19
- method?: string,
20
- data?: any,
21
- afterSubmit?: () => void,
22
- headers?: Record<string, string>
23
- afterAction?: string[],
24
- }
25
-
26
-
27
- export default function (props: FormSchema & {
28
- actions?: FormActionType[]
29
- metaTitle?: string,
30
- columns?: ProFormColumnsType[],
31
- submitRequest?: SubmitRequestType,
32
- extraRenderValues?: Record<string, any>,
33
- }) {
34
-
35
- const [columns, setColumns] = useState<ProFormColumnsType[]>([])
36
- const formRef = useRef<ProFormInstance>()
37
- const [initialized, setInitialized] = useState(false)
38
- const [loading, setLoading] = useState(false)
39
- const hiddenField = useRef<Record<string, any>>({})
40
-
41
- useEffect(() => {
42
- setColumns((cloneDeep(props.columns)?.map((c: ProFormColumnsType & {
43
- formItemProps?: {
44
- rules?: (Rule & {
45
- customType?: string
46
- })[]
47
- }
48
- }) => {
49
- // rules
50
- if (!c.formItemProps) {
51
- c.formItemProps = {}
52
- }
53
- if (!c.formItemProps?.rules) {
54
- c.formItemProps.rules = []
55
- }
56
- c.formItemProps.rules = c.formItemProps.rules.map(rule => {
57
- if (rule.customType && customRule[rule.customType]) {
58
- rule.validator = customRule[rule.customType]
59
- }
60
- return rule
61
- })
62
-
63
- // hideInForm时增加
64
- if (c.hideInForm) {
65
- hiddenField.current[c.dataIndex as string] = props.initialValues?.[c.dataIndex as string]
66
- return null
67
- }
68
-
69
- // item render
70
- const formItemComponent = 'Column.' + upperFirst(c.valueType as string)
71
- if (container.check(formItemComponent)) {
72
- const Component = lazy(container.get(formItemComponent))
73
- c.renderFormItem = (schema, config, form) =>
74
- <Suspense fallback={<Spin/>}>
75
- <Component config={config}
76
- form={form}
77
- fieldProps={c.fieldProps}
78
- key={c.title as string}
79
- rules={c.formItemProps?.rules}
80
- dataIndex={c.dataIndex}
81
- ></Component>
82
- </Suspense>
83
- }
84
- // readonly render
85
- const readonlyComponent = 'Column.Readonly.' + upperFirst(c.valueType as string)
86
- if (container.check(readonlyComponent)) {
87
- const Component = lazy(container.get(readonlyComponent))
88
- c.render = (dom, entity, index, action, schema) =>
89
- <Suspense fallback={<Spin/>}>
90
- <Component key={c.title as string}
91
- entity={entity}
92
- index={index}
93
- action={action}
94
- schema={schema}
95
- dom={dom}
96
- ></Component>
97
- </Suspense>
98
- }
99
-
100
- commonHandler(c)
101
- if (container.schemaHandler[c.valueType as string]) {
102
- return container.schemaHandler[c.valueType as string](c)
103
- }
104
-
105
- return c
106
- }).filter(c => !!c) || []) as ProFormColumnsType[])
107
-
108
- setInitialized(true)
109
- }, []);
110
-
111
- const modalContext = useContext(ModalContext)
112
- const tableContext = useContext(TableContext)
113
-
114
- const handleAfterAction = async (req?: SubmitRequestType) => {
115
- if (req?.afterAction?.includes('tableReload')) {
116
- if (modalContext.contexts) {
117
- modalContext.setAfterClose(() => {
118
- modalContext.contexts?.tableContext?.actionRef.reload()
119
- })
120
- }
121
- if (tableContext.actionRef) {
122
- await tableContext.actionRef.reload()
123
- }
124
- }
125
- if (req?.afterAction?.includes('closeModal') && modalContext.inModal) {
126
- modalContext.closeModal()
127
- }
128
- }
129
-
130
- const onFinish = async (values: any) => {
131
- if (props.submitRequest) {
132
- setLoading(true)
133
- try {
134
- await http({
135
- method: props.submitRequest.method,
136
- url: props.submitRequest.url,
137
- data: Object.assign({}, hiddenField.current, props.submitRequest.data, values),
138
- headers: props.submitRequest.headers,
139
- })
140
-
141
- handleAfterAction(props.submitRequest)
142
- } finally {
143
- setLoading(false)
144
- }
145
- }
146
- }
147
-
148
- return <>
149
- <Row justify={'center'}>
150
- <Col sm={24} md={22} lg={20}>
151
- <FormContext.Provider value={{
152
- formRef: formRef,
153
- extraRenderValues: props.extraRenderValues,
154
- }}>
155
- {!initialized
156
- ? <ProSkeleton type={"list"} list={2}></ProSkeleton>
157
- : <BetaSchemaForm columns={columns}
158
- colProps={props.colProps}
159
- readonly={props.readonly}
160
- grid={true}
161
- loading={loading}
162
- formRef={formRef}
163
- initialValues={props.initialValues}
164
- onFinish={onFinish}
165
- submitter={{
166
- render: () => [
167
- <Actions key={'actions'} loading={loading}
168
- actions={props.actions}></Actions>
169
- ]
170
- }}
171
- ></BetaSchemaForm>
172
- }
173
- </FormContext.Provider>
174
- </Col>
175
- </Row>
176
- </>
177
- }
@@ -1,9 +0,0 @@
1
- import {ProFormInstance} from "@ant-design/pro-components";
2
- import {createContext, MutableRefObject} from "react";
3
-
4
- export type FormContextProps = {
5
- formRef?: MutableRefObject<ProFormInstance | undefined>,
6
- extraRenderValues?: Record<string, any>
7
- }
8
-
9
- export const FormContext = createContext<FormContextProps>({})
@@ -1,251 +0,0 @@
1
- import {MenuDataItem, PageContainer, ProConfigProvider, ProLayout} from "@ant-design/pro-components";
2
- import {Button, Dropdown, Menu, Space} from "antd";
3
- import type {LayoutProps} from "../LayoutContext";
4
- import {LayoutContext} from "../LayoutContext";
5
- import {useEffect, useRef, useState} from "react";
6
- import {usePage} from "@inertiajs/react";
7
- import {routerNavigateTo} from "../../lib/helpers";
8
- import {MenuInfo} from "rc-menu/lib/interface";
9
- import http from "../../lib/http";
10
- // @ts-ignore
11
- import {Route} from '@ant-design/pro-layout/lib/typing';
12
- import {MoonOutlined, SunOutlined} from "@ant-design/icons";
13
-
14
- export default function ({children, pageTitle, siteTitle}: {
15
- children: React.ReactNode,
16
- pageTitle: string,
17
- siteTitle: string,
18
- }) {
19
-
20
- const pageProps = usePage<{
21
- layoutProps: LayoutProps,
22
- }>().props
23
-
24
- const layoutProps = pageProps.layoutProps
25
- const contentRef = useRef<HTMLDivElement>(null)
26
-
27
- const [props, setProps] = useState<LayoutProps>({
28
- title: '',
29
- metaTitle: '',
30
- topMenuActiveKey: '',
31
- menuActiveKey: '',
32
- loading: false,
33
- topMenu: [],
34
- menuList: [],
35
- logo: '',
36
- userMenu: [],
37
- })
38
- const [theme, setTheme] = useState<'light' | 'realDark'>('light')
39
-
40
- const assignProps = (newProps: LayoutProps) => {
41
- setProps(Object.assign(props, newProps))
42
- }
43
-
44
- const headerContentRender = () => {
45
- return <>
46
- <Menu items={props.topMenu}
47
- mode={'horizontal'}
48
- activeKey={props.topMenuActiveKey}
49
- />
50
- </>
51
- }
52
-
53
- const [openKeys, setOpenKeys] = useState<string[]>([])
54
- const [route, setRoute] = useState<Route>()
55
-
56
- useEffect(() => {
57
- function findKeyPath(key: string, list: MenuDataItem[]): string[] {
58
- for (let i = 0; i < list.length; i++) {
59
- const item = list[i];
60
- if (item.key === key) {
61
- return [item.key]
62
- } else if (item.children?.length) {
63
- const path = findKeyPath(key, item.children)
64
- if (path?.length) {
65
- return [item.key as string, ...path]
66
- }
67
- }
68
- }
69
- return []
70
- }
71
-
72
- if (!props.menuActiveKey) {
73
- return
74
- }
75
- setOpenKeys(findKeyPath(props.menuActiveKey, props.menuList || []))
76
-
77
- }, [props.menuActiveKey]);
78
-
79
- useEffect(() => {
80
- if (pageProps.layoutProps?.menuActiveKey) {
81
- assignProps({
82
- menuActiveKey: pageProps.layoutProps.menuActiveKey
83
- })
84
- }
85
-
86
- const title = props.title || layoutProps.title
87
- if (pageProps.layoutProps?.metaTitle) {
88
- assignProps({
89
- metaTitle: pageProps.layoutProps.metaTitle + ' | ' + title
90
- })
91
- } else {
92
- assignProps({
93
- metaTitle: title
94
- })
95
- }
96
- }, [pageProps.layoutProps]);
97
-
98
-
99
- useEffect(() => {
100
-
101
- setProps({
102
- title: layoutProps.title || '',
103
- metaTitle: '',
104
- topMenuActiveKey: layoutProps.topMenuActiveKey,
105
- menuActiveKey: layoutProps.menuActiveKey,
106
- loading: false,
107
- topMenu: layoutProps.topMenu,
108
- menuList: layoutProps.menuList,
109
- logo: layoutProps.logo,
110
- userMenu: layoutProps.userMenu,
111
- })
112
-
113
- const r = {
114
- key: '/',
115
- routes: layoutProps.menuList?.map(menu => {
116
- return {
117
- name: menu.name,
118
- key: menu.key,
119
- children: menu.children?.map(child => {
120
- return {
121
- name: child.name,
122
- key: child.key
123
- }
124
- })
125
- }
126
- })
127
- }
128
-
129
- setRoute(r)
130
-
131
- // 设置内容高度
132
- function onResize() {
133
- if (contentRef.current) {
134
- contentRef.current.style.minHeight = Math.max(window.innerHeight - 200, 200) + 'px'
135
- }
136
- }
137
-
138
- onResize()
139
- window.addEventListener('resize', onResize)
140
- return () => {
141
- window.removeEventListener('resize', onResize)
142
- }
143
-
144
- }, [])
145
-
146
-
147
- const onMenuClick = (info: MenuInfo) => {
148
- const keyPath = info.keyPath.reverse()
149
- let menu: MenuDataItem | undefined = props.menuList?.find(menu => menu.key === keyPath[0]);
150
- for (let i = 1; i < keyPath.length; i++) {
151
- menu = menu?.children?.find(m => m.key === keyPath[i])
152
- }
153
- if (menu?.path) {
154
- assignProps({
155
- loading: true
156
- })
157
- routerNavigateTo(menu.path, {
158
- onSuccess() {
159
- assignProps({
160
- menuActiveKey: info.key
161
- })
162
- },
163
- onFinish() {
164
- assignProps({
165
- loading: false
166
- })
167
- }
168
- })
169
- }
170
- }
171
-
172
- const actionsRender = () => <>
173
- <Space>
174
- <Button type={'text'} onClick={() => {
175
- setTheme(theme === 'light' ? 'realDark' : 'light')
176
- }}>
177
- {theme === 'realDark' ? <MoonOutlined/> : <SunOutlined/>}
178
- </Button>
179
- </Space>
180
- </>
181
-
182
- return <>
183
- <LayoutContext.Provider value={{
184
- assignProps,
185
- props,
186
- }}>
187
- <ProConfigProvider dark={theme === 'realDark'}>
188
- <ProLayout title={siteTitle}
189
- loading={props.loading}
190
- layout="mix"
191
- actionsRender={actionsRender}
192
- route={route}
193
- fixSiderbar={true}
194
- logo={props.logo}
195
- headerContentRender={headerContentRender}
196
- pageTitleRender={p => `${pageTitle} | ${siteTitle} 后台管理`}
197
- footerRender={() => <>
198
- <Space>
199
- <a href="https://www.quansitech.com/" target={'_blank'}>全思科技</a>
200
- <a href="https://github.com/quansitech/" target={'_blank'}>Github</a>
201
- </Space>
202
- </>}
203
- avatarProps={{
204
- title: 'admin',
205
- render(p, dom) {
206
- return <>
207
- <Dropdown menu={{
208
- items: props.userMenu?.map(menu => {
209
- return {
210
- label: menu.title,
211
- key: menu.url,
212
- onClick() {
213
- switch (menu.type) {
214
- case 'open':
215
- window.open(menu.url)
216
- break;
217
- case 'nav':
218
- routerNavigateTo(menu.url)
219
- break
220
- case 'ajax':
221
- http.get(menu.url).then(() => {
222
- window.location.reload()
223
- })
224
- break
225
- }
226
- }
227
- }
228
- }) || [],
229
- }}>
230
- {dom}
231
- </Dropdown>
232
- </>
233
- }
234
- }}
235
- menuProps={{
236
- activeKey: props.menuActiveKey as string,
237
- selectedKeys: [props.menuActiveKey as string],
238
- openKeys: openKeys,
239
- onClick: onMenuClick,
240
- onOpenChange: setOpenKeys
241
- }}
242
- >
243
-
244
- <PageContainer title={pageTitle}>
245
- <div ref={contentRef}>{children}</div>
246
- </PageContainer>
247
- </ProLayout>
248
- </ProConfigProvider>
249
- </LayoutContext.Provider>
250
- </>
251
- }
@@ -1,52 +0,0 @@
1
- import {Head, usePage} from "@inertiajs/react";
2
- import {useEffect, useState} from "react";
3
- import {PageProps} from "@inertiajs/core/types/types";
4
- import New from "./Layout/New";
5
- import {PageContainer} from "@ant-design/pro-components"
6
- import {App} from "antd";
7
- import global from "../lib/global";
8
-
9
- export default function ({children}: {
10
- children: React.ReactNode
11
- }) {
12
- const pageProps: PageProps & {
13
- layoutProps?: {
14
- metaTitle?: string,
15
- enableNewLayout?: boolean
16
- title?: string,
17
- }
18
- } = usePage().props
19
- const {modal, notification, message} = App.useApp()
20
- const [enableNewLayout, setEnableNewLayout] = useState(false)
21
- const [pageTitle, setPageTitle] = useState('')
22
- const [siteTitle, setSiteTitle] = useState('')
23
-
24
- useEffect(() => {
25
- console.log(pageProps)
26
-
27
- if (pageProps.layoutProps?.enableNewLayout) {
28
- setEnableNewLayout(true)
29
- }
30
-
31
- global.modal = modal
32
- global.notification = notification
33
- global.message = message
34
- }, [])
35
-
36
- useEffect(() => {
37
- setPageTitle(pageProps.layoutProps?.metaTitle || '')
38
- pageProps.layoutProps?.title && setSiteTitle(pageProps.layoutProps?.title + '')
39
- }, [pageProps.layoutProps]);
40
-
41
- return <>
42
- {enableNewLayout
43
- ? <New pageTitle={pageTitle} siteTitle={siteTitle} children={children}></New>
44
- : <>
45
- <Head title={pageTitle + ' | ' + siteTitle + ' 后台管理'}></Head>
46
- <PageContainer title={pageTitle}>
47
- {children}
48
- </PageContainer>
49
- </>
50
- }
51
- </>
52
- }
@@ -1,26 +0,0 @@
1
- import {createContext} from "react";
2
- import {MenuDataItem} from "@ant-design/pro-components";
3
-
4
- declare type LayoutContextValue = {
5
- assignProps: (props: LayoutProps) => void,
6
- props: LayoutProps,
7
- }
8
-
9
- export declare type LayoutProps = {
10
- title?: string,
11
- metaTitle?: string,
12
- topMenuActiveKey?: string,
13
- menuActiveKey?: string,
14
- loading?: boolean,
15
- topMenu?: { name: string, key: string }[],
16
- menuList?: MenuDataItem[],
17
- logo?: string,
18
- userMenu?: {
19
- title: string,
20
- url: string,
21
- type: string,
22
-
23
- }[]
24
- }
25
-
26
- export const LayoutContext = createContext<LayoutContextValue>({} as LayoutContextValue)