301 lines
5.8 KiB
TypeScript
301 lines
5.8 KiB
TypeScript
// app.ts 的类型定义
|
|
import { ApiManager } from '../utils/api'
|
|
|
|
// 用户信息接口
|
|
export interface IUserInfo {
|
|
id: string
|
|
nickname?: string
|
|
avatar_url?: string
|
|
avatar_file_id?: string
|
|
gender?: number
|
|
country?: string
|
|
province?: string
|
|
city?: string
|
|
language?: string
|
|
}
|
|
|
|
// 登录响应接口
|
|
export interface ILoginResponse {
|
|
access_token: string
|
|
access_token_expire_time: string
|
|
session_uuid: string
|
|
dict_level?: string
|
|
}
|
|
|
|
// API响应接口
|
|
export interface IApiResponse<T> {
|
|
code: number
|
|
message?: string
|
|
msg?: string
|
|
data: T
|
|
}
|
|
|
|
export interface IRecognitionResponse {
|
|
task_id: string
|
|
status: string
|
|
error_message?: string
|
|
image_id?: string
|
|
// result?: IRecognitionResponseResult
|
|
}
|
|
|
|
export interface IRecognitionResponseResultLevel {
|
|
desc_en: string[]
|
|
desc_zh: string[]
|
|
}
|
|
|
|
export interface IRecognitionResponseResult {
|
|
level1: IRecognitionResponseResultLevel,
|
|
level2: IRecognitionResponseResultLevel,
|
|
level3: IRecognitionResponseResultLevel,
|
|
}
|
|
|
|
export interface IQaExerciseCreateAccepted {
|
|
task_id: string
|
|
status: 'accepted'
|
|
}
|
|
|
|
export interface IQaExerciseTaskStatus {
|
|
task_id: string
|
|
image_id: string
|
|
ref_type: 'qa_exercise'
|
|
ref_id: string
|
|
status: string
|
|
error_message?: string
|
|
}
|
|
|
|
export interface IQaExerciseItem {
|
|
id: number
|
|
image_id: number
|
|
title?: string
|
|
description?: string
|
|
status: string
|
|
question_count: number
|
|
created_by: number
|
|
created_time?: string
|
|
}
|
|
|
|
export type IQaExerciseListResponse = IQaExerciseItem[]
|
|
|
|
export type QaAttemptMode = 'choice' | 'free_text' | 'audio'
|
|
|
|
export interface IQaExerciseQuestion {
|
|
id: number
|
|
exercise_id: number
|
|
image_id: number
|
|
question: string
|
|
user_id: number
|
|
ext: any
|
|
created_time?: string
|
|
}
|
|
|
|
export interface IQaExerciseQueryResponse {
|
|
exercise: IQaExerciseItem
|
|
session: IQaExerciseSession
|
|
questions: IQaExerciseQuestion[]
|
|
}
|
|
|
|
export interface IQaQuestionAttemptAccepted {
|
|
attempt_id: string
|
|
task_id: string
|
|
status: 'accepted'
|
|
}
|
|
|
|
export interface IQaQuestionTaskStatus {
|
|
task_id: string
|
|
ref_type: 'qa_question_attempt'
|
|
ref_id: string
|
|
status: string
|
|
error_message?: string
|
|
}
|
|
|
|
export type QaCorrectness = 'correct' | 'partial' | 'incorrect'
|
|
|
|
export interface IIncorrectSelectionItem {
|
|
content: string
|
|
error_type?: string
|
|
error_reason?: string
|
|
}
|
|
|
|
export interface ISelectedDetail {
|
|
correct: string[]
|
|
incorrect: IIncorrectSelectionItem[]
|
|
}
|
|
|
|
export interface IEvaluationSchema {
|
|
type?: string
|
|
result?: string
|
|
detail?: string
|
|
selected?: ISelectedDetail
|
|
missing_correct?: string[]
|
|
feedback?: string
|
|
}
|
|
|
|
export interface IQaResult {
|
|
attempt_id: string
|
|
status: string
|
|
is_correct?: QaCorrectness
|
|
evaluation?: IEvaluationSchema
|
|
mode: QaAttemptMode
|
|
selected_option_ids?: number[]
|
|
input_text?: string
|
|
recording_id?: string
|
|
stt_text?: string
|
|
updated_time?: string
|
|
}
|
|
|
|
export interface IQaConversationCoreObject {
|
|
object_en: string
|
|
object_zh: string
|
|
[key: string]: any
|
|
}
|
|
|
|
export interface IQaConversationEvent {
|
|
event_en: string
|
|
event_zh: string
|
|
[key: string]: any
|
|
}
|
|
|
|
export interface IQaConversationScene {
|
|
scene_en: string
|
|
scene_zh: string
|
|
[key: string]: any
|
|
}
|
|
|
|
export interface IQaConversationSettingPayload {
|
|
all_possible_events: IQaConversationEvent[]
|
|
all_possible_scenes: IQaConversationScene[]
|
|
core_objects: IQaConversationCoreObject[]
|
|
}
|
|
|
|
export interface IQaConversationSession {
|
|
id: string | number
|
|
status: string
|
|
created_at?: string
|
|
updated_at?: string
|
|
ext?: any
|
|
}
|
|
|
|
export interface IQaConversationSettingResponse {
|
|
image_id: string
|
|
latest_session: IQaConversationSession | null
|
|
setting: IQaConversationSettingPayload
|
|
}
|
|
|
|
export interface IQaConversationDetail {
|
|
id: string | number
|
|
status: string
|
|
created_at?: string
|
|
updated_at?: string
|
|
ext?: any
|
|
messages?: any[]
|
|
[key: string]: any
|
|
}
|
|
|
|
// 单词详情接口
|
|
export interface ExtendedWordDetail {
|
|
word: string
|
|
phonetic: string
|
|
definition: string
|
|
translation: string
|
|
pos: string
|
|
collins: number
|
|
oxford: number
|
|
tag: string
|
|
bnc: number
|
|
frq: number
|
|
exchange: Record<string, string[]>
|
|
detail: string
|
|
audio: string
|
|
}
|
|
|
|
// 积分数据接口
|
|
export interface IPointsData {
|
|
balance: number
|
|
available_balance: number
|
|
frozen_balance: number
|
|
total_purchased: number
|
|
total_refunded: number
|
|
expired_time: string
|
|
is_subscribed: boolean
|
|
subscription_expires_at: string | null
|
|
}
|
|
|
|
export interface IQaExerciseSession {
|
|
id: string | number
|
|
exercise_id: number
|
|
starter_user_id: number
|
|
status: string
|
|
started_at?: string
|
|
completed_at?: string
|
|
progress: number | {
|
|
answered: number
|
|
attempts: Array<{
|
|
attempt_id: string | number
|
|
created_at: string
|
|
is_correct: string
|
|
mode: string
|
|
question_id: string | number
|
|
}>
|
|
}
|
|
score?: number
|
|
ext?: any
|
|
}
|
|
|
|
export interface YdWordDetail {
|
|
ee: {}
|
|
ec: {}
|
|
discriminate: {}
|
|
etym: {}
|
|
expand_ec: {}
|
|
phrs: {}
|
|
simple: {}
|
|
}
|
|
|
|
// 审核历史记录接口
|
|
export interface IAuditHistoryResponse {
|
|
total: number
|
|
items: Array<{
|
|
id: string
|
|
image_url: string
|
|
text: string
|
|
created_at: string
|
|
}>
|
|
}
|
|
|
|
// 每日总结接口
|
|
export interface IDailySummaryResponse {
|
|
total: number
|
|
items: Array<{
|
|
summary_time: string
|
|
image_ids: string[]
|
|
thumbnail_ids: string[]
|
|
}>
|
|
}
|
|
|
|
// 全局数据接口
|
|
export interface IGlobalData {
|
|
isLoggedIn: boolean
|
|
userInfo?: IUserInfo
|
|
token?: string
|
|
dictLevel?: string
|
|
pendingReferrerId?: string
|
|
apiManager: ApiManager
|
|
}
|
|
|
|
// 小程序选项接口
|
|
export interface IAppOption {
|
|
globalData: IGlobalData
|
|
userInfoReadyCallback?: WechatMiniprogram.GetUserInfoSuccessCallback
|
|
initLoginStatus: () => void
|
|
updateLoginStatus: (loginData: {
|
|
access_token: string
|
|
access_token_expire_time: string
|
|
session_uuid: string
|
|
userInfo?: IUserInfo
|
|
dict_level?: string
|
|
}) => void
|
|
clearLoginData: () => void
|
|
cloud?: any
|
|
call: (obj: any, number?: number) => Promise<any>
|
|
}
|