mirror of
https://github.com/soybeanjs/soybean-admin.git
synced 2025-11-12 03:33:41 +08:00
feat(projects): 引入mockjs
This commit is contained in:
@@ -5,6 +5,9 @@
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { fetchTestMock } from '@/service';
|
||||
import AppProvider from './AppProvider.vue';
|
||||
|
||||
fetchTestMock();
|
||||
</script>
|
||||
<style></style>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { useAuthStore } from '@/store';
|
||||
import { useLoading } from '@/hooks';
|
||||
import { setToken, setRefreshToken, setUserInfo, log } from '@/utils';
|
||||
import { setToken, setRefreshToken, setUserInfo, consoleLog } from '@/utils';
|
||||
import type { LoginToken, UserInfo } from '@/interface';
|
||||
import { useRouterPush, useRouteQuery } from '../common';
|
||||
|
||||
@@ -20,7 +20,7 @@ export function useLogin() {
|
||||
* @returns 是否登录成功
|
||||
*/
|
||||
async function login(param: { phone: string; pwdOrCode: string; type: 'pwd' | 'sms' }) {
|
||||
log(param); // 打印参数(接入接口后去除)
|
||||
consoleLog(param); // 打印参数(接入接口后去除)
|
||||
|
||||
startLoading();
|
||||
// 1.这里调用登录接口获取token和refreshToken
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
import { consoleLog } from '@/utils';
|
||||
import { mockRequest } from '../request';
|
||||
|
||||
/** 测试mock数据 */
|
||||
export async function fetchTestMock() {
|
||||
const { data } = await mockRequest.get('/api/getUser');
|
||||
consoleLog('data: ', data);
|
||||
}
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
export * from './demo';
|
||||
export * from './auth';
|
||||
|
||||
@@ -5,3 +5,8 @@ export const request = createRequest({
|
||||
baseURL: import.meta.env.VITE_HTTP_URL,
|
||||
timeout: REQUEST_TIMEOUT
|
||||
});
|
||||
|
||||
export const mockRequest = createRequest({
|
||||
baseURL: '',
|
||||
timeout: REQUEST_TIMEOUT
|
||||
});
|
||||
|
||||
16
src/utils/common/console.ts
Normal file
16
src/utils/common/console.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
/* eslint-disable no-console */
|
||||
|
||||
/** 打印log */
|
||||
export function consoleLog(message?: any, ...optionalParams: any[]) {
|
||||
console.log(message, ...optionalParams);
|
||||
}
|
||||
|
||||
/** 打印警告 */
|
||||
export function consoleWarn(message?: any, ...optionalParams: any[]) {
|
||||
console.warn(message, ...optionalParams);
|
||||
}
|
||||
|
||||
/** 打印错误 */
|
||||
export function consoleError(message?: any, ...optionalParams: any[]) {
|
||||
console.error(message, ...optionalParams);
|
||||
}
|
||||
@@ -2,5 +2,5 @@ export * from './typeof';
|
||||
export * from './color';
|
||||
export * from './icon';
|
||||
export * from './browser';
|
||||
export * from './log';
|
||||
export * from './console';
|
||||
export * from './number';
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
/** 打印log */
|
||||
export function log(data: any) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(data);
|
||||
}
|
||||
Reference in New Issue
Block a user