Agent code and restructuring
This commit is contained in:
@@ -0,0 +1,84 @@
|
||||
# Device MAUI Pages Setup
|
||||
|
||||
Changes needed to get all shared pages rendering in the Device (MAUI Blazor) project.
|
||||
|
||||
## How pages render
|
||||
|
||||
`MainRazor.razor` has a `Router` pointing at the Pages assembly. When the URL matches a `@page` directive (e.g. `/database`), the Router renders that page component with `MainLayout`. All component references resolve from the Components or Pages project. All DI services are already registered in `MauiProgram.cs`.
|
||||
|
||||
Only two things block pages from rendering currently:
|
||||
|
||||
## 1. No route for `/`
|
||||
|
||||
The MAUI app starts at `/`, but `HomePage` only has `@page "/immortal-home"`. Nothing matches → NotFound.
|
||||
|
||||
**Fix:** Add `@page "/"` to `Pages/Pages/Home/HomePage.razor`:
|
||||
|
||||
```razor
|
||||
@page "/"
|
||||
@page "/immortal-home"
|
||||
```
|
||||
|
||||
Then remove `Web/Index.razor` — its `@page "/"` wrapper is redundant since the Pages project now provides the route directly, and `App.razor` already uses `PageLayout` as the default layout.
|
||||
|
||||
## 2. Move dialog portals from Web to Pages
|
||||
|
||||
Pages like `BuildCalculatorPage` and `DatabasePage` trigger dialogs via `IEntityDialogService` etc. The portal components that render the dialog UI (`EntityDialogPortal`, `GlossaryDialogPortal`, `ToastPortal`, `SearchPortal`, `ConfirmationDialogPortal`) live in `Web/Portals/`. The dialog components themselves live in `Web/Dialog/`.
|
||||
|
||||
Since the Device project can't reference the Web project, these need to be moved into the Pages project so both Web and Device can use them:
|
||||
|
||||
- `Web/Portals/*` → `Pages/Portals/`
|
||||
- `Web/Dialog/*` → `Pages/Dialog/`
|
||||
|
||||
Then add them to `Device/MainRazor.razor`:
|
||||
|
||||
```razor
|
||||
<MudThemeProvider IsDarkMode="true"/>
|
||||
<MudDialogProvider/>
|
||||
<MudSnackbarProvider/>
|
||||
|
||||
<EntityDialogPortal/>
|
||||
<GlossaryDialogPortal/>
|
||||
<ToastPortal/>
|
||||
<SearchPortal/>
|
||||
<ConfirmationDialogPortal/>
|
||||
|
||||
<Router AppAssembly="@typeof(IGP.Pages.Home.HomePage).Assembly">
|
||||
...
|
||||
</Router>
|
||||
```
|
||||
|
||||
And add the same portal rendering to `Web/App.razor` (already present, but the types now come from Pages instead of Web).
|
||||
|
||||
## 3. Add storage loading gate (optional)
|
||||
|
||||
The Web project's `App.razor` gates rendering behind `isLoaded` (waits for `IStorageService.Load()`). Some pages may depend on stored data. Add to `MainRazor.razor`:
|
||||
|
||||
```razor
|
||||
@inject IStorageService StorageService
|
||||
|
||||
@if (isLoaded)
|
||||
{
|
||||
<Router ...>
|
||||
...
|
||||
</Router>
|
||||
}
|
||||
|
||||
@code {
|
||||
private bool isLoaded;
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
await StorageService.Load();
|
||||
isLoaded = true;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 4. Static assets
|
||||
|
||||
Images referenced by pages (e.g. `image/hero/Build.png`) are served from `wwwroot/`. These are already copied from `Web/wwwroot/image/hero/` to `Device/wwwroot/image/hero/`. Check for additional asset references as more pages are used.
|
||||
|
||||
## 5. HttpClient base address
|
||||
|
||||
`MauiProgram.cs` line 73 sets `BaseAddress = new Uri("https://0.0.0.0")`. Won't resolve real API calls (e.g. markdown content loading). Needs a valid API URL for the MAUI environment.
|
||||
Reference in New Issue
Block a user