x-star-design 0.0.29 → 0.0.32

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.
@@ -12,6 +12,7 @@ export interface AliplayerConfig {
12
12
  * Aliplayer 实例
13
13
  */
14
14
  export interface AliplayerInstance {
15
+ pause: () => void;
15
16
  seek: (time: number) => void;
16
17
  getCurrentTime: () => number;
17
18
  setPlayerSize: (width: string, height: string) => void;
@@ -131,7 +131,8 @@ var CodeDetailModal = function CodeDetailModal(_ref) {
131
131
  },
132
132
  lang: codeData === null || codeData === void 0 ? void 0 : codeData.language,
133
133
  theme: Theme.LIGHT,
134
- value: codeData === null || codeData === void 0 ? void 0 : codeData.source
134
+ value: codeData === null || codeData === void 0 ? void 0 : codeData.source,
135
+ readOnly: true
135
136
  }) : /*#__PURE__*/React.createElement("pre", {
136
137
  className: "".concat(prefix, "codeCompileResult")
137
138
  }, /*#__PURE__*/React.createElement("code", null, codeData.detail))));
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+ interface Props {
3
+ onReset?: () => void;
4
+ homeLink?: string;
5
+ }
6
+ declare const ErrorPage: ({ onReset, homeLink }: Props) => React.JSX.Element;
7
+ export default ErrorPage;
@@ -0,0 +1,40 @@
1
+ import classNames from 'classnames';
2
+ import React from 'react';
3
+ import { useLocale } from "../../locales";
4
+ import { prefix } from "../../utils/global";
5
+ var ErrorPage = function ErrorPage(_ref) {
6
+ var onReset = _ref.onReset,
7
+ homeLink = _ref.homeLink;
8
+ var _useLocale = useLocale('ErrorPage'),
9
+ t = _useLocale.format;
10
+ return /*#__PURE__*/React.createElement("div", {
11
+ className: classNames("".concat(prefix, "errorPage"))
12
+ }, /*#__PURE__*/React.createElement("div", {
13
+ className: classNames("hello")
14
+ }), /*#__PURE__*/React.createElement("div", {
15
+ className: classNames("ip")
16
+ }), /*#__PURE__*/React.createElement("div", {
17
+ className: classNames("planets")
18
+ }), /*#__PURE__*/React.createElement("div", {
19
+ className: classNames("content")
20
+ }, /*#__PURE__*/React.createElement("div", {
21
+ className: classNames("alert")
22
+ }, /*#__PURE__*/React.createElement("div", {
23
+ className: classNames("alertContent")
24
+ }, /*#__PURE__*/React.createElement("h2", {
25
+ style: {
26
+ fontWeight: 'bold'
27
+ }
28
+ }, t('ERROR')), /*#__PURE__*/React.createElement("div", {
29
+ className: classNames("description")
30
+ }, /*#__PURE__*/React.createElement("div", null, t('ERROR_BOUNDARY_TIP_1')), /*#__PURE__*/React.createElement("div", null, t('ERROR_BOUNDARY_TIP_2')), /*#__PURE__*/React.createElement("div", {
31
+ className: classNames("actions")
32
+ }, /*#__PURE__*/React.createElement("a", {
33
+ href: homeLink || '/'
34
+ }, ">> ".concat(t('RETURN_TO_HOME'))), /*#__PURE__*/React.createElement("a", {
35
+ onClick: onReset
36
+ }, ">> ".concat(t('RETRY')))), /*#__PURE__*/React.createElement("div", null, t('TECHNICAL_DEPARTMENT_CONTACT_EMAIL'), /*#__PURE__*/React.createElement("a", {
37
+ href: "mailto:tech@xinyoudui.com"
38
+ }, 'tech@xinyoudui.com')))))));
39
+ };
40
+ export default ErrorPage;
@@ -5,7 +5,9 @@ import _inherits from "@babel/runtime/helpers/esm/inherits";
5
5
  import _createSuper from "@babel/runtime/helpers/esm/createSuper";
6
6
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
7
7
  // 本组件代码参考自 https://juejin.cn/post/6937474904375689224
8
+ import { message } from 'antd';
8
9
  import React from 'react';
10
+ import ErrorPage from "./error-page";
9
11
 
10
12
  // 出错后显示的元素类型
11
13
 
@@ -52,9 +54,11 @@ var ErrorBoundary = /*#__PURE__*/function (_React$Component) {
52
54
  });
53
55
  // 执行自定义重置逻辑,并重置组件状态
