update
This commit is contained in:
1 parent
7d5114953b
commit
cbc36d19f5
7 files changed
+215
-194
No files matched your search
+42
-35
@@ -19,7 +19,7 @@ export interface IUserSettings extends IUserLocalSettings {
|
||||
level: number
|
||||
}
|
||||
|
||||
export interface IEntry {
|
||||
export interface IDictionaryLookup {
|
||||
id: string
|
||||
list: string[]
|
||||
reading: string[]
|
||||
@@ -31,6 +31,25 @@ export interface IEntry {
|
||||
type: IType
|
||||
description: string
|
||||
tag: string[]
|
||||
level?: number
|
||||
}
|
||||
|
||||
export interface IEntryLookup {
|
||||
entry: string
|
||||
sub: string[]
|
||||
sup: string[]
|
||||
variant: string[]
|
||||
visual: {
|
||||
entry: string
|
||||
}[]
|
||||
amalgamation: {
|
||||
entry: string
|
||||
type?: IType
|
||||
}[]
|
||||
component: {
|
||||
entry: string
|
||||
type?: IType
|
||||
}[]
|
||||
}
|
||||
|
||||
export interface ILibrary {
|
||||
@@ -197,16 +216,16 @@ class Api {
|
||||
|
||||
return await this.axios
|
||||
.get('/api/extra/q', { params })
|
||||
.then((r) => r.data as ILookupResult<IEntry>)
|
||||
.then((r) => r.data as ILookupResult<IDictionaryLookup>)
|
||||
}
|
||||
|
||||
async extra_create(payload: Omit<IEntry, 'id'>) {
|
||||
async extra_create(payload: Omit<IDictionaryLookup, 'id'>) {
|
||||
return await this.axios
|
||||
.put('/api/extra', payload)
|
||||
.then((r) => r.data as { id: string })
|
||||
}
|
||||
|
||||
async extra_update(payload: IEntry) {
|
||||
async extra_update(payload: IDictionaryLookup) {
|
||||
return await this.axios.patch('/api/extra', payload, {
|
||||
params: { id: payload.id },
|
||||
})
|
||||
@@ -226,7 +245,7 @@ class Api {
|
||||
|
||||
return await this.axios
|
||||
.get('/api/character/vocabulary', { params })
|
||||
.then((r) => r.data as ILookupResult<IEntry>)
|
||||
.then((r) => r.data as ILookupResult<IDictionaryLookup>)
|
||||
}
|
||||
|
||||
async character_getSentence(
|
||||
@@ -237,7 +256,18 @@ class Api {
|
||||
|
||||
return await this.axios
|
||||
.get('/api/character/sentence', { params })
|
||||
.then((r) => r.data as ILookupResult<IEntry>)
|
||||
.then((r) => r.data as ILookupResult<IDictionaryLookup>)
|
||||
}
|
||||
|
||||
async vocabulary_getVocabulary(
|
||||
params: ILookup<{ entry: string; distinct?: 'id' }>
|
||||
) {
|
||||
params.offset = params.offset || 0
|
||||
params.limit = params.limit || 5
|
||||
|
||||
return await this.axios
|
||||
.get('/api/vocabulary/vocabulary', { params })
|
||||
.then((r) => r.data as ILookupResult<IDictionaryLookup>)
|
||||
}
|
||||
|
||||
async vocabulary_getSentence(
|
||||
@@ -248,7 +278,7 @@ class Api {
|
||||
|
||||
return await this.axios
|
||||
.get('/api/vocabulary/sentence', { params })
|
||||
.then((r) => r.data as ILookupResult<IEntry>)
|
||||
.then((r) => r.data as ILookupResult<IDictionaryLookup>)
|
||||
}
|
||||
|
||||
async all_getRandom(params: { type: IType }) {
|
||||
@@ -261,7 +291,9 @@ class Api {
|
||||
)
|
||||
}
|
||||
|
||||
async all_getQuery(params: ILookup<{ q: string }>) {
|
||||
async all_getQuery(
|
||||
params: ILookup<{ q: string; type?: IType; distinct?: 'id' }>
|
||||
) {
|
||||
params.offset = params.offset || 0
|
||||
params.limit = params.limit || 5
|
||||
|
||||
@@ -284,38 +316,13 @@ class Api {
|
||||
.get('/api/all', {
|
||||
params,
|
||||
})
|
||||
.then(
|
||||
(r) =>
|
||||
r.data as ILookupResult<
|
||||
IEntry & {
|
||||
level?: number
|
||||
}
|
||||
>
|
||||
)
|
||||
.then((r) => r.data as ILookupResult<IDictionaryLookup>)
|
||||
}
|
||||
|
||||
async all_getComponent(params: { entry: string; type: IType }) {
|
||||
return await this.axios
|
||||
.get('/api/all/components', { params })
|
||||
.then(
|
||||
(r) =>
|
||||
r.data as {
|
||||
sub: string[]
|
||||
sup: string[]
|
||||
variant: string[]
|
||||
visual: {
|
||||
entry: string
|
||||
}[]
|
||||
amalgamation: {
|
||||
entry: string
|
||||
type?: IType
|
||||
}[]
|
||||
component: {
|
||||
entry: string
|
||||
type?: IType
|
||||
}[]
|
||||
}
|
||||
)
|
||||
.then((r) => r.data as IEntryLookup)
|
||||
.catch(() => null)
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user