This commit is contained in:
Xu Chang 2023-12-13 11:57:49 +08:00
parent 09eef978fc
commit 46b46dc83d
24 changed files with 70 additions and 47 deletions

View File

@ -36,6 +36,17 @@ export default OakComponent({
// return
}
}
}
},
// async setPage(value: number) {
// const { oakPagination, total1 } = this.state;
// const { pageSize, total, currentPage, more } = oakPagination || {};
// if (value && pageSize) {
// if ((value * pageSize) > total1) {
// this.setState({ total1: value * pageSize })
// }
// // else {
// // }
// }
// }
}
});

View File

@ -24,5 +24,6 @@ export default function Render(props: WebComponentProps<ED, keyof ED, true, Pagi
onShowSizeChange?: (current: number, size: number) => void;
itemRender?: (page: number, type: 'page' | 'prev' | 'next' | 'jump-prev' | 'jump-next', element: React.ReactNode) => React.ReactNode;
setTotal: () => void;
setPage: (value: number) => void;
}>): "" | React.JSX.Element | undefined;
export {};

View File

@ -4,8 +4,9 @@ import { LeftOutlined, RightOutlined } from '@ant-design/icons';
import Style from './index.module.less';
export default function Render(props) {
const { style, className, oakPagination, oakFullpath, total1, showQuickJumper, size, responsive, role, totalBoundaryShowSizeChanger, rootClassName, showTotal, } = props.data;
const { t, setPageSize, setCurrentPage, setTotal } = props.methods;
const { t, setPageSize, setCurrentPage, setTotal, setPage, setMessage } = props.methods;
const { pageSize, total, currentPage, more } = oakPagination || {};
// const [inputPage, setInputPage] = useState(1);
const itemRender = (_, type, originalElement) => {
if (type === 'prev') {
return <a><LeftOutlined /></a>;
@ -26,5 +27,29 @@ export default function Render(props) {
}} onChange={(page, pageSize) => {
setCurrentPage(page);
}}/>
{/* <div>
<InputNumber
onChange={(value: number) => {
setInputPage(value)
}} />
<Button onClick={() => {
if (more) {
setPage(inputPage)
setCurrentPage(inputPage);
} else {
if ((inputPage * pageSize!) > total1) {
setMessage({
type: 'warning',
content: "没有更多数据了!"
})
return
}
setPage(inputPage)
setCurrentPage(inputPage);
}
}}>跳转</Button>
</div> */}
</div>));
}

View File

@ -10,7 +10,7 @@ export declare abstract class BackendRuntimeContext<ED extends EntityDict & Base
eventOperationMap: Record<string, string[]>;
getNavigatorState(): {
pathname: string;
oakFrom: string;
oakFrom?: string | undefined;
} | undefined;
getSubscriberId(): string | undefined;
getBriefEnvironment(): BriefEnv | undefined;

View File

