pageheader2 根据路由判断当前是否菜单路径
This commit is contained in:
parent
5e279e953c
commit
954f3916fd
|
|
@ -1,9 +1,9 @@
|
||||||
export default OakComponent({
|
export default OakComponent({
|
||||||
isList: false,
|
isList: false,
|
||||||
data: {
|
data: {
|
||||||
slideWidth: 0,
|
slideWidth: 0, //小程序使用
|
||||||
slideLeft: 0,
|
slideLeft: 0, //小程序使用
|
||||||
slideShow: false,
|
slideShow: false, //小程序使用
|
||||||
commonAction: [
|
commonAction: [
|
||||||
'create',
|
'create',
|
||||||
'update',
|
'update',
|
||||||
|
|
|
||||||
|
|
@ -63,7 +63,7 @@ export default OakComponent({
|
||||||
let currentUrl = event.currentTarget.dataset.src;
|
let currentUrl = event.currentTarget.dataset.src;
|
||||||
let urlList = event.currentTarget.dataset.list;
|
let urlList = event.currentTarget.dataset.list;
|
||||||
wx.previewImage({
|
wx.previewImage({
|
||||||
current: currentUrl,
|
current: currentUrl, // 当前显示图片的http链接
|
||||||
urls: urlList, // 需要预览的图片http链接列表
|
urls: urlList, // 需要预览的图片http链接列表
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -90,7 +90,7 @@ export default OakComponent({
|
||||||
attribute: {},
|
attribute: {},
|
||||||
options: [],
|
options: [],
|
||||||
inputType: '',
|
inputType: '',
|
||||||
timeStartStr: '',
|
timeStartStr: '', // 小程序选择时间显示
|
||||||
timeEndStr: '',
|
timeEndStr: '',
|
||||||
selectedLabel: '',
|
selectedLabel: '',
|
||||||
minDateMp: new Date(1980, 1, 1).getTime(),
|
minDateMp: new Date(1980, 1, 1).getTime(),
|
||||||
|
|
|
||||||
|
|
@ -5,4 +5,16 @@ export default OakComponent({
|
||||||
this.navigateBack(delta);
|
this.navigateBack(delta);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
formData({ features }) {
|
||||||
|
const menus = features.contextMenuFactory.menus;
|
||||||
|
const namespace = features.navigator.getNamespace();
|
||||||
|
const location = features.navigator.getLocation();
|
||||||
|
const currentPath = location.pathname; //当前路由path
|
||||||
|
const allowBack = !menus?.find((ele) => features.navigator
|
||||||
|
.getPathname(ele.url || '', namespace)
|
||||||
|
?.toLocaleLowerCase() === currentPath?.toLocaleLowerCase());
|
||||||
|
return {
|
||||||
|
allowBack,
|
||||||
|
};
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ type PageHeaderProps = {
|
||||||
extra?: React.ReactNode;
|
extra?: React.ReactNode;
|
||||||
children?: React.ReactNode;
|
children?: React.ReactNode;
|
||||||
content?: React.ReactNode;
|
content?: React.ReactNode;
|
||||||
|
allowBack: boolean;
|
||||||
};
|
};
|
||||||
type ED = EntityDict & BaseEntityDict;
|
type ED = EntityDict & BaseEntityDict;
|
||||||
export default function Render(props: WebComponentProps<ED, keyof ED, false, PageHeaderProps, {
|
export default function Render(props: WebComponentProps<ED, keyof ED, false, PageHeaderProps, {
|
||||||
|
|
|
||||||
|
|
@ -4,18 +4,23 @@ import { ArrowLeftOutlined } from '@ant-design/icons';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import './index.less';
|
import './index.less';
|
||||||
export default function Render(props) {
|
export default function Render(props) {
|
||||||
const { style, className, showHeader = true, showBack = false, onBack, backIcon, delta, title, subTitle, extra, tags, children, content,
|
const { data, methods } = props;
|
||||||
|
const { style, className, showHeader = true, showBack = false, onBack, backIcon, delta, title, subTitle, extra, tags, children, content,
|
||||||
// contentStyle,
|
// contentStyle,
|
||||||
// contentClassName,
|
// contentClassName,
|
||||||
// bodyStyle,
|
// bodyStyle,
|
||||||
// bodyClassName,
|
// bodyClassName,
|
||||||
} = props.data;
|
allowBack = true, //state取
|
||||||
const { t, goBack } = props.methods;
|
} = data;
|
||||||
|
const { t, goBack } = methods;
|
||||||
const prefixCls = 'oak-new';
|
const prefixCls = 'oak-new';
|
||||||
|
const back = data.hasOwnProperty('showBack')
|
||||||
|
? showBack
|
||||||
|
: allowBack;
|
||||||
return (<div style={style} className={classNames(`${prefixCls}-pageHeader`, className)}>
|
return (<div style={style} className={classNames(`${prefixCls}-pageHeader`, className)}>
|
||||||
{showHeader && (title || showBack || subTitle || tags || extra) && (<div className={`${prefixCls}-pageHeader-header`}>
|
{showHeader && (title || back || subTitle || tags || extra) && (<div className={`${prefixCls}-pageHeader-header`}>
|
||||||
<div className={`${prefixCls}-pageHeader-header-left`}>
|
<div className={`${prefixCls}-pageHeader-header-left`}>
|
||||||
{showBack && (<Button type="text" className={`${prefixCls}-pageHeader-header-back`} onClick={() => {
|
{back && (<Button type="text" className={`${prefixCls}-pageHeader-header-back`} onClick={() => {
|
||||||
if (typeof onBack === 'function') {
|
if (typeof onBack === 'function') {
|
||||||
onBack();
|
onBack();
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ export default OakComponent({
|
||||||
multiple: false,
|
multiple: false,
|
||||||
entityId: '',
|
entityId: '',
|
||||||
entityIds: [],
|
entityIds: [],
|
||||||
pickerRender: {},
|
pickerRender: {}, // OakAbsRefAttrPickerRender
|
||||||
onChange: (() => undefined),
|
onChange: (() => undefined),
|
||||||
},
|
},
|
||||||
formData() {
|
formData() {
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ export default OakComponent({
|
||||||
return this.props.entity;
|
return this.props.entity;
|
||||||
},
|
},
|
||||||
properties: {
|
properties: {
|
||||||
helps: {},
|
helps: {}, // Record<string, string>;
|
||||||
entity: '',
|
entity: '',
|
||||||
attributes: [],
|
attributes: [],
|
||||||
layout: 'horizontal',
|
layout: 'horizontal',
|
||||||
|
|
|
||||||
|
|
@ -322,7 +322,7 @@ export class Cache extends Feature {
|
||||||
opers.forEach((oper) => {
|
opers.forEach((oper) => {
|
||||||
const { entity, operation } = oper;
|
const { entity, operation } = oper;
|
||||||
this.cacheStore.operate(entity, operation, this.context, {
|
this.cacheStore.operate(entity, operation, this.context, {
|
||||||
checkerTypes: ['logical'],
|
checkerTypes: ['logical'], // 这里不能检查data,不然在数据没填完前会有大量异常
|
||||||
dontCollect: true,
|
dontCollect: true,
|
||||||
dontCreateOper: true,
|
dontCreateOper: true,
|
||||||
dontCreateModi: true,
|
dontCreateModi: true,
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ interface IMenu<ED extends EntityDict & BaseEntityDict, T extends keyof ED> {
|
||||||
entity: T;
|
entity: T;
|
||||||
action: ED[T]['Action'] | ED[T]['Action'][];
|
action: ED[T]['Action'] | ED[T]['Action'][];
|
||||||
paths: string[];
|
paths: string[];
|
||||||
|
url?: string;
|
||||||
}
|
}
|
||||||
export declare class ContextMenuFactory<ED extends EntityDict & BaseEntityDict, Cxt extends AsyncContext<ED>, FrontCxt extends SyncContext<ED>, AD extends CommonAspectDict<ED, Cxt> & Record<string, Aspect<ED, Cxt>>> extends Feature {
|
export declare class ContextMenuFactory<ED extends EntityDict & BaseEntityDict, Cxt extends AsyncContext<ED>, FrontCxt extends SyncContext<ED>, AD extends CommonAspectDict<ED, Cxt> & Record<string, Aspect<ED, Cxt>>> extends Feature {
|
||||||
cache: Cache<ED, Cxt, FrontCxt, AD>;
|
cache: Cache<ED, Cxt, FrontCxt, AD>;
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
export const keys = ['xs', 'sm', 'md', 'lg', 'xl', 'xxl'];
|
export const keys = ['xs', 'sm', 'md', 'lg', 'xl', 'xxl'];
|
||||||
export const values = {
|
export const values = {
|
||||||
xs: 576,
|
xs: 576, //小于576
|
||||||
sm: 576,
|
sm: 576,
|
||||||
md: 768,
|
md: 768,
|
||||||
lg: 992,
|
lg: 992,
|
||||||
|
|
|
||||||
|
|
@ -325,7 +325,7 @@ class Cache extends Feature_1.Feature {
|
||||||
opers.forEach((oper) => {
|
opers.forEach((oper) => {
|
||||||
const { entity, operation } = oper;
|
const { entity, operation } = oper;
|
||||||
this.cacheStore.operate(entity, operation, this.context, {
|
this.cacheStore.operate(entity, operation, this.context, {
|
||||||
checkerTypes: ['logical'],
|
checkerTypes: ['logical'], // 这里不能检查data,不然在数据没填完前会有大量异常
|
||||||
dontCollect: true,
|
dontCollect: true,
|
||||||
dontCreateOper: true,
|
dontCreateOper: true,
|
||||||
dontCreateModi: true,
|
dontCreateModi: true,
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ interface IMenu<ED extends EntityDict & BaseEntityDict, T extends keyof ED> {
|
||||||
entity: T;
|
entity: T;
|
||||||
action: ED[T]['Action'] | ED[T]['Action'][];
|
action: ED[T]['Action'] | ED[T]['Action'][];
|
||||||
paths: string[];
|
paths: string[];
|
||||||
|
url?: string;
|
||||||
}
|
}
|
||||||
export declare class ContextMenuFactory<ED extends EntityDict & BaseEntityDict, Cxt extends AsyncContext<ED>, FrontCxt extends SyncContext<ED>, AD extends CommonAspectDict<ED, Cxt> & Record<string, Aspect<ED, Cxt>>> extends Feature {
|
export declare class ContextMenuFactory<ED extends EntityDict & BaseEntityDict, Cxt extends AsyncContext<ED>, FrontCxt extends SyncContext<ED>, AD extends CommonAspectDict<ED, Cxt> & Record<string, Aspect<ED, Cxt>>> extends Feature {
|
||||||
cache: Cache<ED, Cxt, FrontCxt, AD>;
|
cache: Cache<ED, Cxt, FrontCxt, AD>;
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ const tslib_1 = require("tslib");
|
||||||
const react_1 = tslib_1.__importDefault(require("react"));
|
const react_1 = tslib_1.__importDefault(require("react"));
|
||||||
exports.keys = ['xs', 'sm', 'md', 'lg', 'xl', 'xxl'];
|
exports.keys = ['xs', 'sm', 'md', 'lg', 'xl', 'xxl'];
|
||||||
exports.values = {
|
exports.values = {
|
||||||
xs: 576,
|
xs: 576, //小于576
|
||||||
sm: 576,
|
sm: 576,
|
||||||
md: 768,
|
md: 768,
|
||||||
lg: 992,
|
lg: 992,
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,23 @@ export default OakComponent({
|
||||||
this.navigateBack(delta);
|
this.navigateBack(delta);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
formData({ features }) {
|
||||||
|
const menus = features.contextMenuFactory.menus;
|
||||||
|
const namespace = features.navigator.getNamespace();
|
||||||
|
|
||||||
|
const location = features.navigator.getLocation();
|
||||||
|
const currentPath = location.pathname; //当前路由path
|
||||||
|
const allowBack = !menus?.find(
|
||||||
|
(ele) =>
|
||||||
|
features.navigator
|
||||||
|
.getPathname(ele.url || '', namespace)
|
||||||
|
?.toLocaleLowerCase() === currentPath?.toLocaleLowerCase()
|
||||||
|
);
|
||||||
|
|
||||||
|
return {
|
||||||
|
allowBack,
|
||||||
|
};
|
||||||
|
}
|
||||||
}) as <ED2 extends EntityDict & BaseEntityDict, T2 extends keyof ED2>(
|
}) as <ED2 extends EntityDict & BaseEntityDict, T2 extends keyof ED2>(
|
||||||
props: ReactComponentProps<
|
props: ReactComponentProps<
|
||||||
ED2,
|
ED2,
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,8 @@ type PageHeaderProps = {
|
||||||
// contentClassName?: string;
|
// contentClassName?: string;
|
||||||
// bodyStyle?: React.ReactNode;
|
// bodyStyle?: React.ReactNode;
|
||||||
// bodyClassName?: string;
|
// bodyClassName?: string;
|
||||||
|
|
||||||
|
allowBack: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
type ED = EntityDict & BaseEntityDict;
|
type ED = EntityDict & BaseEntityDict;
|
||||||
|
|
@ -42,6 +44,7 @@ export default function Render(
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
) {
|
) {
|
||||||
|
const { data, methods } = props;
|
||||||
const {
|
const {
|
||||||
style,
|
style,
|
||||||
className,
|
className,
|
||||||
|
|
@ -61,19 +64,23 @@ export default function Render(
|
||||||
// contentClassName,
|
// contentClassName,
|
||||||
// bodyStyle,
|
// bodyStyle,
|
||||||
// bodyClassName,
|
// bodyClassName,
|
||||||
} = props.data;
|
allowBack = true, //state取
|
||||||
const { t, goBack } = props.methods;
|
} = data;
|
||||||
|
const { t, goBack } = methods;
|
||||||
const prefixCls = 'oak-new';
|
const prefixCls = 'oak-new';
|
||||||
|
const back = data.hasOwnProperty('showBack')
|
||||||
|
? showBack
|
||||||
|
: allowBack;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
style={style}
|
style={style}
|
||||||
className={classNames(`${prefixCls}-pageHeader`, className)}
|
className={classNames(`${prefixCls}-pageHeader`, className)}
|
||||||
>
|
>
|
||||||
{showHeader && (title || showBack || subTitle || tags || extra) && (
|
{showHeader && (title || back || subTitle || tags || extra) && (
|
||||||
<div className={`${prefixCls}-pageHeader-header`}>
|
<div className={`${prefixCls}-pageHeader-header`}>
|
||||||
<div className={`${prefixCls}-pageHeader-header-left`}>
|
<div className={`${prefixCls}-pageHeader-header-left`}>
|
||||||
{showBack && (
|
{back && (
|
||||||
<Button
|
<Button
|
||||||
type="text"
|
type="text"
|
||||||
className={`${prefixCls}-pageHeader-header-back`}
|
className={`${prefixCls}-pageHeader-header-back`}
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@ interface IMenu<ED extends EntityDict & BaseEntityDict, T extends keyof ED> {
|
||||||
entity: T;
|
entity: T;
|
||||||
action: ED[T]['Action'] | ED[T]['Action'][];
|
action: ED[T]['Action'] | ED[T]['Action'][];
|
||||||
paths: string[];
|
paths: string[];
|
||||||
|
url?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export class ContextMenuFactory<
|
export class ContextMenuFactory<
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue