venus-design 0.2.4 → 0.2.7

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.
@@ -6,7 +6,7 @@ export declare const getRouteMap: () => any;
6
6
  export declare function checkPathname(pathname: string): boolean;
7
7
  export declare const AddButtonNew: (props: any) => React.JSX.Element | null;
8
8
  export declare const EditButton: (props: any) => React.JSX.Element | null;
9
- export declare const ADDButtona: (props: any) => React.JSX.Element | null;
9
+ export declare const ADDButtona: (props: any) => Promise<React.JSX.Element | null>;
10
10
  export declare const DetailButton: (props: any) => React.JSX.Element | null;
11
11
  export declare const CommonButton: (props: any) => React.JSX.Element | null;
12
12
  export declare const ButtonPath: (props: any) => React.JSX.Element | null;
@@ -1,24 +1,72 @@
1
+ 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); }
1
2
  import "antd/es/button/style";
2
3
  import _Button from "antd/es/button";
3
4
  var _excluded = ["pathname", "callback"],
4
5
  _excluded2 = ["pathname", "callback"],
5
6
  _excluded3 = ["btnname", "btnicon", "pathname", "callback"],
6
- _excluded4 = ["pathname", "callback"];
7
+ _excluded4 = ["pathname", "callback"],
8
+ _excluded5 = ["pathname", "callback"];
7
9
  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); }
8
10
  function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
9
11
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
10
- import React from 'react';
11
- import { getUmi } from "./..";
12
+ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
13
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
14
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
15
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
16
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
17
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
18
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
19
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
20
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
21
+ import React, { useEffect, useState } from 'react';
22
+ import { useUmi } from "./..";
12
23
  import { PlusOutlined } from '@ant-design/icons';
13
24
  import { StyleProvider, legacyLogicalPropertiesTransformer } from "@ant-design/cssinjs";
14
- var _getUmi = getUmi(),
15
- getDvaApp = _getUmi.getDvaApp,
16
- Link = _getUmi.Link;
25
+
17
26
  /**
18
27
  * 获取数据对象
19
28
  */
20
29
  export var getRouteMap = function getRouteMap() {
21
- var instance = getDvaApp ? getDvaApp() : {
30
+ var _useState = useState(null),
31
+ _useState2 = _slicedToArray(_useState, 2),
32
+ umiData = _useState2[0],
33
+ setUmi = _useState2[1];
34
+ // 使用 useUmi 获取 Umi 模块中的 Link 组件
35
+ useEffect(function () {
36
+ var loadUmiLink = /*#__PURE__*/function () {
37
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
38
+ var umiModule;
39
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
40
+ while (1) switch (_context.prev = _context.next) {
41
+ case 0:
42
+ _context.prev = 0;
43
+ _context.next = 3;
44
+ return useUmi();
45
+ case 3:
46
+ umiModule = _context.sent;
47
+ if (umiModule) {
48
+ setUmi(umiModule);
49
+ }
50
+ _context.next = 10;
51
+ break;
52
+ case 7:
53
+ _context.prev = 7;
54
+ _context.t0 = _context["catch"](0);
55
+ console.warn('加载 Umi Link 失败,使用 React Router Link 作为备用:', _context.t0);
56
+ case 10:
57
+ case "end":
58
+ return _context.stop();
59
+ }
60
+ }, _callee, null, [[0, 7]]);
61
+ }));
62
+ return function loadUmiLink() {
63
+ return _ref.apply(this, arguments);
64
+ };
65
+ }();
66
+ loadUmiLink();
67
+ }, []); // 依赖数组为空,只在组件挂载时执行一次
68
+ //@ts-ignore
69
+ var instance = umiData && umiData.getDvaApp ? umiData.getDvaApp() : {
22
70
  _store: {
23
71
  getState: function getState() {}
24
72
  }
@@ -45,6 +93,47 @@ export var AddButtonNew = function AddButtonNew(props) {
45
93
  var pathname = props.pathname,
46
94
  callback = props.callback,
47
95
  others = _objectWithoutProperties(props, _excluded);
96
+ var _useState3 = useState(null),
97
+ _useState4 = _slicedToArray(_useState3, 2),
98
+ LinkComponent = _useState4[0],
99
+ setLinkComponent = _useState4[1];
100
+
101
+ // 使用 useUmi 获取 Umi 模块中的 Link 组件
102
+ useEffect(function () {
103
+ var loadUmiLink = /*#__PURE__*/function () {
104
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
105
+ var umiModule;
106
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
107
+ while (1) switch (_context2.prev = _context2.next) {
108
+ case 0:
109
+ _context2.prev = 0;
110
+ _context2.next = 3;
111
+ return useUmi();
112
+ case 3:
113
+ umiModule = _context2.sent;
114
+ //@ts-ignore
115
+ if (umiModule && umiModule.Link) {
116
+ //@ts-ignore
117
+ setLinkComponent(umiModule.Link);
118
+ }
119
+ _context2.next = 10;
120
+ break;
121
+ case 7:
122
+ _context2.prev = 7;
123
+ _context2.t0 = _context2["catch"](0);
124
+ console.warn('加载 Umi Link 失败,使用 React Router Link 作为备用:', _context2.t0);
125
+ case 10:
126
+ case "end":
127
+ return _context2.stop();
128
+ }
129
+ }, _callee2, null, [[0, 7]]);
130
+ }));
131
+ return function loadUmiLink() {
132
+ return _ref2.apply(this, arguments);
133
+ };
134
+ }();
135
+ loadUmiLink();
136
+ }, []); // 依赖数组为空,只在组件挂载时执行一次
48
137
  if (!checkPathname(pathname)) return null;
49
138
  var buttonNode = /*#__PURE__*/React.createElement(StyleProvider, {
50
139
  hashPriority: "high",
@@ -58,7 +147,7 @@ export var AddButtonNew = function AddButtonNew(props) {
58
147
  return callback && callback();
59
148
  }
60
149
  }, others), props.children || '新增'));
