暂存
This commit is contained in:
@@ -69,9 +69,25 @@ export const ProjectProvider: React.FC<{ children: React.ReactNode }> = ({
|
||||
setIsConfigured(true);
|
||||
|
||||
try {
|
||||
await apiFetch(`${config.BACKEND_URL}/openproject/?network=${net}`, {
|
||||
method: "POST",
|
||||
});
|
||||
const response = await apiFetch(
|
||||
`${config.BACKEND_URL}/openproject/?network=${net}`,
|
||||
{
|
||||
method: "POST",
|
||||
},
|
||||
);
|
||||
if (!response.ok) {
|
||||
throw new Error(`HTTP ${response.status}`);
|
||||
}
|
||||
const data = await response.json();
|
||||
const bbox = Array.isArray(data?.map_extent?.bbox)
|
||||
? data.map_extent.bbox.map((value: number) => Number(value))
|
||||
: null;
|
||||
if (bbox && bbox.length === 4) {
|
||||
setMapExtent(bbox);
|
||||
localStorage.setItem("NEXT_PUBLIC_MAP_EXTENT", bbox.join(","));
|
||||
localStorage.removeItem(`${ws}_map_view`);
|
||||
setCurrentProject((prev) => ({ ...prev, extent: bbox }));
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Failed to open project:", error);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user