@nine-lab/nine-mu 0.1.379 โ 0.1.381
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 +25 -9
- 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 +27 -3
package/package.json
CHANGED
|
@@ -205,13 +205,37 @@ class NineExceptionHook extends React.Component {
|
|
|
205
205
|
// ==========================================
|
|
206
206
|
// ๐ฏ 3. ํต์ฌ: ์ธ๋ถ ์ฃผ์
ํ 404 ๋ผ์ฐํ
๊ธฐ๋ฅ ํ์ฌ
|
|
207
207
|
// ==========================================
|
|
208
|
-
export function NineHook({
|
|
209
|
-
|
|
208
|
+
export function NineHook({ menuUrl, views, error404, onCatch, fallback, styles, containerStyle }) {
|
|
209
|
+
const [menuData, setMenuData] = useState([]);
|
|
210
|
+
|
|
211
|
+
// ๐ฏ AI๊ฐ ํ์ผ์ ์์ ํ๋ฉด ๋ฐํ์์ ์ค์๊ฐ ๋ฐ์๋๋๋ก ๋์ fetch ์ฒ๋ฆฌ
|
|
212
|
+
useEffect(() => {
|
|
213
|
+
if (!menuUrl) return;
|
|
214
|
+
|
|
215
|
+
const fetchRoutes = async () => {
|
|
216
|
+
try {
|
|
217
|
+
// ์บ์ ๋ฒ์คํ
(?t=...)์ ์ถ๊ฐํ๋ฉด AI๊ฐ ์์ ํ์ ๋ ๋ธ๋ผ์ฐ์ ์บ์๋ฅผ ํ์ง ์๊ณ ์ฆ์ ๋ฐ์๋ฉ๋๋ค.
|
|
218
|
+
const response = await fetch(`${menuUrl}?t=${Date.now()}`);
|
|
219
|
+
if (response.ok) {
|
|
220
|
+
const data = await response.json();
|
|
221
|
+
setMenuData(data);
|
|
222
|
+
}
|
|
223
|
+
} catch (e) {
|
|
224
|
+
console.error("[Nine-Library] ๋ฐํ์ ๋ฉ๋ด ๋๊ธฐํ ์คํจ:", e);
|
|
225
|
+
}
|
|
226
|
+
};
|
|
227
|
+
|
|
228
|
+
fetchRoutes();
|
|
229
|
+
|
|
230
|
+
// ํ์์: ์ฃผ์์ฐฝ popstate๋ ํน์ ๋ณต๊ตฌ ์ด๋ฒคํธ ์์ ์ ์ฌํธ์ถํ๋๋ก ํธ๋ฆฌ๊ฑฐ ์ฐ๋ ๊ฐ๋ฅ
|
|
231
|
+
}, [menuUrl]);
|
|
232
|
+
|
|
233
|
+
// ๋ฐ์ดํฐ๊ฐ ๋ก๋๋๊ธฐ ์ ์๋ ๊ฐ๋ณ๊ฒ ๋ก๋ฉ ์ํ๋ฅผ ๋ณด์ฌ์ฃผ๊ณ , ์๋ฃ๋๋ฉด ๋ผ์ฐํฐ ๊ตฌ์ถ
|
|
210
234
|
const dynamicRoutes = createDynamicRoutes(menuData, views, error404);
|
|
211
235
|
|
|
212
236
|
return React.createElement(
|
|
213
237
|
ScreenProvider,
|
|
214
|
-
|
|
238
|
+
{ menuData },
|
|
215
239
|
React.createElement(
|
|
216
240
|
NineExceptionHook,
|
|
217
241
|
{ onCatch, fallback, styles, containerStyle },
|