@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/esm/client.js
CHANGED
|
@@ -18,7 +18,6 @@ import Box from '@mui/material/Box';
|
|
|
18
18
|
import { useRequest, useReactive } from 'ahooks';
|
|
19
19
|
import React, { useImperativeHandle, useEffect, useRef } from 'react';
|
|
20
20
|
import { joinURL } from 'ufo';
|
|
21
|
-
const PAGES_KIT_BLOCKLET_DID = 'z8iZiDFg3vkkrPwsiba1TLXy3H9XHzFERsP8o';
|
|
22
21
|
const CenteredContainer = ({ children }) => (_jsx(Box, { display: "flex", justifyContent: "center", alignItems: "center", minHeight: "100vh", children: children }));
|
|
23
22
|
const api = createAxios({
|
|
24
23
|
baseURL: joinURL(((_a = window === null || window === void 0 ? void 0 : window.blocklet) === null || _a === void 0 ? void 0 : _a.prefix) || ''),
|
|
@@ -176,41 +175,22 @@ export const RuntimeComponent = (props) => {
|
|
|
176
175
|
}
|
|
177
176
|
}, [proxyState.rawState]);
|
|
178
177
|
const { loading } = useRequest(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
179
|
-
var _a;
|
|
180
178
|
if (props.state) {
|
|
181
179
|
return null;
|
|
182
180
|
}
|
|
183
181
|
if (!props.did && !props.projectId) {
|
|
184
182
|
return null;
|
|
185
183
|
}
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
}
|
|
197
|
-
else if (props.projectId) {
|
|
198
|
-
let pagesKitBaseUrl = props.siteFrom;
|
|
199
|
-
if (!pagesKitBaseUrl) {
|
|
200
|
-
pagesKitBaseUrl = window.location.origin;
|
|
201
|
-
// find pages kit prefix from window.blocklet
|
|
202
|
-
const pagesKitMountPoint = (_a = window.blocklet) === null || _a === void 0 ? void 0 : _a.componentMountPoints.find((i) => i.did === PAGES_KIT_BLOCKLET_DID);
|
|
203
|
-
if (pagesKitMountPoint) {
|
|
204
|
-
pagesKitBaseUrl = joinURL(pagesKitBaseUrl, pagesKitMountPoint.mountPoint);
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
const apiUrl = joinURL(pagesKitBaseUrl, 'api/projects', props.projectId, 'pages');
|
|
208
|
-
// get state from project by projectId
|
|
209
|
-
const { data } = yield api.get(apiUrl);
|
|
210
|
-
proxyState.rawState = data;
|
|
211
|
-
stateData = data;
|
|
212
|
-
}
|
|
213
|
-
return stateData;
|
|
184
|
+
// 统一使用 /api/pages 接口
|
|
185
|
+
const { data } = yield api.get('/api/pages', {
|
|
186
|
+
params: {
|
|
187
|
+
did: props.did,
|
|
188
|
+
projectId: props.projectId,
|
|
189
|
+
siteFrom: props.siteFrom,
|
|
190
|
+
},
|
|
191
|
+
});
|
|
192
|
+
proxyState.rawState = data.state || data;
|
|
193
|
+
return data;
|
|
214
194
|
}), {
|
|
215
195
|
refreshDeps: [props.did, props.state, props.projectId],
|
|
216
196
|
});
|