@yueglobal/ui 1.0.0
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.
- package/LICENSE +21 -0
- package/README.md +148 -0
- package/dist/assets/gw-logo.png +0 -0
- package/dist/assets/hs-logo.png +0 -0
- package/dist/assets/hs-wx.png +0 -0
- package/dist/assets/platform-logo.png +0 -0
- package/dist/assets/yldm-applet.png +0 -0
- package/dist/assets/ylqq-title.png +0 -0
- package/dist/assets/yxh-applet.png +0 -0
- package/dist/components/svg-icon/declaration.svg +23 -0
- package/dist/components/svg-icon/expo.svg +23 -0
- package/dist/components/svg-icon/home.svg +13 -0
- package/dist/components/svg-icon/hwc.svg +20 -0
- package/dist/components/svg-icon/index.d.ts +20 -0
- package/dist/components/svg-icon/index.js +95 -0
- package/dist/components/svg-icon/insurance.svg +14 -0
- package/dist/components/svg-icon/law.svg +23 -0
- package/dist/components/svg-icon/location.svg +9 -0
- package/dist/components/svg-icon/selection.svg +16 -0
- package/dist/components/svg-icon/single-window.svg +8 -0
- package/dist/components/svg-icon/taxation.svg +13 -0
- package/dist/components/svg-icon/trade-data.svg +18 -0
- package/dist/components/svg-icon/training.svg +17 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +2 -0
- package/dist/yue-page-footer/data/privacy-policy.d.ts +3 -0
- package/dist/yue-page-footer/data/privacy-policy.js +97 -0
- package/dist/yue-page-footer/data/terms-of-service.d.ts +3 -0
- package/dist/yue-page-footer/data/terms-of-service.js +129 -0
- package/dist/yue-page-footer/index.d.ts +7 -0
- package/dist/yue-page-footer/index.js +93 -0
- package/dist/yue-page-footer/index.less +168 -0
- package/dist/yue-page-footer/info-modal/index.d.ts +6 -0
- package/dist/yue-page-footer/info-modal/index.js +56 -0
- package/dist/yue-page-header/breadcrumb/index.d.ts +5 -0
- package/dist/yue-page-header/breadcrumb/index.js +82 -0
- package/dist/yue-page-header/first-menus/index.d.ts +7 -0
- package/dist/yue-page-header/first-menus/index.js +115 -0
- package/dist/yue-page-header/first-menus/index.less +86 -0
- package/dist/yue-page-header/helper.d.ts +71 -0
- package/dist/yue-page-header/helper.js +326 -0
- package/dist/yue-page-header/index.d.ts +23 -0
- package/dist/yue-page-header/index.js +75 -0
- package/dist/yue-page-header/index.less +43 -0
- package/dist/yue-page-header/right-content/index.d.ts +10 -0
- package/dist/yue-page-header/right-content/index.js +50 -0
- package/dist/yue-page-header/right-content/index.less +35 -0
- package/dist/yue-page-header/second-menus/index.d.ts +8 -0
- package/dist/yue-page-header/second-menus/index.js +132 -0
- package/dist/yue-page-header/second-menus/index.less +161 -0
- package/package.json +67 -0
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
2
|
+
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."); }
|
|
3
|
+
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); }
|
|
4
|
+
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; }
|
|
5
|
+
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; } }
|
|
6
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
7
|
+
function _objectDestructuringEmpty(obj) { if (obj == null) throw new TypeError("Cannot destructure " + obj); }
|
|
8
|
+
import { Button, Modal } from 'antd';
|
|
9
|
+
import React, { forwardRef, memo, useImperativeHandle, useState } from 'react';
|
|
10
|
+
var Index = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
11
|
+
_objectDestructuringEmpty(_ref);
|
|
12
|
+
var _useState = useState(false),
|
|
13
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
14
|
+
visible = _useState2[0],
|
|
15
|
+
setVisible = _useState2[1];
|
|
16
|
+
var _useState3 = useState(''),
|
|
17
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
18
|
+
modalTitle = _useState4[0],
|
|
19
|
+
setModalTitle = _useState4[1];
|
|
20
|
+
var _useState5 = useState(null),
|
|
21
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
22
|
+
modalContent = _useState6[0],
|
|
23
|
+
setModalContent = _useState6[1];
|
|
24
|
+
useImperativeHandle(ref, function () {
|
|
25
|
+
return {
|
|
26
|
+
show: function show(title, content) {
|
|
27
|
+
setModalTitle(title);
|
|
28
|
+
setModalContent(content);
|
|
29
|
+
setVisible(true);
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
});
|
|
33
|
+
return /*#__PURE__*/React.createElement(Modal, {
|
|
34
|
+
centered: true,
|
|
35
|
+
destroyOnHidden: true,
|
|
36
|
+
width: 800,
|
|
37
|
+
open: visible,
|
|
38
|
+
onCancel: function onCancel() {
|
|
39
|
+
return setVisible(false);
|
|
40
|
+
},
|
|
41
|
+
title: modalTitle,
|
|
42
|
+
footer: /*#__PURE__*/React.createElement(Button, {
|
|
43
|
+
type: "primary",
|
|
44
|
+
onClick: function onClick() {
|
|
45
|
+
return setVisible(false);
|
|
46
|
+
}
|
|
47
|
+
}, "\u5173\u95ED"),
|
|
48
|
+
styles: {
|
|
49
|
+
body: {
|
|
50
|
+
maxHeight: '65vh',
|
|
51
|
+
overflowY: 'auto'
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}, modalContent);
|
|
55
|
+
});
|
|
56
|
+
export default /*#__PURE__*/memo(Index);
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { Breadcrumb } from 'antd';
|
|
2
|
+
import React, { memo, useMemo } from 'react';
|
|
3
|
+
import { LocationIcon } from "../../components/svg-icon";
|
|
4
|
+
import { getFullPathNodesByPath, uniqByPath } from "../helper";
|
|
5
|
+
var Index = function Index(_ref) {
|
|
6
|
+
var breadcrumbs = _ref.breadcrumbs,
|
|
7
|
+
routes = _ref.routes,
|
|
8
|
+
pathname = _ref.pathname,
|
|
9
|
+
onRouteChange = _ref.onRouteChange;
|
|
10
|
+
var breadcrumbItems = useMemo(function () {
|
|
11
|
+
if (breadcrumbs) {
|
|
12
|
+
return breadcrumbs.map(function (item) {
|
|
13
|
+
var _item$key;
|
|
14
|
+
return {
|
|
15
|
+
path: (_item$key = item.key) !== null && _item$key !== void 0 && _item$key.startsWith('/') ? item.key : undefined,
|
|
16
|
+
title: item.label
|
|
17
|
+
};
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
if (routes && pathname) {
|
|
21
|
+
var _paths;
|
|
22
|
+
var routeList = Object.values(routes).filter(function (d) {
|
|
23
|
+
return !d.redirect && d.access !== false && !d.isLayout;
|
|
24
|
+
});
|
|
25
|
+
var paths = getFullPathNodesByPath(routeList, pathname);
|
|
26
|
+
if (!paths.find(function (p) {
|
|
27
|
+
return p.title === '首页' || p.name === '首页' || p.path === '/' || p.path === '/home';
|
|
28
|
+
})) {
|
|
29
|
+
paths.unshift({
|
|
30
|
+
title: '首页',
|
|
31
|
+
path: '/'
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
if ((_paths = paths) !== null && _paths !== void 0 && _paths.length) {
|
|
35
|
+
paths = uniqByPath(paths);
|
|
36
|
+
if (paths.length > 1) {
|
|
37
|
+
return paths.map(function (item) {
|
|
38
|
+
return {
|
|
39
|
+
path: item.realpath || item.path,
|
|
40
|
+
title: item.title
|
|
41
|
+
};
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return undefined;
|
|
47
|
+
}, [breadcrumbs, routes, pathname]);
|
|
48
|
+
var itemRender = function itemRender(currentRoute, _, items, paths) {
|
|
49
|
+
var _items;
|
|
50
|
+
var isLast = (currentRoute === null || currentRoute === void 0 ? void 0 : currentRoute.path) === ((_items = items[items.length - 1]) === null || _items === void 0 ? void 0 : _items.path);
|
|
51
|
+
var fullPath = paths.join('/');
|
|
52
|
+
if (!fullPath.startsWith('/')) {
|
|
53
|
+
fullPath = '/' + fullPath;
|
|
54
|
+
}
|
|
55
|
+
return isLast ? /*#__PURE__*/React.createElement("span", null, currentRoute.title) : /*#__PURE__*/React.createElement("a", {
|
|
56
|
+
onClick: function onClick() {
|
|
57
|
+
onRouteChange === null || onRouteChange === void 0 || onRouteChange({
|
|
58
|
+
key: fullPath,
|
|
59
|
+
label: currentRoute.title
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
}, currentRoute.title);
|
|
63
|
+
};
|
|
64
|
+
if (!(breadcrumbItems !== null && breadcrumbItems !== void 0 && breadcrumbItems.length)) {
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
68
|
+
className: "yue-flex breadcrumb"
|
|
69
|
+
}, /*#__PURE__*/React.createElement(LocationIcon, {
|
|
70
|
+
style: {
|
|
71
|
+
fontSize: 16
|
|
72
|
+
}
|
|
73
|
+
}), /*#__PURE__*/React.createElement(Breadcrumb, {
|
|
74
|
+
separator: ">",
|
|
75
|
+
items: breadcrumbItems,
|
|
76
|
+
style: {
|
|
77
|
+
fontSize: 12
|
|
78
|
+
},
|
|
79
|
+
itemRender: itemRender
|
|
80
|
+
}));
|
|
81
|
+
};
|
|
82
|
+
export default /*#__PURE__*/memo(Index);
|
|
@@ -0,0 +1,115 @@
|
|
|
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 { ConfigProvider, Menu } from 'antd';
|
|
12
|
+
import React, { memo, useEffect, useState } from 'react';
|
|
13
|
+
import { deepClone, firstMenuList, mainHost } from "../helper";
|
|
14
|
+
import "./index.less";
|
|
15
|
+
var Index = function Index(_ref) {
|
|
16
|
+
var setVisible = _ref.setVisible;
|
|
17
|
+
var _useState = useState(deepClone(firstMenuList)),
|
|
18
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
19
|
+
menuList = _useState2[0],
|
|
20
|
+
setMenuList = _useState2[1];
|
|
21
|
+
|
|
22
|
+
// 获取新闻资讯的类目
|
|
23
|
+
var fetchNewsData = /*#__PURE__*/function () {
|
|
24
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(apiUrl) {
|
|
25
|
+
var _res$data;
|
|
26
|
+
var res, _res$data$find, result;
|
|
27
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
28
|
+
while (1) switch (_context.prev = _context.next) {
|
|
29
|
+
case 0:
|
|
30
|
+
if (apiUrl) {
|
|
31
|
+
_context.next = 2;
|
|
32
|
+
break;
|
|
33
|
+
}
|
|
34
|
+
return _context.abrupt("return", undefined);
|
|
35
|
+
case 2:
|
|
36
|
+
_context.next = 4;
|
|
37
|
+
return fetch(apiUrl).then(function (res) {
|
|
38
|
+
return res.json();
|
|
39
|
+
});
|
|
40
|
+
case 4:
|
|
41
|
+
res = _context.sent;
|
|
42
|
+
if (!(res !== null && res !== void 0 && (_res$data = res.data) !== null && _res$data !== void 0 && _res$data.length)) {
|
|
43
|
+
_context.next = 8;
|
|
44
|
+
break;
|
|
45
|
+
}
|
|
46
|
+
result = (_res$data$find = res.data.find(function (d) {
|
|
47
|
+
return d.classFlag === 'zcfg';
|
|
48
|
+
})) === null || _res$data$find === void 0 ? void 0 : _res$data$find.children;
|
|
49
|
+
return _context.abrupt("return", result === null || result === void 0 ? void 0 : result.map(function (d) {
|
|
50
|
+
return {
|
|
51
|
+
key: "".concat(mainHost, "/consultation/content-list?classId=").concat(d.id, "&title=").concat(d.className),
|
|
52
|
+
label: d.className,
|
|
53
|
+
icon: /*#__PURE__*/React.createElement("i", {
|
|
54
|
+
className: "yue-icon-dot"
|
|
55
|
+
})
|
|
56
|
+
};
|
|
57
|
+
}));
|
|
58
|
+
case 8:
|
|
59
|
+
return _context.abrupt("return", undefined);
|
|
60
|
+
case 9:
|
|
61
|
+
case "end":
|
|
62
|
+
return _context.stop();
|
|
63
|
+
}
|
|
64
|
+
}, _callee);
|
|
65
|
+
}));
|
|
66
|
+
return function fetchNewsData(_x) {
|
|
67
|
+
return _ref2.apply(this, arguments);
|
|
68
|
+
};
|
|
69
|
+
}();
|
|
70
|
+
useEffect(function () {
|
|
71
|
+
try {
|
|
72
|
+
var list = deepClone(firstMenuList);
|
|
73
|
+
var index = list.findIndex(function (m) {
|
|
74
|
+
return !!m.request;
|
|
75
|
+
});
|
|
76
|
+
if (index > -1) {
|
|
77
|
+
var menu = list[index];
|
|
78
|
+
fetchNewsData(menu.request).then(function (res) {
|
|
79
|
+
if (res) {
|
|
80
|
+
menu.children = res;
|
|
81
|
+
setMenuList(list);
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
} catch (e) {}
|
|
86
|
+
}, []);
|
|
87
|
+
var onItem = function onItem(_ref3) {
|
|
88
|
+
var key = _ref3.key;
|
|
89
|
+
if (key !== null && key !== void 0 && key.startsWith('http')) {
|
|
90
|
+
window.location.href = key;
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
return /*#__PURE__*/React.createElement(ConfigProvider, {
|
|
94
|
+
theme: {
|
|
95
|
+
components: {
|
|
96
|
+
Menu: {
|
|
97
|
+
activeBarHeight: 5,
|
|
98
|
+
itemPaddingInline: 20,
|
|
99
|
+
itemColor: '#000',
|
|
100
|
+
dropdownWidth: '100%',
|
|
101
|
+
horizontalLineHeight: '30px'
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}, /*#__PURE__*/React.createElement(Menu, {
|
|
106
|
+
items: menuList,
|
|
107
|
+
mode: "horizontal",
|
|
108
|
+
rootClassName: "yue-page-header-first-menu",
|
|
109
|
+
onClick: onItem,
|
|
110
|
+
onOpenChange: function onOpenChange(val) {
|
|
111
|
+
setVisible(!!(val !== null && val !== void 0 && val.length));
|
|
112
|
+
}
|
|
113
|
+
}));
|
|
114
|
+
};
|
|
115
|
+
export default /*#__PURE__*/memo(Index);
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
.yue-page-header-first-menu {
|
|
2
|
+
&.ant-menu-root {
|
|
3
|
+
flex: 1;
|
|
4
|
+
background-color: transparent;
|
|
5
|
+
padding-inline: 30px;
|
|
6
|
+
font-size: 20px;
|
|
7
|
+
color: #000;
|
|
8
|
+
height: 100%;
|
|
9
|
+
width: 100%;
|
|
10
|
+
border-bottom: none;
|
|
11
|
+
|
|
12
|
+
& > li {
|
|
13
|
+
display: flex;
|
|
14
|
+
align-items: center;
|
|
15
|
+
justify-content: center;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.ant-menu-submenu-title {
|
|
19
|
+
height: 100%;
|
|
20
|
+
display: flex;
|
|
21
|
+
align-items: center;
|
|
22
|
+
justify-content: center;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.ant-menu-item-selected {
|
|
26
|
+
color: #1a4bff;
|
|
27
|
+
|
|
28
|
+
&::after {
|
|
29
|
+
//border-bottom-width: 6px;
|
|
30
|
+
border-bottom-color: #1a4bff;
|
|
31
|
+
border-radius: 3px 3px 0 0;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
&.ant-menu-submenu-popup {
|
|
37
|
+
left: 0 !important;
|
|
38
|
+
padding: 0;
|
|
39
|
+
font-size: 18px;
|
|
40
|
+
background-color: rgba(4, 41, 131, 80%);
|
|
41
|
+
border-radius: 0;
|
|
42
|
+
width: 100%;
|
|
43
|
+
|
|
44
|
+
.ant-menu-sub {
|
|
45
|
+
display: flex;
|
|
46
|
+
justify-content: center;
|
|
47
|
+
background-color: transparent;
|
|
48
|
+
border-radius: 0;
|
|
49
|
+
box-shadow: none;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.ant-menu-item {
|
|
53
|
+
width: max-content;
|
|
54
|
+
flex: unset;
|
|
55
|
+
color: #fff;
|
|
56
|
+
margin: 0;
|
|
57
|
+
border-radius: 0;
|
|
58
|
+
height: 60px;
|
|
59
|
+
line-height: 30px;
|
|
60
|
+
display: flex;
|
|
61
|
+
align-items: center;
|
|
62
|
+
padding-inline: 16px;
|
|
63
|
+
flex-shrink: 0;
|
|
64
|
+
|
|
65
|
+
.anticon {
|
|
66
|
+
font-size: 20px;
|
|
67
|
+
flex-shrink: 0;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.ant-menu-item-active,
|
|
72
|
+
.ant-menu-item-selected {
|
|
73
|
+
color: #fff !important;
|
|
74
|
+
background: linear-gradient(90deg, #17f1a1, #1a4bff);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.yue-icon-dot {
|
|
78
|
+
min-width: auto !important;
|
|
79
|
+
min-height: auto !important;
|
|
80
|
+
width: 5px;
|
|
81
|
+
height: 5px;
|
|
82
|
+
border-radius: 50%;
|
|
83
|
+
background-color: rgba(255, 255, 255, 80%);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
export interface YueMenuItem {
|
|
3
|
+
key: string;
|
|
4
|
+
label: string;
|
|
5
|
+
icon?: ReactNode;
|
|
6
|
+
children?: YueMenuItem[];
|
|
7
|
+
request?: string;
|
|
8
|
+
}
|
|
9
|
+
export interface YueBreadcrumb {
|
|
10
|
+
key?: string;
|
|
11
|
+
label: string;
|
|
12
|
+
}
|
|
13
|
+
export declare const mainHost = "https://www.yueglobal.com";
|
|
14
|
+
/**
|
|
15
|
+
* 一级菜单(主菜单)
|
|
16
|
+
*/
|
|
17
|
+
export declare const firstMenuList: YueMenuItem[];
|
|
18
|
+
/**
|
|
19
|
+
* 将树结构转换为一维数组
|
|
20
|
+
* @param data
|
|
21
|
+
*/
|
|
22
|
+
export declare function flattenTreeList<T extends {
|
|
23
|
+
children?: T[];
|
|
24
|
+
}>(data: T[]): T[];
|
|
25
|
+
/**
|
|
26
|
+
* 将 firstMenuList 转换为一维数组并根据 key 长度排序
|
|
27
|
+
* @param isSort 是否进行排序
|
|
28
|
+
* @returns 排序后的一维数组
|
|
29
|
+
*/
|
|
30
|
+
export declare function flattenMenuList(isSort?: boolean): YueMenuItem[];
|
|
31
|
+
/**
|
|
32
|
+
* 加载script域外资源
|
|
33
|
+
* @param src
|
|
34
|
+
* @param async
|
|
35
|
+
*/
|
|
36
|
+
export declare function loadScript(src: string, async?: boolean): Promise<unknown>;
|
|
37
|
+
/**
|
|
38
|
+
* 检查页面中是否已存在指定文件名的script资源
|
|
39
|
+
* @param filename 要检查的脚本文件名
|
|
40
|
+
* @returns 如果存在返回true,否则返回false
|
|
41
|
+
*/
|
|
42
|
+
export declare function checkExistScript(filename: string): boolean;
|
|
43
|
+
export interface YueRouteData {
|
|
44
|
+
id?: string;
|
|
45
|
+
parentId?: string;
|
|
46
|
+
title: string;
|
|
47
|
+
name?: string;
|
|
48
|
+
path: string;
|
|
49
|
+
realpath?: string;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* 根据path值获取完整的节点路径数组(支持动态路由参数)
|
|
53
|
+
* @param arr - 包含id, parentId, title, path字段的数组
|
|
54
|
+
* @param path - 要查找的完整path值
|
|
55
|
+
* @returns 完整的节点路径数组,如果未找到则返回空数组
|
|
56
|
+
*/
|
|
57
|
+
export declare function getFullPathNodesByPath<T extends YueRouteData>(arr: T[], path: string): T[];
|
|
58
|
+
/**
|
|
59
|
+
* 根据path值对数组进行去重
|
|
60
|
+
* @param arr - 包含path字段的数组
|
|
61
|
+
* @returns 去重后的数组
|
|
62
|
+
*/
|
|
63
|
+
export declare function uniqByPath<T extends {
|
|
64
|
+
path: string;
|
|
65
|
+
}>(arr: T[]): T[];
|
|
66
|
+
/**
|
|
67
|
+
* 深度拷贝对象或数组
|
|
68
|
+
* @param obj - 要深度拷贝的对象或数组
|
|
69
|
+
* @returns 拷贝后的新对象或数组
|
|
70
|
+
*/
|
|
71
|
+
export declare function deepClone<T>(obj: T): T;
|