feat: 在生产环境中排除 mock 数据

This commit is contained in:
h_mo 2023-03-30 08:22:39 +08:00
parent a7c36064f5
commit 0598f3a09d

View File

@ -1,6 +1,6 @@
import { createAlova } from 'alova'; import { createAlova } from 'alova';
import AdapterUniapp from '@alova/adapter-uniapp'; import AdapterUniapp from '@alova/adapter-uniapp';
import { getBaseUrl } from '@/utils/env'; import { getBaseUrl, isDevMode } from '@/utils/env';
import { mockAdapter } from '@/mock'; import { mockAdapter } from '@/mock';
import { assign } from 'lodash-es'; import { assign } from 'lodash-es';
import { useAuthStore } from '@/state/modules/auth'; import { useAuthStore } from '@/state/modules/auth';
@ -24,7 +24,7 @@ const HEADER = {
const alovaInstance = createAlova({ const alovaInstance = createAlova({
baseURL: BASE_URL, baseURL: BASE_URL,
...AdapterUniapp({ ...AdapterUniapp({
mockRequest: mockAdapter, mockRequest: isDevMode() ? mockAdapter : undefined,
}), }),
timeout: 5000, timeout: 5000,
beforeRequest: (method) => { beforeRequest: (method) => {