Merge branch 'dev' into release

This commit is contained in:
Xu Chang 2024-11-05 10:24:32 +08:00
commit 4f6b4f0f24
24 changed files with 456 additions and 82 deletions

View File

@ -2,12 +2,12 @@ import { ED, OakAbsAttrDef } from '../../types/AbstractComponent';
import { ReactComponentProps } from '../../types/Page';
import { Breakpoint } from 'antd';
declare const _default: <ED2 extends ED, T2 extends keyof ED2>(props: ReactComponentProps<ED2, T2, false, {
column?: number | Record<Breakpoint, number>;
column?: number | Record<Breakpoint, number> | undefined;
entity: T2;
attributes: OakAbsAttrDef[];
data: Partial<ED2[T2]['Schema']>;
title?: string;
bordered?: boolean;
layout?: 'horizontal' | 'vertical';
data: Partial<ED2[T2]["Schema"]>;
title?: string | undefined;
bordered?: boolean | undefined;
layout?: "horizontal" | "vertical" | undefined;
}>) => React.ReactElement;
export default _default;

View File

@ -3,8 +3,8 @@ import { ReactComponentProps } from '../../types/Page';
import { ECode } from '../../types/ErrorPage';
declare const _default: <ED2 extends ED, T2 extends keyof ED2>(props: ReactComponentProps<ED2, T2, false, {
code: ECode;
title?: string;
desc?: string;
title?: string | undefined;
desc?: string | undefined;
children?: React.ReactNode;
icon?: React.ReactNode;
}>) => React.ReactElement;

View File

@ -1,2 +1,4 @@
declare const _default: (props: import("../../..").ReactComponentProps<import("oak-domain/lib/types").EntityDict & import("oak-domain/lib/base-app-domain").EntityDict, "i18n", true, WechatMiniprogram.Component.DataOption>) => React.ReactElement;
/// <reference types="wechat-miniprogram" />
/// <reference types="react" />
declare const _default: (props: import("../../..").ReactComponentProps<import("oak-domain/lib/types").EntityDict & import("oak-domain/lib/base-app-domain").EntityDict, "i18n", true, WechatMiniprogram.Component.DataOption>) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
export default _default;

View File

@ -1,2 +1,4 @@
declare const _default: (props: import("../../..").ReactComponentProps<import("oak-domain/lib/types").EntityDict & import("oak-domain/lib/base-app-domain").EntityDict, "i18n", false, WechatMiniprogram.Component.DataOption>) => React.ReactElement;
/// <reference types="wechat-miniprogram" />
/// <reference types="react" />
declare const _default: (props: import("../../..").ReactComponentProps<import("oak-domain/lib/types").EntityDict & import("oak-domain/lib/base-app-domain").EntityDict, "i18n", false, WechatMiniprogram.Component.DataOption>) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
export default _default;

View File

@ -10,13 +10,18 @@ declare const _default: <ED2 extends ED, T2 extends keyof ED2>(props: ReactCompo
data: RowWithActions<ED2, T2>[];
loading: boolean;
tablePagination?: React.ReactNode | false;
rowSelection?: TableProps<RowWithActions<ED2, T2>>['rowSelection'];
hideHeader?: boolean;
disableSerialNumber?: boolean;
size?: 'large' | 'middle' | 'small';
scroll?: TableProps<RowWithActions<ED2, T2>>['scroll'];
rowSelection?: import("antd/es/table/interface").TableRowSelection<RowWithActions<ED2, T2>> | undefined;
hideHeader?: boolean | undefined;
disableSerialNumber?: boolean | undefined;
size?: "small" | "large" | "middle" | undefined;
scroll?: ({
x?: string | number | true | undefined;
y?: string | number | undefined;
} & {
scrollToFirstRowOnChange?: boolean | undefined;
}) | undefined;
empty?: React.ReactNode;
opWidth?: number;
ellipsis?: boolean;
opWidth?: number | undefined;
ellipsis?: boolean | undefined;
}>) => React.ReactElement;
export default _default;

View File