61
- if (!callback) {
150
+ if (!callback && LinkComponent) {
62
151
  var searchParams = "?";
63
152
  // 如果others不为空,则将others中参数转变为url参数赋值给searchParams
64
153
  if (props.otherParams) {
@@ -66,7 +155,7 @@ export var AddButtonNew = function AddButtonNew(props) {
66
155
  searchParams += key + "=" + props.otherParams[key] + "&";
67
156
  }
68
157
  }
69
- return /*#__PURE__*/React.createElement(Link, {
158
+ return /*#__PURE__*/React.createElement(LinkComponent, {
70
159
  to: {
71
160
  pathname: pathname,
72
161
  search: searchParams
@@ -78,9 +167,49 @@ export var AddButtonNew = function AddButtonNew(props) {
78
167
  export var EditButton = function EditButton(props) {
79
168
  var pathname = props.pathname,
80
169
  callback = props.callback;
170
+ var _useState5 = useState(null),
171
+ _useState6 = _slicedToArray(_useState5, 2),
172
+ LinkComponent = _useState6[0],
173
+ setLinkComponent = _useState6[1];
174
+ // 使用 useUmi 获取 Umi 模块中的 Link 组件
175
+ useEffect(function () {
176
+ var loadUmiLink = /*#__PURE__*/function () {
177
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
178
+ var umiModule;
179
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
180
+ while (1) switch (_context3.prev = _context3.next) {
181
+ case 0:
182
+ _context3.prev = 0;
183
+ _context3.next = 3;
184
+ return useUmi();
185
+ case 3:
186
+ umiModule = _context3.sent;
187
+ //@ts-ignore
188
+ if (umiModule && umiModule.Link) {
189
+ //@ts-ignore
190
+ setLinkComponent(umiModule.Link);
191
+ }
192
+ _context3.next = 10;
193
+ break;
194
+ case 7:
195
+ _context3.prev = 7;
196
+ _context3.t0 = _context3["catch"](0);
197
+ console.warn('加载 Umi Link 失败,使用 React Router Link 作为备用:', _context3.t0);
198
+ case 10:
199
+ case "end":
200
+ return _context3.stop();
201
+ }
202
+ }, _callee3, null, [[0, 7]]);
203
+ }));
204
+ return function loadUmiLink() {
205
+ return _ref3.apply(this, arguments);
206
+ };
207
+ }();
208
+ loadUmiLink();
209
+ }, []); // 依赖数组为空,只在组件挂载时执行一次
81
210
  if (!checkPathname(pathname)) return null;
82
- if (!callback) {
83
- return /*#__PURE__*/React.createElement(Link, {
211
+ if (!callback && LinkComponent) {
212
+ return /*#__PURE__*/React.createElement(LinkComponent, {
84
213
  to: pathname
85
214
  }, props.children || '编辑');
86
215
  }
@@ -90,28 +219,125 @@ export var EditButton = function EditButton(props) {
90
219
  }
91
220
  }, props.children || '编辑');
92
221
  };
93
- export var ADDButtona = function ADDButtona(props) {
94
- var pathname = props.pathname,
95
- callback = props.callback;
96
- if (!checkPathname(pathname)) return null;
97
- if (!callback) {
98
- return /*#__PURE__*/React.createElement(Link, {
99
- to: pathname
100
- }, props.children || '新增 ');
101
- }
102
- return /*#__PURE__*/React.createElement("a", {
103
- onClick: function onClick() {
104
- return callback && callback();
105
- }
106
- }, props.children || '新增 ');
107
- };
222
+ export var ADDButtona = /*#__PURE__*/function () {
223
+ var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(props) {
224
+ var pathname, callback, _useState7, _useState8, LinkComponent, setLinkComponent;
225
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
226
+ while (1) switch (_context5.prev = _context5.next) {
227
+ case 0:
228
+ pathname = props.pathname, callback = props.callback;
229
+ _useState7 = useState(null), _useState8 = _slicedToArray(_useState7, 2), LinkComponent = _useState8[0], setLinkComponent = _useState8[1]; // 使用 useUmi 获取 Umi 模块中的 Link 组件
230
+ useEffect(function () {
231
+ var loadUmiLink = /*#__PURE__*/function () {
232
+ var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
233
+ var umiModule;
234
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
235
+ while (1) switch (_context4.prev = _context4.next) {
236
+ case 0:
237
+ _context4.prev = 0;
238
+ _context4.next = 3;
239
+ return useUmi();
240
+ case 3:
241
+ umiModule = _context4.sent;
242
+ //@ts-ignore
243
+ if (umiModule && umiModule.Link) {
244
+ //@ts-ignore
245
+ setLinkComponent(umiModule.Link);
246
+ }
247
+ _context4.next = 10;
248
+ break;
249
+ case 7:
250
+ _context4.prev = 7;
251
+ _context4.t0 = _context4["catch"](0);
252
+ console.warn('加载 Umi Link 失败,使用 React Router Link 作为备用:', _context4.t0);
253
+ case 10:
254
+ case "end":
255
+ return _context4.stop();
256
+ }
257
+ }, _callee4, null, [[0, 7]]);
258
+ }));
259
+ return function loadUmiLink() {
260
+ return _ref5.apply(this, arguments);
261
+ };
262
+ }();
263
+ loadUmiLink();
264
+ }, []); // 依赖数组为空,只在组件挂载时执行一次
265
+ if (checkPathname(pathname)) {
266
+ _context5.next = 5;
267
+ break;
268
+ }
269
+ return _context5.abrupt("return", null);
270
+ case 5:
271
+ if (!(!callback && LinkComponent)) {
272
+ _context5.next = 7;
273
+ break;
274
+ }
275
+ return _context5.abrupt("return", /*#__PURE__*/React.createElement(LinkComponent, {
276
+ to: pathname
277
+ }, props.children || '新增 '));
278
+ case 7:
279
+ return _context5.abrupt("return", /*#__PURE__*/React.createElement("a", {
280
+ onClick: function onClick() {
281
+ return callback && callback();
282
+ }
283
+ }, props.children || '新增 '));
284
+ case 8:
285
+ case "end":
286
+ return _context5.stop();
287
+ }
288
+ }, _callee5);
289
+ }));
290
+ return function ADDButtona(_x) {
291
+ return _ref4.apply(this, arguments);
292
+ };
293
+ }();
108
294
  export var DetailButton = function DetailButton(props) {
109
295
  var pathname = props.pathname,
110
296
  callback = props.callback,
111
297
  others = _objectWithoutProperties(props, _excluded2);
298
+ var _useState9 = useState(null),
299
+ _useState10 = _slicedToArray(_useState9, 2),
300
+ LinkComponent = _useState10[0],
301
+ setLinkComponent = _useState10[1];
302
+ // 使用 useUmi 获取 Umi 模块中的 Link 组件
303
+ useEffect(function () {
304
+ var loadUmiLink = /*#__PURE__*/function () {
305
+ var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
306
+ var umiModule;
307
+ return _regeneratorRuntime().wrap(function _callee6$(_context6) {
308
+ while (1) switch (_context6.prev = _context6.next) {
309
+ case 0:
310
+ _context6.prev = 0;
311
+ _context6.next = 3;
312
+ return useUmi();
313
+ case 3:
314
+ umiModule = _context6.sent;
315
+ //@ts-ignore
316
+ if (umiModule && umiModule.Link) {
317
+ //@ts-ignore
318
+ setLinkComponent(umiModule.Link);
319
+ }
320
+ _context6.next = 10;
321
+ break;
322
+ case 7:
323
+ _context6.prev = 7;
324
+ _context6.t0 = _context6["catch"](0);
325
+ console.warn('加载 Umi Link 失败,使用 React Router Link 作为备用:', _context6.t0);
326
+ case 10:
327
+ case "end":
328
+ return _context6.stop();
329
+ }
330
+ }, _callee6, null, [[0, 7]]);
331
+ }));
332
+ return function loadUmiLink() {
333
+ return _ref6.apply(this, arguments);
334
+ };
335
+ }();
336
+ loadUmiLink();
337
+ }, []); // 依赖数组为空,只在组件挂载时执行一次
112
338
  if (!checkPathname(pathname)) return null;
