Feature/remove mock server (#88)

This commit is contained in:
crazywoola
2023-05-18 10:50:34 +08:00
committed by GitHub
parent c6ba67a770
commit a43ef7a926
13 changed files with 10 additions and 1171 deletions

View File

@@ -1,4 +1,4 @@
import { API_PREFIX, MOCK_API_PREFIX, PUBLIC_API_PREFIX, IS_CE_EDITION } from '@/config'
import { API_PREFIX, PUBLIC_API_PREFIX, IS_CE_EDITION } from '@/config'
import Toast from '@/app/components/base/toast'
const TIME_OUT = 100000
@@ -33,7 +33,6 @@ export type IOnError = (msg: string) => void
type IOtherOptions = {
isPublicAPI?: boolean
isMock?: boolean
needAllResponseContent?: boolean
onData?: IOnData // for stream
onError?: IOnError
@@ -116,7 +115,14 @@ const handleStream = (response: any, onData: IOnData, onCompleted?: IOnCompleted
read()
}
const baseFetch = (url: string, fetchOptions: any, { isPublicAPI = false, isMock = false, needAllResponseContent }: IOtherOptions) => {
const baseFetch = (
url: string,
fetchOptions: any,
{
isPublicAPI = false,
needAllResponseContent
}: IOtherOptions
) => {
const options = Object.assign({}, baseOptions, fetchOptions)
if (isPublicAPI) {
const sharedToken = globalThis.location.pathname.split('/').slice(-1)[0]
@@ -124,9 +130,6 @@ const baseFetch = (url: string, fetchOptions: any, { isPublicAPI = false, isMock
}
let urlPrefix = isPublicAPI ? PUBLIC_API_PREFIX : API_PREFIX
if (isMock)
urlPrefix = MOCK_API_PREFIX
let urlWithPrefix = `${urlPrefix}${url.startsWith('/') ? url : `/${url}`}`
const { method, params, body } = options