@fle-ui/plus-goods-detail-drawer
Version:
@fle-ui/plus-goods-detail-drawer
58 lines • 1.67 kB
JavaScript
import "antd/es/anchor/style";
import _Anchor from "antd/es/anchor";
import React from 'react';
var AnchorNavigation = function AnchorNavigation(_ref) {
var goodsData = _ref.goodsData,
bounds = _ref.bounds,
_ref$hideFields = _ref.hideFields,
hideFields = _ref$hideFields === void 0 ? [] : _ref$hideFields;
if (!goodsData) return null;
var anchorItems = [{
key: 'sales-type',
href: '#sales-type',
title: '销售类型',
show: !hideFields.includes('salesType')
}, {
key: 'basic-info',
href: '#basic-info',
title: '基本信息',
show: !hideFields.includes('basicInfo')
}, {
key: 'sales-info',
href: '#sales-info',
title: '销售信息',
show: !hideFields.includes('salesInfo')
}, {
key: 'logistics-info',
href: '#logistics-info',
title: '物流信息',
show: !hideFields.includes('freightInfo')
}, {
key: 'goods-detail',
href: '#goods-detail',
title: '商品详情',
show: !hideFields.includes('goodsDetail')
}].filter(function (item) {
return item.show;
});
return /*#__PURE__*/React.createElement("div", {
className: "anchor-navigation"
}, /*#__PURE__*/React.createElement(_Anchor, {
key: "anchor-".concat(bounds) // 使用 key 强制重新渲染
,
bounds: bounds,
targetOffset: 40,
direction: "horizontal",
getContainer: function getContainer() {
return document.getElementsByClassName('goods-detail-drawer-body')[0];
},
items: anchorItems.map(function (item) {
return {
key: item.key,
href: item.href,
title: item.title
};
})
}));
};
export default AnchorNavigation;