113
- if (!callback) {
114
- return /*#__PURE__*/React.createElement(Link, {
339
+ if (!callback && LinkComponent) {
340
+ return /*#__PURE__*/React.createElement(LinkComponent, {
115
341
  to: pathname
116
342
  }, props.children || '查看');
117
343
  }
@@ -122,6 +348,47 @@ export var DetailButton = function DetailButton(props) {
122
348
  }, props.children || '查看');
123
349
  };
124
350
  export var CommonButton = function CommonButton(props) {
351
+ var _useState11 = useState(null),
352
+ _useState12 = _slicedToArray(_useState11, 2),
353
+ LinkComponent = _useState12[0],
354
+ setLinkComponent = _useState12[1];
355
+ // 使用 useUmi 获取 Umi 模块中的 Link 组件
356
+ useEffect(function () {
357
+ var loadUmiLink = /*#__PURE__*/function () {
358
+ var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
359
+ var umiModule;
360
+ return _regeneratorRuntime().wrap(function _callee7$(_context7) {
361
+ while (1) switch (_context7.prev = _context7.next) {
362
+ case 0:
363
+ _context7.prev = 0;
364
+ _context7.next = 3;
365
+ return useUmi();
366
+ case 3:
367
+ umiModule = _context7.sent;
368
+ //@ts-ignore
369
+ if (umiModule && umiModule.Link) {
370
+ //@ts-ignore
371
+ setLinkComponent(umiModule.Link);
372
+ }
373
+ _context7.next = 10;
374
+ break;
375
+ case 7:
376
+ _context7.prev = 7;
377
+ _context7.t0 = _context7["catch"](0);
378
+ console.warn('加载 Umi Link 失败,使用 React Router Link 作为备用:', _context7.t0);
379
+ case 10:
380
+ case "end":
381
+ return _context7.stop();
382
+ }
383
+ }, _callee7, null, [[0, 7]]);
384
+ }));
385
+ return function loadUmiLink() {
386
+ return _ref7.apply(this, arguments);
387
+ };
388
+ }();
389
+ loadUmiLink();
390
+ }, []); // 依赖数组为空,只在组件挂载时执行一次
391
+
125
392
  var btnname = props.btnname,
126
393
  btnicon = props.btnicon,
127
394
  pathname = props.pathname,
@@ -140,8 +407,8 @@ export var CommonButton = function CommonButton(props) {
140
407
  return callback && callback();
141
408
  }
142
409
  }, others), props.children || btnname));
143
- if (!callback) {
144
- return /*#__PURE__*/React.createElement(Link, {
410
+ if (!callback && LinkComponent) {
411
+ return /*#__PURE__*/React.createElement(LinkComponent, {
145
412
  to: pathname
146
413
  }, buttonNode);
147
414
  }
@@ -188,6 +455,49 @@ export var AddButton = function AddButton(props) {
188
455
  var pathname = props.pathname,
189
456
  callback = props.callback,
190
457
  others = _objectWithoutProperties(props, _excluded4);
458
+ var _useState13 = useState(null),
459
+ _useState14 = _slicedToArray(_useState13, 2),
460
+ LinkComponent = _useState14[0],
461
+ setLinkComponent = _useState14[1];
462
+ // 使用 useUmi 获取 Umi 模块中的 Link 组件
463
+ useEffect(function () {
464
+ var loadUmiLink = /*#__PURE__*/function () {
465
+ var _ref8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
466
+ var umiModule;
467
+ return _regeneratorRuntime().wrap(function _callee8$(_context8) {
468
+ while (1) switch (_context8.prev = _context8.next) {
469
+ case 0:
470
+ _context8.prev = 0;
471
+ _context8.next = 3;
472
+ return useUmi();
473
+ case 3:
474
+ umiModule = _context8.sent;
475
+ //@ts-ignore
476
+ if (umiModule && umiModule.Link) {
477
+ console.log(umiModule);
478
+
479
+ //@ts-ignore
480
+ setLinkComponent(umiModule.Link);
481
+ }
482
+ _context8.next = 10;
483
+ break;
484
+ case 7:
485
+ _context8.prev = 7;
486
+ _context8.t0 = _context8["catch"](0);
487
+ console.warn('加载 Umi Link 失败,使用 React Router Link 作为备用:', _context8.t0);
488
+ case 10:
489
+ case "end":
490
+ return _context8.stop();
491
+ }
492
+ }, _callee8, null, [[0, 7]]);
493
+ }));
494
+ return function loadUmiLink() {
495
+ return _ref8.apply(this, arguments);
496
+ };
497
+ }();
498
+ loadUmiLink();
499
+ }, []); // 依赖数组为空,只在组件挂载时执行一次
500
+
191
501
  if (!checkPathname(pathname)) return null;
192
502
  var buttonNode = /*#__PURE__*/React.createElement(StyleProvider, {
193
503
  hashPriority: "high",
@@ -201,8 +511,8 @@ export var AddButton = function AddButton(props) {
201
511
  return callback && callback();
202
512
  }
203
513
  }, others), props.children || '新增'));
