@arcblock/ux 1.16.8 → 1.16.9
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/lib/Result/common.js +165 -0
- package/lib/Result/html/index.js +123 -0
- package/lib/Result/html/template.js +25 -0
- package/lib/Result/index.js +61 -0
- package/lib/Result/result.js +69 -0
- package/lib/Result/translations.js +61 -0
- package/package.json +4 -4
- package/src/Result/common.js +111 -0
- package/src/Result/html/index.js +61 -0
- package/src/Result/html/template.js +71 -0
- package/src/Result/index.js +31 -0
- package/src/Result/result.js +56 -0
- package/src/Result/translations.js +56 -0
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.ComingSoon = exports.Maintenance = exports.Error = exports.InternalServerError = exports.Forbidden = exports.PageNotFound = void 0;
|
|
7
|
+
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
|
|
10
|
+
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
11
|
+
|
|
12
|
+
var _useTheme = _interopRequireDefault(require("@material-ui/core/styles/useTheme"));
|
|
13
|
+
|
|
14
|
+
var _result = _interopRequireDefault(require("./result"));
|
|
15
|
+
|
|
16
|
+
var _translations = _interopRequireDefault(require("./translations"));
|
|
17
|
+
|
|
18
|
+
var _Logo = _interopRequireDefault(require("../Logo"));
|
|
19
|
+
|
|
20
|
+
var _context = require("../Locale/context");
|
|
21
|
+
|
|
22
|
+
const _excluded = ["locale"],
|
|
23
|
+
_excluded2 = ["locale"],
|
|
24
|
+
_excluded3 = ["locale"],
|
|
25
|
+
_excluded4 = ["locale"],
|
|
26
|
+
_excluded5 = ["locale"],
|
|
27
|
+
_excluded6 = ["locale"];
|
|
28
|
+
|
|
29
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
30
|
+
|
|
31
|
+
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; }
|
|
32
|
+
|
|
33
|
+
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; }
|
|
34
|
+
|
|
35
|
+
// 优先使用显式指定的 locale, 再尝试使用 context 中的 locale, 最后使用默认 'en'
|
|
36
|
+
const useLocale = locale => {
|
|
37
|
+
locale = ['zh', 'en'].includes(locale) ? locale : '';
|
|
38
|
+
const {
|
|
39
|
+
locale: localeFromContext
|
|
40
|
+
} = (0, _context.useLocaleContext)() || {
|
|
41
|
+
locale: 'en'
|
|
42
|
+
};
|
|
43
|
+
return locale || localeFromContext;
|
|
44
|
+
}; // 404
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
const PageNotFound = _ref => {
|
|
48
|
+
let {
|
|
49
|
+
locale
|
|
50
|
+
} = _ref,
|
|
51
|
+
rest = _objectWithoutProperties(_ref, _excluded);
|
|
52
|
+
|
|
53
|
+
locale = useLocale(locale);
|
|
54
|
+
return /*#__PURE__*/_react.default.createElement(_result.default, Object.assign({
|
|
55
|
+
icon: /*#__PURE__*/_react.default.createElement(StyledLogo, null),
|
|
56
|
+
title: _translations.default[locale][404].title,
|
|
57
|
+
description: _translations.default[locale][404].description
|
|
58
|
+
}, rest));
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
exports.PageNotFound = PageNotFound;
|
|
62
|
+
PageNotFound.status = '404'; // 403
|
|
63
|
+
|
|
64
|
+
const Forbidden = _ref2 => {
|
|
65
|
+
let {
|
|
66
|
+
locale
|
|
67
|
+
} = _ref2,
|
|
68
|
+
rest = _objectWithoutProperties(_ref2, _excluded2);
|
|
69
|
+
|
|
70
|
+
locale = useLocale(locale);
|
|
71
|
+
return /*#__PURE__*/_react.default.createElement(_result.default, Object.assign({
|
|
72
|
+
icon: /*#__PURE__*/_react.default.createElement(StyledLogo, null),
|
|
73
|
+
title: _translations.default[locale][403].title,
|
|
74
|
+
description: _translations.default[locale][403].description
|
|
75
|
+
}, rest));
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
exports.Forbidden = Forbidden;
|
|
79
|
+
Forbidden.status = '403'; // 500
|
|
80
|
+
|
|
81
|
+
const InternalServerError = _ref3 => {
|
|
82
|
+
let {
|
|
83
|
+
locale
|
|
84
|
+
} = _ref3,
|
|
85
|
+
rest = _objectWithoutProperties(_ref3, _excluded3);
|
|
86
|
+
|
|
87
|
+
locale = useLocale(locale);
|
|
88
|
+
return /*#__PURE__*/_react.default.createElement(_result.default, Object.assign({
|
|
89
|
+
icon: /*#__PURE__*/_react.default.createElement(StyledLogo, null),
|
|
90
|
+
title: _translations.default[locale][500].title,
|
|
91
|
+
description: _translations.default[locale][500].description
|
|
92
|
+
}, rest));
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
exports.InternalServerError = InternalServerError;
|
|
96
|
+
InternalServerError.status = '500'; // 通用错误
|
|
97
|
+
|
|
98
|
+
const Error = _ref4 => {
|
|
99
|
+
let {
|
|
100
|
+
locale
|
|
101
|
+
} = _ref4,
|
|
102
|
+
rest = _objectWithoutProperties(_ref4, _excluded4);
|
|
103
|
+
|
|
104
|
+
locale = useLocale(locale);
|
|
105
|
+
return /*#__PURE__*/_react.default.createElement(_result.default, Object.assign({
|
|
106
|
+
icon: /*#__PURE__*/_react.default.createElement(StyledLogo, null),
|
|
107
|
+
title: _translations.default[locale].error.title,
|
|
108
|
+
description: _translations.default[locale].error.description
|
|
109
|
+
}, rest));
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
exports.Error = Error;
|
|
113
|
+
Error.status = 'error'; // under maintenance
|
|
114
|
+
|
|
115
|
+
const Maintenance = _ref5 => {
|
|
116
|
+
let {
|
|
117
|
+
locale
|
|
118
|
+
} = _ref5,
|
|
119
|
+
rest = _objectWithoutProperties(_ref5, _excluded5);
|
|
120
|
+
|
|
121
|
+
locale = useLocale(locale);
|
|
122
|
+
return /*#__PURE__*/_react.default.createElement(_result.default, Object.assign({
|
|
123
|
+
icon: /*#__PURE__*/_react.default.createElement(StyledLogo, null),
|
|
124
|
+
title: _translations.default[locale].maintenance.title,
|
|
125
|
+
description: _translations.default[locale].maintenance.description
|
|
126
|
+
}, rest));
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
exports.Maintenance = Maintenance;
|
|
130
|
+
Maintenance.status = 'maintenance'; // coming soon
|
|
131
|
+
|
|
132
|
+
const ComingSoon = _ref6 => {
|
|
133
|
+
let {
|
|
134
|
+
locale
|
|
135
|
+
} = _ref6,
|
|
136
|
+
rest = _objectWithoutProperties(_ref6, _excluded6);
|
|
137
|
+
|
|
138
|
+
locale = useLocale(locale);
|
|
139
|
+
return /*#__PURE__*/_react.default.createElement(_result.default, Object.assign({
|
|
140
|
+
icon: /*#__PURE__*/_react.default.createElement(StyledLogo, null),
|
|
141
|
+
title: _translations.default[locale]['coming-soon'].title,
|
|
142
|
+
description: _translations.default[locale]['coming-soon'].description
|
|
143
|
+
}, rest));
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
exports.ComingSoon = ComingSoon;
|
|
147
|
+
ComingSoon.status = 'coming-soon'; // arcblock logo
|
|
148
|
+
|
|
149
|
+
const StyledLogo = props => {
|
|
150
|
+
const theme = (0, _useTheme.default)();
|
|
151
|
+
return /*#__PURE__*/_react.default.createElement(StyledLogoRoot, Object.assign({
|
|
152
|
+
showText: false,
|
|
153
|
+
theme: theme
|
|
154
|
+
}, props));
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
const StyledLogoRoot = (0, _styledComponents.default)(_Logo.default).withConfig({
|
|
158
|
+
displayName: "common__StyledLogoRoot",
|
|
159
|
+
componentId: "sc-1wnp76o-0"
|
|
160
|
+
})(["*{stroke:", ";}"], _ref7 => {
|
|
161
|
+
let {
|
|
162
|
+
theme
|
|
163
|
+
} = _ref7;
|
|
164
|
+
return theme.palette.grey[500];
|
|
165
|
+
});
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = render;
|
|
7
|
+
|
|
8
|
+
var _template = _interopRequireDefault(require("./template"));
|
|
9
|
+
|
|
10
|
+
var _translations = _interopRequireDefault(require("../translations"));
|
|
11
|
+
|
|
12
|
+
const _excluded = ["locale"],
|
|
13
|
+
_excluded2 = ["locale"],
|
|
14
|
+
_excluded3 = ["locale"],
|
|
15
|
+
_excluded4 = ["locale"],
|
|
16
|
+
_excluded5 = ["locale"],
|
|
17
|
+
_excluded6 = ["locale"],
|
|
18
|
+
_excluded7 = ["status", "locale"];
|
|
19
|
+
|
|
20
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
21
|
+
|
|
22
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
23
|
+
|
|
24
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
25
|
+
|
|
26
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
27
|
+
|
|
28
|
+
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; }
|
|
29
|
+
|
|
30
|
+
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; }
|
|
31
|
+
|
|
32
|
+
const renderers = {
|
|
33
|
+
404: _ref => {
|
|
34
|
+
let {
|
|
35
|
+
locale = 'en'
|
|
36
|
+
} = _ref,
|
|
37
|
+
rest = _objectWithoutProperties(_ref, _excluded);
|
|
38
|
+
|
|
39
|
+
return _template.default.render(_objectSpread({
|
|
40
|
+
title: _translations.default[locale][404].title,
|
|
41
|
+
description: _translations.default[locale][404].description
|
|
42
|
+
}, rest));
|
|
43
|
+
},
|
|
44
|
+
403: _ref2 => {
|
|
45
|
+
let {
|
|
46
|
+
locale = 'en'
|
|
47
|
+
} = _ref2,
|
|
48
|
+
rest = _objectWithoutProperties(_ref2, _excluded2);
|
|
49
|
+
|
|
50
|
+
return _template.default.render(_objectSpread({
|
|
51
|
+
title: _translations.default[locale][403].title,
|
|
52
|
+
description: _translations.default[locale][403].description
|
|
53
|
+
}, rest));
|
|
54
|
+
},
|
|
55
|
+
500: _ref3 => {
|
|
56
|
+
let {
|
|
57
|
+
locale = 'en'
|
|
58
|
+
} = _ref3,
|
|
59
|
+
rest = _objectWithoutProperties(_ref3, _excluded3);
|
|
60
|
+
|
|
61
|
+
return _template.default.render(_objectSpread({
|
|
62
|
+
title: _translations.default[locale][500].title,
|
|
63
|
+
description: _translations.default[locale][500].description
|
|
64
|
+
}, rest));
|
|
65
|
+
},
|
|
66
|
+
error: _ref4 => {
|
|
67
|
+
let {
|
|
68
|
+
locale = 'en'
|
|
69
|
+
} = _ref4,
|
|
70
|
+
rest = _objectWithoutProperties(_ref4, _excluded4);
|
|
71
|
+
|
|
72
|
+
return _template.default.render(_objectSpread({
|
|
73
|
+
title: _translations.default[locale].error.title,
|
|
74
|
+
description: _translations.default[locale].error.description
|
|
75
|
+
}, rest));
|
|
76
|
+
},
|
|
77
|
+
maintenance: _ref5 => {
|
|
78
|
+
let {
|
|
79
|
+
locale = 'en'
|
|
80
|
+
} = _ref5,
|
|
81
|
+
rest = _objectWithoutProperties(_ref5, _excluded5);
|
|
82
|
+
|
|
83
|
+
return _template.default.render(_objectSpread({
|
|
84
|
+
title: _translations.default[locale].maintenance.title,
|
|
85
|
+
description: _translations.default[locale].maintenance.description
|
|
86
|
+
}, rest));
|
|
87
|
+
},
|
|
88
|
+
'coming-soon': _ref6 => {
|
|
89
|
+
let {
|
|
90
|
+
locale = 'en'
|
|
91
|
+
} = _ref6,
|
|
92
|
+
rest = _objectWithoutProperties(_ref6, _excluded6);
|
|
93
|
+
|
|
94
|
+
return _template.default.render(_objectSpread({
|
|
95
|
+
title: _translations.default[locale]['coming-soon'].title,
|
|
96
|
+
description: _translations.default[locale]['coming-soon'].description
|
|
97
|
+
}, rest));
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
function render() {
|
|
102
|
+
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
103
|
+
|
|
104
|
+
const {
|
|
105
|
+
status,
|
|
106
|
+
locale = 'en'
|
|
107
|
+
} = options,
|
|
108
|
+
rest = _objectWithoutProperties(options, _excluded7);
|
|
109
|
+
|
|
110
|
+
if (status) {
|
|
111
|
+
const renderer = renderers[status];
|
|
112
|
+
|
|
113
|
+
if (!renderer) {
|
|
114
|
+
throw new Error("Please provide a valid status. Valid values are: ".concat(Object.keys(renderers).join(', ')));
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
return renderer(_objectSpread({
|
|
118
|
+
locale
|
|
119
|
+
}, rest));
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
return _template.default.render(_objectSpread({}, rest));
|
|
123
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
const arcblockLogoSvg = '<svg xmlns="http://www.w3.org/2000/svg" width="45" height="52" viewBox="0 0 45 52"><g fill="none" fill-rule="evenodd" stroke="#000"><path d="M.5 13.077L22.15.577l21.651 12.5v25l-21.65 12.5L.5 38.077zM22.15.577v50M.5 13.077l43.301 25m-43.301 0l43.301-25"></path><path d="M22.15 38.077l10.826-6.25-10.825-18.75-10.825 18.75z"></path></g></svg>';
|
|
8
|
+
|
|
9
|
+
function render(_ref) {
|
|
10
|
+
let {
|
|
11
|
+
pageTitle,
|
|
12
|
+
title,
|
|
13
|
+
icon,
|
|
14
|
+
description,
|
|
15
|
+
extra
|
|
16
|
+
} = _ref;
|
|
17
|
+
// eslint-disable-next-line no-param-reassign
|
|
18
|
+
pageTitle = pageTitle || "".concat(title, " - Blocklet Server");
|
|
19
|
+
return "\n <!DOCTYPE html>\n <html lang=\"en\">\n <head>\n <meta charset=\"UTF-8\">\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n <title>".concat(pageTitle, "</title>\n <style>\n html {\n box-sizing: border-box;\n font-size: 16px;\n }\n *, *::before, *::after {\n box-sizing: inherit;\n }\n html, body {\n height: 100%;\n }\n body {\n margin: 0;\n }\n .container {\n display: flex;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n height: 100%;\n padding: 16px;\n background-color: #f7f8fb;\n }\n .svg-wrapper *{\n stroke: #9e9e9e;\n }\n .title {\n margin-top: 24px;\n font-size: 22px;\n font-weight: 400;\n color: #47494E;\n text-align: center;\n }\n .description {\n margin-top: 8px;\n font-size: 14px;\n color: #7F828B;\n text-align: center;\n }\n .extra {\n margin-top: 24px;\n }\n </style>\n </head>\n <body>\n <div class=\"container\">\n ").concat(icon ? "<img src=\"".concat(icon, "\" />") : "<span class=\"svg-wrapper\">".concat(arcblockLogoSvg, "</span>"), "\n <div class=\"title\">\n ").concat(title, "\n </div>\n ").concat(description ? "<div class=\"description\">".concat(description, "</div>") : '', "\n ").concat(extra ? "<div class=\"extra\">".concat(extra, "</div>") : '', "\n </div>\n </body>\n </html>");
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
var _default = {
|
|
23
|
+
render
|
|
24
|
+
};
|
|
25
|
+
exports.default = _default;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = ResultWrapper;
|
|
7
|
+
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
|
|
10
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
+
|
|
12
|
+
var _result = _interopRequireDefault(require("./result"));
|
|
13
|
+
|
|
14
|
+
var common = _interopRequireWildcard(require("./common"));
|
|
15
|
+
|
|
16
|
+
const _excluded = ["status"];
|
|
17
|
+
|
|
18
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
19
|
+
|
|
20
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
21
|
+
|
|
22
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
23
|
+
|
|
24
|
+
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; }
|
|
25
|
+
|
|
26
|
+
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; }
|
|
27
|
+
|
|
28
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
29
|
+
|
|
30
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
31
|
+
|
|
32
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
33
|
+
|
|
34
|
+
const componentsKeyByStatus = Object.keys(common).reduce((acc, cur) => _objectSpread(_objectSpread({}, acc), {}, {
|
|
35
|
+
[common[cur].status || cur]: common[cur]
|
|
36
|
+
}), {});
|
|
37
|
+
|
|
38
|
+
function ResultWrapper(_ref) {
|
|
39
|
+
let {
|
|
40
|
+
status
|
|
41
|
+
} = _ref,
|
|
42
|
+
rest = _objectWithoutProperties(_ref, _excluded);
|
|
43
|
+
|
|
44
|
+
if (status) {
|
|
45
|
+
if (componentsKeyByStatus[status]) {
|
|
46
|
+
const Component = componentsKeyByStatus[status];
|
|
47
|
+
return /*#__PURE__*/_react.default.createElement(Component, rest);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
throw new Error("Please provide a valid status for Result.status. Valid values are: ".concat(Object.keys(componentsKeyByStatus).join(', ')));
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return /*#__PURE__*/_react.default.createElement(_result.default, rest);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
ResultWrapper.propTypes = {
|
|
57
|
+
status: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number])
|
|
58
|
+
};
|
|
59
|
+
ResultWrapper.defaultProps = {
|
|
60
|
+
status: ''
|
|
61
|
+
};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
|
|
10
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
+
|
|
12
|
+
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
13
|
+
|
|
14
|
+
var _Box = _interopRequireDefault(require("@material-ui/core/Box"));
|
|
15
|
+
|
|
16
|
+
const _excluded = ["icon", "title", "description", "extra"];
|
|
17
|
+
|
|
18
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
|
+
|
|
20
|
+
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; }
|
|
21
|
+
|
|
22
|
+
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; }
|
|
23
|
+
|
|
24
|
+
function Result(_ref) {
|
|
25
|
+
let {
|
|
26
|
+
icon,
|
|
27
|
+
title,
|
|
28
|
+
description,
|
|
29
|
+
extra
|
|
30
|
+
} = _ref,
|
|
31
|
+
rest = _objectWithoutProperties(_ref, _excluded);
|
|
32
|
+
|
|
33
|
+
return /*#__PURE__*/_react.default.createElement(Root, rest, icon, typeof title === 'string' ? /*#__PURE__*/_react.default.createElement(_Box.default, {
|
|
34
|
+
mt: 3,
|
|
35
|
+
fontSize: 22,
|
|
36
|
+
fontWeight: 400,
|
|
37
|
+
color: "#47494E",
|
|
38
|
+
textAlign: "center"
|
|
39
|
+
}, title) : title, typeof description === 'string' ? /*#__PURE__*/_react.default.createElement(_Box.default, {
|
|
40
|
+
mt: 1,
|
|
41
|
+
fontSize: 14,
|
|
42
|
+
color: "#7F828B",
|
|
43
|
+
textAlign: "center"
|
|
44
|
+
}, description) : description, /*#__PURE__*/_react.default.createElement(_Box.default, {
|
|
45
|
+
mt: 3
|
|
46
|
+
}, extra));
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
Result.propTypes = {
|
|
50
|
+
icon: _propTypes.default.any,
|
|
51
|
+
title: _propTypes.default.any.isRequired,
|
|
52
|
+
description: _propTypes.default.any,
|
|
53
|
+
actions: _propTypes.default.any,
|
|
54
|
+
extra: _propTypes.default.any
|
|
55
|
+
};
|
|
56
|
+
Result.defaultProps = {
|
|
57
|
+
icon: '',
|
|
58
|
+
description: '',
|
|
59
|
+
actions: null,
|
|
60
|
+
extra: null
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const Root = _styledComponents.default.div.withConfig({
|
|
64
|
+
displayName: "result__Root",
|
|
65
|
+
componentId: "sc-1ttf6c9-0"
|
|
66
|
+
})(["display:flex;flex-direction:column;justify-content:center;align-items:center;height:100%;padding:16px;background-color:#f7f8fb;"]);
|
|
67
|
+
|
|
68
|
+
var _default = Result;
|
|
69
|
+
exports.default = _default;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _default = {
|
|
8
|
+
en: {
|
|
9
|
+
404: {
|
|
10
|
+
title: '404 - Page Not Found',
|
|
11
|
+
description: 'Sorry about that, the page you are looking for does not exist or has been moved.'
|
|
12
|
+
},
|
|
13
|
+
403: {
|
|
14
|
+
title: '403 – Forbidden',
|
|
15
|
+
description: 'Sorry, you are not authorized to access this page.'
|
|
16
|
+
},
|
|
17
|
+
500: {
|
|
18
|
+
title: '500 - Internal Server Error',
|
|
19
|
+
description: 'An internal server error has occured. Please try again later.'
|
|
20
|
+
},
|
|
21
|
+
error: {
|
|
22
|
+
title: 'Application Error',
|
|
23
|
+
description: 'Something went wrong. Please try again later.'
|
|
24
|
+
},
|
|
25
|
+
maintenance: {
|
|
26
|
+
title: 'Offline for maintenance',
|
|
27
|
+
description: 'This app is undergoing maintenance right now. Please check back later.'
|
|
28
|
+
},
|
|
29
|
+
'coming-soon': {
|
|
30
|
+
title: 'Coming Soon',
|
|
31
|
+
description: "Our website is under construction. We'll be here soon with our new website."
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
zh: {
|
|
35
|
+
404: {
|
|
36
|
+
title: '404 - 页面未找到',
|
|
37
|
+
description: '很抱歉,您正在寻找的页面不存在或已被移动。'
|
|
38
|
+
},
|
|
39
|
+
403: {
|
|
40
|
+
title: '403 – 禁止访问',
|
|
41
|
+
description: '很抱歉,您没有权限访问此页面。'
|
|
42
|
+
},
|
|
43
|
+
500: {
|
|
44
|
+
title: '500 - 内部服务器错误',
|
|
45
|
+
description: '发生了一个内部服务器错误。请稍后再试。'
|
|
46
|
+
},
|
|
47
|
+
error: {
|
|
48
|
+
title: 'Application Error',
|
|
49
|
+
description: '出错了, 请稍后再试。'
|
|
50
|
+
},
|
|
51
|
+
maintenance: {
|
|
52
|
+
title: '维护中',
|
|
53
|
+
description: '应用程序正在进行维护。请稍后再查看。'
|
|
54
|
+
},
|
|
55
|
+
'coming-soon': {
|
|
56
|
+
title: '即将上线',
|
|
57
|
+
description: '我们的网站正在建设中。我们很快就会在这里推出我们的新网站。'
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
exports.default = _default;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arcblock/ux",
|
|
3
|
-
"version": "1.16.
|
|
3
|
+
"version": "1.16.9",
|
|
4
4
|
"description": "Common used react components for arcblock products",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -53,10 +53,10 @@
|
|
|
53
53
|
"react": ">=16.12.0",
|
|
54
54
|
"react-ga": "^2.7.0"
|
|
55
55
|
},
|
|
56
|
-
"gitHead": "
|
|
56
|
+
"gitHead": "4dc8cf3eb4ca262e22b21cba7feaba2cab88f14d",
|
|
57
57
|
"dependencies": {
|
|
58
|
-
"@arcblock/icons": "^1.16.
|
|
59
|
-
"@arcblock/react-hooks": "^1.16.
|
|
58
|
+
"@arcblock/icons": "^1.16.9",
|
|
59
|
+
"@arcblock/react-hooks": "^1.16.9",
|
|
60
60
|
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
|
|
61
61
|
"@material-ui/core": "^4.12.3",
|
|
62
62
|
"@material-ui/icons": "4.11.2",
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/* eslint-disable react/prop-types */
|
|
2
|
+
/* eslint-disable no-param-reassign */
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import styled from 'styled-components';
|
|
5
|
+
import useTheme from '@material-ui/core/styles/useTheme';
|
|
6
|
+
import Result from './result';
|
|
7
|
+
import translations from './translations';
|
|
8
|
+
import Logo from '../Logo';
|
|
9
|
+
import { useLocaleContext } from '../Locale/context';
|
|
10
|
+
|
|
11
|
+
// 优先使用显式指定的 locale, 再尝试使用 context 中的 locale, 最后使用默认 'en'
|
|
12
|
+
const useLocale = locale => {
|
|
13
|
+
locale = ['zh', 'en'].includes(locale) ? locale : '';
|
|
14
|
+
const { locale: localeFromContext } = useLocaleContext() || { locale: 'en' };
|
|
15
|
+
return locale || localeFromContext;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
// 404
|
|
19
|
+
export const PageNotFound = ({ locale, ...rest }) => {
|
|
20
|
+
locale = useLocale(locale);
|
|
21
|
+
return (
|
|
22
|
+
<Result
|
|
23
|
+
icon={<StyledLogo />}
|
|
24
|
+
title={translations[locale][404].title}
|
|
25
|
+
description={translations[locale][404].description}
|
|
26
|
+
{...rest}
|
|
27
|
+
/>
|
|
28
|
+
);
|
|
29
|
+
};
|
|
30
|
+
PageNotFound.status = '404';
|
|
31
|
+
|
|
32
|
+
// 403
|
|
33
|
+
export const Forbidden = ({ locale, ...rest }) => {
|
|
34
|
+
locale = useLocale(locale);
|
|
35
|
+
return (
|
|
36
|
+
<Result
|
|
37
|
+
icon={<StyledLogo />}
|
|
38
|
+
title={translations[locale][403].title}
|
|
39
|
+
description={translations[locale][403].description}
|
|
40
|
+
{...rest}
|
|
41
|
+
/>
|
|
42
|
+
);
|
|
43
|
+
};
|
|
44
|
+
Forbidden.status = '403';
|
|
45
|
+
|
|
46
|
+
// 500
|
|
47
|
+
export const InternalServerError = ({ locale, ...rest }) => {
|
|
48
|
+
locale = useLocale(locale);
|
|
49
|
+
return (
|
|
50
|
+
<Result
|
|
51
|
+
icon={<StyledLogo />}
|
|
52
|
+
title={translations[locale][500].title}
|
|
53
|
+
description={translations[locale][500].description}
|
|
54
|
+
{...rest}
|
|
55
|
+
/>
|
|
56
|
+
);
|
|
57
|
+
};
|
|
58
|
+
InternalServerError.status = '500';
|
|
59
|
+
|
|
60
|
+
// 通用错误
|
|
61
|
+
export const Error = ({ locale, ...rest }) => {
|
|
62
|
+
locale = useLocale(locale);
|
|
63
|
+
return (
|
|
64
|
+
<Result
|
|
65
|
+
icon={<StyledLogo />}
|
|
66
|
+
title={translations[locale].error.title}
|
|
67
|
+
description={translations[locale].error.description}
|
|
68
|
+
{...rest}
|
|
69
|
+
/>
|
|
70
|
+
);
|
|
71
|
+
};
|
|
72
|
+
Error.status = 'error';
|
|
73
|
+
|
|
74
|
+
// under maintenance
|
|
75
|
+
export const Maintenance = ({ locale, ...rest }) => {
|
|
76
|
+
locale = useLocale(locale);
|
|
77
|
+
return (
|
|
78
|
+
<Result
|
|
79
|
+
icon={<StyledLogo />}
|
|
80
|
+
title={translations[locale].maintenance.title}
|
|
81
|
+
description={translations[locale].maintenance.description}
|
|
82
|
+
{...rest}
|
|
83
|
+
/>
|
|
84
|
+
);
|
|
85
|
+
};
|
|
86
|
+
Maintenance.status = 'maintenance';
|
|
87
|
+
|
|
88
|
+
// coming soon
|
|
89
|
+
export const ComingSoon = ({ locale, ...rest }) => {
|
|
90
|
+
locale = useLocale(locale);
|
|
91
|
+
return (
|
|
92
|
+
<Result
|
|
93
|
+
icon={<StyledLogo />}
|
|
94
|
+
title={translations[locale]['coming-soon'].title}
|
|
95
|
+
description={translations[locale]['coming-soon'].description}
|
|
96
|
+
{...rest}
|
|
97
|
+
/>
|
|
98
|
+
);
|
|
99
|
+
};
|
|
100
|
+
ComingSoon.status = 'coming-soon';
|
|
101
|
+
|
|
102
|
+
// arcblock logo
|
|
103
|
+
const StyledLogo = props => {
|
|
104
|
+
const theme = useTheme();
|
|
105
|
+
return <StyledLogoRoot showText={false} theme={theme} {...props} />;
|
|
106
|
+
};
|
|
107
|
+
const StyledLogoRoot = styled(Logo)`
|
|
108
|
+
* {
|
|
109
|
+
stroke: ${({ theme }) => theme.palette.grey[500]};
|
|
110
|
+
}
|
|
111
|
+
`;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import template from './template';
|
|
2
|
+
import translations from '../translations';
|
|
3
|
+
|
|
4
|
+
const renderers = {
|
|
5
|
+
404: ({ locale = 'en', ...rest }) => {
|
|
6
|
+
return template.render({
|
|
7
|
+
title: translations[locale][404].title,
|
|
8
|
+
description: translations[locale][404].description,
|
|
9
|
+
...rest,
|
|
10
|
+
});
|
|
11
|
+
},
|
|
12
|
+
403: ({ locale = 'en', ...rest }) => {
|
|
13
|
+
return template.render({
|
|
14
|
+
title: translations[locale][403].title,
|
|
15
|
+
description: translations[locale][403].description,
|
|
16
|
+
...rest,
|
|
17
|
+
});
|
|
18
|
+
},
|
|
19
|
+
500: ({ locale = 'en', ...rest }) => {
|
|
20
|
+
return template.render({
|
|
21
|
+
title: translations[locale][500].title,
|
|
22
|
+
description: translations[locale][500].description,
|
|
23
|
+
...rest,
|
|
24
|
+
});
|
|
25
|
+
},
|
|
26
|
+
error: ({ locale = 'en', ...rest }) => {
|
|
27
|
+
return template.render({
|
|
28
|
+
title: translations[locale].error.title,
|
|
29
|
+
description: translations[locale].error.description,
|
|
30
|
+
...rest,
|
|
31
|
+
});
|
|
32
|
+
},
|
|
33
|
+
maintenance: ({ locale = 'en', ...rest }) => {
|
|
34
|
+
return template.render({
|
|
35
|
+
title: translations[locale].maintenance.title,
|
|
36
|
+
description: translations[locale].maintenance.description,
|
|
37
|
+
...rest,
|
|
38
|
+
});
|
|
39
|
+
},
|
|
40
|
+
'coming-soon': ({ locale = 'en', ...rest }) => {
|
|
41
|
+
return template.render({
|
|
42
|
+
title: translations[locale]['coming-soon'].title,
|
|
43
|
+
description: translations[locale]['coming-soon'].description,
|
|
44
|
+
...rest,
|
|
45
|
+
});
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export default function render(options = {}) {
|
|
50
|
+
const { status, locale = 'en', ...rest } = options;
|
|
51
|
+
if (status) {
|
|
52
|
+
const renderer = renderers[status];
|
|
53
|
+
if (!renderer) {
|
|
54
|
+
throw new Error(
|
|
55
|
+
`Please provide a valid status. Valid values are: ${Object.keys(renderers).join(', ')}`
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
return renderer({ locale, ...rest });
|
|
59
|
+
}
|
|
60
|
+
return template.render({ ...rest });
|
|
61
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
const arcblockLogoSvg =
|
|
2
|
+
'<svg xmlns="http://www.w3.org/2000/svg" width="45" height="52" viewBox="0 0 45 52"><g fill="none" fill-rule="evenodd" stroke="#000"><path d="M.5 13.077L22.15.577l21.651 12.5v25l-21.65 12.5L.5 38.077zM22.15.577v50M.5 13.077l43.301 25m-43.301 0l43.301-25"></path><path d="M22.15 38.077l10.826-6.25-10.825-18.75-10.825 18.75z"></path></g></svg>';
|
|
3
|
+
|
|
4
|
+
function render({ pageTitle, title, icon, description, extra }) {
|
|
5
|
+
// eslint-disable-next-line no-param-reassign
|
|
6
|
+
pageTitle = pageTitle || `${title} - Blocklet Server`;
|
|
7
|
+
return `
|
|
8
|
+
<!DOCTYPE html>
|
|
9
|
+
<html lang="en">
|
|
10
|
+
<head>
|
|
11
|
+
<meta charset="UTF-8">
|
|
12
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
13
|
+
<title>${pageTitle}</title>
|
|
14
|
+
<style>
|
|
15
|
+
html {
|
|
16
|
+
box-sizing: border-box;
|
|
17
|
+
font-size: 16px;
|
|
18
|
+
}
|
|
19
|
+
*, *::before, *::after {
|
|
20
|
+
box-sizing: inherit;
|
|
21
|
+
}
|
|
22
|
+
html, body {
|
|
23
|
+
height: 100%;
|
|
24
|
+
}
|
|
25
|
+
body {
|
|
26
|
+
margin: 0;
|
|
27
|
+
}
|
|
28
|
+
.container {
|
|
29
|
+
display: flex;
|
|
30
|
+
flex-direction: column;
|
|
31
|
+
justify-content: center;
|
|
32
|
+
align-items: center;
|
|
33
|
+
height: 100%;
|
|
34
|
+
padding: 16px;
|
|
35
|
+
background-color: #f7f8fb;
|
|
36
|
+
}
|
|
37
|
+
.svg-wrapper *{
|
|
38
|
+
stroke: #9e9e9e;
|
|
39
|
+
}
|
|
40
|
+
.title {
|
|
41
|
+
margin-top: 24px;
|
|
42
|
+
font-size: 22px;
|
|
43
|
+
font-weight: 400;
|
|
44
|
+
color: #47494E;
|
|
45
|
+
text-align: center;
|
|
46
|
+
}
|
|
47
|
+
.description {
|
|
48
|
+
margin-top: 8px;
|
|
49
|
+
font-size: 14px;
|
|
50
|
+
color: #7F828B;
|
|
51
|
+
text-align: center;
|
|
52
|
+
}
|
|
53
|
+
.extra {
|
|
54
|
+
margin-top: 24px;
|
|
55
|
+
}
|
|
56
|
+
</style>
|
|
57
|
+
</head>
|
|
58
|
+
<body>
|
|
59
|
+
<div class="container">
|
|
60
|
+
${icon ? `<img src="${icon}" />` : `<span class="svg-wrapper">${arcblockLogoSvg}</span>`}
|
|
61
|
+
<div class="title">
|
|
62
|
+
${title}
|
|
63
|
+
</div>
|
|
64
|
+
${description ? `<div class="description">${description}</div>` : ''}
|
|
65
|
+
${extra ? `<div class="extra">${extra}</div>` : ''}
|
|
66
|
+
</div>
|
|
67
|
+
</body>
|
|
68
|
+
</html>`;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export default { render };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import Result from './result';
|
|
4
|
+
import * as common from './common';
|
|
5
|
+
|
|
6
|
+
const componentsKeyByStatus = Object.keys(common).reduce(
|
|
7
|
+
(acc, cur) => ({ ...acc, [common[cur].status || cur]: common[cur] }),
|
|
8
|
+
{}
|
|
9
|
+
);
|
|
10
|
+
|
|
11
|
+
export default function ResultWrapper({ status, ...rest }) {
|
|
12
|
+
if (status) {
|
|
13
|
+
if (componentsKeyByStatus[status]) {
|
|
14
|
+
const Component = componentsKeyByStatus[status];
|
|
15
|
+
return <Component {...rest} />;
|
|
16
|
+
}
|
|
17
|
+
throw new Error(
|
|
18
|
+
`Please provide a valid status for Result.status. Valid values are: ${Object.keys(
|
|
19
|
+
componentsKeyByStatus
|
|
20
|
+
).join(', ')}`
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
return <Result {...rest} />;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
ResultWrapper.propTypes = {
|
|
27
|
+
status: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
28
|
+
};
|
|
29
|
+
ResultWrapper.defaultProps = {
|
|
30
|
+
status: '',
|
|
31
|
+
};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import styled from 'styled-components';
|
|
4
|
+
import Box from '@material-ui/core/Box';
|
|
5
|
+
|
|
6
|
+
function Result({ icon, title, description, extra, ...rest }) {
|
|
7
|
+
return (
|
|
8
|
+
<Root {...rest}>
|
|
9
|
+
{icon}
|
|
10
|
+
{typeof title === 'string' ? (
|
|
11
|
+
<Box mt={3} fontSize={22} fontWeight={400} color="#47494E" textAlign="center">
|
|
12
|
+
{title}
|
|
13
|
+
</Box>
|
|
14
|
+
) : (
|
|
15
|
+
title
|
|
16
|
+
)}
|
|
17
|
+
|
|
18
|
+
{typeof description === 'string' ? (
|
|
19
|
+
<Box mt={1} fontSize={14} color="#7F828B" textAlign="center">
|
|
20
|
+
{description}
|
|
21
|
+
</Box>
|
|
22
|
+
) : (
|
|
23
|
+
description
|
|
24
|
+
)}
|
|
25
|
+
|
|
26
|
+
<Box mt={3}>{extra}</Box>
|
|
27
|
+
</Root>
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
Result.propTypes = {
|
|
32
|
+
icon: PropTypes.any,
|
|
33
|
+
title: PropTypes.any.isRequired,
|
|
34
|
+
description: PropTypes.any,
|
|
35
|
+
actions: PropTypes.any,
|
|
36
|
+
extra: PropTypes.any,
|
|
37
|
+
};
|
|
38
|
+
Result.defaultProps = {
|
|
39
|
+
icon: '',
|
|
40
|
+
description: '',
|
|
41
|
+
actions: null,
|
|
42
|
+
extra: null,
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
const Root = styled.div`
|
|
46
|
+
display: flex;
|
|
47
|
+
flex-direction: column;
|
|
48
|
+
justify-content: center;
|
|
49
|
+
align-items: center;
|
|
50
|
+
height: 100%;
|
|
51
|
+
padding: 16px;
|
|
52
|
+
|
|
53
|
+
background-color: #f7f8fb;
|
|
54
|
+
`;
|
|
55
|
+
|
|
56
|
+
export default Result;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
en: {
|
|
3
|
+
404: {
|
|
4
|
+
title: '404 - Page Not Found',
|
|
5
|
+
description:
|
|
6
|
+
'Sorry about that, the page you are looking for does not exist or has been moved.',
|
|
7
|
+
},
|
|
8
|
+
403: {
|
|
9
|
+
title: '403 – Forbidden',
|
|
10
|
+
description: 'Sorry, you are not authorized to access this page.',
|
|
11
|
+
},
|
|
12
|
+
500: {
|
|
13
|
+
title: '500 - Internal Server Error',
|
|
14
|
+
description: 'An internal server error has occured. Please try again later.',
|
|
15
|
+
},
|
|
16
|
+
error: {
|
|
17
|
+
title: 'Application Error',
|
|
18
|
+
description: 'Something went wrong. Please try again later.',
|
|
19
|
+
},
|
|
20
|
+
maintenance: {
|
|
21
|
+
title: 'Offline for maintenance',
|
|
22
|
+
description: 'This app is undergoing maintenance right now. Please check back later.',
|
|
23
|
+
},
|
|
24
|
+
'coming-soon': {
|
|
25
|
+
title: 'Coming Soon',
|
|
26
|
+
description: "Our website is under construction. We'll be here soon with our new website.",
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
|
|
30
|
+
zh: {
|
|
31
|
+
404: {
|
|
32
|
+
title: '404 - 页面未找到',
|
|
33
|
+
description: '很抱歉,您正在寻找的页面不存在或已被移动。',
|
|
34
|
+
},
|
|
35
|
+
403: {
|
|
36
|
+
title: '403 – 禁止访问',
|
|
37
|
+
description: '很抱歉,您没有权限访问此页面。',
|
|
38
|
+
},
|
|
39
|
+
500: {
|
|
40
|
+
title: '500 - 内部服务器错误',
|
|
41
|
+
description: '发生了一个内部服务器错误。请稍后再试。',
|
|
42
|
+
},
|
|
43
|
+
error: {
|
|
44
|
+
title: 'Application Error',
|
|
45
|
+
description: '出错了, 请稍后再试。',
|
|
46
|
+
},
|
|
47
|
+
maintenance: {
|
|
48
|
+
title: '维护中',
|
|
49
|
+
description: '应用程序正在进行维护。请稍后再查看。',
|
|
50
|
+
},
|
|
51
|
+
'coming-soon': {
|
|
52
|
+
title: '即将上线',
|
|
53
|
+
description: '我们的网站正在建设中。我们很快就会在这里推出我们的新网站。',
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
};
|