beer-assembly-biz 1.1.1-alpha.10 → 1.1.1-alpha.12

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.
@@ -0,0 +1,7 @@
1
+ import React, { FC } from 'react';
2
+ export declare type BackPageContainerProps = {
3
+ title?: string | undefined;
4
+ children?: React.ReactNode | undefined;
5
+ };
6
+ export declare const Component: FC<BackPageContainerProps>;
7
+ export default Component;
@@ -0,0 +1,33 @@
1
+ import React from 'react';
2
+ import { css } from '@emotion/css';
3
+ import { PageContainer } from '@ant-design/pro-components';
4
+ import { useNavigate } from 'react-router-dom';
5
+ export const Component = (props) => {
6
+ const navigate = useNavigate();
7
+ return React.createElement(React.Fragment, null,
8
+ React.createElement(PageContainer, { onBack: () => {
9
+ navigate(-1);
10
+ }, className: css `
11
+ .ant-page-header-heading {
12
+ padding-block-start: 0 !important;
13
+ }
14
+
15
+ .ant-page-header-heading-title {
16
+ font-size: 15px;
17
+ line-height: 1.5;
18
+ color: #333;
19
+ }
20
+ `, header: {
21
+ style: {
22
+ background: '#fff',
23
+ padding: '10px 24px 10px 24px',
24
+ borderBottom: '1px solid rgba(0, 0, 0, 0.06)'
25
+ }
26
+ }, title: props.title, ghost: true, childrenContentStyle: {
27
+ padding: '0'
28
+ } },
29
+ React.createElement("div", { className: css `
30
+ padding: 12px 16px;
31
+ ` }, props.children)));
32
+ };
33
+ export default Component;
@@ -0,0 +1,6 @@
1
+ import React, { FC } from 'react';
2
+ export declare type InlineContainer = {
3
+ children?: React.ReactNode;
4
+ };
5
+ export declare const Component: FC<InlineContainer>;
6
+ export default Component;
@@ -0,0 +1,28 @@
1
+ import React from 'react';
2
+ import { App, ConfigProvider } from 'antd';
3
+ export const Component = (props) => {
4
+ return React.createElement(App, null,
5
+ React.createElement(ConfigProvider, { theme: {
6
+ token: {
7
+ fontSize: 12,
8
+ controlHeight: 26,
9
+ fontWeightStrong: 500
10
+ },
11
+ components: {
12
+ Table: {
13
+ motion: false,
14
+ headerColor: '#333',
15
+ rowHoverBg: '#f5f6f7',
16
+ rowSelectedBg: '#f4f5f6',
17
+ rowSelectedHoverBg: '#e6e7e8',
18
+ headerBg: '#fafafa',
19
+ cellPaddingInlineSM: 6,
20
+ cellPaddingBlockSM: 7
21
+ },
22
+ Switch: {
23
+ fontSize: 10
24
+ }
25
+ }
26
+ } }, props?.children));
27
+ };
28
+ export default Component;
@@ -0,0 +1,16 @@
1
+ import React, { FC } from 'react';
2
+ import { TabPaneProps } from 'antd';
3
+ export interface Tab extends Omit<TabPaneProps, 'tab'> {
4
+ key: string;
5
+ label: React.ReactNode;
6
+ }
7
+ export declare type MyPageContainerProps = {
8
+ title?: string | undefined;
9
+ children?: React.ReactNode | undefined;
10
+ tabList?: Tab[];
11
+ onTabChange?: (e: string) => void;
12
+ onRefresh?: () => void;
13
+ banner?: React.ReactNode;
14
+ };
15
+ export declare const Component: FC<MyPageContainerProps>;
16
+ export default Component;
@@ -0,0 +1,71 @@
1
+ import React, { useEffect, useState } from 'react';
2
+ import { css } from '@emotion/css';
3
+ import { PageContainer } from '@ant-design/pro-components';
4
+ import { message, Modal, Tabs } from 'antd';
5
+ import { Outlet, useLocation } from 'react-router-dom';
6
+ import ParentContext from './content/ParentContext';
7
+ const pathPartition = (sessionStorage.getItem('DETAIL_PARTITION') || '') === ''
8
+ ? ['CREATE', 'EDIT', 'AUDIT', 'PREVIEW', 'DETAIL', 'READ', 'IN', 'INPUT', 'OUTPUT']
9
+ : JSON.parse(sessionStorage.getItem('DETAIL_PARTITION') || '[]');
10
+ export const Component = (props) => {
11
+ const location = useLocation();
12
+ const [messageApi, contextHolder] = message.useMessage();
13
+ const [modal, contextModalHolder] = Modal.useModal();
14
+ const [isSubpage, setIsSubpage] = useState(false);
15
+ useEffect(() => {
16
+ const partition = pathPartition.find(path => {
17
+ return location.pathname.toUpperCase()
18
+ .indexOf(`/${path}/`) > -1;
19
+ });
20
+ if (partition !== undefined) {
21
+ setIsSubpage(true);
22
+ }
23
+ else {
24
+ setIsSubpage(false);
25
+ }
26
+ }, [location]);
27
+ return React.createElement(React.Fragment, null,
28
+ React.createElement(ParentContext.Provider, { value: {
29
+ messageApi,
30
+ modal,
31
+ active: () => {
32
+ props?.onRefresh?.();
33
+ }
34
+ } },
35
+ contextHolder,
36
+ contextModalHolder,
37
+ React.createElement(PageContainer, { style: { display: isSubpage ? 'none' : 'block' }, className: css `
38
+ .ant-page-header-heading {
39
+ padding-block-start: 0 !important;
40
+ }
41
+
42
+ .ant-page-header-heading-title {
43
+ font-size: 15px;
44
+ line-height: 1.5;
45
+ color: #333;
46
+ }
47
+ `, header: {
48
+ style: {
49
+ background: '#fff',
50
+ padding: (props?.tabList?.length || 0) <= 0 ? '10px 24px 10px 24px' : '10px 24px 2px 24px',
51
+ borderBottom: (props?.tabList?.length || 0) <= 0 ? '1px solid rgba(0, 0, 0, 0.06)' : undefined
52
+ }
53
+ }, title: props.title, ghost: true, childrenContentStyle: {
54
+ padding: '0'
55
+ } },
56
+ (props?.tabList?.length || 0) > 0 ? React.createElement(React.Fragment, null,
57
+ React.createElement(Tabs, { size: "small", items: props?.tabList, className: css `
58
+ background: #fff;
59
+ border-bottom: 1px solid rgba(0, 0, 0, 0.06);
60
+
61
+ .ant-tabs-nav::before {
62
+ display: none;
63
+ }
64
+ `, tabBarStyle: { margin: '0 24px' }, onChange: (e) => props?.onTabChange?.(e) })) : undefined,
65
+ props?.banner,
66
+ React.createElement("div", { className: css `
67
+ padding: 12px 16px;
68
+ ` }, props.children)),
69
+ React.createElement(Outlet, null)));
70
+ };
71
+ export default Component;
@@ -0,0 +1,8 @@
1
+ import React, { FC } from 'react';
2
+ export declare type PermissionProps = {
3
+ domain: string;
4
+ permission: string;
5
+ children?: React.ReactNode | undefined;
6
+ };
7
+ export declare const Component: FC<PermissionProps>;
8
+ export default Component;
package/Permission.js ADDED
@@ -0,0 +1,7 @@
1
+ import React, { useContext } from 'react';
2
+ import PermissionContext from './content/PermissionContext';
3
+ export const Component = (props) => {
4
+ const { isPermission } = useContext(PermissionContext);
5
+ return React.createElement(React.Fragment, null, isPermission(props.domain, props.permission) ? props?.children : undefined);
6
+ };
7
+ export default Component;
package/Upgrade.d.ts ADDED
@@ -0,0 +1,7 @@
1
+ import { FC } from 'react';
2
+ export declare type UpgradeComponentProps = {
3
+ localVersion: string;
4
+ request?: () => Promise<string> | undefined;
5
+ };
6
+ declare const App: FC<UpgradeComponentProps>;
7
+ export default App;
package/Upgrade.js ADDED
@@ -0,0 +1,46 @@
1
+ import React, { useEffect } from 'react';
2
+ import { Modal } from 'antd';
3
+ const TIME_KEY = 'VERSION_TIME';
4
+ const App = (props) => {
5
+ useEffect(() => {
6
+ // 每5分钟执行一次
7
+ setTimeout(async () => {
8
+ // 读取缓存的上次弹出更新时间
9
+ const lastTime = Number(localStorage.getItem(TIME_KEY) || 0);
10
+ if (Number.isNaN(lastTime)) {
11
+ localStorage.removeItem(TIME_KEY);
12
+ return;
13
+ }
14
+ // 30分钟执行一次
15
+ if (new Date().getTime() <= lastTime + 1800000) {
16
+ return;
17
+ }
18
+ // 更新刷新时间
19
+ localStorage.setItem(TIME_KEY, new Date().getTime()
20
+ .toString());
21
+ const newVersion = await props.request?.();
22
+ if (newVersion === undefined || newVersion === '') {
23
+ return;
24
+ }
25
+ if (newVersion === props.localVersion) {
26
+ return;
27
+ }
28
+ // 弹出提示框
29
+ Modal.confirm({
30
+ title: '版本更新提示',
31
+ content: React.createElement(React.Fragment, null,
32
+ React.createElement("p", { style: {
33
+ fontSize: '15px',
34
+ lineHeight: '26px'
35
+ } }, "\u60A8\u5DF2\u7ECF\u957F\u65F6\u95F4\u672A\u4F7F\u7528\u6B64\u9875\u9762\uFF0C\u5728\u6B64\u671F\u95F4\u5E73\u53F0\u6709\u8FC7\u66F4\u65B0\uFF0C\u5982\u60A8\u6B64\u65F6\u5728\u9875\u9762\u4E2D\u6CA1\u6709\u586B\u5199\u76F8\u5173\u4FE1\u606F\u7B49\u64CD\u4F5C\uFF0C\u8BF7\u70B9\u51FB\u5237\u65B0\u9875\u9762\u4F7F\u7528\u6700\u65B0\u7248\u672C\uFF01")),
36
+ okText: '确定',
37
+ cancelText: '取消',
38
+ onOk: () => {
39
+ window.location.reload();
40
+ }
41
+ });
42
+ }, 5000);
43
+ }, []);
44
+ return React.createElement(React.Fragment, null);
45
+ };
46
+ export default App;
@@ -33,12 +33,16 @@ const App = (props) => {
33
33
  };