@ -1,20 +1,21 @@
/// <reference types="react" />
import { ReactComponentProps } from '../../types/Page';
import { ED } from '../../types/AbstractComponent';
declare const _default: <ED2 extends ED, T2 extends keyof ED2>(props: ReactComponentProps<ED2, T2, false, {
style?: React.CSSProperties;
className?: string;
style?: import("react").CSSProperties | undefined;
className?: string | undefined;
title?: React.ReactNode;
showBack?: boolean;
onBack?: () => void;
showBack?: boolean | undefined;
onBack?: (() => void) | undefined;
backIcon?: React.ReactNode;
delta?: number;
delta?: number | undefined;
extra?: React.ReactNode;
subTitle?: React.ReactNode;
contentMargin?: boolean;
contentStyle?: React.CSSProperties;
contentClassName?: string;
contentMargin?: boolean | undefined;
contentStyle?: import("react").CSSProperties | undefined;
contentClassName?: string | undefined;
tags?: React.ReactNode;
children?: React.ReactNode;
showHeader?: boolean;
showHeader?: boolean | undefined;
}>) => React.ReactElement;
export default _default;

View File

@ -1,22 +1,23 @@
/// <reference types="react" />
import { ReactComponentProps } from '../../types/Page';
import { ED } from '../../types/AbstractComponent';
declare const _default: <ED2 extends ED, T2 extends keyof ED2>(props: ReactComponentProps<ED2, T2, false, {
style?: React.CSSProperties;
className?: string;
showHeader?: boolean;
showBack?: boolean;
onBack?: () => void;
style?: import("react").CSSProperties | undefined;
className?: string | undefined;
showHeader?: boolean | undefined;
showBack?: boolean | undefined;
onBack?: (() => void) | undefined;
backIcon?: React.ReactNode;
delta?: number;
delta?: number | undefined;
title?: React.ReactNode;
subTitle?: React.ReactNode;
tags?: React.ReactNode;
extra?: React.ReactNode;
children?: React.ReactNode;
content: React.ReactNode;
contentStyle?: React.CSSProperties;
contentClassName?: string;
bodyStyle?: React.CSSProperties;
bodyClassName?: string;
contentStyle?: import("react").CSSProperties | undefined;
contentClassName?: string | undefined;
bodyStyle?: import("react").CSSProperties | undefined;
bodyClassName?: string | undefined;
}>) => React.ReactElement;
export default _default;

View File

@ -1,12 +1,13 @@
/// <reference types="react" />
import { ReactComponentProps } from '../../types/Page';
import { ED } from '../../types/AbstractComponent';
declare const _default: <ED2 extends ED, T2 extends keyof ED2>(props: ReactComponentProps<ED2, T2, false, {
entity: T2;
style?: React.CSSProperties;
className?: string;
showQuickJumper?: boolean;
size?: 'default' | 'small';
showSizeChanger?: boolean;
showTotal?: (total: number, range: [number, number]) => React.ReactNode;
style?: import("react").CSSProperties | undefined;
className?: string | undefined;
showQuickJumper?: boolean | undefined;
size?: "small" | "default" | undefined;
showSizeChanger?: boolean | undefined;
showTotal?: ((total: number, range: [number, number]) => React.ReactNode) | undefined;
}>) => React.ReactElement;
export default _default;

View File

