@jay.kou/rak-ssr
Version:
A react based UI components for admin system
50 lines (48 loc) • 1.65 kB
JavaScript
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
var _excluded = ["type"];
import { delGlobal } from "../utils";
import BaseTreeSelect from "./BaseTreeSelect";
import { jsx as _jsx } from "react/jsx-runtime";
/**
* 数据挂在window上作为缓存, 避免重复请求
*/
export var CacheName = '@@treeSelectData';
export var CacheStatusName = '@@treeSelectDataIsStart';
function BusinessTreeSelectBuilder(_ref) {
var _ref$apis = _ref.apis,
apis = _ref$apis === void 0 ? [] : _ref$apis,
_ref$defaultProps = _ref.defaultProps,
defaultProps = _ref$defaultProps === void 0 ? {} : _ref$defaultProps;
return function (props) {
var type = props.type,
rest = _objectWithoutProperties(props, _excluded);
var target = apis.find(function (item) {
return item.type === type;
});
if (!target) return null;
return /*#__PURE__*/_jsx(BaseTreeSelect, _objectSpread(_objectSpread(_objectSpread({
type: type
}, defaultProps), target.defaultProps || {}), {}, {
loadFunction: target.api
}, rest));
};
}
export default BusinessTreeSelectBuilder;
export var clearTreeSelectCache = function clearTreeSelectCache(type) {
if (type) {
delGlobal(CacheName, type);
delGlobal(CacheStatusName, type);
} else {
delGlobal(CacheName);
delGlobal(CacheStatusName);
}
};
// 用于生成api文档
export var BizTreeApi = function BizTreeApi() {
return null;
};
// 用于生成api文档
export var BusinessTreeSelectSelf = function BusinessTreeSelectSelf() {
return null;
};