34
34
  const onConfirmLogin = async (code, slider) => {
35
35
  const params = form.getFieldsValue();
36
- const result = (await props?.requestLogin?.(code, slider, params)) || true;
37
- // 如果处理成功, 关闭Loading
38
- if (result) {
39
- setIsLoading(false);
36
+ const func = props?.requestLogin;
37
+ if (func !== undefined) {
38
+ const result = await func(code, slider, params);
39
+ if (!result) {
40
+ return false;
41
+ }
40
42
  }
41
- return result;
43
+ // 如果处理成功, 关闭Loading
44
+ setIsLoading(false);
45
+ return true;
42
46
  };
43
47
  return React.createElement(Form, { form: form },
44
48
  React.createElement(Form.Item, { name: "username", style: { marginBottom: 12 } },
@@ -0,0 +1,8 @@
1
+ import type { MessageInstance } from 'antd/es/message/interface';
2
+ import type { HookAPI } from 'antd/es/modal/useModal';
3
+ declare const ParentContext: import("react").Context<{
4
+ messageApi: MessageInstance | undefined;
5
+ modal: HookAPI | undefined;
6
+ active: () => void;
7
+ }>;
8
+ export default ParentContext;
@@ -0,0 +1,9 @@
1
+ import { createContext } from 'react';
2
+ const ParentContext = createContext({
3
+ messageApi: undefined,
4
+ modal: undefined,
5
+ active: () => {
6
+ console.log('parent context');
7
+ }
8
+ });
9
+ export default ParentContext;
@@ -0,0 +1,4 @@
1
+ declare const PermissionContext: import("react").Context<{
2
+ isPermission: (domain: string, permission: string) => boolean;
3
+ }>;
4
+ export default PermissionContext;
@@ -0,0 +1,12 @@
1
+ import { createContext } from 'react';
2
+ const PermissionContext = createContext({
3
+ isPermission: (domain, permission) => {
4
+ console.log('parent context' + domain);
5
+ console.log('parent context' + permission);
6
+ if (!permission) {
7
+ return false;
8
+ }
9
+ return true;
10
+ }
11
+ });
12
+ export default PermissionContext;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "beer-assembly-biz",
3
3
  "private": false,
4
- "version": "1.1.1-alpha.10",
4
+ "version": "1.1.1-alpha.12",
5
5
  "scripts": {
6
6
  "pub-w": "tsc && copy package.json .\\dist\\package.json && npm publish ./dist",
7
7
  "pub-m": "tsc && cp -a src/icon ./dist && cp -a src/fonts ./dist && cp -a src/images ./dist && cp package.json ./dist/package.json && npm publish ./dist"
@@ -12,7 +12,7 @@
12
12
  "@emotion/css": "^11.11.2",
13
13
  "antd": "^5.10.0",
14
14
  "beer-network": "^1.1.1-alpha.14",
15
- "beer-assembly": "^1.1.1-alpha.57",
15
+ "beer-assembly": "^1.1.1-alpha.70",
16
16
  "dayjs": "^1.11.13",
17
17
  "history": "^5.3.0",
18
18
  "lodash": "^4.17.21",