Skip to content

Commit 5d71231

Browse files
committed
temp
2 parents cd35784 + b0f0d27 commit 5d71231

File tree

5 files changed

+12
-11
lines changed

5 files changed

+12
-11
lines changed

iCourse/Helpers/Http.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public Http(TimeSpan timeout)
1515
: base(new HttpClientHandler
1616
{
1717
UseCookies = true,
18-
ServerCertificateCustomValidationCallback = (HttpRequestMessage request, X509Certificate2 certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) => true
18+
ServerCertificateCustomValidationCallback = (message, cert, chain, errors) => true
1919
})
2020
{
2121
Timeout = timeout;

iCourse/Helpers/JLUiCourseApi.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ public class JLUiCourseApi
2424

2525
public JLUiCourseApi()
2626
{
27-
WeakReferenceMessenger.Default.Register<AttemptLoginMessage>(this, AttemptLoginAsync);
2827
}
2928

3029
~JLUiCourseApi()
@@ -131,10 +130,10 @@ public async Task AddToFavoritesAsync(Course course)
131130
}
132131
}
133132

134-
private async void AttemptLoginAsync(object recipient, AttemptLoginMessage message)
133+
public async void AttemptLoginAsync(string captcha)
135134
{
136135

137-
var response = await PostLoginAsync(message.Captcha);
136+
var response = await PostLoginAsync(captcha);
138137
var json = JObject.Parse(response);
139138

140139
var code = json["code"].ToObject<int>();
@@ -272,7 +271,7 @@ private async Task<List<Course>> GetFavoriteCoursesAsync()
272271
return coursesList;
273272
}
274273

275-
private async Task<(bool isSuccess, string? msg)> SelectCourseAsync(Course courseInfo)
274+
private async Task<(bool isSuccess, string? msg)> SelectCourseAsync(CourseInfo courseInfo)
276275
{
277276
client.SetReferer("https://icourses.jlu.edu.cn/xsxk/elective/grablessons?batchId=" + batch.batchId);
278277

@@ -321,6 +320,8 @@ public async void StartSelectClassAsync()
321320
{
322321
var list = await GetFavoriteCoursesAsync();
323322

323+
Logger.WriteLine("收藏中的课程:\n" + string.Join("\n", list.Select(c => c.Name)));
324+
324325
int totalTasks = list.Count;
325326
int completedTasks = 0;
326327

iCourse/Messages/AttemptLoginMessage.cs

Lines changed: 0 additions & 4 deletions
This file was deleted.

iCourse/Models/Course.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ public enum ClassSelectType
88
Elective, RestrictedElective
99
}
1010

11-
public class Course : ObservableObject
11+
public class Course : ObservableObject
1212
{
1313
public Course()
1414
{
@@ -20,6 +20,7 @@ public Course(JToken json)
2020
TeacherName = json["SKJS"].ToString();
2121
Campus = json["XQ"].ToString();
2222
ClassLocation = json["YPSJDD"].ToString();
23+
ClazzType = json["teachingClassType"].ToString();
2324
SecretVal = json["secretVal"].ToString();
2425
CourseId = json["JXBID"].ToString();
2526

@@ -34,6 +35,7 @@ public Course(JToken json)
3435
public string Name { get; set; }
3536
public string CourseId { get; set; }
3637
public string TeacherName { get; set; }
38+
public string ClazzType { get; set; }
3739
public string Campus { get; set; }
3840
public ClassSelectType SelectType { get; set; }
3941
public string ClassLocation { get; set; }

iCourse/ViewModels/CaptchaWindowViewModel.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
using iCourse.Messages;
55
using System.IO;
66
using System.Windows.Media.Imaging;
7+
using iCourse.Helpers;
8+
using Microsoft.Extensions.DependencyInjection;
79

810
namespace iCourse.ViewModels
911
{
@@ -37,7 +39,7 @@ private void LoadCaptchaImage(string base64Image)
3739
[RelayCommand]
3840
private void CloseWindow()
3941
{
40-
WeakReferenceMessenger.Default.Send<AttemptLoginMessage>(new AttemptLoginMessage(Captcha));
42+
App.ServiceProvider.GetService<JLUiCourseApi>().AttemptLoginAsync(captcha);
4143
WeakReferenceMessenger.Default.Send<CloseWindowMessage>(new CloseWindowMessage(typeof(CaptchaWindowViewModel)));
4244
}
4345

0 commit comments

Comments
 (0)