@ -14,7 +14,7 @@ export type SerializedData = {
be?: BriefEnv;
ns?: {
pathname: string;
oakFrom: string;
oakFrom?: string;
};
};
export declare abstract class FrontendRuntimeContext<ED extends EntityDict & BaseEntityDict, Cxt extends AsyncContext<ED>, AD extends CommonAspectDict<ED, Cxt> & Record<string, Aspect<ED, Cxt>>> extends SyncContext<ED> {

View File

@ -10,7 +10,7 @@ export declare class Navigator extends Feature {
urlFormat(url: URL): string;
constructState(pathname: string, state?: Record<string, any>, search?: string): {
pathname: string;
oakFrom: string;
oakFrom: string | undefined;
};
constructSearch(search?: string | null, state?: Record<string, any>): string;
constructUrl(url: string, state?: Record<string, any>, disableNamespace?: boolean): string;

View File

@ -21,7 +21,8 @@ export class Navigator extends Feature {
}
urlFormat(url) {
const urlParse = new URL(url.toString(), this.base);
const url2 = urlParse.toString();
let url2 = urlParse.toString();
url2 = decodeURIComponent(url2);
return url2.replace(this.base, '');
}
constructState(pathname, state, search) {
@ -31,7 +32,7 @@ export class Navigator extends Feature {
const oakFrom = searchParams.get('oakFrom');
return {
pathname,
oakFrom,
oakFrom: oakFrom ? decodeURIComponent(oakFrom) : undefined,
};
}
constructSearch(search, state) {
@ -46,7 +47,9 @@ export class Navigator extends Feature {
}
}
}
return searchParams.toString();
let searchStr = searchParams.toString();
searchStr = decodeURIComponent(searchStr);
return searchStr;
}
constructUrl(url, state, disableNamespace) {
const urlParse = this.urlParse(url);

View File

@ -14,7 +14,7 @@ export declare class Navigator extends CommonNavigator {
getLocation(): Location;
getState(): {
pathname: string;
oakFrom: string;
oakFrom: string | undefined;
};
getPathname(pathname: string, namespace?: string): string;
private getUrlAndProps;

View File

@ -25,12 +25,7 @@ export class Navigator extends CommonNavigator {
getState() {
const { pathname, state } = this.getLocation();
const state2 = this.constructState(pathname, state);
return {
pathname: state2.pathname,
oakFrom: state2.oakFrom
? decodeURIComponent(state2.oakFrom)
: '',
};
return state2;
}
getPathname(pathname, namespace) {
if (!/^\/{1}/.test(pathname)) {

View File

@ -17,7 +17,7 @@ export declare class Navigator extends CommonNavigator {
};
getState(): {
pathname: string;
oakFrom: string;
oakFrom: string | undefined;
};
private getUrlAndProps;
navigateTo<ED extends EntityDict & BaseEntityDict, T2 extends keyof ED>(options: {

View File

@ -14,7 +14,7 @@ export declare class Navigator extends CommonNavigator {
getLocation(): import("history").Location;
getState(): {
pathname: string;
oakFrom: string;
oakFrom: string | undefined;
};
private getUrlAndProps;
navigateTo<ED extends EntityDict & BaseEntityDict, T2 extends keyof ED>(options: {

View File

@ -19,12 +19,7 @@ export class Navigator extends CommonNavigator {
getState() {
const { pathname, state, search } = this.getLocation();
const state2 = this.constructState(pathname, state, search);
return {
pathname: state2.pathname,
oakFrom: state2.oakFrom
? decodeURIComponent(state2.oakFrom)
: '',
};
return state2;
}
getUrlAndProps(options, state, disableNamespace) {
const { url, ...rest } = options;

View File

@ -10,7 +10,7 @@ export declare abstract class BackendRuntimeContext<ED extends EntityDict & Base
eventOperationMap: Record<string, string[]>;
getNavigatorState(): {
pathname: string;
oakFrom: string;
oakFrom?: string | undefined;
} | undefined;
getSubscriberId(): string | undefined;
getBriefEnvironment(): BriefEnv | undefined;

View File

@ -14,7 +14,7 @@ export type SerializedData = {
be?: BriefEnv;
ns?: {
pathname: string;
oakFrom: string;
oakFrom?: string;
};
};
export declare abstract class FrontendRuntimeContext<ED extends EntityDict & BaseEntityDict, Cxt extends AsyncContext<ED>, AD extends CommonAspectDict<ED, Cxt> & Record<string, Aspect<ED, Cxt>>> extends SyncContext<ED> {

View File

@ -10,7 +10,7 @@ export declare class Navigator extends Feature {
urlFormat(url: URL): string;
constructState(pathname: string, state?: Record<string, any>, search?: string): {
pathname: string;
oakFrom: string;
oakFrom: string | undefined;
};
constructSearch(search?: string | null, state?: Record<string, any>): string;
constructUrl(url: string, state?: Record<string, any>, disableNamespace?: boolean): string;

View File

@ -24,7 +24,8 @@ class Navigator extends Feature_1.Feature {
}
urlFormat(url) {
const urlParse = new url_1.url(url.toString(), this.base);
const url2 = urlParse.toString();
let url2 = urlParse.toString();
url2 = decodeURIComponent(url2);
return url2.replace(this.base, '');
}
constructState(pathname, state, search) {
@ -34,7 +35,7 @@ class Navigator extends Feature_1.Feature {
const oakFrom = searchParams.get('oakFrom');
return {
pathname,
oakFrom,
oakFrom: oakFrom ? decodeURIComponent(oakFrom) : undefined,
};
}
constructSearch(search, state) {
@ -49,7 +50,9 @@ class Navigator extends Feature_1.Feature {
}
}
}
return searchParams.toString();
let searchStr = searchParams.toString();
searchStr = decodeURIComponent(searchStr);
return searchStr;
}
constructUrl(url, state, disableNamespace) {
const urlParse = this.urlParse(url);

View File

@ -14,7 +14,7 @@ export declare class Navigator extends CommonNavigator {
getLocation(): Location;
getState(): {
pathname: string;
oakFrom: string;
oakFrom: string | undefined;
};
getPathname(pathname: string, namespace?: string): string;
private getUrlAndProps;

View File

@ -28,12 +28,7 @@ class Navigator extends navigator_common_1.Navigator {
getState() {
const { pathname, state } = this.getLocation();
const state2 = this.constructState(pathname, state);
return {
pathname: state2.pathname,
oakFrom: state2.oakFrom
? decodeURIComponent(state2.oakFrom)
: '',
};
return state2;
}
getPathname(pathname, namespace) {
if (!/^\/{1}/.test(pathname)) {

View File

@ -17,7 +17,7 @@ export declare class Navigator extends CommonNavigator {
};
getState(): {
pathname: string;
oakFrom: string;
oakFrom: string | undefined;
};
private getUrlAndProps;
navigateTo<ED extends EntityDict & BaseEntityDict, T2 extends keyof ED>(options: {

View File

@ -14,7 +14,7 @@ export declare class Navigator extends CommonNavigator {
getLocation(): import("history").Location;
getState(): {
pathname: string;
oakFrom: string;
oakFrom: string | undefined;
};
private getUrlAndProps;
navigateTo<ED extends EntityDict & BaseEntityDict, T2 extends keyof ED>(options: {

View File

@ -22,12 +22,7 @@ class Navigator extends navigator_common_1.Navigator {
getState() {
const { pathname, state, search } = this.getLocation();
const state2 = this.constructState(pathname, state, search);
return {
pathname: state2.pathname,
oakFrom: state2.oakFrom
? decodeURIComponent(state2.oakFrom)
: '',
};
return state2;
}
getUrlAndProps(options, state, disableNamespace) {
const { url, ...rest } = options;

View File

@ -9,7 +9,7 @@ export abstract class BackendRuntimeContext<ED extends EntityDict & BaseEntityDi
private be?: BriefEnv;
private ns?: {
pathname: string;
oakFrom: string;
oakFrom?: string;
}
// 本map中记录了要求推送event到客户端的operaion
eventOperationMap: Record<string, string[]> = {};

View File

@ -15,7 +15,7 @@ export type SerializedData = {
be?: BriefEnv;
ns?: {
pathname: string;
oakFrom: string;
oakFrom?: string;
};
};

View File

@ -1180,7 +1180,7 @@ class SingleNode<ED extends EntityDict & BaseEntityDict,
this.operation = {
id: generateNewId(),
action: this.id ? 'update' : 'create',
data: {}, getFilter
data: {},
}
}
super.setDirty();