@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,326 @@
|
|
|
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 _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
3
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
4
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
5
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
6
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
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
|
+
import React from 'react';
|
|
10
|
+
import { ExpoIcon, HomeIcon, HwcIcon, InsuranceIcon, LawIcon, SelectionIcon, TaxationIcon, TradeDataIcon, TrainingIcon } from "../components/svg-icon";
|
|
11
|
+
// 主网站域名
|
|
12
|
+
export var mainHost = 'https://www.yueglobal.com';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* 一级菜单(主菜单)
|
|
16
|
+
*/
|
|
17
|
+
export var firstMenuList = [{
|
|
18
|
+
key: 'home',
|
|
19
|
+
label: '出海服务',
|
|
20
|
+
children: [{
|
|
21
|
+
key: mainHost,
|
|
22
|
+
label: '首页',
|
|
23
|
+
icon: /*#__PURE__*/React.createElement(HomeIcon, null)
|
|
24
|
+
}, {
|
|
25
|
+
key: "".concat(mainHost, "/selection/"),
|
|
26
|
+
label: '选品中心',
|
|
27
|
+
icon: /*#__PURE__*/React.createElement(SelectionIcon, null)
|
|
28
|
+
}, {
|
|
29
|
+
key: "".concat(mainHost, "/expo/"),
|
|
30
|
+
label: '会展服务',
|
|
31
|
+
icon: /*#__PURE__*/React.createElement(ExpoIcon, null)
|
|
32
|
+
}, {
|
|
33
|
+
key: "".concat(mainHost, "/training/"),
|
|
34
|
+
label: '出海培训',
|
|
35
|
+
icon: /*#__PURE__*/React.createElement(TrainingIcon, null)
|
|
36
|
+
}, {
|
|
37
|
+
key: "".concat(mainHost, "/law/"),
|
|
38
|
+
label: '专业咨询',
|
|
39
|
+
icon: /*#__PURE__*/React.createElement(LawIcon, null)
|
|
40
|
+
}, {
|
|
41
|
+
key: "".concat(mainHost, "/ktms-web/"),
|
|
42
|
+
label: '通关税务',
|
|
43
|
+
icon: /*#__PURE__*/React.createElement(TaxationIcon, null)
|
|
44
|
+
}, {
|
|
45
|
+
key: "".concat(mainHost, "/hwc/"),
|
|
46
|
+
label: '海外仓储',
|
|
47
|
+
icon: /*#__PURE__*/React.createElement(HwcIcon, null)
|
|
48
|
+
}, {
|
|
49
|
+
key: "".concat(mainHost, "/finance-insurance/"),
|
|
50
|
+
label: '金融服务',
|
|
51
|
+
icon: /*#__PURE__*/React.createElement(InsuranceIcon, null)
|
|
52
|
+
}, {
|
|
53
|
+
key: "".concat(mainHost, "/trade-data/"),
|
|
54
|
+
label: '外贸数据',
|
|
55
|
+
icon: /*#__PURE__*/React.createElement(TradeDataIcon, null)
|
|
56
|
+
}]
|
|
57
|
+
}, {
|
|
58
|
+
key: "".concat(mainHost, "/#9"),
|
|
59
|
+
label: '新闻资讯',
|
|
60
|
+
request: '/api/gwtrade-plat-front/whitelist/cms-content-class/classTree?siteFlag=uce'
|
|
61
|
+
}, {
|
|
62
|
+
key: "".concat(mainHost, "/#10"),
|
|
63
|
+
label: '国际市场'
|
|
64
|
+
}, {
|
|
65
|
+
key: "".concat(mainHost, "/#11"),
|
|
66
|
+
label: '省内产业'
|
|
67
|
+
}, {
|
|
68
|
+
key: "".concat(mainHost, "/aboutus"),
|
|
69
|
+
label: '关于我们'
|
|
70
|
+
}];
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* 将树结构转换为一维数组
|
|
74
|
+
* @param data
|
|
75
|
+
*/
|
|
76
|
+
export function flattenTreeList(data) {
|
|
77
|
+
// 递归函数,将嵌套的菜单数组转换为一维数组
|
|
78
|
+
var flatten = function flatten(items) {
|
|
79
|
+
var result = [];
|
|
80
|
+
var _iterator = _createForOfIteratorHelper(items),
|
|
81
|
+
_step;
|
|
82
|
+
try {
|
|
83
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
84
|
+
var item = _step.value;
|
|
85
|
+
result.push(item);
|
|
86
|
+
if (item !== null && item !== void 0 && item.children) {
|
|
87
|
+
result.push.apply(result, _toConsumableArray(flatten(item.children)));
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
} catch (err) {
|
|
91
|
+
_iterator.e(err);
|
|
92
|
+
} finally {
|
|
93
|
+
_iterator.f();
|
|
94
|
+
}
|
|
95
|
+
return result;
|
|
96
|
+
};
|
|
97
|
+
return flatten(data);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* 将 firstMenuList 转换为一维数组并根据 key 长度排序
|
|
102
|
+
* @param isSort 是否进行排序
|
|
103
|
+
* @returns 排序后的一维数组
|
|
104
|
+
*/
|
|
105
|
+
export function flattenMenuList(isSort) {
|
|
106
|
+
// 将嵌套的菜单数组转换为一维数组
|
|
107
|
+
var flattenedList = flattenTreeList(firstMenuList);
|
|
108
|
+
|
|
109
|
+
// 如果需要排序,则根据 key 的长度进行降序排序
|
|
110
|
+
if (isSort) {
|
|
111
|
+
return flattenedList.sort(function (a, b) {
|
|
112
|
+
return b.key.length - a.key.length;
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
return flattenedList;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* 加载script域外资源
|
|
120
|
+
* @param src
|
|
121
|
+
* @param async
|
|
122
|
+
*/
|
|
123
|
+
export function loadScript(src, async) {
|
|
124
|
+
return new Promise(function (resolve, reject) {
|
|
125
|
+
var script = document.querySelector("script[src=\"".concat(src, "\"]"));
|
|
126
|
+
if (!script) {
|
|
127
|
+
// 还没加载此sdk文件,则创建script
|
|
128
|
+
var _script = document.createElement('script');
|
|
129
|
+
_script.src = src;
|
|
130
|
+
if (async) {
|
|
131
|
+
_script.async = true;
|
|
132
|
+
_script.defer = true;
|
|
133
|
+
}
|
|
134
|
+
_script.onerror = function () {
|
|
135
|
+
console.error('[hs-sdk] 加载失败:', src);
|
|
136
|
+
reject(false);
|
|
137
|
+
};
|
|
138
|
+
_script.onload = function () {
|
|
139
|
+
resolve(true);
|
|
140
|
+
};
|
|
141
|
+
// 添加到文档中
|
|
142
|
+
document.head.appendChild(_script);
|
|
143
|
+
} else {
|
|
144
|
+
resolve(true);
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* 检查页面中是否已存在指定文件名的script资源
|
|
151
|
+
* @param filename 要检查的脚本文件名
|
|
152
|
+
* @returns 如果存在返回true,否则返回false
|
|
153
|
+
*/
|
|
154
|
+
export function checkExistScript(filename) {
|
|
155
|
+
// 使用filename参数检查script标签是否存在
|
|
156
|
+
var script = document.querySelector("script[src*=\"".concat(filename, "\"]"));
|
|
157
|
+
return !!script;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* 检查路径是否匹配,支持路由参数匹配
|
|
162
|
+
* @param routePath 路由定义路径,可能包含参数如 /news/:id/detail
|
|
163
|
+
* @param actualPath 实际访问路径,如 /news/123/detail
|
|
164
|
+
* @returns 是否匹配
|
|
165
|
+
*/
|
|
166
|
+
function isPathMatch(routePath, actualPath) {
|
|
167
|
+
if (routePath === actualPath) {
|
|
168
|
+
return true;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
// 将路径分割为段
|
|
172
|
+
var routeSegments = routePath.split('/').filter(function (segment) {
|
|
173
|
+
return segment !== '';
|
|
174
|
+
});
|
|
175
|
+
var actualSegments = actualPath.split('/').filter(function (segment) {
|
|
176
|
+
return segment !== '';
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
// 长度不一致则不匹配
|
|
180
|
+
if (routeSegments.length !== actualSegments.length) {
|
|
181
|
+
return false;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
// 逐段匹配
|
|
185
|
+
for (var i = 0; i < routeSegments.length; i++) {
|
|
186
|
+
var routeSeg = routeSegments[i];
|
|
187
|
+
var actualSeg = actualSegments[i];
|
|
188
|
+
|
|
189
|
+
// 如果路由段是参数形式(以:开头),则认为匹配
|
|
190
|
+
if (routeSeg.startsWith(':')) {
|
|
191
|
+
continue; // 参数段直接跳过,认为匹配
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
// 非参数段需要完全匹配
|
|
195
|
+
if (routeSeg !== actualSeg) {
|
|
196
|
+
return false;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
return true;
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* 根据path值获取完整的节点路径数组(支持动态路由参数)
|
|
203
|
+
* @param arr - 包含id, parentId, title, path字段的数组
|
|
204
|
+
* @param path - 要查找的完整path值
|
|
205
|
+
* @returns 完整的节点路径数组,如果未找到则返回空数组
|
|
206
|
+
*/
|
|
207
|
+
export function getFullPathNodesByPath(arr, path) {
|
|
208
|
+
if (!path || path === '/') {
|
|
209
|
+
return [];
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
// 将路径按'/'分割,过滤掉空字符串
|
|
213
|
+
var pathSegments = path.split('/').filter(function (segment) {
|
|
214
|
+
return segment !== '';
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
// 用于存储匹配的节点路径
|
|
218
|
+
var result = [];
|
|
219
|
+
|
|
220
|
+
// 从根节点开始查找
|
|
221
|
+
var currentPath = '';
|
|
222
|
+
var _loop = function _loop() {
|
|
223
|
+
var segment = pathSegments[i];
|
|
224
|
+
|
|
225
|
+
// 构建当前层级的路径
|
|
226
|
+
var tempCurrentPath;
|
|
227
|
+
if (i === 0) {
|
|
228
|
+
tempCurrentPath = "/".concat(segment);
|
|
229
|
+
} else {
|
|
230
|
+
tempCurrentPath = "".concat(currentPath, "/").concat(segment);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
// 查找匹配当前路径的节点(支持参数匹配)
|
|
234
|
+
var matchedNode;
|
|
235
|
+
|
|
236
|
+
// 首先尝试精确匹配
|
|
237
|
+
matchedNode = arr.find(function (item) {
|
|
238
|
+
return item.path === tempCurrentPath;
|
|
239
|
+
});
|
|
240
|
+
|
|
241
|
+
// 如果精确匹配失败,尝试参数化匹配
|
|
242
|
+
if (!matchedNode) {
|
|
243
|
+
matchedNode = arr.find(function (item) {
|
|
244
|
+
return isPathMatch(item.path, tempCurrentPath);
|
|
245
|
+
});
|
|
246
|
+
if (matchedNode) {
|
|
247
|
+
matchedNode.realpath = tempCurrentPath;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
if (matchedNode) {
|
|
251
|
+
result.push(matchedNode);
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
// 更新currentPath用于下一次循环
|
|
255
|
+
currentPath = tempCurrentPath;
|
|
256
|
+
};
|
|
257
|
+
for (var i = 0; i < pathSegments.length; i++) {
|
|
258
|
+
_loop();
|
|
259
|
+
}
|
|
260
|
+
return result;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* 根据path值对数组进行去重
|
|
265
|
+
* @param arr - 包含path字段的数组
|
|
266
|
+
* @returns 去重后的数组
|
|
267
|
+
*/
|
|
268
|
+
export function uniqByPath(arr) {
|
|
269
|
+
var seenPaths = new Set();
|
|
270
|
+
var result = [];
|
|
271
|
+
var _iterator2 = _createForOfIteratorHelper(arr),
|
|
272
|
+
_step2;
|
|
273
|
+
try {
|
|
274
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
275
|
+
var item = _step2.value;
|
|
276
|
+
// 检查path是否已经存在
|
|
277
|
+
if (!seenPaths.has(item.path)) {
|
|
278
|
+
seenPaths.add(item.path);
|
|
279
|
+
result.push(item);
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
} catch (err) {
|
|
283
|
+
_iterator2.e(err);
|
|
284
|
+
} finally {
|
|
285
|
+
_iterator2.f();
|
|
286
|
+
}
|
|
287
|
+
return result;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* 深度拷贝对象或数组
|
|
292
|
+
* @param obj - 要深度拷贝的对象或数组
|
|
293
|
+
* @returns 拷贝后的新对象或数组
|
|
294
|
+
*/
|
|
295
|
+
export function deepClone(obj) {
|
|
296
|
+
// 处理 null 和 undefined
|
|
297
|
+
if (obj === null || obj === undefined) {
|
|
298
|
+
return obj;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
// 处理原始类型
|
|
302
|
+
if (_typeof(obj) !== 'object') {
|
|
303
|
+
return obj;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
// 处理日期对象
|
|
307
|
+
if (obj instanceof Date) {
|
|
308
|
+
return new Date(obj.getTime());
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
// 处理数组
|
|
312
|
+
if (Array.isArray(obj)) {
|
|
313
|
+
return obj.map(function (item) {
|
|
314
|
+
return deepClone(item);
|
|
315
|
+
});
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
// 处理普通对象
|
|
319
|
+
var clonedObj = {};
|
|
320
|
+
for (var key in obj) {
|
|
321
|
+
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
322
|
+
clonedObj[key] = deepClone(obj[key]);
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
return clonedObj;
|
|
326
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
|
+
import { YueBreadcrumb, YueMenuItem } from './helper';
|
|
3
|
+
import './index.less';
|
|
4
|
+
export interface YuePageHeaderProps {
|
|
5
|
+
width?: string | number;
|
|
6
|
+
backgroundColor?: string;
|
|
7
|
+
menuItems?: YueMenuItem[];
|
|
8
|
+
pageTitle?: string;
|
|
9
|
+
pageIcon?: ReactNode;
|
|
10
|
+
breadcrumbs?: YueBreadcrumb[];
|
|
11
|
+
routes?: any;
|
|
12
|
+
pathname?: string;
|
|
13
|
+
onRouteChange?: (item: {
|
|
14
|
+
key: string;
|
|
15
|
+
label?: string;
|
|
16
|
+
}) => void;
|
|
17
|
+
rightContent?: ReactNode;
|
|
18
|
+
onLocaleChange?: (value: {
|
|
19
|
+
locale: string;
|
|
20
|
+
}) => void;
|
|
21
|
+
}
|
|
22
|
+
declare const _default: React.NamedExoticComponent<YuePageHeaderProps>;
|
|
23
|
+
export default _default;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
var _excluded = ["width", "backgroundColor", "rightContent", "onLocaleChange"];
|
|
2
|
+
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); }
|
|
3
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
4
|
+
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."); }
|
|
5
|
+
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); }
|
|
6
|
+
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; }
|
|
7
|
+
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; } }
|
|
8
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
9
|
+
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; }
|
|
10
|
+
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; }
|
|
11
|
+
import React, { memo, useMemo, useState } from 'react';
|
|
12
|
+
import logoImg from "../assets/gw-logo.png";
|
|
13
|
+
import titleImg from "../assets/ylqq-title.png";
|
|
14
|
+
import FirstMenus from "./first-menus";
|
|
15
|
+
import { mainHost } from "./helper";
|
|
16
|
+
import "./index.less";
|
|
17
|
+
import RightContent from "./right-content";
|
|
18
|
+
import SecondMenus from "./second-menus";
|
|
19
|
+
var Index = function Index(_ref) {
|
|
20
|
+
var _ref$width = _ref.width,
|
|
21
|
+
width = _ref$width === void 0 ? '80%' : _ref$width,
|
|
22
|
+
_ref$backgroundColor = _ref.backgroundColor,
|
|
23
|
+
backgroundColor = _ref$backgroundColor === void 0 ? '#fff' : _ref$backgroundColor,
|
|
24
|
+
rightContent = _ref.rightContent,
|
|
25
|
+
onLocaleChange = _ref.onLocaleChange,
|
|
26
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
27
|
+
var _useState = useState(false),
|
|
28
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
29
|
+
visible = _useState2[0],
|
|
30
|
+
setVisible = _useState2[1];
|
|
31
|
+
var hasSecondMenu = useMemo(function () {
|
|
32
|
+
var _props$breadcrumbs, _props$menuItems;
|
|
33
|
+
return !!props.pageTitle || !!((_props$breadcrumbs = props.breadcrumbs) !== null && _props$breadcrumbs !== void 0 && _props$breadcrumbs.length) || !!((_props$menuItems = props.menuItems) !== null && _props$menuItems !== void 0 && _props$menuItems.length);
|
|
34
|
+
}, [props.pageTitle, props.breadcrumbs, props.menuItems]);
|
|
35
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
36
|
+
style: {
|
|
37
|
+
backgroundColor: backgroundColor,
|
|
38
|
+
height: 80 + (hasSecondMenu ? 60 : 0)
|
|
39
|
+
}
|
|
40
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
41
|
+
className: "yue-page-header",
|
|
42
|
+
style: backgroundColor === 'transparent' ? {
|
|
43
|
+
backgroundColor: 'rgba(255, 255, 255, 0.15)'
|
|
44
|
+
} : {
|
|
45
|
+
backgroundColor: backgroundColor
|
|
46
|
+
}
|
|
47
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
48
|
+
className: "yue-page-header-topbar yue-flex",
|
|
49
|
+
style: {
|
|
50
|
+
width: width
|
|
51
|
+
}
|
|
52
|
+
}, /*#__PURE__*/React.createElement("a", {
|
|
53
|
+
href: mainHost,
|
|
54
|
+
className: "yue-flex title-bar"
|
|
55
|
+
}, /*#__PURE__*/React.createElement("img", {
|
|
56
|
+
src: logoImg,
|
|
57
|
+
alt: "",
|
|
58
|
+
className: "logo"
|
|
59
|
+
}), /*#__PURE__*/React.createElement("img", {
|
|
60
|
+
src: titleImg,
|
|
61
|
+
alt: "",
|
|
62
|
+
className: "title"
|
|
63
|
+
})), /*#__PURE__*/React.createElement("div", {
|
|
64
|
+
className: "menus-bar"
|
|
65
|
+
}, /*#__PURE__*/React.createElement(FirstMenus, {
|
|
66
|
+
setVisible: setVisible
|
|
67
|
+
})), /*#__PURE__*/React.createElement(RightContent, {
|
|
68
|
+
content: rightContent,
|
|
69
|
+
onLocaleChange: onLocaleChange
|
|
70
|
+
})), hasSecondMenu && /*#__PURE__*/React.createElement(SecondMenus, _extends({
|
|
71
|
+
width: width,
|
|
72
|
+
visible: visible
|
|
73
|
+
}, props))));
|
|
74
|
+
};
|
|
75
|
+
export default /*#__PURE__*/memo(Index);
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
.yue-page-header {
|
|
2
|
+
position: fixed;
|
|
3
|
+
top: 0;
|
|
4
|
+
left: 0;
|
|
5
|
+
width: 100%;
|
|
6
|
+
z-index: 100;
|
|
7
|
+
line-height: 1.415;
|
|
8
|
+
|
|
9
|
+
* {
|
|
10
|
+
box-sizing: border-box;
|
|
11
|
+
outline: none;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.yue-flex {
|
|
15
|
+
display: flex;
|
|
16
|
+
align-items: center;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.yue-page-header-topbar {
|
|
21
|
+
margin: 0 auto;
|
|
22
|
+
height: 80px;
|
|
23
|
+
max-width: 100%;
|
|
24
|
+
|
|
25
|
+
.title-bar {
|
|
26
|
+
flex-shrink: 0;
|
|
27
|
+
cursor: pointer;
|
|
28
|
+
gap: 16px;
|
|
29
|
+
|
|
30
|
+
.logo {
|
|
31
|
+
height: 34px;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.title {
|
|
35
|
+
height: 29px;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.menus-bar {
|
|
40
|
+
flex: 1 1 0%;
|
|
41
|
+
min-width: 0;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
|
+
import './index.less';
|
|
3
|
+
interface Props {
|
|
4
|
+
content?: ReactNode;
|
|
5
|
+
onLocaleChange?: (value: {
|
|
6
|
+
locale: string;
|
|
7
|
+
}) => void;
|
|
8
|
+
}
|
|
9
|
+
declare const _default: React.NamedExoticComponent<Props>;
|
|
10
|
+
export default _default;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import React, { memo, useEffect } from 'react';
|
|
2
|
+
import { SingleWindowIcon } from "../../components/svg-icon";
|
|
3
|
+
import { checkExistScript, loadScript } from "../helper";
|
|
4
|
+
import "./index.less";
|
|
5
|
+
|
|
6
|
+
// 单一窗口的跳转地址
|
|
7
|
+
var singleWindowUrl = 'https://gd.singlewindow.cn/';
|
|
8
|
+
// 翻译插件的地址
|
|
9
|
+
var translateUrl = 'https://gdin.com.cn/szgw-libs/translate.min.js?elementId=gw_translate';
|
|
10
|
+
var Index = function Index(_ref) {
|
|
11
|
+
var content = _ref.content,
|
|
12
|
+
onLocaleChange = _ref.onLocaleChange;
|
|
13
|
+
useEffect(function () {
|
|
14
|
+
if (!checkExistScript('translate.min.js')) {
|
|
15
|
+
loadScript(translateUrl, true).then(function () {
|
|
16
|
+
setTimeout(function () {
|
|
17
|
+
var _window$szTranslate, _window$szTranslate$o;
|
|
18
|
+
// @ts-ignore
|
|
19
|
+
(_window$szTranslate = window.szTranslate) === null || _window$szTranslate === void 0 || (_window$szTranslate$o = _window$szTranslate.on) === null || _window$szTranslate$o === void 0 || _window$szTranslate$o.call(_window$szTranslate, 'locale', onLocaleChange);
|
|
20
|
+
}, 1000);
|
|
21
|
+
});
|
|
22
|
+
} else {
|
|
23
|
+
var _window$szTranslate2, _window$szTranslate2$, _window$szTranslate3, _window$szTranslate3$;
|
|
24
|
+
// @ts-ignore
|
|
25
|
+
(_window$szTranslate2 = window.szTranslate) === null || _window$szTranslate2 === void 0 || (_window$szTranslate2$ = _window$szTranslate2.init) === null || _window$szTranslate2$ === void 0 || _window$szTranslate2$.call(_window$szTranslate2, {
|
|
26
|
+
element: document.getElementById('gw_translate')
|
|
27
|
+
});
|
|
28
|
+
// @ts-ignore
|
|
29
|
+
(_window$szTranslate3 = window.szTranslate) === null || _window$szTranslate3 === void 0 || (_window$szTranslate3$ = _window$szTranslate3.on) === null || _window$szTranslate3$ === void 0 || _window$szTranslate3$.call(_window$szTranslate3, 'locale', onLocaleChange);
|
|
30
|
+
}
|
|
31
|
+
return function () {
|
|
32
|
+
var _window$szTranslate4, _window$szTranslate4$;
|
|
33
|
+
// @ts-ignore
|
|
34
|
+
(_window$szTranslate4 = window.szTranslate) === null || _window$szTranslate4 === void 0 || (_window$szTranslate4$ = _window$szTranslate4.off) === null || _window$szTranslate4$ === void 0 || _window$szTranslate4$.call(_window$szTranslate4, 'locale', onLocaleChange);
|
|
35
|
+
};
|
|
36
|
+
}, []);
|
|
37
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
38
|
+
className: "yue-flex yue-page-header-right-content"
|
|
39
|
+
}, /*#__PURE__*/React.createElement("a", {
|
|
40
|
+
href: singleWindowUrl,
|
|
41
|
+
target: "_blank",
|
|
42
|
+
rel: "noopener noreferrer",
|
|
43
|
+
className: "yue-flex link"
|
|
44
|
+
}, /*#__PURE__*/React.createElement("span", null, "\u5355\u4E00\u7A97\u53E3"), /*#__PURE__*/React.createElement(SingleWindowIcon, null)), /*#__PURE__*/React.createElement("div", {
|
|
45
|
+
className: "vr"
|
|
46
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
47
|
+
id: "gw_translate"
|
|
48
|
+
}), content);
|
|
49
|
+
};
|
|
50
|
+
export default /*#__PURE__*/memo(Index);
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
.yue-page-header-right-content {
|
|
2
|
+
flex-shrink: 0;
|
|
3
|
+
gap: 14px;
|
|
4
|
+
font-size: 15px;
|
|
5
|
+
margin-left: 12px;
|
|
6
|
+
|
|
7
|
+
.vr {
|
|
8
|
+
width: 1px;
|
|
9
|
+
height: 22px;
|
|
10
|
+
background-color: rgba(0, 0, 0, 40%);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.link {
|
|
14
|
+
text-decoration: none;
|
|
15
|
+
color: #000;
|
|
16
|
+
gap: 8px;
|
|
17
|
+
height: 34px;
|
|
18
|
+
border-radius: 4px;
|
|
19
|
+
padding-inline: 4px;
|
|
20
|
+
|
|
21
|
+
&:hover {
|
|
22
|
+
color: rgba(0, 0, 0, 90%);
|
|
23
|
+
background-color: rgba(0, 0, 0, 4%);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.anticon {
|
|
27
|
+
color: #2860f3;
|
|
28
|
+
font-size: 16px;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.sz-translate-bar.mode3 {
|
|
33
|
+
font-size: 16px;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { YuePageHeaderProps } from '../index';
|
|
3
|
+
import './index.less';
|
|
4
|
+
interface Props extends Omit<YuePageHeaderProps, 'rightContent'> {
|
|
5
|
+
visible: boolean;
|
|
6
|
+
}
|
|
7
|
+
declare const _default: React.NamedExoticComponent<Props>;
|
|
8
|
+
export default _default;
|