@nine-lab/nine-mu 0.1.385 โ 0.1.387
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/dist/nine-mu.js +29 -52
- package/dist/nine-mu.js.map +1 -1
- package/dist/nine-mu.umd.js +1 -1
- package/dist/nine-mu.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/components/hook/NineHook.js +25 -34
package/package.json
CHANGED
|
@@ -208,20 +208,24 @@ class NineExceptionHook extends React.Component {
|
|
|
208
208
|
// ==========================================
|
|
209
209
|
// ๐ฏ 3. ์ต์ข
์๊ฒฐ: ์์ ์ปดํฌ๋ํธ(children)๋ฅผ ์์ฉํ๋ ๊ตฌ์กฐ๋ก ๋ณ๊ฒฝ
|
|
210
210
|
// ==========================================
|
|
211
|
-
export function NineHook({
|
|
212
|
-
const
|
|
211
|
+
export function NineHook({ menuUrl, views, error404, onCatch, fallback, styles, containerStyle }) {
|
|
212
|
+
const { menuData, setMenuData } = useContext(ScreenContext) || {};
|
|
213
|
+
const [localMenuData, setLocalMenuData] = useState([]);
|
|
213
214
|
|
|
215
|
+
// ๋ถ๋ชจ ์ปจํ
์คํธ๊ฐ ์์ ๋๋ฅผ ๋๋นํ ์์ ์ฅ์น ๋ฐ ์ค์๊ฐ fetch
|
|
214
216
|
const fetchRoutes = async () => {
|
|
215
217
|
if (!menuUrl) return;
|
|
216
218
|
try {
|
|
217
219
|
const response = await fetch(`${menuUrl}?t=${Date.now()}`);
|
|
218
220
|
if (response.ok) {
|
|
219
221
|
const data = await response.json();
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
}
|
|
222
|
+
|
|
223
|
+
// ์ ์ญ Context๊ฐ ์์ผ๋ฉด ๊ฑฐ๊ธฐ์ ์ฐ๋ฌ๋ฃ๊ณ , ์์ผ๋ฉด ๋ก์ปฌ ์คํ
์ดํธ์ ์ ์ฅ
|
|
224
|
+
if (window.setNineMenuDataGlobal) {
|
|
225
|
+
window.setNineMenuDataGlobal(data);
|
|
226
|
+
} else {
|
|
227
|
+
setLocalMenuData(data);
|
|
228
|
+
}
|
|
225
229
|
}
|
|
226
230
|
} catch (e) {
|
|
227
231
|
console.error("[Nine-Library] ๋ฐํ์ ๋ฉ๋ด ๋๊ธฐํ ์คํจ:", e);
|
|
@@ -241,37 +245,24 @@ export function NineHook({ children, menuUrl, views, error404, onCatch, fallback
|
|
|
241
245
|
};
|
|
242
246
|
}, [menuUrl]);
|
|
243
247
|
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
return React.createElement(
|
|
247
|
-
'div',
|
|
248
|
-
{ style: { padding: '25px', color: '#666', fontFamily: 'monospace', background: '#121314', minHeight: '100vh' } },
|
|
249
|
-
'>> Initializing menu matrix telemetry...'
|
|
250
|
-
);
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
const dynamicRoutes = createDynamicRoutes(menuData, views, error404);
|
|
248
|
+
const targetData = menuData && menuData.length > 0 ? menuData : localMenuData;
|
|
249
|
+
const dynamicRoutes = createDynamicRoutes(targetData, views, error404);
|
|
254
250
|
|
|
255
251
|
return React.createElement(
|
|
256
|
-
|
|
257
|
-
{
|
|
252
|
+
NineExceptionHook,
|
|
253
|
+
{ onCatch, fallback, styles, containerStyle },
|
|
258
254
|
React.createElement(
|
|
259
|
-
|
|
260
|
-
{
|
|
261
|
-
children,
|
|
255
|
+
Suspense,
|
|
256
|
+
{ fallback: React.createElement('div', { style: { padding: '25px', color: '#666', fontFamily: 'monospace' } }, '>> Loading component matrix...') },
|
|
262
257
|
React.createElement(
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
React.createElement(
|
|
270
|
-
|
|
271
|
-
path: route.path,
|
|
272
|
-
element: React.createElement(route.Component, { key: route.path })
|
|
273
|
-
})
|
|
274
|
-
)
|
|
258
|
+
Routes,
|
|
259
|
+
null,
|
|
260
|
+
dynamicRoutes.map((route) =>
|
|
261
|
+
React.createElement(Route, {
|
|
262
|
+
key: route.path,
|
|
263
|
+
path: route.path,
|
|
264
|
+
element: React.createElement(route.Component, { key: route.path })
|
|
265
|
+
})
|
|
275
266
|
)
|
|
276
267
|
)
|
|
277
268
|
)
|