Ajoutez des fichiers projet.

This commit is contained in:
taywon committed 2026-10-06 01:27:51 +02:00
1 parent 2f1b2a0dcc
commit 99b860c967
68 files changed
+1974

No files matched your search

@@ -0,0 +1,18 @@
@page "/counter"
<PageTitle>Counter</PageTitle>
<h1>Counter</h1>
<p role="status">Current count: @currentCount</p>
<button class="btn btn-primary" @onclick="IncrementCount">Click me</button>
@code {
private int currentCount = 0;
private void IncrementCount()
{
currentCount++;
}
}
@@ -0,0 +1,14 @@
@page "/"
@using Intendant.Shared.Services
@inject IFormFactor FormFactor
<PageTitle>Home</PageTitle>
<h1>Hello, world!</h1>
Welcome to your new app running on <em>@factor</em> using <em>@platform</em>.
@code {
private string factor => FormFactor.GetFormFactor();
private string platform => FormFactor.GetPlatform();
}
@@ -0,0 +1,5 @@
@page "/not-found"
@layout MainLayout
<h3>Not Found</h3>
<p>Sorry, the content you are looking for does not exist.</p>
@@ -0,0 +1,118 @@
@page "/settings"
@using Intendant.Shared.Services
@inject IOpenAiSettingsService SettingsService
@inject IOpenAiResponsesService ResponsesService
<PageTitle>Paramètres</PageTitle>
<h1>Paramètres OpenAI</h1>
<div class="mb-3">
<label class="form-label" for="openai-api-key">Clé API (optionnelle)</label>
<input id="openai-api-key" class="form-control" @bind="apiKey" />
</div>
<div class="mb-3">
<label class="form-label" for="openai-endpoint">Endpoint</label>
<input id="openai-endpoint" class="form-control" @bind="endpoint" placeholder="https://api.openai.com/v1" />
</div>
<div class="mb-3">
<label class="form-label" for="openai-model">Modèle</label>
<input id="openai-model" class="form-control" @bind="model" placeholder="gpt-5-mini" />
</div>
<div class="d-flex gap-2">
<button type="button" class="btn btn-primary" @onclick="SaveAsync" disabled="@isBusy">Enregistrer</button>
<button type="button" class="btn btn-outline-secondary" @onclick="TestAsync" disabled="@isBusy">Tester</button>
</div>
@if (!string.IsNullOrWhiteSpace(message))
{
<div class="alert alert-success mt-3" role="alert">@message</div>
}
@if (!string.IsNullOrWhiteSpace(error))
{
<div class="alert alert-danger mt-3" role="alert">@error</div>
}
@if (!string.IsNullOrWhiteSpace(testResult))
{
<div class="alert alert-info mt-3" role="alert">@testResult</div>
}
@code {
private string apiKey = string.Empty;
private string endpoint = string.Empty;
private string model = string.Empty;
private string message = string.Empty;
private string error = string.Empty;
private string testResult = string.Empty;
private bool isBusy;
protected override async Task OnInitializedAsync()
{
OpenAiResponsesOptions settings = await SettingsService.GetAsync();
apiKey = settings.ApiKey;
endpoint = settings.Endpoint;
model = settings.Model;
}
private async Task SaveAsync()
{
isBusy = true;
error = string.Empty;
testResult = string.Empty;
try
{
await SettingsService.SaveAsync(new OpenAiResponsesOptions
{
ApiKey = apiKey,
Endpoint = endpoint,
Model = model,
});
message = "Paramètres enregistrés.";
}
catch (Exception ex)
{
message = string.Empty;
error = ex.Message;
}
finally
{
isBusy = false;
}
}
private async Task TestAsync()
{
isBusy = true;
error = string.Empty;
message = string.Empty;
testResult = string.Empty;
try
{
await SettingsService.SaveAsync(new OpenAiResponsesOptions
{
ApiKey = apiKey,
Endpoint = endpoint,
Model = model,
});
string response = await ResponsesService.GenerateTextAsync("Réponds uniquement par: OK");
testResult = response;
}
catch (Exception ex)
{
error = ex.Message;
}
finally
{
isBusy = false;
}
}
}
@@ -0,0 +1,63 @@
@page "/weather"
<PageTitle>Weather</PageTitle>
<h1>Weather</h1>
<p>This component demonstrates showing data.</p>
@if (forecasts == null)
{
<p><em>Loading...</em></p>
}
else
{
<table class="table">
<thead>
<tr>
<th>Date</th>
<th aria-label="Temperature in Celsius">Temp. (C)</th>
<th aria-label="Temperature in Fahrenheit">Temp. (F)</th>
<th>Summary</th>
</tr>
</thead>
<tbody>
@foreach (var forecast in forecasts)
{
<tr>
<td>@forecast.Date.ToShortDateString()</td>
<td>@forecast.TemperatureC</td>
<td>@forecast.TemperatureF</td>
<td>@forecast.Summary</td>
</tr>
}
</tbody>
</table>
}
@code {
private WeatherForecast[]? forecasts;
protected override async Task OnInitializedAsync()
{
// Simulate asynchronous loading to demonstrate a loading indicator
await Task.Delay(500);
var startDate = DateOnly.FromDateTime(DateTime.Now);
var summaries = new[] { "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" };
forecasts = Enumerable.Range(1, 5).Select(index => new WeatherForecast
{
Date = startDate.AddDays(index),
TemperatureC = Random.Shared.Next(-20, 55),
Summary = summaries[Random.Shared.Next(summaries.Length)]
}).ToArray();
}
private class WeatherForecast
{
public DateOnly Date { get; set; }
public int TemperatureC { get; set; }
public string? Summary { get; set; }
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
}
}