@blocklet/pages-kit-runtime 0.1.23 → 0.1.25
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 +10 -30
- package/lib/cjs/components/custom-component/index.js +1 -0
- package/lib/cjs/components/index.js +1 -0
- package/lib/cjs/tsconfig.tsbuildinfo +1 -1
- package/lib/esm/client.js +10 -30
- package/lib/esm/components/custom-component/index.js +1 -0
- package/lib/esm/components/index.js +1 -0
- package/lib/esm/tsconfig.tsbuildinfo +1 -1
- package/lib/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
package/lib/cjs/client.js
CHANGED
|
@@ -57,7 +57,6 @@ const Box_1 = __importDefault(require("@mui/material/Box"));
|
|
|
57
57
|
const ahooks_1 = require("ahooks");
|
|
58
58
|
const react_1 = __importStar(require("react"));
|
|
59
59
|
const ufo_1 = require("ufo");
|
|
60
|
-
const PAGES_KIT_BLOCKLET_DID = 'z8iZiDFg3vkkrPwsiba1TLXy3H9XHzFERsP8o';
|
|
61
60
|
const CenteredContainer = ({ children }) => ((0, jsx_runtime_1.jsx)(Box_1.default, { display: "flex", justifyContent: "center", alignItems: "center", minHeight: "100vh", children: children }));
|
|
62
61
|
const api = (0, js_sdk_1.createAxios)({
|
|
63
62
|
baseURL: (0, ufo_1.joinURL)(((_a = window === null || window === void 0 ? void 0 : window.blocklet) === null || _a === void 0 ? void 0 : _a.prefix) || ''),
|
|
@@ -215,41 +214,22 @@ const RuntimeComponent = (props) => {
|
|
|
215
214
|
}
|
|
216
215
|
}, [proxyState.rawState]);
|
|
217
216
|
const { loading } = (0, ahooks_1.useRequest)(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
218
|
-
var _a;
|
|
219
217
|
if (props.state) {
|
|
220
218
|
return null;
|
|
221
219
|
}
|
|
222
220
|
if (!props.did && !props.projectId) {
|
|
223
221
|
return null;
|
|
224
222
|
}
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
}
|
|
236
|
-
else if (props.projectId) {
|
|
237
|
-
let pagesKitBaseUrl = props.siteFrom;
|
|
238
|
-
if (!pagesKitBaseUrl) {
|
|
239
|
-
pagesKitBaseUrl = window.location.origin;
|
|
240
|
-
// find pages kit prefix from window.blocklet
|
|
241
|
-
const pagesKitMountPoint = (_a = window.blocklet) === null || _a === void 0 ? void 0 : _a.componentMountPoints.find((i) => i.did === PAGES_KIT_BLOCKLET_DID);
|
|
242
|
-
if (pagesKitMountPoint) {
|
|
243
|
-
pagesKitBaseUrl = (0, ufo_1.joinURL)(pagesKitBaseUrl, pagesKitMountPoint.mountPoint);
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
const apiUrl = (0, ufo_1.joinURL)(pagesKitBaseUrl, 'api/projects', props.projectId, 'pages');
|
|
247
|
-
// get state from project by projectId
|
|
248
|
-
const { data } = yield api.get(apiUrl);
|
|
249
|
-
proxyState.rawState = data;
|
|
250
|
-
stateData = data;
|
|
251
|
-
}
|
|
252
|
-
return stateData;
|
|
223
|
+
// 统一使用 /api/pages 接口
|
|
224
|
+
const { data } = yield api.get('/api/pages', {
|
|
225
|
+
params: {
|
|
226
|
+
did: props.did,
|
|
227
|
+
projectId: props.projectId,
|
|
228
|
+
siteFrom: props.siteFrom,
|
|
229
|
+
},
|
|
230
|
+
});
|
|
231
|
+
proxyState.rawState = data.state || data;
|
|
232
|
+
return data;
|
|
253
233
|
}), {
|
|
254
234
|
refreshDeps: [props.did, props.state, props.projectId],
|
|
255
235
|
});
|
|
@@ -14,4 +14,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
// eslint-disable-next-line import/export
|
|
17
18
|
__exportStar(require("./settings"), exports);
|
|
@@ -15,4 +15,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./create-resource"), exports);
|
|
18
|
+
// eslint-disable-next-line import/export
|
|
18
19
|
__exportStar(require("./custom-component"), exports);
|