diff --git a/Language/JSON.cs b/Language/JSON.cs index 9c4be15..5907b9c 100644 --- a/Language/JSON.cs +++ b/Language/JSON.cs @@ -1,6 +1,6 @@ namespace Language { - public static class JSON + public struct JSON { public struct Client { @@ -14,7 +14,7 @@ public struct N2MT { - public MSG message = new MSG(); + public MSG message = new(); public N2MT() { @@ -22,7 +22,7 @@ public struct MSG { - public Data result = new Data(); + public Data result = new(); public MSG() { diff --git a/Language/Language.cs b/Language/Language.cs index c3c2ff4..b024fba 100644 --- a/Language/Language.cs +++ b/Language/Language.cs @@ -6,12 +6,16 @@ var wwwClient = new HttpClient(); +var defaultJSONConfigure = new JsonSerializerOptions +{ + IncludeFields = true +}; var assetsClientJSON = JsonSerializer.Deserialize(await File.ReadAllBytesAsync(Path.Combine(AppContext.BaseDirectory, "Assets", "Client.json")), new JsonSerializerOptions { IncludeFields = true }); -wwwClient.DefaultRequestHeaders.Add("X-Naver-Client-Id", assetsClientJSON.nhnID); -wwwClient.DefaultRequestHeaders.Add("X-Naver-Client-Secret", assetsClientJSON.nhnPw); +wwwClient.DefaultRequestHeaders.Add("X-NCP-APIGW-API-KEY-ID", assetsClientJSON.nhnID); +wwwClient.DefaultRequestHeaders.Add("X-NCP-APIGW-API-KEY", assetsClientJSON.nhnPw); var qwilightEntryPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "source", "repos", "Qwilight"); var twilightEntryPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "IdeaProjects", "Twilight"); @@ -272,7 +276,7 @@ async ValueTask N2Mt(string targetLanguage, string src) { - var t = await wwwClient.SendAsync(new HttpRequestMessage(HttpMethod.Post, "https://openapi.naver.com/v1/papago/n2mt") + var t = await wwwClient.SendAsync(new HttpRequestMessage(HttpMethod.Post, "https://naveropenapi.apigw.ntruss.com/nmt/v1/translation") { Content = new FormUrlEncodedContent(new[] { KeyValuePair.Create("source", "ko"), KeyValuePair.Create("target", targetLanguage), KeyValuePair.Create("text", src) }), Version = HttpVersion.Version20 @@ -280,10 +284,7 @@ var text = await t.Content.ReadAsStringAsync().ConfigureAwait(false); if (t.IsSuccessStatusCode) { - return JsonSerializer.Deserialize(text, new JsonSerializerOptions - { - IncludeFields = true - }).message.result.translatedText; + return JsonSerializer.Deserialize(text, defaultJSONConfigure).message.result.translatedText; } else { diff --git a/Qwilight/Assets/Language.json b/Qwilight/Assets/Language.json index 3123a6c..c67cb9b 100644 --- a/Qwilight/Assets/Language.json +++ b/Qwilight/Assets/Language.json @@ -707,6 +707,22 @@ "ko-KR": "업데이트 내역", "en-US": "Update History" }, + "DateText0": { + "ko-KR": "{0}초 전", + "en-US": "$200 seconds before" + }, + "DateText1": { + "ko-KR": "{0}분 전", + "en-US": "$200 minutes ago" + }, + "DateText2": { + "ko-KR": "{0}시간 전", + "en-US": "$200 hours ago" + }, + "DateText3": { + "ko-KR": "{0}일 전", + "en-US": "$200 days ago" + }, "DBConfigure": { "ko-KR": "데이터베이스 설정", "en-US": "Database Settings" diff --git a/Qwilight/Qwilight.csproj b/Qwilight/Qwilight.csproj index a012f16..a38dbbf 100644 --- a/Qwilight/Qwilight.csproj +++ b/Qwilight/Qwilight.csproj @@ -35,6 +35,14 @@ win-arm64 + + False + + + + False + + diff --git a/Qwilight/System/DB.cs b/Qwilight/System/DB.cs index a44d8ca..dd3e918 100644 --- a/Qwilight/System/DB.cs +++ b/Qwilight/System/DB.cs @@ -566,7 +566,7 @@ { NoteFileCount = noteFileCount, Date = date, - DateText = date.ToString("yyyy-MM-dd HH:mm:ss"), + DateText = Utility.GetDateText(date), CommentID = rows.GetString("Comment"), AvatarName = rows.GetString("Name"), ModeComponentValue = new() diff --git a/Qwilight/System/LanguageSystem/LanguageSystem.g.cs b/Qwilight/System/LanguageSystem/LanguageSystem.g.cs index 4e34e94..d01d772 100644 --- a/Qwilight/System/LanguageSystem/LanguageSystem.g.cs +++ b/Qwilight/System/LanguageSystem/LanguageSystem.g.cs @@ -179,6 +179,10 @@ public string DataCount3Contents { get; set; } public string DataCount3Text { get; set; } public string DateAssistText { get; set; } + public string DateText0 { get; set; } + public string DateText1 { get; set; } + public string DateText2 { get; set; } + public string DateText3 { get; set; } public string DBConfigure { get; set; } public string DefaultAudioFilePathText { get; set; } public string DefaultAudioVarietyContents { get; set; } diff --git a/Qwilight/Utilities/Utility.cs b/Qwilight/Utilities/Utility.cs index 3d5c38c..085cb5c 100644 --- a/Qwilight/Utilities/Utility.cs +++ b/Qwilight/Utilities/Utility.cs @@ -360,7 +360,7 @@ IsTwilightComment = true, NoteFileCount = 1, Date = dateValue ?? DateTime.MinValue, - DateText = dateValue?.ToString("yyyy-MM-dd HH:mm:ss") ?? "❌", + DateText = dateValue != null ? Utility.GetDateText(dateValue.Value) : "❌", CommentID = data.commentID, AvatarName = data.avatarName, ModeComponentValue = new() @@ -545,5 +545,28 @@ using var targetWMI = new ManagementObjectSearcher(textWMI); return targetWMI.Get().Cast(); } + + public static string GetDateText(DateTime date) + { + var value = DateTime.Now - date; + var total = value.TotalSeconds; + if (total < 60) + { + return string.Format(LanguageSystem.Instance.DateText0, value.Seconds); + } + if (total < 60 * 60) + { + return string.Format(LanguageSystem.Instance.DateText1, value.Minutes); + } + if (total < 60 * 60 * 24) + { + return string.Format(LanguageSystem.Instance.DateText2, value.Hours); + } + if (total < 60 * 60 * 24 * 30) + { + return string.Format(LanguageSystem.Instance.DateText3, value.Days); + } + return date.ToString("yyyy-MM-dd HH:mm:ss"); + } } } \ No newline at end of file diff --git a/Qwilight/ViewModel/WwwLevelViewModel.cs b/Qwilight/ViewModel/WwwLevelViewModel.cs index 2526e0d..270fd7d 100644 --- a/Qwilight/ViewModel/WwwLevelViewModel.cs +++ b/Qwilight/ViewModel/WwwLevelViewModel.cs @@ -841,7 +841,7 @@ AvatarWwwValue = new(avatar.avatarID), AvatarName = avatar.avatarName }).ToArray()); - WwwLevelAvatarValue ??= _lastWwwLevelAvatar ?? WwwLevelAvatarCollection.FirstOrDefault(); + WwwLevelAvatarValue ??= _lastWwwLevelAvatar; } IsAvatarIDsLoading = false; });