@ -1,15 +1,143 @@
.pagination {
:global {
.ant-pagination-next {
cursor: pointer !important
}
}
}
// .pagination {
// :global {
// .ant-pagination-next {
// cursor: pointer !important
// }
// }
// }
.paginationNoMore {
:global {
.ant-pagination-next {
cursor: not-allowed !important
}
}
}
@pagination-prefix-cls: rc-pagination;
@primary-color: #1890ff;
@pagination-item-bg: #fff;
@pagination-item-size: 28px;
@pagination-item-size-sm: 24px;
@pagination-font-family: Arial;
@pagination-font-weight-active: 500;
@pagination-item-bg-active: #fff;
@pagination-item-link-bg: #fff;
@pagination-item-disabled-color-active: #fff;
@pagination-item-disabled-bg-active: darken(hsv(0, 0, 96%), 10%);
@pagination-item-input-bg: #fff;
.@{pagination-prefix-cls} {
width: 100%;
ul,
ol {
margin: 0;
padding: 0;
list-style: none !important;
flex: 1 !important;
}
&-total-text {
display: inline-block;
height: @pagination-item-size;
margin-right: 8px;
line-height: @pagination-item-size - 2px;
vertical-align: middle;
}
&-item {
border: none !important;
&:hover {
background-color: #eee;
border-radius: 4px;
transition: all 0.3s;
}
&-active {
border: 1px solid @primary-color !important;
border-radius: 4px !important;
}
}
&-prev {
margin-right: 8px;
}
&-prev,
&-next {
display: inline-block;
min-width: @pagination-item-size;
height: @pagination-item-size;
color: rgba(0, 0, 0, 0.85);
font-family: @pagination-font-family;
line-height: @pagination-item-size;
text-align: center;
vertical-align: middle;
list-style: none;
border-radius: 2px;
cursor: pointer;
transition: all 0.3s;
}
&-prev,
&-next {
outline: 0;
button {
color: rgba(0, 0, 0, 0.85);
cursor: pointer;
user-select: none;
}
&:hover button {
border-color: #40a9ff;
}
.@{pagination-prefix-cls}-item-link {
display: block;
width: 100%;
height: 100%;
font-size: 12px;
text-align: center;
background-color: @pagination-item-link-bg;
border: 1px solid #d9d9d9;
border-radius: 2px;
outline: none;
transition: all 0.3s;
}
&:focus .@{pagination-prefix-cls}-item-link,
&:hover .@{pagination-prefix-cls}-item-link {
color: @primary-color;
border-color: @primary-color;
}
}
&-prev button:after {
content: '';
display: block;
}
&-next button:after {
content: '';
display: block;
}
&-disabled {
&,
&:hover,
&:focus {
cursor: not-allowed;
.@{pagination-prefix-cls}-item-link {
color: fade(#000, 25%);
border-color: #d9d9d9;
cursor: not-allowed;
}
}
}
}

13
es/components/pagination/pager.d.ts vendored Normal file
View File

@ -0,0 +1,13 @@
import { PaginationProps } from 'antd';
import React from 'react';
export interface PagerProps extends Pick<PaginationProps, 'itemRender'> {
rootPrefixCls: string;
page: number;
active?: boolean;
className?: string;
showTitle: boolean;
onClick?: (page: number) => void;
onKeyPress?: (e: React.KeyboardEvent<HTMLLIElement>, onClick: PagerProps['onClick'], page: PagerProps['page']) => void;
}
declare const Pager: React.FC<PagerProps>;
export default Pager;

View File

@ -0,0 +1,22 @@
import classNames from 'classnames';
import React from 'react';
import Style from "./index.module.less";
const Pager = (props) => {
const { rootPrefixCls, page, active, className, showTitle, onClick, onKeyPress, itemRender, } = props;
const prefixCls = `${rootPrefixCls}-item`;
const cls = classNames(prefixCls, Style[`${prefixCls}`], {
[Style[`${prefixCls}-active`]]: active,
[Style[`${prefixCls}-disabled`]]: !page,
}, className);
const handleClick = () => {
onClick && onClick(page);
};
const handleKeyPress = (e) => {
onKeyPress && onKeyPress(e, onClick, page);
};
const pager = itemRender && itemRender(page, 'page', <a rel="nofollow">{page}</a>);
return pager ? (<li title={showTitle ? String(page) : undefined} className={cls} onClick={handleClick} onKeyDown={handleKeyPress} tabIndex={0}>
{pager}
</li>) : null;
};
export default Pager;

View File

@ -1,6 +1,7 @@
import React from "react";
import { WebComponentProps } from "../../types/Page";
import { ED } from "../../types/AbstractComponent";
import 'rc-pagination/assets/index.css';
export interface IPaginationProps {
style?: React.CSSProperties;
className?: string;
@ -9,5 +10,6 @@ export interface IPaginationProps {
showSizeChanger?: boolean;
showTotal?: (total: number, range: [number, number]) => React.ReactNode;
newTotal: number;
showTitle?: boolean;
}
export default function Render(props: WebComponentProps<ED, keyof ED, true, IPaginationProps, {}>): React.JSX.Element | null;

View File

@ -1,10 +1,23 @@
import React from "react";
import { Pagination } from "antd";
import React, { useState, useEffect, useRef } from "react";
import { LeftOutlined, RightOutlined } from "@ant-design/icons";
import classNames from "classnames";
import Style from "./index.module.less";
import { isInteger } from "lodash";
import Pager from './pager';
import Options from 'rc-pagination/es/Options';
import zhCN from 'rc-pagination/es/locale/zh_CN';
import Select from 'antd/es/select';
import 'rc-pagination/assets/index.css';
function calculatePage(p, pageSize, total) {
const _pageSize = typeof p === 'undefined' ? pageSize : p;
return Math.floor((total - 1) / _pageSize) + 1;
}
const MiniSelect = (props) => <Select {...props} showSearch size="small"/>;
const MiddleSelect = (props) => <Select {...props} showSearch size="middle"/>;
MiniSelect.Option = Select.Option;
MiddleSelect.Option = Select.Option;
export default function Render(props) {
const { style, className, oakPagination, oakFullpath, newTotal, showQuickJumper, showSizeChanger, size, showTotal, } = props.data;
const { style, className, oakPagination, oakFullpath, newTotal, showQuickJumper, showSizeChanger, size, showTotal, showTitle, } = props.data;
const { t, setPageSize, setCurrentPage } = props.methods;
const { pageSize, total, currentPage, more, count } = oakPagination || {};
const itemRender = (_, type, originalElement) => {
@ -33,12 +46,175 @@ export default function Render(props) {
if (count === 0) {
return null;
}
return (<Pagination style={style} className={classNames(className, {
[Style.pagination]: more,
[Style.paginationNoMore]: !more,
})} itemRender={itemRender} pageSize={pageSize} total={newTotal} current={currentPage} showQuickJumper={showQuickJumper} showSizeChanger={showSizeChanger} size={size} showTotal={showTotal} onShowSizeChange={(current, pageSize) => {
setPageSize(pageSize);
}} onChange={(page, pageSize) => {
setCurrentPage(page);
}}/>);
const prefixCls = 'rc-pagination';
const selectPrefixCls = 'rc-select';
const paginationRef = useRef(null);
const [internalInputVal, setInternalInputVal] = useState(currentPage);
useEffect(() => {
setInternalInputVal(currentPage);
}, [currentPage]);
const hasPrev = currentPage > 1;
const hasNext = currentPage < calculatePage(undefined, pageSize, newTotal);
const allPages = calculatePage(undefined, pageSize, newTotal);
const prevPage = currentPage - 1 > 0 ? currentPage - 1 : 0;
const nextPage = currentPage + 1 < allPages ? currentPage + 1 : allPages;
function isValid(page) {
return isInteger(page) && page !== currentPage && isInteger(newTotal) && newTotal > 0;
}
function handleChange(page) {
if (isValid(page)) {
const currentPage = calculatePage(undefined, pageSize, newTotal);
let newPage = page;
if (page > currentPage) {
newPage = currentPage;
}
else if (page < 1) {
newPage = 1;
}
if (newPage !== internalInputVal) {
setInternalInputVal(newPage);
}
setCurrentPage(newPage);
return newPage;
}
return currentPage;
}
//总条数
const totalText = showTotal ? (<li className={Style[`${prefixCls}-total-text`]}>
{showTotal(newTotal, [
total === 0 ? 0 : newTotal,
currentPage * pageSize > newTotal ? newTotal : currentPage * pageSize,
])}
</li>) : (<li className={Style[`${prefixCls}-total-text`]}>
{newTotal >= total ? (more ? newTotal + '+' : (currentPage - 1) * pageSize + count) : total}
</li>);
//上一页
function renderPrev(prevPage) {
const prevButton = (<a>
<LeftOutlined />
</a>);
return React.isValidElement(prevButton)
? React.cloneElement(prevButton, { disabled: !hasPrev })
: prevButton;
}
function prevHandle() {
if (hasPrev)
handleChange(currentPage - 1);
}
let prev = renderPrev(prevPage);
if (prev) {
const prevDisabled = !hasPrev || !newTotal;
prev = (<li title={showTitle ? '上一页' : undefined} onClick={prevHandle} tabIndex={prevDisabled ? undefined : 0} className={classNames(Style[`${prefixCls}-prev`], {
[Style[`${prefixCls}-disabled`]]: prevDisabled,
})} aria-disabled={prevDisabled}>
{prev}
</li>);
}
//下一页
function renderNext(nextPage) {
const nextButton = (<a style={{
cursor: more ? "pointer" : "not-allowed",
color: more ? "#006cb7" : "rgba(0, 0, 0, 0.25)",
}} onClick={more ? () => {
if (currentPage) {
setCurrentPage(currentPage + 1);
}
} : undefined}>
<RightOutlined />
</a>);
return React.isValidElement(nextButton)
? React.cloneElement(nextButton, { disabled: !hasNext })
: nextButton;
}
function nextHandle() {
if (hasNext)
handleChange(currentPage + 1);
}
let next = renderNext(nextPage);
if (next) {
let nextDisabled, nextTabIndex;
// if (simple) {
// nextDisabled = !hasNext;
// nextTabIndex = hasPrev ? 0 : null;
// } else {
nextDisabled = !hasNext || !newTotal;
nextTabIndex = nextDisabled ? undefined : 0;
// }
next = (<li title={showTitle ? '下一页' : undefined} onClick={nextHandle} tabIndex={nextTabIndex} className={classNames(Style[`${prefixCls}-next`], {
[Style[`${prefixCls}-disabled`]]: nextDisabled,
})} aria-disabled={nextDisabled}>
{next}
</li>);
}
//页码
const pagerList = [];
const pagerProps = {
rootPrefixCls: prefixCls,
onClick: handleChange,
showTitle: showTitle,
itemRender,
page: -1,
};
const pageBufferSize = 5;
if (allPages <= pageBufferSize * 2) {
if (!allPages) {
pagerList.push(<Pager {...pagerProps} key="noPager" page={1} className={classNames(className, {
[`${prefixCls}-item-disabled`]: true,
})}/>);
}
for (let i = 1; i <= allPages; i += 1) {
pagerList.push(<Pager {...pagerProps} key={i} page={i} active={currentPage === i}/>);
}
}
else {
const left = Math.min(allPages - pageBufferSize * 2 + 1, Math.max(1, currentPage - pageBufferSize));
const right = Math.min(left + pageBufferSize * 2 - 1, allPages);
for (let i = left; i <= right; i += 1) {
pagerList.push(<Pager {...pagerProps} key={i} page={i} active={currentPage === i}/>);
}
}
function changePageSize(size) {
const newCurrent = calculatePage(size, pageSize, newTotal);
const nextCurrent = currentPage > newCurrent && newCurrent !== 0 ? newCurrent : currentPage;
setPageSize(size);
setInternalInputVal(nextCurrent);
setCurrentPage(nextCurrent);
}
const shouldDisplayQuickJumper = newTotal > pageSize ? showQuickJumper : false;
const goButton = showQuickJumper && showQuickJumper.goButton;
let gotoButton = goButton;
return (
// <Pagination
// style={style}
// className={classNames(className, {
// [Style.pagination]: more,
// [Style.paginationNoMore]: !more,
// })}
// itemRender={itemRender}
// pageSize={pageSize}
// total={newTotal}
// current={currentPage}
// showQuickJumper={showQuickJumper}
// showSizeChanger={showSizeChanger}
// size={size}
// showTotal={showTotal}
// onShowSizeChange={(current: number, pageSize: number) => {
// setPageSize(pageSize);
// }}
// onChange={(page: number, pageSize: number) => {
// setCurrentPage(page);
// }}
// />
<ul className={classNames(className, {
[Style[`${prefixCls}-end`]]: true,
})} style={style} ref={paginationRef}>
{totalText}
{prev}
{/* {simple ? simplePager : pagerList} */}
{pagerList}
{next}
<Options locale={zhCN} rootPrefixCls={prefixCls}
// disabled={disabled}
selectComponentClass={size === 'small' ? MiniSelect : MiddleSelect} selectPrefixCls={selectPrefixCls} changeSize={changePageSize} pageSize={pageSize} showSizeChanger={showSizeChanger} quickGo={shouldDisplayQuickJumper ? handleChange : undefined} goButton={gotoButton}/>
</ul>);
}

View File

@ -4,7 +4,7 @@ declare const _default: <ED2 extends ED, T2 extends keyof ED2, T3 extends string
helps: Record<string, string>;
entity: T2;
attributes: OakAbsAttrUpsertDef<ED2, T2, T3>[];
data: ED2[T2]['Schema'];
data: ED2[T2]["Schema"];
layout: 'horizontal' | 'vertical';
mode: 'default' | 'card';
}>) => React.ReactElement;

View File

@ -183,7 +183,7 @@ export class SubScriber extends Feature {
}
else if (this.socketState === 'connected' && newEvents.length > 0) {
await new Promise((resolve, reject) => {
// this.socket.emit('sub', newEvents, (result) => {
// this.socket!.emit('sub', newEvents, (result: string) => {
// if (result) {
// this.message.setMessage({
// type: 'error',

19
es/page.react.d.ts vendored
View File

@ -49,21 +49,21 @@ export declare function createComponent<IsList extends boolean, ED extends Entit
redirectTo<T2_1 extends keyof ED>(options: {
url: string;
} & OakNavigateToParameters<ED, T2_1>, state?: Record<string, any> | undefined, disableNamespace?: boolean | undefined): Promise<void>;
addItem<T_1 extends keyof ED>(data: Omit<ED[T_1]["CreateSingle"]["data"], "id"> & {
addItem<T extends keyof ED>(data: Omit<ED[T]["CreateSingle"]["data"], "id"> & {
id?: string | undefined;
}, path?: string | undefined): string;
addItems<T_2 extends keyof ED>(data: (Omit<ED[T_2]["CreateSingle"]["data"], "id"> & {
addItems<T_1 extends keyof ED>(data: (Omit<ED[T_1]["CreateSingle"]["data"], "id"> & {
id?: string | undefined;
})[], path?: string | undefined): string[];
removeItem(id: string, path?: string | undefined): void;
removeItems(ids: string[], path?: string | undefined): void;
updateItem<T_3 extends keyof ED>(data: ED[T_3]["Update"]["data"], id: string, action?: ED[T_3]["Action"] | undefined, path?: string | undefined): void;
updateItems<T_4 extends keyof ED>(data: ED[T_4]["Update"]["data"], ids: string[], action?: ED[T_4]["Action"] | undefined, path?: string | undefined): void;
updateItem<T_2 extends keyof ED>(data: ED[T_2]["Update"]["data"], id: string, action?: ED[T_2]["Action"] | undefined, path?: string | undefined): void;
updateItems<T_3 extends keyof ED>(data: ED[T_3]["Update"]["data"], ids: string[], action?: ED[T_3]["Action"] | undefined, path?: string | undefined): void;
recoverItem(id: string, path?: string | undefined): void;
recoverItems(ids: string[], path?: string | undefined): void;
resetItem(id: string, path?: string | undefined): void;
update<T_5 extends keyof ED>(data: ED[T_5]["Update"]["data"], action?: ED[T_5]["Action"] | undefined, path?: string | undefined): void;
create<T_6 extends keyof ED>(data: Omit<ED[T_6]["CreateSingle"]["data"], "id">, path?: string | undefined): void;
update<T_4 extends keyof ED>(data: ED[T_4]["Update"]["data"], action?: ED[T_4]["Action"] | undefined, path?: string | undefined): void;
create<T_5 extends keyof ED>(data: Omit<ED[T_5]["CreateSingle"]["data"], "id">, path?: string | undefined): void;
remove(path?: string | undefined): void;
isCreation(path?: string | undefined): boolean;
clean(lsn?: number | undefined, dontPublish?: true | undefined, path?: string | undefined): void;
@ -77,7 +77,7 @@ export declare function createComponent<IsList extends boolean, ED extends Entit
getFreshValue(path?: string | undefined): Partial<import("oak-domain/lib/types").GeneralEntityShape> | Partial<import("oak-domain/lib/types").GeneralEntityShape>[] | undefined;
checkOperation<T2_2 extends keyof ED>(entity: T2_2, operation: Omit<ED[T2_2]["Operation"], "id">, checkerTypes?: CheckerType[] | undefined): boolean | { [A in ED[T2_2]["Action"]]: boolean | import("oak-domain/lib/types").OakUserException<ED>; }[ED[T2_2]["Action"]];
tryExecute(path?: string | undefined, action?: string | undefined): boolean | { [A_1 in ED[keyof ED]["Action"]]: boolean | import("oak-domain/lib/types").OakUserException<ED>; }[ED[keyof ED]["Action"]];
getOperations<T_7 extends keyof ED>(path?: string | undefined): {
getOperations<T_6 extends keyof ED>(path?: string | undefined): {
entity: keyof ED;
operation: ED[keyof ED]["Operation"];
}[] | undefined;
@ -119,7 +119,10 @@ export declare function createComponent<IsList extends boolean, ED extends Entit
componentWillReceiveProps?(nextProps: Readonly<ComponentProps<ED, T, TProperty>>, nextContext: any): void;
UNSAFE_componentWillReceiveProps?(nextProps: Readonly<ComponentProps<ED, T, TProperty>>, nextContext: any): void;
componentWillUpdate?(nextProps: Readonly<ComponentProps<ED, T, TProperty>>, nextState: Readonly<ComponentData<ED, T, FormedData, TData>>, nextContext: any): void;
UNSAFE_componentWillUpdate?(nextProps: Readonly<ComponentProps<ED, T, TProperty>>, nextState: Readonly<ComponentData<ED, T, FormedData, TData>>, nextContext: any): void;
UNSAFE_componentWillUpdate?(nextProps: Readonly<ComponentProps<ED, T, TProperty>>, nextState: Readonly<ComponentData<ED, T, FormedData, TData>>, nextContext: any): void; /**
* setState后先调willUnmount析构callback不被调用的情况willUnmount需要将runningTree上的node正确析构
* by Xc 20240806
*/
};
contextType?: React.Context<any> | undefined;
};

View File

@ -30,4 +30,5 @@ export default class DebugConnector<ED extends EntityDict & BaseEntityDict, Cxt
getEndpointRouter(): string;
parseBridgeRequestQuery(urlParams: string): any;
getFullData(keys?: (keyof ED)[]): Promise<{ [T in keyof ED]?: ED[T]["OpSchema"][] | undefined; }>;
getCorsHeader(): string[];
}

View File

@ -87,5 +87,9 @@ export default class DebugConnector {
async getFullData(keys) {
return this.debugStore.getCurrentData(keys);
}
getCorsHeader() {
throw new Error('not available in debugConnector');
return [];
}
}
;

View File

@ -187,7 +187,7 @@ class SubScriber extends Feature_1.Feature {
}
else if (this.socketState === 'connected' && newEvents.length > 0) {
await new Promise((resolve, reject) => {
// this.socket.emit('sub', newEvents, (result) => {
// this.socket!.emit('sub', newEvents, (result: string) => {
// if (result) {
// this.message.setMessage({
// type: 'error',
@ -200,6 +200,7 @@ class SubScriber extends Feature_1.Feature {
// resolve(undefined);
// }
// });
// TODO 临时代码 后续结合文档再解决
this.socket.emit('sub', newEvents);
resolve(undefined);
});

19
lib/page.react.d.ts vendored
View File

@ -49,21 +49,21 @@ export declare function createComponent<IsList extends boolean, ED extends Entit
redirectTo<T2_1 extends keyof ED>(options: {
url: string;
} & OakNavigateToParameters<ED, T2_1>, state?: Record<string, any> | undefined, disableNamespace?: boolean | undefined): Promise<void>;
addItem<T_1 extends keyof ED>(data: Omit<ED[T_1]["CreateSingle"]["data"], "id"> & {
addItem<T extends keyof ED>(data: Omit<ED[T]["CreateSingle"]["data"], "id"> & {
id?: string | undefined;
}, path?: string | undefined): string;
addItems<T_2 extends keyof ED>(data: (Omit<ED[T_2]["CreateSingle"]["data"], "id"> & {
addItems<T_1 extends keyof ED>(data: (Omit<ED[T_1]["CreateSingle"]["data"], "id"> & {
id?: string | undefined;
})[], path?: string | undefined): string[];
removeItem(id: string, path?: string | undefined): void;
removeItems(ids: string[], path?: string | undefined): void;
updateItem<T_3 extends keyof ED>(data: ED[T_3]["Update"]["data"], id: string, action?: ED[T_3]["Action"] | undefined, path?: string | undefined): void;
updateItems<T_4 extends keyof ED>(data: ED[T_4]["Update"]["data"], ids: string[], action?: ED[T_4]["Action"] | undefined, path?: string | undefined): void;
updateItem<T_2 extends keyof ED>(data: ED[T_2]["Update"]["data"], id: string, action?: ED[T_2]["Action"] | undefined, path?: string | undefined): void;
updateItems<T_3 extends keyof ED>(data: ED[T_3]["Update"]["data"], ids: string[], action?: ED[T_3]["Action"] | undefined, path?: string | undefined): void;
recoverItem(id: string, path?: string | undefined): void;
recoverItems(ids: string[], path?: string | undefined): void;
resetItem(id: string, path?: string | undefined): void;
update<T_5 extends keyof ED>(data: ED[T_5]["Update"]["data"], action?: ED[T_5]["Action"] | undefined, path?: string | undefined): void;
create<T_6 extends keyof ED>(data: Omit<ED[T_6]["CreateSingle"]["data"], "id">, path?: string | undefined): void;
update<T_4 extends keyof ED>(data: ED[T_4]["Update"]["data"], action?: ED[T_4]["Action"] | undefined, path?: string | undefined): void;
create<T_5 extends keyof ED>(data: Omit<ED[T_5]["CreateSingle"]["data"], "id">, path?: string | undefined): void;
remove(path?: string | undefined): void;
isCreation(path?: string | undefined): boolean;
clean(lsn?: number | undefined, dontPublish?: true | undefined, path?: string | undefined): void;
@ -77,7 +77,7 @@ export declare function createComponent<IsList extends boolean, ED extends Entit
getFreshValue(path?: string | undefined): Partial<import("oak-domain/lib/types").GeneralEntityShape> | Partial<import("oak-domain/lib/types").GeneralEntityShape>[] | undefined;
checkOperation<T2_2 extends keyof ED>(entity: T2_2, operation: Omit<ED[T2_2]["Operation"], "id">, checkerTypes?: CheckerType[] | undefined): boolean | { [A in ED[T2_2]["Action"]]: boolean | import("oak-domain/lib/types").OakUserException<ED>; }[ED[T2_2]["Action"]];
tryExecute(path?: string | undefined, action?: string | undefined): boolean | { [A_1 in ED[keyof ED]["Action"]]: boolean | import("oak-domain/lib/types").OakUserException<ED>; }[ED[keyof ED]["Action"]];
getOperations<T_7 extends keyof ED>(path?: string | undefined): {
getOperations<T_6 extends keyof ED>(path?: string | undefined): {
entity: keyof ED;
operation: ED[keyof ED]["Operation"];
}[] | undefined;
@ -119,7 +119,10 @@ export declare function createComponent<IsList extends boolean, ED extends Entit
componentWillReceiveProps?(nextProps: Readonly<ComponentProps<ED, T, TProperty>>, nextContext: any): void;
UNSAFE_componentWillReceiveProps?(nextProps: Readonly<ComponentProps<ED, T, TProperty>>, nextContext: any): void;
componentWillUpdate?(nextProps: Readonly<ComponentProps<ED, T, TProperty>>, nextState: Readonly<ComponentData<ED, T, FormedData, TData>>, nextContext: any): void;
UNSAFE_componentWillUpdate?(nextProps: Readonly<ComponentProps<ED, T, TProperty>>, nextState: Readonly<ComponentData<ED, T, FormedData, TData>>, nextContext: any): void;
UNSAFE_componentWillUpdate?(nextProps: Readonly<ComponentProps<ED, T, TProperty>>, nextState: Readonly<ComponentData<ED, T, FormedData, TData>>, nextContext: any): void; /**
* setState后先调willUnmount析构callback不被调用的情况willUnmount需要将runningTree上的node正确析构
* by Xc 20240806
*/
};
contextType?: React.Context<any> | undefined;
};

View File

@ -30,4 +30,5 @@ export default class DebugConnector<ED extends EntityDict & BaseEntityDict, Cxt
getEndpointRouter(): string;
parseBridgeRequestQuery(urlParams: string): any;
getFullData(keys?: (keyof ED)[]): Promise<{ [T in keyof ED]?: ED[T]["OpSchema"][] | undefined; }>;
getCorsHeader(): string[];
}

View File

@ -90,6 +90,10 @@ class DebugConnector {
async getFullData(keys) {
return this.debugStore.getCurrentData(keys);
}
getCorsHeader() {
throw new Error('not available in debugConnector');
return [];
}
}
exports.default = DebugConnector;
;

View File

@ -1,6 +1,6 @@
{
"name": "oak-frontend-base",
"version": "5.3.16",
"version": "5.3.17",
"description": "oak框架中前端与业务逻辑无关的平台部分",
"author": {
"name": "XuChang"
@ -20,7 +20,6 @@
"format-message-parse": "^6.2.4",
"history": "^5.3.0",
"i18n-js": "^4.3.0",
"keepalive-for-react": "^2.0.7",
"node-schedule": "^2.1.1",
"nprogress": "^0.2.0",
"oak-common-aspect": "^3.0.2",
@ -91,7 +90,7 @@
"copy-wxs": "copyfiles -u 1 src/**/*.wxs es/",
"copy-xml": "copyfiles -u 1 src/**/*.xml es/",
"copy-wxml": "copyfiles -u 1 src/**/*.wxml es/",
"build": "tsc -p tsconfig.lib.json && tsc -p tsconfig.es.json && npm run copy-js && npm run copy-less && npm run copy-wxs && npm run copy-svg && npm run copy-xml && npm run copy-wxml && npm run copy-json",
"build": "tsc -p tsconfig.lib.json && tsc -p tsconfig.es.json && npm run copy-js && npm run copy-less && npm run copy-wxs && npm run copy-svg && npm run copy-xml && npm run copy-wxml && npm run copy-json && rimraf lib/components/* ",
"test": "ts-node ./test/test.ts",
"prepare": "rimraf node_modules/react & rimraf node_modules/react-native & rimraf node_modules/react-dom & rimraf node_modules/react-router & rimraf node_modules/react-router-dom",
"remove-antd": "rimraf node_modules/antd & rimraf node_modules/antd-mobile & rimraf node_modules/@ant-design & rimraf node_modules/antd-mobile-icons & rimraf node_modules/antd-mobile-v5-count"

View File

@ -117,4 +117,9 @@ export default class DebugConnector<ED extends EntityDict & BaseEntityDict, Cxt
async getFullData(keys?: (keyof ED)[]) {
return this.debugStore.getCurrentData(keys);
}
getCorsHeader() {
throw new Error('not available in debugConnector');
return [] as string[];
}
};