204
- if (!callback) {
205
- return /*#__PURE__*/React.createElement(Link, {
514
+ if (!callback && LinkComponent) {
515
+ return /*#__PURE__*/React.createElement(LinkComponent, {
206
516
  to: pathname
207
517
  }, buttonNode);
208
518
  }
@@ -210,10 +520,54 @@ export var AddButton = function AddButton(props) {
210
520
  };
211
521
  export var AButton = function AButton(props) {
212
522
  var pathname = props.pathname,
213
- callback = props.callback;
523
+ callback = props.callback,
524
+ others = _objectWithoutProperties(props, _excluded5);
525
+ var _useState15 = useState(null),
526
+ _useState16 = _slicedToArray(_useState15, 2),
527
+ LinkComponent = _useState16[0],
528
+ setLinkComponent = _useState16[1];
529
+
530
+ // 使用 useUmi 获取 Umi 模块中的 Link 组件
531
+ useEffect(function () {
532
+ var loadUmiLink = /*#__PURE__*/function () {
533
+ var _ref9 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
534
+ var umiModule;
535
+ return _regeneratorRuntime().wrap(function _callee9$(_context9) {
536
+ while (1) switch (_context9.prev = _context9.next) {
537
+ case 0:
538
+ _context9.prev = 0;
539
+ _context9.next = 3;
540
+ return useUmi();
541
+ case 3:
542
+ umiModule = _context9.sent;
543
+ console.log(umiModule);
544
+
545
+ //@ts-ignore
546
+ if (umiModule && umiModule.Link) {
547
+ //@ts-ignore
548
+ setLinkComponent(umiModule.Link);
549
+ }
550
+ _context9.next = 11;
551
+ break;
552
+ case 8:
553
+ _context9.prev = 8;
554
+ _context9.t0 = _context9["catch"](0);
555
+ console.warn('加载 Umi Link 失败,使用 React Router Link 作为备用:', _context9.t0);
556
+ case 11:
557
+ case "end":
558
+ return _context9.stop();
559
+ }
560
+ }, _callee9, null, [[0, 8]]);
561
+ }));
562
+ return function loadUmiLink() {
563
+ return _ref9.apply(this, arguments);
564
+ };
565
+ }();
566
+ loadUmiLink();
567
+ }, []); // 依赖数组为空,只在组件挂载时执行一次
214
568
  if (!checkPathname(pathname)) return null;
215
- if (!callback) {
216
- return /*#__PURE__*/React.createElement(Link, {
569
+ if (!callback && LinkComponent) {
570
+ return /*#__PURE__*/React.createElement(LinkComponent, {
217
571
  to: pathname
218
572
  }, props.children || '新增');
219
573
  }
@@ -30,7 +30,6 @@ export declare const isValidDate: (dateString: string) => boolean;
30
30
  export declare const getweek: (e: any) => string;
31
31
  export declare const getOptionName: (options: any, id: any, key?: string) => any;
32
32
  export declare const formatLarkAvatar: (str: string) => any;
33
- export declare const getUmi: () => any;
34
33
  export declare const getApp: () => any;
35
34
  export declare const isVenusStrNotNull: (data: string) => boolean;
36
35
  /**
@@ -12,7 +12,7 @@ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol
12
12
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
13
13
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
14
14
  import qs from 'qs';
15
- import { getAppByUser, getDifyConfigs, listAppData, mnLoginDify, storage } from "./..";
15
+ import { getAppByUser, getDifyConfigs, listAppData, mnLoginDify, storage, useUmi } from "./..";
16
16
  import { useEffect, useState } from 'react';
17
17
  import CryptoJS from "crypto-js";
18
18
 
@@ -255,29 +255,30 @@ export var formatLarkAvatar = function formatLarkAvatar(str) {
255
255
  console.log(e);
256
256
  }
257
257
  };
258
- export var getUmi = function getUmi() {
259
- // src/utils/history.ts
260
- var umiData;
261
- try {
262
- umiData = require('umi');
263
- } catch (e) {
264
- try {
265
- // 尝试从 @umijs/max 中引入 history
266
- umiData = require('@umijs/max');
267
- } catch (e) {
268
- // 如果都失败,可以考虑使用其他方式创建 history 或抛出错误
269
- console.warn('无法找到 umi 模块。请确保你的项目中安装了 @umijs/max 或 umi。');
270
- throw new Error('无法找到 umi 模块。请确保你的项目中安装了 @umijs/max 或 umi。');
271
- }
272
- }
273
- return umiData;
274
- };
275
258
 
259
+ /*
260
+ const getUmi = ()=>{
261
+ // src/utils/history.ts
262
+ let umiData: any;
263
+ try {
264
+ umiData = require('umi');
265
+ } catch (e) {
266
+ try {
267
+ // 尝试从 @umijs/max 中引入 history
268
+ umiData = require('@umijs/max');
269
+ } catch (e) {
270
+ // 如果都失败,可以考虑使用其他方式创建 history 或抛出错误
271
+ console.warn('无法找到 umi 模块。请确保你的项目中安装了 @umijs/max 或 umi。');
272
+ throw new Error('无法找到 umi 模块。请确保你的项目中安装了 @umijs/max 或 umi。');
273
+ }
274
+ }
275
+ return umiData;
276
+ }
277
+ */
276
278
  //获取消息弹窗,适配antd5.0 和antd4.0
277
279
  export var getApp = function getApp() {
278
280
  var appData;
279
281
  try {
280
- // 尝试从 @umijs/max 中引入 history
281
282
  appData = require('antd');
282
283
  if (appData.App) {
283
284
  var app = appData.App;
@@ -401,52 +402,90 @@ export var initOwnerApp = /*#__PURE__*/function () {
401
402
  //获取默认菜单
402
403
  export var getDefaultMenu = function getDefaultMenu() {
403
404
  var ownerApp = storage.getSessionItem("OWNER_APP");
404
- var _getUmi = getUmi(),
405
- history = _getUmi.history;
405
+ var _useState = useState(null),
406
+ _useState2 = _slicedToArray(_useState, 2),
407
+ umi = _useState2[0],
408
+ setUmi = _useState2[1];
409
+ // 使用 useUmi 获取 Umi 模块中的 Link 组件
410
+ useEffect(function () {
411
+ var loadUmiLink = /*#__PURE__*/function () {
412
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
413
+ var umiModule;
414
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
415
+ while (1) switch (_context2.prev = _context2.next) {
416
+ case 0:
417
+ _context2.prev = 0;
418
+ _context2.next = 3;
419
+ return useUmi();
420
+ case 3:
421
+ umiModule = _context2.sent;
422
+ //@ts-ignore
423
+ if (umiModule && umiModule) {
424
+ //@ts-ignore
425
+ setUmi(umiModule.Link);
426
+ }
427
+ _context2.next = 10;
428
+ break;
429
+ case 7:
430
+ _context2.prev = 7;
431
+ _context2.t0 = _context2["catch"](0);
432
+ console.warn('加载 Umi Link 失败,使用 React Router Link 作为备用:', _context2.t0);
433
+ case 10:
434
+ case "end":
435
+ return _context2.stop();
436
+ }
437
+ }, _callee2, null, [[0, 7]]);
438
+ }));
439
+ return function loadUmiLink() {
440
+ return _ref2.apply(this, arguments);
441
+ };
442
+ }();
443
+ loadUmiLink();
444
+ }, []); // 依赖数组为空,只在组件挂载时执行一次
406
445
  if (ownerApp != null && ownerApp.appName != "试验管理") {
407
- history.push("/main");
446
+ umi.history.push("/main");
408
447
  } else {
409
- history.push("/main/home");
448
+ umi.history.push("/main/home");
410
449
  }
411
450
  };
412
451
  //获取dify配置信息
413
452
  export var getDifyConfig = function getDifyConfig() {
414
453
  //@ts-ignore
415
- var _useState = useState({}),
416
- _useState2 = _slicedToArray(_useState, 2),
417
- data = _useState2[0],
418
- saveData = _useState2[1];
454
+ var _useState3 = useState({}),
455
+ _useState4 = _slicedToArray(_useState3, 2),
456
+ data = _useState4[0],
457
+ saveData = _useState4[1];
419
458
  var difyConfig = storage.getSessionItem("dify_config");
420
459
  var request = /*#__PURE__*/function () {
421
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
460
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
422
461
  var res;
423
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
424
- while (1) switch (_context2.prev = _context2.next) {
462
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
463
+ while (1) switch (_context3.prev = _context3.next) {
425
464
  case 0:
426
465
  if (!difyConfig) {
427
- _context2.next = 4;
466
+ _context3.next = 4;
428
467
  break;
429
468
  }
430
469
  saveData(JSON.parse(difyConfig));
431
- _context2.next = 8;
470
+ _context3.next = 8;
432
471
  break;
433
472
  case 4:
434
- _context2.next = 6;
473
+ _context3.next = 6;
435
474
  return getDifyConfigs();
436
475
  case 6:
437
- res = _context2.sent;
476
+ res = _context3.sent;
438
477
  if (res && res.success) {
439
478
  storage.setSessionItem("dify_config", JSON.stringify(res.data));
440
479
  saveData(res.data);
441
480
  }
442
481
  case 8:
443
482
  case "end":
444
- return _context2.stop();
483
+ return _context3.stop();
445
484
  }
446
- }, _callee2);
485
+ }, _callee3);
447
486
  }));
448
487
  return function request() {
449
- return _ref2.apply(this, arguments);
488
+ return _ref3.apply(this, arguments);
450
489
  };
451
490
  }();
452
491
  useEffect(function () {
@@ -465,12 +504,12 @@ export var getDifyUserNames = function getDifyUserNames() {
465
504
 
466
505
  //模拟登录到dify
467
506
  export var onMnLoginDify = /*#__PURE__*/function () {
468
- var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
507
+ var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
469
508
  var res;
470
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
471
- while (1) switch (_context3.prev = _context3.next) {
509
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
510
+ while (1) switch (_context4.prev = _context4.next) {
472
511
  case 0:
473
- _context3.next = 2;
512
+ _context4.next = 2;
474
513
  return mnLoginDify({
475
514
  email: "j1420865679@163.com",
476
515
  language: "zh-Hans",
@@ -478,7 +517,7 @@ export var onMnLoginDify = /*#__PURE__*/function () {
478
517
  remember_me: true
479
518
  });
480
519
  case 2:
481
- res = _context3.sent;
520
+ res = _context4.sent;
482
521
  //console.log(res);
483
522
  if (res && res.result == "success") {
484
523
  localStorage.setItem("console_token", res.data.access_token);
@@ -487,11 +526,11 @@ export var onMnLoginDify = /*#__PURE__*/function () {
487
526
  }
488
527
  case 4:
489
528
  case "end":
490
- return _context3.stop();
529
+ return _context4.stop();
491
530
  }
492
- }, _callee3);
531
+ }, _callee4);
493
532
  }));
494
533
  return function onMnLoginDify() {
495
- return _ref3.apply(this, arguments);
534
+ return _ref4.apply(this, arguments);
496
535
  };
497
536
  }();
@@ -1,15 +1,62 @@
1
+ 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); }
1
2
  import "antd/es/result/style";
2
3
  import _Result from "antd/es/result";
3
4
  import "antd/es/button/style";
4
5
  import _Button from "antd/es/button";
5
- import React from 'react';
6
+ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
7
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
8
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
9
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
10
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
11
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
12
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
13
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
14
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
15
+ import React, { useEffect, useState } from 'react';
6
16
  import { StyleProvider, legacyLogicalPropertiesTransformer } from "@ant-design/cssinjs";
7
- import { getUmi } from "./..";
8
- var _getUmi = getUmi(),
9
- history = _getUmi.history;
17
+ import { useUmi } from "./..";
10
18
  var App = function App(props) {
19
+ var _useState = useState(null),
20
+ _useState2 = _slicedToArray(_useState, 2),
21
+ umiData = _useState2[0],
22
+ setUmi = _useState2[1];
23
+ // 使用 useUmi 获取 Umi 模块中的 Link 组件
24
+ useEffect(function () {
25
+ var loadUmiLink = /*#__PURE__*/function () {
26
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
27
+ var umiModule;
28
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
29
+ while (1) switch (_context.prev = _context.next) {
30
+ case 0:
31
+ _context.prev = 0;
32
+ _context.next = 3;
33
+ return useUmi();
34
+ case 3:
35
+ umiModule = _context.sent;
36
+ if (umiModule) {
37
+ setUmi(umiModule);
38
+ }
39
+ _context.next = 10;
40
+ break;
41
+ case 7:
42
+ _context.prev = 7;
43
+ _context.t0 = _context["catch"](0);
44
+ console.warn('加载 Umi Link 失败,使用 React Router Link 作为备用:', _context.t0);
45
+ case 10:
46
+ case "end":
47
+ return _context.stop();
48
+ }
49
+ }, _callee, null, [[0, 7]]);
50
+ }));
51
+ return function loadUmiLink() {
52
+ return _ref.apply(this, arguments);
53
+ };
54
+ }();
55
+ loadUmiLink();
56
+ }, []); // 依赖数组为空,只在组件挂载时执行一次
11
57
  var onHome = function onHome() {
12
- history.push("/loginLayout/login");
58
+ //@ts-ignore
59
+ umiData && umiData.history.push("/loginLayout/login");
13
60
  };
