Skip to content

Commit 8f2ddd9

Browse files
committed
feat: 添加RenewService,重构文件结构,重构Course
1 parent f3eeb91 commit 8f2ddd9

19 files changed

+255
-96
lines changed

eslint.config.js

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,24 @@ import pluginReactHooks from 'eslint-plugin-react-hooks'
66

77
/** @type {import('eslint').Linter.Config[]} */
88
export default [
9-
pluginJs.configs.recommended,
9+
{ name: 'globalIgnore', ignores: ['dist/', 'android/', 'eslint.config.js'] },
10+
{ name: 'pluginJs.configs.recommended', ...pluginJs.configs.recommended },
1011
...tseslint.configs.recommendedTypeChecked,
11-
pluginReact.configs.flat.recommended,
12-
pluginReact.configs.flat['jsx-runtime'],
13-
{ plugins: { 'react-hooks': pluginReactHooks } },
14-
{ rules: pluginReactHooks.configs.recommended.rules },
1512
{
13+
name: 'pluginReact.configs.flat.recommended',
14+
...pluginReact.configs.flat.recommended,
15+
},
16+
{
17+
name: "pluginReact.configs.flat['jsx-runtime']",
18+
...pluginReact.configs.flat['jsx-runtime'],
19+
},
20+
{
21+
name: 'pluginReactHooks',
22+
plugins: { 'react-hooks': pluginReactHooks },
23+
rules: pluginReactHooks.configs.recommended.rules,
24+
},
25+
{
26+
name: 'customConfig',
1627
settings: { react: { version: 'detect' } },
1728
languageOptions: {
1829
globals: globals.browser,
@@ -21,8 +32,6 @@ export default [
2132
tsconfigRootDir: import.meta.dirname,
2233
},
2334
},
24-
},
25-
{
26-
ignores: ['dist/', 'android/', 'eslint.config.js'],
35+
rules: { eqeqeq: ['error', 'always'] },
2736
},
2837
]

src/extension/ExtensionWidgetCapability.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { WidgetExtension } from './Extension'
77
import { z } from 'zod'
88
import { afterDone, PromiseAwaited } from '../utils/func'
99
import { BorrowedHandle, BorrowManager } from './BorrowManager'
10-
import { ZjuamService } from '../interop/zjuam'
10+
import { ZjuamService } from '../services/ZjuamService'
1111
import { encodeReturn } from './ExtensionIO'
1212

1313
type ResolveHandle<H> = H extends BorrowedHandle<infer O> ? O : H

src/interop/credential.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { env } from './env'
2-
import { ZjuamService } from './zjuam'
2+
import { ZjuamService } from '../services/ZjuamService'
33

44
export type Credential = {
55
username: string

src/models/Course.ts

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

src/models/CourseBase.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { Semester } from './shared'
2+
3+
/**课程最基础的识别信息。选课课号为唯一标识符。
4+
*
5+
* 某些上游不返回学期字段,此时semester字段通过选课课号解析,可能不准确(如实际秋学期的课,该字段为秋冬)。
6+
*/
7+
export interface CourseBase {
8+
/**学年&学期 */
9+
semester: Semester
10+
/**选课号 如(2024-2025-1)-761T0060-0017687-4 */
11+
id: string
12+
/**课程名称(中文) */
13+
name: string
14+
}

src/models/CourseClassInfo.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { WeekType, DayOfWeek } from './shared'
2+
3+
/**课程教学信息,包括教师和上课时间地点。 */
4+
export interface CourseClassInfo {
5+
/**教师姓名 */
6+
teacherName: string
7+
/**上课时间地点 */
8+
classes: ClassArrangement[]
9+
}
10+
/**相对于学期的上课时间、地点 */
11+
12+
export interface ClassArrangement {
13+
/**上课周次 */
14+
weekType: WeekType
15+
dayOfWeek: DayOfWeek
16+
/**从第几节开始 =djj */
17+
startSection: number
18+
/**持续节数 =kccd */
19+
sectionCount: number
20+
/**地点 =skdd */
21+
location: string
22+
}

src/models/CourseCombined.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { CourseBase } from '@/models/CourseBase'
2+
import { CourseTodoInfo } from './CourseTodoInfo'
3+
import { CourseGradeInfo } from './CourseGradeInfo'
4+
import { CourseExamInfo } from './CourseExamInfo'
5+
import { CourseClassInfo } from './CourseClassInfo'
6+
import { Maybe } from '@/utils/type'
7+
8+
export type DataOrigin = 'class' | 'exam' | 'grade' | 'xzzdTodo'
9+
/**从课程表、考试、成绩、学在浙大多方来源合并的课程信息。
10+
*
11+
* 注意:如果没有来自'class'的信息(如实践课),则学期可能不准确(单个学期的课可能被解析为长学期)
12+
*/
13+
export type CourseCombined = CourseBase &
14+
Maybe<CourseClassInfo> &
15+
Maybe<CourseExamInfo> &
16+
Maybe<CourseGradeInfo> &
17+
Maybe<CourseTodoInfo> & { origin: DataOrigin[] }

src/models/CourseExamInfo.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/**课程考试信息。 */
2+
export interface CourseExamInfo {
3+
/**考试 */
4+
exams: ExamArrangement[]
5+
}
6+
7+
export type ExamType = 'midterm' | 'final'
8+
/**单场考试安排 */
9+
export interface ExamArrangement {
10+
type: ExamType
11+
startAt: Date
12+
endAt: Date
13+
/**考试地点,可空 */
14+
location?: string
15+
/**座位号,可空,原样保留上游结果,不需要转Number再转字符串 */
16+
seat?: string
17+
}
Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
import type { Course } from './Course'
2-
3-
export interface Grade {
4-
course: Pick<Course, 'semester' | 'id' | 'name' | 'credit'>
1+
export interface CourseGradeInfo {
2+
/**学分 */
3+
credit: number
54
/**原始成绩。包括“缺考”、“缓考”等 */
65
rawScore: string
76
/**原始绩点(原样保留上游数据) */

src/models/CourseTodoInfo.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { XzzdTodoType } from '@/spiders/XzzdSpider'
2+
3+
export interface CourseTodoInfo {
4+
todos: CourseTodo[]
5+
}
6+
7+
export interface CourseTodo {
8+
endAt: Date
9+
/**待办名称 */
10+
title: string
11+
type: XzzdTodoType
12+
}

0 commit comments

Comments
 (0)