diff --git a/README.md b/README.md index 08b75b4..81d669c 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ - +

@@ -35,10 +35,23 @@ - +

+## 线上预览 +- [vue3-vant4-mobile](https://vue3-vant4-mobile.xiangshu233.cn/) + +账号:admin,密码:123456 + +账号:test,密码:123456 + + +或者扫描以下二维码进入手机演示 +

+ +

+ ## 基础知识 既然你搜了 `vue3`、`vant4` 此类关键词,则默认你会用这些配套技术栈。 diff --git a/mock/_createProductionServer.ts b/mock/_createProductionServer.ts index de81d38..74125af 100644 --- a/mock/_createProductionServer.ts +++ b/mock/_createProductionServer.ts @@ -1,6 +1,6 @@ import { createProdMockServer } from 'vite-plugin-mock/es/createProdMockServer'; -const modules: Recordable = import.meta.glob('./**/*.ts'); +const modules = import.meta.glob('./**/*.ts', { eager: true }) as any; const mockModules: any[] = []; Object.keys(modules).forEach((key) => { diff --git a/mock/user/user.ts b/mock/user/user.ts index cf6f938..48dd380 100644 --- a/mock/user/user.ts +++ b/mock/user/user.ts @@ -2,39 +2,37 @@ import { MockMethod } from 'vite-plugin-mock'; import { getRequestToken, requestParams, resultError, resultSuccess } from '../_util'; import { ResultEnum } from '@/enums/httpEnum'; -export function createFakeUserList() { - return [ - { - userId: 1, - username: 'admin', - password: '123456', - nickname: '一条咸鱼', - realname: 'administrator', - avatar: 'https://fastly.jsdelivr.net/npm/@vant/assets/cat.jpeg', - cover: '', - sign: '一年精通三年熟练五年入门', - industry: 4, - gender: 0, - phone: '15758791450', - token: 'fakeToken1', - }, - { - userId: 2, - username: 'test', - password: '123456', - nickname: '萝卜头', - realname: 'test user', - avatar: - 'https://link.jscdn.cn/1drv/aHR0cHM6Ly8xZHJ2Lm1zL3UvcyFBaFhWN0U3bHBTaWtsbkNaWjYxY0lLczdEUGlpP2U9Yldkd0Fp.jpg', - cover: '', - sign: '这个家伙很懒,什么都没有写~', - industry: 7, - gender: 1, - phone: '18822137893', - token: 'fakeToken2', - }, - ]; -} +const fakeUserList = [ + { + userId: 1, + username: 'admin', + password: '123456', + nickname: '一条咸鱼', + realname: 'administrator', + avatar: 'https://fastly.jsdelivr.net/npm/@vant/assets/cat.jpeg', + cover: '', + sign: '一年精通三年熟练五年入门', + industry: 4, + gender: 0, + phone: '15758791450', + token: 'fakeToken1', + }, + { + userId: 2, + username: 'test', + password: '123456', + nickname: '萝卜头', + realname: 'test user', + avatar: + 'https://link.jscdn.cn/1drv/aHR0cHM6Ly8xZHJ2Lm1zL3UvcyFBaFhWN0U3bHBTaWtsbkNaWjYxY0lLczdEUGlpP2U9Yldkd0Fp.jpg', + cover: '', + sign: '这个家伙很懒,什么都没有写~', + industry: 7, + gender: 1, + phone: '18822137893', + token: 'fakeToken2', + }, +]; export default [ { @@ -43,7 +41,7 @@ export default [ method: 'post', response: ({ body }) => { const { username, password } = body; - const checkUser = createFakeUserList().find( + const checkUser = fakeUserList.find( (item) => item.username === username && password === item.password ); if (!checkUser) { @@ -66,7 +64,7 @@ export default [ response: (request: requestParams) => { const token = getRequestToken(request); if (!token) return resultError('无效令牌'); - const checkUser = createFakeUserList().find((item) => item.token === token); + const checkUser = fakeUserList.find((item) => item.token === token); if (!checkUser) { return resultError('没有获取到对应的用户信息', { code: ResultEnum.TOKEN_EXPIRED, @@ -82,7 +80,7 @@ export default [ response: (request: requestParams) => { const token = getRequestToken(request); if (!token) return resultError('无效令牌'); - const checkUser = createFakeUserList().find((item) => item.token === token); + const checkUser = fakeUserList.find((item) => item.token === token); if (!checkUser) { return resultError('无效令牌'); } diff --git a/src/utils/domUtils.ts b/src/utils/domUtils.ts index 126a114..ead55d5 100644 --- a/src/utils/domUtils.ts +++ b/src/utils/domUtils.ts @@ -158,6 +158,7 @@ export function off( export function once(el: HTMLElement, event: string, fn: EventListener): void { const listener = function (this: any, ...args: unknown[]) { if (fn) { + // @ts-ignore fn.apply(this, args); } off(el, event, listener);