update
This commit is contained in:
1 parent
ffbe5fed18
commit
b32007acd1
6 files changed
+939
-55
No files matched your search
+84
-28
@@ -9,17 +9,21 @@ export interface ILevelBrowserByType {
|
||||
|
||||
export type ILevelBrowser = Record<ITypeLevel, ILevelBrowserByType>
|
||||
|
||||
export interface IUserSettings {
|
||||
identifier: string
|
||||
level: number
|
||||
export interface IUserLocalSettings {
|
||||
levelMin?: number
|
||||
level_browser?: ILevelBrowser
|
||||
}
|
||||
|
||||
export interface IUserSettings extends IUserLocalSettings {
|
||||
identifier: string
|
||||
level: number
|
||||
}
|
||||
|
||||
export interface IEntry {
|
||||
id: string
|
||||
entry: string[]
|
||||
list: string[]
|
||||
reading: string[]
|
||||
audio: string[]
|
||||
translation: string[]
|
||||
type: IType
|
||||
description: string
|
||||
@@ -36,6 +40,17 @@ export interface ILibrary {
|
||||
isShared?: boolean
|
||||
}
|
||||
|
||||
export interface IQuiz {
|
||||
id: string
|
||||
type: IType
|
||||
direction: 'forward' | 'backward'
|
||||
entry: string
|
||||
nextReview?: string // format: date-time
|
||||
wrongStreak?: number
|
||||
hint: string
|
||||
mnemonic: string
|
||||
}
|
||||
|
||||
export type ILookup<T> = T & {
|
||||
offset?: number
|
||||
limit?: number
|
||||
@@ -109,17 +124,23 @@ class Api {
|
||||
return r
|
||||
}
|
||||
|
||||
async user_updateSettings(u: Omit<IUserSettings, 'identifier' | 'level'>) {
|
||||
async user_updateSettings(u: IUserLocalSettings) {
|
||||
return await this.axios.patch('/api/user', u)
|
||||
}
|
||||
|
||||
async quiz_getMany(payload: {
|
||||
async quiz_getById(params: { id: string }) {
|
||||
return await this.axios
|
||||
.get('/api/quiz', { params })
|
||||
.then((r) => r.data as IQuiz)
|
||||
.catch(() => null)
|
||||
}
|
||||
|
||||
async quiz_getManyByEntries(payload: {
|
||||
entries: string[]
|
||||
select: string[]
|
||||
type?: string
|
||||
type: string
|
||||
direction?: string
|
||||
}) {
|
||||
return await this.axios.post('/api/quiz/getMany', payload).then(
|
||||
return await this.axios.post('/api/quiz/getManyByEntries', payload).then(
|
||||
(r) =>
|
||||
r.data as {
|
||||
result: {
|
||||
@@ -142,6 +163,10 @@ class Api {
|
||||
)
|
||||
}
|
||||
|
||||
async quiz_updateSrsLevel(params: { id: string; df: number }) {
|
||||
return await this.axios.patch('/api/quiz/srsLevel', { params })
|
||||
}
|
||||
|
||||
async quiz_create(payload: { entries: string[]; type: IType }) {
|
||||
return await this.axios.put('/api/quiz', payload).then(
|
||||
(r) =>
|
||||
@@ -153,6 +178,12 @@ class Api {
|
||||
)
|
||||
}
|
||||
|
||||
async quiz_update(payload: Partial<IQuiz> & { id: string }) {
|
||||
return await this.axios.patch('/api/quiz', payload, {
|
||||
params: { id: payload.id },
|
||||
})
|
||||
}
|
||||
|
||||
async quiz_deleteMany(params: { entries: string[]; type: IType }) {
|
||||
return await this.axios.post('/api/quiz/deleteMany', params)
|
||||
}
|
||||
@@ -185,39 +216,51 @@ class Api {
|
||||
}
|
||||
|
||||
async character_getRadical(params: { entry: string }) {
|
||||
return await this.axios.get('/api/character/radical', { params }).then(
|
||||
(r) =>
|
||||
r.data as {
|
||||
result: {
|
||||
return await this.axios
|
||||
.get('/api/character/radical', { params })
|
||||
.then(
|
||||
(r) =>
|
||||
r.data as {
|
||||
sub: string[]
|
||||
sup: string[]
|
||||
variant: string[]
|
||||
visual: string[]
|
||||
} | null
|
||||
}
|
||||
)
|
||||
}
|
||||
)
|
||||
.catch(() => null)
|
||||
}
|
||||
|
||||
async character_getVocabulary(
|
||||
params: ILookup<{ entry: string; distinct?: 'id' }>
|
||||
) {
|
||||
return await this.axios.get('/api/character/vocabulary', { params }).then(
|
||||
(r) =>
|
||||
r.data as ILookupResult<{
|
||||
entry: string
|
||||
}>
|
||||
)
|
||||
params.offset = params.offset || 0
|
||||
params.limit = params.limit || 5
|
||||
|
||||
return await this.axios
|
||||
.get('/api/character/vocabulary', { params })
|
||||
.then((r) => r.data as ILookupResult<IEntry>)
|
||||
}
|
||||
|
||||
async character_getSentence(
|
||||
params: ILookup<{ entry: string; distinct?: 'id' }>
|
||||
) {
|
||||
return await this.axios.get('/api/character/sentence', { params }).then(
|
||||
(r) =>
|
||||
r.data as ILookupResult<{
|
||||
entry: string
|
||||
}>
|
||||
)
|
||||
params.offset = params.offset || 0
|
||||
params.limit = params.limit || 5
|
||||
|
||||
return await this.axios
|
||||
.get('/api/character/sentence', { params })
|
||||
.then((r) => r.data as ILookupResult<IEntry>)
|
||||
}
|
||||
|
||||
async vocabulary_getSentence(
|
||||
params: ILookup<{ entry: string; distinct?: 'id' }>
|
||||
) {
|
||||
params.offset = params.offset || 0
|
||||
params.limit = params.limit || 5
|
||||
|
||||
return await this.axios
|
||||
.get('/api/vocabulary/sentence', { params })
|
||||
.then((r) => r.data as ILookupResult<IEntry>)
|
||||
}
|
||||
|
||||
async all_getRandom(params: { type: IType }) {
|
||||
@@ -263,6 +306,19 @@ class Api {
|
||||
)
|
||||
}
|
||||
|
||||
async all_tokenize(params: { entry: string }) {
|
||||
return await this.axios
|
||||
.get('/api/all/tokenize', {
|
||||
params,
|
||||
})
|
||||
.then(
|
||||
(r) =>
|
||||
r.data as {
|
||||
result: string[]
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
async all_getReading(params: { entry: string }) {
|
||||
return await this.axios
|
||||
.get('/api/all/reading', {
|
||||
|
||||
Reference in new issue
Block a user