feat: 模板适配层、易班能力与全局状态

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
zhongyidianandClaude Opus 4.8 committed 2026-08-18 13:39:42 +08:00
1 parent 3995656175
commit d3ae0a8ca7
45 files changed
+6931 -179

No files matched your search

-34
View File
@@ -1,34 +0,0 @@
/**
* 全局类型定义
*/
// 用户相关类型
export interface User {
id: string;
name: string;
email: string;
avatar?: string;
}
// API 响应类型
export interface PaginationParams {
page: number;
pageSize: number;
}
export interface PaginationResponse<T> {
list: T[];
total: number;
page: number;
pageSize: number;
}
// 通用类型
export type Nullable<T> = T | null;
export type Optional<T> = T | undefined;
// 组件 Props 基础类型
export interface BaseComponentProps {
className?: string;
children?: React.ReactNode;
}
+137
View File
@@ -0,0 +1,137 @@
/**
* 易班 videoajax.js 相关类型定义
*/
// 声明外部依赖(由 vite.config.ts 注入的 videoajax.js 提供,运行时可能加载失败)
declare global {
var videoAjax: (() => VideoAjax) | undefined;
}
/**
* VideoAjax 实例接口
*/
export interface VideoAjax {
setHost(host: string): void;
addUserDefine(
param: UserDefineParam,
callback?: (data: unknown) => void,
): void;
getUserDefineInfoByUser(
param: UserDefineParam,
callback: (data: VideoAjaxResponse | undefined) => void,
): void;
getUserDefineInfo(
param: UserDefineParam,
callback: (data: VideoAjaxResponse | undefined) => void,
): void;
finishCourse(
param: { order: number; co: string; process: number },
callback?: (status: boolean, data: unknown) => void,
): void;
getfinishCourse(
param: { order: number; co: string },
callback: (data: unknown) => void,
): void;
quitBreakPoint(
param: {
user_id: string;
course_id: string;
lesson_id: string;
break_point: number;
},
callback?: (status: boolean, data: unknown) => void,
): void;
getBreakPoint(
param: { user_id: string; course_id: string; lesson_id: string },
callback: (status: boolean, data: unknown) => void,
): void;
getUserAnswer(
param: {
user_id: string;
lesson_id: string;
course_id: string;
question_order: number;
answer: string;
},
callback?: (status: boolean, data: unknown) => void,
): void;
}
/**
* UserDefine 接口参数
*/
export interface UserDefineParam {
lessonId: string;
key?: string | number;
order?: string | number;
content?: string;
}
/**
* VideoAjax 响应项
*/
export interface VideoAjaxResponseItem {
content?: string;
}
/**
* VideoAjax 响应
*/
export interface VideoAjaxResponse {
code: number;
msg?: string;
data: {
value?: VideoAjaxResponseItem[] | string;
process?: string;
};
}
/**
* 用户存储获取状态
*/
export type UserStorageFetchStatus =
| "success"
| "empty"
| "unauthenticated"
| "error";
/**
* 用户存储获取结果
*/
export interface UserStorageFetchResult {
status: UserStorageFetchStatus;
content: string;
code?: number;
message?: string;
}
/**
* 存储后端类型
*/
export type StorageBackend = "auto" | "yiban" | "session";
/**
* 存储选项
*/
export interface StorageOptions {
backend?: StorageBackend;
}
/**
* 易班请求结果
*/
export interface YibanRequestResult<T = unknown> {
success: boolean;
data?: T;
error?: string;
}
/**
* 播放断点参数
*/
export interface BreakPointParams {
userId: string;
courseId: string;
lessonId: string;
breakPoint?: number;
}