@blocklet/pages-kit-runtime 0.1.8 → 0.1.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/cjs/client.js CHANGED
@@ -1,38 +1,49 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
15
10
  };
16
11
  var __importDefault = (this && this.__importDefault) || function (mod) {
17
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
18
13
  };
14
+ var _a;
19
15
  Object.defineProperty(exports, "__esModule", { value: true });
20
- exports.ProjectRuntime = void 0;
21
16
  const jsx_runtime_1 = require("react/jsx-runtime");
17
+ const result_1 = __importDefault(require("@arcblock/ux/lib/components/result"));
18
+ const spinner_1 = __importDefault(require("@arcblock/ux/lib/components/spinner"));
19
+ const js_sdk_1 = require("@blocklet/js-sdk");
22
20
  // @ts-ignore
23
21
  const home_1 = __importDefault(require("@blocklet/pages-kit-inner-components/home"));
24
- // @ts-ignore
25
- __exportStar(require("@blocklet/pages-kit-inner-components/home"), exports);
26
- class ProjectRuntime {
27
- constructor({ state, projectId }) {
28
- this.state = state;
29
- this.projectId = projectId;
22
+ const Box_1 = __importDefault(require("@mui/material/Box"));
23
+ const ahooks_1 = require("ahooks");
24
+ const ufo_1 = require("ufo");
25
+ const CenteredContainer = ({ children }) => ((0, jsx_runtime_1.jsx)(Box_1.default, { display: "flex", justifyContent: "center", alignItems: "center", minHeight: "100vh", children: children }));
26
+ const api = (0, js_sdk_1.createAxios)({
27
+ baseURL: (0, ufo_1.joinURL)(((_a = window === null || window === void 0 ? void 0 : window.blocklet) === null || _a === void 0 ? void 0 : _a.prefix) || ''),
28
+ });
29
+ exports.default = (props) => {
30
+ const { loading } = (0, ahooks_1.useRequest)(() => __awaiter(void 0, void 0, void 0, function* () {
31
+ const { data } = yield api.get('/api/pages', { params: props });
32
+ const dataResult = props.handleData ? props.handleData(data) : data;
33
+ // @ts-ignore
34
+ window.__PAGE_STATE__ = dataResult.state;
35
+ // @ts-ignore
36
+ window.__PROJECT_ID__ = dataResult.did;
37
+ return data;
38
+ }), {
39
+ refreshDeps: [props.did],
40
+ });
41
+ if (loading) {
42
+ return ((0, jsx_runtime_1.jsx)(CenteredContainer, { children: (0, jsx_runtime_1.jsx)(spinner_1.default, {}) }));
30
43
  }
31
- render() {
32
- // eslint-disable-next-line no-console
33
- console.log('ProjectRuntime', this.state, this.projectId);
34
- return (0, jsx_runtime_1.jsx)(home_1.default, {});
44
+ // @ts-ignore
45
+ if (!window.__PAGE_STATE__) {
46
+ return ((0, jsx_runtime_1.jsx)(CenteredContainer, { children: (0, jsx_runtime_1.jsx)(result_1.default, { status: "404", title: "404", subTitle: "Sorry, the page you visited does not exist." }) }));
35
47
  }
36
- }
37
- exports.ProjectRuntime = ProjectRuntime;
38
- exports.default = ProjectRuntime;
48
+ return (0, jsx_runtime_1.jsx)(home_1.default, {});
49
+ };