14
61
  return /*#__PURE__*/React.createElement(StyleProvider, {
15
62
  hashPriority: "high",
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ declare const useUmi: () => Promise<any>;
3
+ export declare const useUmiModule: () => React.ComponentType<any> | null;
4
+ export default useUmi;
@@ -0,0 +1,90 @@
1
+ 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); }
2
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
3
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
4
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
5
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
6
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
7
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
8
+ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
9
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
10
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
11
+ import { useState, useEffect } from 'react';
12
+ var useUmi = /*#__PURE__*/function () {
13
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
14
+ var umi, umiMax;
15
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
16
+ while (1) switch (_context.prev = _context.next) {
17
+ case 0:
18
+ _context.prev = 0;
19
+ _context.next = 3;
20
+ return import('umi');
21
+ case 3:
22
+ umi = _context.sent;
23
+ return _context.abrupt("return", umi);
24
+ case 7:
25
+ _context.prev = 7;
26
+ _context.t0 = _context["catch"](0);
27
+ _context.prev = 9;
28
+ _context.next = 12;
29
+ return import('@umijs/max');
30
+ case 12:
31
+ umiMax = _context.sent;
32
+ return _context.abrupt("return", umiMax);
33
+ case 16:
34
+ _context.prev = 16;
35
+ _context.t1 = _context["catch"](9);
36
+ // 如果都失败,处理错误
37
+ console.warn('无法找到 umi 模块。请确保你的项目中安装了 @umijs/max 或 umi。');
38
+ throw new Error('无法找到 umi 模块。请确保你的项目中安装了 @umijs/max 或 umi。');
39
+ case 20:
40
+ case "end":
41
+ return _context.stop();
42
+ }
43
+ }, _callee, null, [[0, 7], [9, 16]]);
44
+ }));
45
+ return function useUmi() {
46
+ return _ref.apply(this, arguments);
47
+ };
48
+ }();
49
+ export var useUmiModule = function useUmiModule() {
50
+ var _useState = useState(null),
51
+ _useState2 = _slicedToArray(_useState, 2),
52
+ umiData = _useState2[0],
53
+ setUmi = _useState2[1];
54
+ // 使用 useUmi 获取 Umi 模块中的 Link 组件
55
+ useEffect(function () {
56
+ var loadUmiLink = /*#__PURE__*/function () {
57
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
58
+ var umiModule;
59
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
60
+ while (1) switch (_context2.prev = _context2.next) {
61
+ case 0:
62
+ _context2.prev = 0;
63
+ _context2.next = 3;
64
+ return useUmi();
65
+ case 3:
66
+ umiModule = _context2.sent;
67
+ if (umiModule) {
68
+ setUmi(umiModule);
69
+ }
70
+ _context2.next = 10;
71
+ break;
72
+ case 7:
73
+ _context2.prev = 7;
74
+ _context2.t0 = _context2["catch"](0);
75
+ console.warn('加载 Umi Link 失败,使用 React Router Link 作为备用:', _context2.t0);
76
+ case 10:
77
+ case "end":
78
+ return _context2.stop();
79
+ }
80
+ }, _callee2, null, [[0, 7]]);
81
+ }));
82
+ return function loadUmiLink() {
83
+ return _ref2.apply(this, arguments);
84
+ };
85
+ }();
86
+ loadUmiLink();
87
+ }, []); // 依赖数组为空,只在组件挂载时执行一次
88
+ return umiData;
89
+ };
90
+ export default useUmi;
@@ -1,10 +1,58 @@
1
- import React from 'react';
2
- import { getUmi } from "./..";
3
- var _getUmi = getUmi(),
4
- Outlet = _getUmi.Outlet;
1
+ 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); }
2
+ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
3
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
4
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
5
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
6
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
7
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
8
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
9
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
10
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
11
+ import React, { useEffect, useState } from 'react';
12
+ import { useUmi } from "./..";
5
13
  var RenderRoute = function RenderRoute(props) {
6
- if (Outlet) {
7
- return /*#__PURE__*/React.createElement(Outlet, null);
14
+ var _useState = useState(null),
15
+ _useState2 = _slicedToArray(_useState, 2),
16
+ OutletCompoment = _useState2[0],
17
+ setOutlet = _useState2[1];
18
+ // 使用 useUmi 获取 Umi 模块中的 Link 组件
19
+ useEffect(function () {
20
+ var loadUmiLink = /*#__PURE__*/function () {
21
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
22
+ var umiModule;
23
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
24
+ while (1) switch (_context.prev = _context.next) {
25
+ case 0:
26
+ _context.prev = 0;
27
+ _context.next = 3;
28
+ return useUmi();
29
+ case 3:
30
+ umiModule = _context.sent;
31
+ //@ts-ignore
32
+ if (umiModule && umiModule.Outlet) {
33
+ //@ts-ignore
34
+ setOutlet(umiModule.Outlet);
35
+ }
36
+ _context.next = 10;
37
+ break;
38
+ case 7:
39
+ _context.prev = 7;
40
+ _context.t0 = _context["catch"](0);
41
+ console.warn('加载 Umi Link 失败,使用 React Router Link 作为备用:', _context.t0);
42
+ case 10:
43
+ case "end":
44
+ return _context.stop();
45
+ }
46
+ }, _callee, null, [[0, 7]]);
47
+ }));
48
+ return function loadUmiLink() {
49
+ return _ref.apply(this, arguments);
50
+ };
51
+ }();
52
+ loadUmiLink();
53
+ }, []); // 依赖数组为空,只在组件挂载时执行一次
54
+ if (OutletCompoment) {
55
+ return /*#__PURE__*/React.createElement(OutletCompoment, null);
8
56
  } else {
9
57
  return props.children;
10
58
  }
@@ -11,11 +11,9 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
11
11
  function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
12
12
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
13
13
  import React, { useEffect, useState } from 'react';
14
- import { handleDetail, BISpin, getDetailColumnData, getUmi } from "./..";
14
+ import { handleDetail, BISpin, getDetailColumnData } from "./..";
15
15
  import { StyleProvider, legacyLogicalPropertiesTransformer } from "@ant-design/cssinjs";
16
16
  import "./style.less";
17
- var _getUmi = getUmi(),
18
- Outlet = _getUmi.Outlet;
19
17
  var VenusDetail = function VenusDetail(props) {
20
18
  //@ts-ignore
21
19
  var _useState = useState([]),
@@ -73,7 +71,7 @@ var VenusDetail = function VenusDetail(props) {
73
71
  },
74
72
  //@ts-ignore
75
73
  handleDetail(columns, props.data, props.dataAfter) //处理详细信息
76
- , Outlet ? /*#__PURE__*/React.createElement(Outlet, null) : props.children))) :
74
+ , props.children))) :
77
75
  /*#__PURE__*/
