- Agent Compare 기준으로 런처 빠른 실행 칩, 검색 히스토리 탐색, 선택 항목 미리보기 패널을 현재 런처에 이식 - 하단 위젯 바, QuickLook(F3), 화면 OCR(F4), 관련 서비스/partial 파일을 현재 LauncherWindow/LauncherViewModel 구조에 연결 - UsageRankingService 상위 항목 조회와 SearchHistoryService를 추가해 실행 상위 경로/검색 기록이 실제 런처 동작에 반영되도록 정리 - README.md, docs/DEVELOPMENT.md에 이식 범위와 검증 결과를 2026-04-05 11:58 (KST) 기준으로 기록 검증 결과 - dotnet build src/AxCopilot/AxCopilot.csproj -c Release -v minimal -p:OutputPath=bin\\verify\\ -p:IntermediateOutputPath=obj\\verify\\ 경고 0 / 오류 0
53 lines
1.3 KiB
C#
53 lines
1.3 KiB
C#
using System.Net.Http;
|
|
|
|
namespace AxCopilot.Services;
|
|
|
|
internal static class WeatherWidgetService
|
|
{
|
|
private static string? _cached;
|
|
private static DateTime _cacheTime = DateTime.MinValue;
|
|
private static bool _fetching;
|
|
private static readonly TimeSpan Ttl = TimeSpan.FromMinutes(30);
|
|
|
|
public static string CachedText => _cached ?? "--";
|
|
|
|
public static async Task RefreshAsync(bool internalMode)
|
|
{
|
|
if (internalMode)
|
|
{
|
|
_cached = "--";
|
|
return;
|
|
}
|
|
|
|
if (_cached != null && DateTime.Now - _cacheTime < Ttl)
|
|
return;
|
|
if (_fetching)
|
|
return;
|
|
|
|
_fetching = true;
|
|
try
|
|
{
|
|
using var client = new HttpClient();
|
|
client.Timeout = TimeSpan.FromSeconds(6);
|
|
var raw = await client.GetStringAsync("https://wttr.in/?format=%c+%t");
|
|
_cached = raw.Trim().Replace("+", " ");
|
|
_cacheTime = DateTime.Now;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogService.Warn($"날씨 위젯 갱신 실패: {ex.Message}");
|
|
_cached ??= "--";
|
|
}
|
|
finally
|
|
{
|
|
_fetching = false;
|
|
}
|
|
}
|
|
|
|
public static void Invalidate()
|
|
{
|
|
_cached = null;
|
|
_cacheTime = DateTime.MinValue;
|
|
}
|
|
}
|