All checks were successful
Build / build-and-test (push) Successful in 29s
[UX] 在路由加载时如果有新的路由请求直接拦截取消 (beforeEach 路由守卫)
21 lines
559 B
JavaScript
21 lines
559 B
JavaScript
import { defineStore } from 'pinia'
|
|
import { useApiRequest } from '../composables/apiRequest.js'
|
|
|
|
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
|
|
}
|
|
})
|