78
76
  //@ts-ignore
79
77
  React.createElement(BISpin, null));
@@ -7,11 +7,8 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
7
7
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
8
8
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
9
9
  import React from "react";
10
- import { getColumnDateSearchProps, getColumnSearchProps, getColumnNumberSearchProps, dataToEnum, getUmi } from "./..";
10
+ import { getColumnDateSearchProps, getColumnSearchProps, getColumnNumberSearchProps, dataToEnum } from "./..";
11
11
  import { assemblyFilterData, handleDataIndex } from "./handleVenusEditTableFormFunctions";
12
- import { StyleProvider, legacyLogicalPropertiesTransformer } from "@ant-design/cssinjs";
13
- var _getUmi = getUmi(),
14
- history = _getUmi.history;
15
12
  /**
16
13
  * 表格列的类型(用于列筛选)
17
14
  */
@@ -152,22 +149,6 @@ export var VENUS_TABLE_COLUMNRENDER_TYPE = {
152
149
  }
153
150
  };
154
151
  },
155
- //项目列表项目名称超链接
156
- "rendeProjectNameDetail": function rendeProjectNameDetail(column, actions) {
157
- return function (text, record, _, action) {
158
- var name = text.length > 15 ? text.substring(0, 16) + '...' : text;
159
- return [/*#__PURE__*/React.createElement(StyleProvider, {
160
- hashPriority: "high",
161
- transformers: [legacyLogicalPropertiesTransformer]
162
- }, /*#__PURE__*/React.createElement(_Tooltip, {
163
- title: text
164
- }, /*#__PURE__*/React.createElement("a", {
165
- onClick: function onClick() {
166
- history.push("/project/project/editKz?id=" + record.innerId + "&type=detail");
167
- }
168
- }, name)))];
169
- };
170
- },
171
152
  "rendeCollectionProject": function rendeCollectionProject(column, actions) {
172
153
  return function (text, record, _, action) {
173
154
  if (1 === text) {
@@ -3,7 +3,7 @@ import { VenusFormDataVo, VenusFormGroupInterface, VenusFormItemInterface, Venus
3
3
  * 组装表单项
4
4
  * @param formGroupData 表单分组的集合
5
5
  */
6
- export declare const handleFormItems: (formGroupData: [VenusFormGroupInterface], type: string, disabled: boolean, formWatchData: {}) => any;
6
+ export declare const handleFormItems: (formGroupData: VenusFormGroupInterface[], type: string, disabled: boolean, formWatchData: {}) => any;
7
7
  /**
8
8
  * 处理树型表单项的下拉选项集合
9
9
  */
@@ -40,4 +40,4 @@ export declare const setVenusFormFormate: (formItemData: VenusFormGroupInterface
40
40
  * @param val
41
41
  * @returns
42
42
  */
43
- export declare const getVenusFormFormate: (formItemData: [VenusFormGroupInterface], val: any) => any;
43
+ export declare const getVenusFormFormate: (formItemData: VenusFormGroupInterface[], val: any) => any;
@@ -17,10 +17,9 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
17
17
  function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
18
18
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
19
19
  import React, { useEffect, useState } from 'react';
20
- import { ProForm, getFormData, getUmi, getVenusFormFormate, handleFormItems, setVenusFormFormate } from "./..";
20
+ import { ProForm, getFormData, getVenusFormFormate, handleFormItems, setVenusFormFormate, useUmiModule } from "./..";
21
21
  import "./style.less";
22
- var _getUmi = getUmi(),
23
- Outlet = _getUmi.Outlet;
22
+
24
23
  /**
25
24
  * 表单组件
26
25
  * @param props
@@ -37,6 +36,7 @@ var VenusForm = function VenusForm(props) {
37
36
  _useState4 = _slicedToArray(_useState3, 2),
38
37
  isSetData = _useState4[0],
39
38
  setSetData = _useState4[1];
39
+ var umi = useUmiModule();
40
40
  var _useState5 = useState({}),
41
41
  _useState6 = _slicedToArray(_useState5, 2),
42
42
  formWatchData = _useState6[0],
@@ -172,7 +172,11 @@ var VenusForm = function VenusForm(props) {
172
172
  * 默认的取消按钮点击处理
173
173
  */
174
174
  var defaultHandleCancel = function defaultHandleCancel() {
175
- history.go(-1);
175
+ //@ts-ignore
176
+ if (umi && umi.history) {
177
+ //@ts-ignore
178
+ umi.history.go(-1);
179
+ }
176
180
  };
177
181
  /**
178
182
  * 默认的保存
@@ -217,7 +221,7 @@ var VenusForm = function VenusForm(props) {
217
221
  ,
218
222
  disabled: props.disabled || false //是否禁用
219
223
  }), handleFormItems(formData, props.adjustFlag !== undefined ? "adjust" : isEdit + "", props.disabled || false, formWatchData) //处理表单项
220
- , Outlet ? /*#__PURE__*/React.createElement(Outlet, null) : props.children,
224
+ , props.children,
221
225
  //提交和取消按钮
222
226
  !props.submitNodeFlag && props.submitNodeFlag !== undefined ? null : props.haveSaveFlag && props.haveSaveFlag ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
223
227
  className: "VenusForm_formFooter"
@@ -11,9 +11,7 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
11
11
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
12
12
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
13
13
  import React from "react";
14
- import { getColumnDateSearchProps, handleDataIndex, assemblyFilterData, getColumnSearchProps, getColumnNumberSearchProps, dataToEnum, DownLoad, downloadFile, DetailButton, isVenusStrNotNull, getUmi } from "./..";
15
- var _getUmi = getUmi(),
16
- history = _getUmi.history;
14
+ import { getColumnDateSearchProps, handleDataIndex, assemblyFilterData, getColumnSearchProps, getColumnNumberSearchProps, dataToEnum, DownLoad, downloadFile, DetailButton, isVenusStrNotNull } from "./..";
17
15
  /**
18
16
  * 表格列的类型(用于列筛选)
19
17
  */
@@ -151,19 +149,6 @@ export var VENUS_TABLE_COLUMNRENDER_TYPE = {
151
149
  }
152
150
  };
153
151
  },
154
- //项目列表项目名称超链接
155
- "rendeProjectNameDetail": function rendeProjectNameDetail(column, actions) {
156
- return function (text, record, _, action) {
157
- var name = text.length > 15 ? text.substring(0, 16) + '...' : text;
158
- return [/*#__PURE__*/React.createElement(_Tooltip, {
159
- title: text
160
- }, /*#__PURE__*/React.createElement("a", {
161
- onClick: function onClick() {
162
- history.push("/project/project/editKz?id=" + record.innerId + "&type=detail");
163
- }
164
- }, name))];
165
- };
166
- },
167
152
  //审批记录列表名称超链接
168
153
  "rendeWorkFlowDetail": function rendeWorkFlowDetail(column, actions) {
169
154
  return function (text, record, _, action) {
package/dist/index.d.ts CHANGED
@@ -16,7 +16,8 @@ export { default as request } from './Config/request';
16
16
  export { default as storage, checkCookieAuth } from './Config/storage';
17
17
  export { LIVE_ACCESS_TOKEN, LIVE_REFRESH_TOKEN, VENUS_PROJECT_INFO, LIVE_ACCESS_TOKEN_EXPIRES_TIME, LIVE_REFRESH_TOKEN_EXPIRES_TIME, HISTORY_PATHNAME, QUICK_ENTRY_OPEN, DATE_FORMAT, DATETIME_FORMAT, SPECIAL_DATETIME_FORMAT, SPECIAL_DATETIME_FORMAT_30, SPECIAL_DATETIME_FORMAT_00, ADMIN_APP_TOKEN, BUCKET, chromeWin32, chromeWin64, chromeMac } from './Config/constants';
18
18
  export { default as proxy, hostMap } from './Config/proxy';
19
- export { thousandSeparator, unitWanNum, tableUnitWanNum, getCookieDomain, getUrlParams, getUrlSearchStr, renderMillion, isNotNullVenus, renderFileNameAndIds, renderFileNameAndIdsNew, renderTableFileNameAndIds, haveSecLevel, haveSecLevelNew, isValidDate, getweek, formatLarkAvatar, isVenusStrNotNull, getApp, encrypt, initOwnerApp, getDefaultMenu, getDifyConfig, getDifyUserNames, onMnLoginDify, deleteSessionKeysWithPrefix, getUmi } from './Config/utils';
19
+ export { thousandSeparator, unitWanNum, tableUnitWanNum, getCookieDomain, getUrlParams, getUrlSearchStr, renderMillion, isNotNullVenus, renderFileNameAndIds, renderFileNameAndIdsNew, renderTableFileNameAndIds, haveSecLevel, haveSecLevelNew, isValidDate, getweek, formatLarkAvatar, isVenusStrNotNull, getApp, encrypt, initOwnerApp, getDefaultMenu, getDifyConfig, getDifyUserNames, onMnLoginDify, deleteSessionKeysWithPrefix, } from './Config/utils';
20
+ export { default as useUmi, useUmiModule } from './Hooks/useUmi';
20
21
  export { default as AuthButton, ButtonPath, checkPathname, getRouteMap, AddButtonNew, EditButton, ADDButtona, DetailButton, CommonButton, VenusButton, AddButton, AButton } from './AuthButton';
21
22
  export { default as DataView } from './DataView';
22
23
  export { default as BISpin } from './BISpin';
package/dist/index.js CHANGED
@@ -16,7 +16,8 @@ export { default as request } from "./Config/request";
16
16
  export { default as storage, checkCookieAuth } from "./Config/storage";
17
17
  export { LIVE_ACCESS_TOKEN, LIVE_REFRESH_TOKEN, VENUS_PROJECT_INFO, LIVE_ACCESS_TOKEN_EXPIRES_TIME, LIVE_REFRESH_TOKEN_EXPIRES_TIME, HISTORY_PATHNAME, QUICK_ENTRY_OPEN, DATE_FORMAT, DATETIME_FORMAT, SPECIAL_DATETIME_FORMAT, SPECIAL_DATETIME_FORMAT_30, SPECIAL_DATETIME_FORMAT_00, ADMIN_APP_TOKEN, BUCKET, chromeWin32, chromeWin64, chromeMac } from "./Config/constants";
18
18
  export { default as proxy, hostMap } from "./Config/proxy";
19
- export { thousandSeparator, unitWanNum, tableUnitWanNum, getCookieDomain, getUrlParams, getUrlSearchStr, renderMillion, isNotNullVenus, renderFileNameAndIds, renderFileNameAndIdsNew, renderTableFileNameAndIds, haveSecLevel, haveSecLevelNew, isValidDate, getweek, formatLarkAvatar, isVenusStrNotNull, getApp, encrypt, initOwnerApp, getDefaultMenu, getDifyConfig, getDifyUserNames, onMnLoginDify, deleteSessionKeysWithPrefix, getUmi } from "./Config/utils";
19
+ export { thousandSeparator, unitWanNum, tableUnitWanNum, getCookieDomain, getUrlParams, getUrlSearchStr, renderMillion, isNotNullVenus, renderFileNameAndIds, renderFileNameAndIdsNew, renderTableFileNameAndIds, haveSecLevel, haveSecLevelNew, isValidDate, getweek, formatLarkAvatar, isVenusStrNotNull, getApp, encrypt, initOwnerApp, getDefaultMenu, getDifyConfig, getDifyUserNames, onMnLoginDify, deleteSessionKeysWithPrefix } from "./Config/utils";
20
+ export { default as useUmi, useUmiModule } from "./Hooks/useUmi";
20
21
  export { default as AuthButton, ButtonPath, checkPathname, getRouteMap, AddButtonNew, EditButton, ADDButtona, DetailButton, CommonButton, VenusButton, AddButton, AButton } from "./AuthButton";
21
22
  export { default as DataView } from "./DataView";
22
23
  export { default as BISpin } from "./BISpin";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "venus-design",
3
- "version": "0.2.4",
3
+ "version": "0.2.7",
4
4
  "description": "venus all compoments",
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -92,7 +92,6 @@
92
92
  "@types/react-loadable": "^5.5.11",
93
93
  "@types/react-resizable": "^3.0.3",
94
94
  "@umijs/lint": "^4.0.0",
95
- "@umijs/max": "^4.4.4",
96
95
  "react": "^16.12.0|| ^18.3.1 ||^19.1.0",
97
96
  "react-dom": "^16.8.5 || ^18.3.1 ||^19.1.0",
98
97
  "antd": "^4.6.4 || ^5.23.4",
@@ -118,8 +117,6 @@
118
117
  "react-loadable": "^5.5.0",
119
118
  "react-resizable": "^3.0.4",
120
119
  "stylelint": "^14.9.1",
121
- "umi-request": "^1.4.0",
122
- "@umijs/max": "^4.4.4",
123
- "umi": "^3.5.0"
120
+ "umi-request": "^1.4.0"
124
121
  }
125
122
  }