目录滚动observer容错
This commit is contained in:
parent
5f9de0de10
commit
122e868b52
|
|
@ -168,8 +168,10 @@ export function TocView(props) {
|
|||
rootMargin: '0px 0px -75% 0px',
|
||||
});
|
||||
// 开始观察所有内容区块
|
||||
sections.forEach(section => {
|
||||
observer.observe(section);
|
||||
sections?.forEach(section => {
|
||||
if (section) {
|
||||
observer.observe(section);
|
||||
}
|
||||
});
|
||||
return () => {
|
||||
if (tocContainer) {
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ export default OakComponent({
|
|||
breadcrumbItems: [],
|
||||
showAddArticle: false,
|
||||
showAddMenu: true,
|
||||
parentId: undefined,
|
||||
parentId: '',
|
||||
articleMenuId: '', //非空时展示atricle表格
|
||||
unsub: undefined,
|
||||
},
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ export default function Render(props) {
|
|||
<div className={Styles.header}>
|
||||
<Breadcrumb items={breadcrumbItems} itemRender={itemRender} separator=">"/>
|
||||
<Space>
|
||||
{!!showAddArticle && (<Button key="article" type="primary" icon={<PlusOutlined />} onClick={() => onAddArticle()}>{t('addArticle')}</Button>)}
|
||||
{(!!showAddArticle && !(parentId === '' && articleMenuId === '')) && (<Button key="article" type="primary" icon={<PlusOutlined />} onClick={() => onAddArticle()}>{t('addArticle')}</Button>)}
|
||||
{!!showAddMenu && (<Button key="menu" type="primary" icon={<PlusOutlined />} onClick={() => setAddMenuOpen(true)}>{t('addMenu')}</Button>)}
|
||||
</Space>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
import { GenerateUrlFn } from "../../../types/Article";
|
||||
declare const _default: (props: import("oak-frontend-base").ReactComponentProps<import("../../../oak-app-domain").EntityDict, "articleMenu", true, {
|
||||
entity: string;
|
||||
entityId: string;
|
||||
|
|
@ -7,6 +8,6 @@ declare const _default: (props: import("oak-frontend-base").ReactComponentProps<
|
|||
onArticleClick: (atricleId: string) => void;
|
||||
empty: React.ReactNode | undefined;
|
||||
changeAddArticle: (show: boolean) => void;
|
||||
generateUrl: (mode: "article" | "menu", type: "detail" | "editor" | "preview" | "create", id: string) => string;
|
||||
generateUrl: GenerateUrlFn;
|
||||
}>) => React.ReactElement;
|
||||
export default _default;
|
||||
|
|
|
|||
|
|
@ -98,7 +98,7 @@ export default OakComponent({
|
|||
onArticleClick: (atricleId) => undefined,
|
||||
empty: undefined,
|
||||
changeAddArticle: (show) => undefined,
|
||||
generateUrl: (mode, type, id) => undefined,
|
||||
generateUrl: ((mode, type, id) => { }),
|
||||
},
|
||||
listeners: {
|
||||
'entity,entityId,parentId'(prev, next) {
|
||||
|
|
|
|||
|
|
@ -248,8 +248,10 @@ export function TocView(
|
|||
});
|
||||
|
||||
// 开始观察所有内容区块
|
||||
sections.forEach(section => {
|
||||
observer.observe(section);
|
||||
sections?.forEach(section => {
|
||||
if (section) {
|
||||
observer.observe(section);
|
||||
}
|
||||
});
|
||||
|
||||
return () => {
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ export default OakComponent({
|
|||
}[],
|
||||
showAddArticle: false,
|
||||
showAddMenu: true,
|
||||
parentId: undefined as string | undefined,
|
||||
parentId: '',
|
||||
articleMenuId: '', //非空时展示atricle表格
|
||||
unsub: undefined as undefined | (() => void),
|
||||
},
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ export default function Render(
|
|||
onAddMenu: (menuName: string) => Promise<boolean>;
|
||||
changeAddArticle: (show: boolean) => void;
|
||||
onAddArticle: () => void;
|
||||
menuCheck:(isArticle: boolean) =>void;
|
||||
menuCheck: (isArticle: boolean) => void;
|
||||
}
|
||||
>
|
||||
) {
|
||||
|
|
@ -44,7 +44,7 @@ export default function Render(
|
|||
const { oakFullpath, oakLoading, oakExecuting, entity, entityId, title, breadcrumbItems, origin = 'qiniu', menuEmpty, articleEmpty, parentId, articleMenuId, showAddArticle, showAddMenu,
|
||||
generateUrl,
|
||||
} = data;
|
||||
const { t, onBreadcrumItemClick, onMenuClick, onAddMenu, changeAddArticle, onAddArticle, menuCheck } = methods;
|
||||
const { t, onBreadcrumItemClick, onMenuClick, onAddMenu, changeAddArticle, onAddArticle, menuCheck } = methods;
|
||||
|
||||
const [addMenuOpen, setAddMenuOpen] = useState(false);
|
||||
|
||||
|
|
@ -66,7 +66,7 @@ export default function Render(
|
|||
separator=">"
|
||||
/>
|
||||
<Space>
|
||||
{!!showAddArticle && (
|
||||
{(!!showAddArticle && !(parentId === '' && articleMenuId === '')) && (
|
||||
<Button key="article" type="primary" icon={<PlusOutlined />} onClick={() => onAddArticle()}>{t('addArticle')}</Button>
|
||||
)}
|
||||
{!!showAddMenu && (
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
import dayjs from "dayjs";
|
||||
import copy from 'copy-to-clipboard';
|
||||
import { DATA_SUBSCRIBER_KEYS } from "../../../config/constants";
|
||||
import { GenerateUrlFn, Mode, Action } from "../../../types/Article";
|
||||
|
||||
export default OakComponent({
|
||||
entity: 'articleMenu',
|
||||
|
|
@ -101,7 +102,7 @@ export default OakComponent({
|
|||
onArticleClick: (atricleId: string) => undefined as void,
|
||||
empty: undefined as React.ReactNode | undefined,
|
||||
changeAddArticle: (show: boolean) => undefined as void,
|
||||
generateUrl: (mode: 'article' | 'menu', type: 'detail' | 'editor' | 'preview' | 'create', id: string) => undefined as unknown as string,
|
||||
generateUrl: ((mode: Mode, type: Action, id: string) => {}) as GenerateUrlFn,
|
||||
},
|
||||
listeners: {
|
||||
'entity,entityId,parentId'(prev, next) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue