@chaoswise/business 0.0.11 → 0.0.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  import _Watermark from "@chaoswise/ui/lib/Watermark";
2
2
  import _message from "@chaoswise/ui/lib/message";
3
- var _excluded = ["type", "fetchWatermark", "densityConfig"];
3
+ var _excluded = ["type", "fetchWatermark", "densityConfig", "children"];
4
4
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
5
5
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
6
6
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
@@ -17,10 +17,9 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
17
17
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
18
18
  function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
19
19
  function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
20
- import React, { useEffect, useState, useRef, useCallback } from "react";
20
+ import React, { useEffect, useState, useRef, useCallback, useMemo } from "react";
21
21
  import PropTypes from "prop-types";
22
22
  import moment from "moment";
23
- import { fetchGet } from "@chaoswise/request";
24
23
  import "./index.less";
25
24
 
26
25
  // 疏密类型
@@ -46,7 +45,9 @@ var WatermarkCom = function WatermarkCom(_ref) {
46
45
  return _regeneratorRuntime().wrap(function _callee$(_context) {
47
46
  while (1) switch (_context.prev = _context.next) {
48
47
  case 0:
49
- return _context.abrupt("return", fetchGet("/docp/gateway/douc/api/v1/watermark/query").then(function (res) {
48
+ return _context.abrupt("return", fetch("/docp/gateway/douc/api/v1/watermark/query").then(function (res) {
49
+ return res.json();
50
+ }).then(function (res) {
50
51
  if (res && res.code === 100000) {
51
52
  return res.data;
52
53
  } else {
@@ -63,9 +64,12 @@ var WatermarkCom = function WatermarkCom(_ref) {
63
64
  })) : _ref$fetchWatermark,
64
65
  _ref$densityConfig = _ref.densityConfig,
65
66
  densityConfig = _ref$densityConfig === void 0 ? {} : _ref$densityConfig,
67
+ children = _ref.children,
66
68
  rest = _objectWithoutProperties(_ref, _excluded);
67
69
  var watermarkRef = useRef();
68
- var _useState = useState(false),
70
+
71
+ // 默认为 false 的话,刷新页面会有bug
72
+ var _useState = useState(true),
69
73
  _useState2 = _slicedToArray(_useState, 2),
70
74
  visible = _useState2[0],
71
75
  setVisible = _useState2[1];
@@ -141,7 +145,7 @@ var WatermarkCom = function WatermarkCom(_ref) {
141
145
  }
142
146
  }, []);
143
147
  useEffect(function () {
144
- if (!visible) {
148
+ if (!visible || children) {
145
149
  return;
146
150
  }
147
151
  watermarkRef.current && document.body.append(watermarkRef.current);
@@ -150,11 +154,20 @@ var WatermarkCom = function WatermarkCom(_ref) {
150
154
  return function () {
151
155
  watermarkRef.current && watermarkRef.current.remove();
152
156
  };
153
- }, [visible]);
154
- return /*#__PURE__*/React.createElement("div", {
155
- ref: targetRef,
156
- className: visible ? "portal-watermark" : "portal-watermark-hidden"
157
- }, /*#__PURE__*/React.createElement(_Watermark, _extends({}, watermarkProps, rest)));
157
+ }, [visible, children]);
158
+ function renderWatermark() {
159
+ if (children) {
160
+ return visible ? /*#__PURE__*/React.createElement(_Watermark, _extends({}, watermarkProps, rest, {
161
+ zIndex: 10000
162
+ }), children) : children;
163
+ } else {
164
+ return /*#__PURE__*/React.createElement("div", {
165
+ ref: targetRef,
166
+ className: visible ? "portal-watermark" : "portal-watermark-hidden"
167
+ }, /*#__PURE__*/React.createElement(_Watermark, _extends({}, watermarkProps, rest)));
168
+ }
169
+ }
170
+ return renderWatermark();
158
171
  };
159
172
  WatermarkCom.propTypes = {
160
173
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chaoswise/business",
3
- "version": "0.0.11",
3
+ "version": "0.0.13",
4
4
  "description": "业务组件库",
5
5
  "keywords": [
6
6
  "ui",
@@ -105,5 +105,5 @@
105
105
  "access": "public"
106
106
  },
107
107
  "license": "MIT",
108
- "gitHead": "60181c1fdb22f05a1d323960462760a08c4769c0"
108
+ "gitHead": "1121ba93642b5739af19ea1fcec86a737d5655d4"
109
109
  }