54
56
  _defineProperty(_assertThisInitialized(_this), "resetErrorBoundary", function () {
55
- if (_this.props.onReset) {
56
- _this.props.onReset();
57
- }
57
+ var _this$props$onReset = _this.props.onReset,
58
+ onReset = _this$props$onReset === void 0 ? function () {
59
+ message.info('开发人员正在解救陷入黑洞的代码,请耐心等待和尝试。Developers are rescuing code trapped in a black hole. Please be patient and try again');
60
+ } : _this$props$onReset;
61
+ onReset();
58
62
  _this.reset();
59
63
  });
60
64
  return _this;
@@ -64,6 +68,8 @@ var ErrorBoundary = /*#__PURE__*/function (_React$Component) {
64
68
  value: function componentDidCatch(error, errorInfo) {
65
69
  if (this.props.onError) {
66
70
  this.props.onError(error, errorInfo.componentStack);
71
+ } else {
72
+ console.error('Page Crash! Have been captured by error boundary.');
67
73
  }
68
74
  this.setState({
69
75
  error: error
@@ -97,7 +103,13 @@ var ErrorBoundary = /*#__PURE__*/function (_React$Component) {
97
103
  var _this$props2 = this.props,
98
104
  fallback = _this$props2.fallback,
99
105
  FallbackComponent = _this$props2.FallbackComponent,
100
- fallbackRender = _this$props2.fallbackRender;
106
+ _this$props2$fallback = _this$props2.fallbackRender,
107
+ fallbackRender = _this$props2$fallback === void 0 ? function (props) {
108
+ // fallback 组件的渲染函数 ErrorPage需要自己定义该组件
109
+ return /*#__PURE__*/React.createElement(ErrorPage, {
110
+ onReset: props.resetErrorBoundary
111
+ });
112
+ } : _this$props2$fallback;
101
113
  var error = this.state.error;
102
114
  if (error !== null) {
103
115
  var fallbackProps = {
@@ -54,5 +54,13 @@ declare const _default: {
54
54
  readonly CONTACT_TIP: "Please Scan The QR Code";
55
55
  readonly CONTACT_US: "Contact Us";
56
56
  };
57
+ readonly ErrorPage: {
58
+ readonly ERROR: "☹ Error";
59
+ readonly ERROR_BOUNDARY_TIP_1: "Sorry, the code accidentally got caught in a black hole and the page crashed.";
60
+ readonly ERROR_BOUNDARY_TIP_2: "You can try accessing the page again, or you can visit another page first.";
61
+ readonly RETURN_TO_HOME: "Return to home";
62
+ readonly RETRY: "Retry";
63
+ readonly TECHNICAL_DEPARTMENT_CONTACT_EMAIL: "Technical department contact email: ";
64
+ };
57
65
  };
58
66
  export default _default;
@@ -53,5 +53,13 @@ export default {
53
53
  CONTACT_TELEPHONE: 'Telephone: +1-510-760-1098',
54
54
  CONTACT_TIP: 'Please Scan The QR Code',
55
55
  CONTACT_US: 'Contact Us'
56
+ },
57
+ ErrorPage: {
58
+ ERROR: '☹ Error',
59
+ ERROR_BOUNDARY_TIP_1: 'Sorry, the code accidentally got caught in a black hole and the page crashed.',
60
+ ERROR_BOUNDARY_TIP_2: 'You can try accessing the page again, or you can visit another page first.',
61
+ RETURN_TO_HOME: 'Return to home',
62
+ RETRY: 'Retry',
63
+ TECHNICAL_DEPARTMENT_CONTACT_EMAIL: 'Technical department contact email: '
56
64
  }
57
65
  };
@@ -7,7 +7,7 @@ interface LocaleProviderProps {
7
7
  }
8
8
  export declare const LocaleProvider: ({ children, locale, }: LocaleProviderProps) => React.JSX.Element;
9
9
  type MessageMap = typeof zh_CN | typeof en_US;
10
- export declare const useLocale: <T extends "VisualDataConfig" | "TranslateButton" | "CodeDetailModal" | "ContactButton">(slice: T) => {
10
+ export declare const useLocale: <T extends "VisualDataConfig" | "TranslateButton" | "CodeDetailModal" | "ContactButton" | "ErrorPage">(slice: T) => {
11
11
  locale: string;
12
12
  format: <U extends keyof MessageMap[T]>(key: U) => ({
13
13
  readonly VisualDataConfig: {
@@ -65,6 +65,14 @@ export declare const useLocale: <T extends "VisualDataConfig" | "TranslateButton
65
65
  readonly CONTACT_TIP: "微信扫码,直接咨询";
66
66
  readonly CONTACT_US: "联系我们";
67
67
  };
68
+ readonly ErrorPage: {
69
+ readonly ERROR: "☹ 出错啦";
70
+ readonly ERROR_BOUNDARY_TIP_1: "不好意思,代码意外卷入了黑洞,页面发生了崩溃。";
71
+ readonly ERROR_BOUNDARY_TIP_2: "您可以重试访问该页面,或可以先访问其他页面。";
72
+ readonly RETURN_TO_HOME: "回到首页";
73
+ readonly RETRY: "重试";
74
+ readonly TECHNICAL_DEPARTMENT_CONTACT_EMAIL: "技术部联系邮箱:";
75
+ };
68
76
  } | {
69
77
  readonly VisualDataConfig: {
70
78
  readonly Time_MS: "Time Limit(MS)";
@@ -121,9 +129,17 @@ export declare const useLocale: <T extends "VisualDataConfig" | "TranslateButton
121
129
  readonly CONTACT_TIP: "Please Scan The QR Code";
122
130
  readonly CONTACT_US: "Contact Us";
123
131
  };
132
+ readonly ErrorPage: {
133
+ readonly ERROR: "☹ Error";
134
+ readonly ERROR_BOUNDARY_TIP_1: "Sorry, the code accidentally got caught in a black hole and the page crashed.";
135
+ readonly ERROR_BOUNDARY_TIP_2: "You can try accessing the page again, or you can visit another page first.";
136
+ readonly RETURN_TO_HOME: "Return to home";
137
+ readonly RETRY: "Retry";
138
+ readonly TECHNICAL_DEPARTMENT_CONTACT_EMAIL: "Technical department contact email: ";
139
+ };
124
140
  })[T][U];
125
141
  };
126
- export declare const getFormat: <T extends "VisualDataConfig" | "TranslateButton" | "CodeDetailModal" | "ContactButton">(locale: string | undefined, slice: T) => <U extends keyof MessageMap[T]>(key: U) => ({
142
+ export declare const getFormat: <T extends "VisualDataConfig" | "TranslateButton" | "CodeDetailModal" | "ContactButton" | "ErrorPage">(locale: string | undefined, slice: T) => <U extends keyof MessageMap[T]>(key: U) => ({
127
143
  readonly VisualDataConfig: {
128
144
  readonly Time_MS: "时间限制(MS)";
129
145
  readonly Space_MS: "空间限制(KB)";
@@ -179,6 +195,14 @@ export declare const getFormat: <T extends "VisualDataConfig" | "TranslateButton
179
195
  readonly CONTACT_TIP: "微信扫码,直接咨询";
180
196
  readonly CONTACT_US: "联系我们";
181
197
  };
198
+ readonly ErrorPage: {
199
+ readonly ERROR: "☹ 出错啦";
200
+ readonly ERROR_BOUNDARY_TIP_1: "不好意思,代码意外卷入了黑洞,页面发生了崩溃。";
201
+ readonly ERROR_BOUNDARY_TIP_2: "您可以重试访问该页面,或可以先访问其他页面。";
202
+ readonly RETURN_TO_HOME: "回到首页";
203
+ readonly RETRY: "重试";
204
+ readonly TECHNICAL_DEPARTMENT_CONTACT_EMAIL: "技术部联系邮箱:";
205
+ };
182
206
  } | {
183
207
  readonly VisualDataConfig: {
184
208
  readonly Time_MS: "Time Limit(MS)";
@@ -235,5 +259,13 @@ export declare const getFormat: <T extends "VisualDataConfig" | "TranslateButton
235
259
  readonly CONTACT_TIP: "Please Scan The QR Code";
236
260
  readonly CONTACT_US: "Contact Us";
237
261
  };
262
+ readonly ErrorPage: {
263
+ readonly ERROR: "☹ Error";
264
+ readonly ERROR_BOUNDARY_TIP_1: "Sorry, the code accidentally got caught in a black hole and the page crashed.";
265
+ readonly ERROR_BOUNDARY_TIP_2: "You can try accessing the page again, or you can visit another page first.";
266
+ readonly RETURN_TO_HOME: "Return to home";
267
+ readonly RETRY: "Retry";
268
+ readonly TECHNICAL_DEPARTMENT_CONTACT_EMAIL: "Technical department contact email: ";
269
+ };
238
270
  })[T][U];
239
271
  export {};
@@ -54,5 +54,13 @@ declare const _default: {
54
54
  readonly CONTACT_TIP: "微信扫码,直接咨询";
55
55
  readonly CONTACT_US: "联系我们";
56
56
  };
57
+ readonly ErrorPage: {
58
+ readonly ERROR: "☹ 出错啦";
59
+ readonly ERROR_BOUNDARY_TIP_1: "不好意思,代码意外卷入了黑洞,页面发生了崩溃。";
60
+ readonly ERROR_BOUNDARY_TIP_2: "您可以重试访问该页面,或可以先访问其他页面。";
61
+ readonly RETURN_TO_HOME: "回到首页";
62
+ readonly RETRY: "重试";
63
+ readonly TECHNICAL_DEPARTMENT_CONTACT_EMAIL: "技术部联系邮箱:";
64
+ };
57
65
  };
58
66
  export default _default;
@@ -53,5 +53,13 @@ export default {
53
53
  CONTACT_TELEPHONE: '电话:17367064678',
54
54
  CONTACT_TIP: '微信扫码,直接咨询',
55
55
  CONTACT_US: '联系我们'
56
+ },
57
+ ErrorPage: {
58
+ ERROR: '☹ 出错啦',
59
+ ERROR_BOUNDARY_TIP_1: '不好意思,代码意外卷入了黑洞,页面发生了崩溃。',
60
+ ERROR_BOUNDARY_TIP_2: '您可以重试访问该页面,或可以先访问其他页面。',
61
+ RETURN_TO_HOME: '回到首页',
62
+ RETRY: '重试',
63
+ TECHNICAL_DEPARTMENT_CONTACT_EMAIL: '技术部联系邮箱:'
56
64
  }
57
65
  };
@@ -428,3 +428,74 @@
428
428
  .x-star-design-contactButtonCard .x-star-design-card-body {
429
429
  padding: 5px;
430
430
  }
431
+
432
+ .x-star-design-errorPage {
433
+ position: relative;
434
+ width: 100vw;
435
+ height: calc(87vh - 64px);
436
+ }
437
+ .x-star-design-errorPage .hello {
438
+ position: absolute;
439
+ bottom: 240px;
440
+ left: 100px;
441
+ width: 204px;
442
+ height: 96px;
443
+ background: url("https://media.strapi.turingstar.com.cn/production/2023/3/hello_0dd8b00bbf.png") 100% no-repeat;
444
+ background-size: 100% 100%;
445
+ }
446
+ .x-star-design-errorPage .ip {
447
+ position: absolute;
448
+ bottom: 0;
449
+ left: 0;
450
+ width: 240px;
451
+ height: 280px;
452
+ background: url("https://media.strapi.turingstar.com.cn/production/2023/3/_31e3aca7f2.png") 100% no-repeat;
453
+ background-size: 100% 100%;
454
+ }
455
+ .x-star-design-errorPage .planets {
456
+ position: absolute;
457
+ top: 0;
458
+ right: 0;
459
+ width: 240px;
460
+ height: 280px;
461
+ background: url("https://media.strapi.turingstar.com.cn/production/2023/3/background_right_6ff67955bc.png") 100% no-repeat;
462
+ background-size: 100% 100%;
463
+ }
464
+ .x-star-design-errorPage .content {
465
+ position: absolute;
466
+ top: 50%;
467
+ left: 50%;
468
+ display: flex;
469
+ justify-content: space-around;
470
+ align-items: center;
471
+ color: rgba(0, 0, 0, 0.88);
472
+ transform: translate(-50%, -50%);
473
+ flex-direction: column;
474
+ }
475
+ .x-star-design-errorPage .content .alert {
476
+ position: relative;
477
+ display: flex;
478
+ align-items: flex-start;
479
+ margin: 0;
480
+ padding: 8px 12px;
481
+ border: 1px solid #ffccc7;
482
+ border-radius: 8px;
483
+ font-size: 16px;
484
+ color: rgba(0, 0, 0, 0.88);
485
+ background-color: #fff2f0;
486
+ padding-inline: 24px;
487
+ padding-block: 20px;
488
+ box-sizing: border-box;
489
+ }
490
+ .x-star-design-errorPage .content .alert .description {
491
+ display: flex;
492
+ flex-direction: column;
493
+ }
494
+ .x-star-design-errorPage .content .alert .description div {
495
+ line-height: 2.5rem;
496
+ }
497
+ .x-star-design-errorPage .content .alert .description .actions {
498
+ display: flex;
499
+ justify-content: space-between;
500
+ width: 50%;
501
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "x-star-design",
3
- "version": "0.0.29",
3
+ "version": "0.0.32",
4
4
  "description": "A react component library developed by turingstar",
5
5
  "license": "MIT",
6
6
  "module": "dist/index.js",