fix: 修复问题
- 修复刷课错误不会停止 - 添加课程刷新 - 添加课程列表、记录列表缓存 - 显示当前版本
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { For, Show, createEffect, type JSX } from "solid-js";
|
||||
import type { RecordType } from "~/service/wk";
|
||||
import type { CourseKind, RecordType } from "~/service/wk";
|
||||
import type { AccountItem } from "~/store/account";
|
||||
import type { CourseType } from "~/types/Course";
|
||||
import type { RecordItem } from "~/service/wk";
|
||||
@@ -8,6 +8,10 @@ type RecordTypeOption = {
|
||||
label: string;
|
||||
value: RecordType;
|
||||
};
|
||||
type CourseRecordTypeOption = {
|
||||
label: string;
|
||||
value: CourseKind;
|
||||
};
|
||||
|
||||
interface CourseWorkspaceProps {
|
||||
selectedAccount: AccountItem | null;
|
||||
@@ -15,12 +19,17 @@ interface CourseWorkspaceProps {
|
||||
selectedCourseId: number | null;
|
||||
selectedCourse: CourseType | null;
|
||||
recordType: RecordType;
|
||||
courseKind: CourseKind;
|
||||
currentCourseKindLabel: string;
|
||||
showingCachedRecords: boolean;
|
||||
recordTypeOptions: RecordTypeOption[];
|
||||
courseRecordTypeOptions: CourseRecordTypeOption[];
|
||||
records: RecordItem[];
|
||||
studyLogs: string[];
|
||||
recordsLoading: boolean;
|
||||
recordError: string;
|
||||
isRefreshingRecords: boolean;
|
||||
isRefreshingCourseRecords: boolean;
|
||||
isRunningStudy: boolean;
|
||||
isRefreshingLogs: boolean;
|
||||
autoScrollLogs: boolean;
|
||||
@@ -29,7 +38,9 @@ interface CourseWorkspaceProps {
|
||||
logFontSize: number;
|
||||
onSelectCourse: (courseId: number) => void;
|
||||
onRefreshRecords: () => void;
|
||||
onRefreshCourseRecords: () => void;
|
||||
onChangeRecordType: (value: RecordType) => void;
|
||||
onChangeCourseRecordType: (value: CourseKind) => void;
|
||||
onStartStudy: () => void;
|
||||
onStopStudy: () => void;
|
||||
onRefreshLogs: () => void;
|
||||
@@ -108,9 +119,34 @@ const CourseWorkspace = (props: CourseWorkspaceProps) => {
|
||||
}
|
||||
>
|
||||
<div class="flex min-h-0 flex-col overflow-hidden rounded-3xl border border-zinc-200 bg-[linear-gradient(180deg,rgba(248,250,252,0.9),rgba(255,255,255,0.95))]">
|
||||
<div class="border-b border-zinc-200 px-4 py-3">
|
||||
<p class="text-sm font-semibold text-zinc-800">课程列表</p>
|
||||
<p class="mt-1 text-xs text-zinc-500">点击课程查看对应记录</p>
|
||||
<div class="flex flex-wrap items-center justify-between gap-3 border-b border-zinc-200 px-4 py-3">
|
||||
<div class="border-b border-zinc-200 px-4 py-3">
|
||||
<p class="text-sm font-semibold text-zinc-800">课程列表</p>
|
||||
<p class="mt-1 text-xs text-zinc-500">点击课程查看对应记录</p>
|
||||
</div>
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
<select
|
||||
class="rounded-xl border border-zinc-200 bg-white px-3 py-2 text-sm transition outline-none focus:border-cyan-400"
|
||||
value={props.courseKind}
|
||||
onChange={(event) =>
|
||||
props.onChangeCourseRecordType(
|
||||
event.currentTarget.value as CourseKind,
|
||||
)
|
||||
}
|
||||
>
|
||||
<For each={props.courseRecordTypeOptions}>
|
||||
{(item) => <option value={item.value}>{item.label}</option>}
|
||||
</For>
|
||||
</select>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-xl border border-zinc-200 bg-white px-3 py-2 text-sm text-zinc-700 transition hover:bg-zinc-100 disabled:cursor-not-allowed disabled:opacity-60"
|
||||
disabled={props.isRefreshingCourseRecords}
|
||||
onClick={props.onRefreshCourseRecords}
|
||||
>
|
||||
{props.isRefreshingCourseRecords ? "刷新中..." : "刷新记录"}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div
|
||||
@@ -120,6 +156,13 @@ const CourseWorkspace = (props: CourseWorkspaceProps) => {
|
||||
: "flex min-h-0 flex-1 flex-col gap-3 overflow-y-auto p-3"
|
||||
}
|
||||
>
|
||||
<Show when={props.selectedCourseList.length === 0}>
|
||||
<EmptyState>
|
||||
当前“{props.currentCourseKindLabel}
|
||||
”下没有课程,请切换分类或刷新课程列表。
|
||||
</EmptyState>
|
||||
</Show>
|
||||
|
||||
<For each={props.selectedCourseList}>
|
||||
{(course) => {
|
||||
const selected = () => course.id === props.selectedCourseId;
|
||||
@@ -169,6 +212,13 @@ const CourseWorkspace = (props: CourseWorkspaceProps) => {
|
||||
? props.selectedCourse.name
|
||||
: "请选择课程"}
|
||||
</p>
|
||||
<Show
|
||||
when={props.showingCachedRecords && !props.recordsLoading}
|
||||
>
|
||||
<p class="mt-1 text-xs text-amber-600">
|
||||
当前显示的是本地缓存记录。
|
||||
</p>
|
||||
</Show>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
|
||||
Reference in New Issue
Block a user