Files
ao3-mirror-ssr/src/stores/api.js
UnknownMp 3a6d10c2ec
All checks were successful
Build / build-and-test (push) Successful in 29s
修整了代码, 移除不必要导入, 使代码紧凑
[UX]
在路由加载时如果有新的路由请求直接拦截取消 (beforeEach 路由守卫)
2025-05-31 19:11:20 +08:00

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
}
})