21 lines
556 B
JavaScript
21 lines
556 B
JavaScript
import { defineStore } from 'pinia'
|
|
import { useApiRequest } from '../composables/apiRequest'
|
|
|
|
export const useApiStore = defineStore('api', () => {
|
|
async function getWork(workId, chapterId) {
|
|
const path = chapterId ? `work/${workId}/${chapterId}` : `work/${workId}`
|
|
const { execute } = useApiRequest('GET', path)
|
|
return await execute()
|
|
}
|
|
|
|
async function workSimpleSearch(keyword, page = 1) {
|
|
const { execute } = useApiRequest('GET', 'search/simple', { keyword, page })
|
|
return await execute()
|
|
}
|
|
|
|
return {
|
|
getWork,
|
|
workSimpleSearch
|
|
}
|
|
})
|