v4.1.7细节更新

This commit is contained in:
XiaoDaiGua-Ray 2023-08-14 17:42:05 +08:00
parent 1be73da92a
commit 6f98e8fb0d
7 changed files with 37 additions and 17 deletions

4
cfg.ts
View File

@ -135,6 +135,10 @@ const config: AppConfigExport = {
find: '@use-images', find: '@use-images',
replacement: path.resolve(__dirname, './src/assets/images'), replacement: path.resolve(__dirname, './src/assets/images'),
}, },
{
find: '@mock',
replacement: path.resolve(__dirname, './mock'),
},
], ],
} }

View File

@ -1,26 +1,17 @@
import { defineMock } from 'vite-plugin-mock-dev-server' import { defineMock } from 'vite-plugin-mock-dev-server'
import { pagination, stringify, response, array } from '@mock/shared/utils'
import { tableMock } from '@mock/shared/database'
import Mock from 'mockjs' import Mock from 'mockjs'
import { pagination, stringify, response } from '../shared/utils'
import { array } from '../shared/database'
export const getPersonList = defineMock({ export const getPersonList = defineMock({
url: '/api/list', url: '/api/list',
method: 'GET', method: 'GET',
delay: 500, delay: 500,
response: (req, res) => { response: (req, res) => {
const person = () => ({
id: Mock.Random.guid(),
address: Mock.Random.county(true),
email: Mock.Random.email(),
name: Mock.Random.cname(),
age: Mock.Random.integer(18, 60),
createDate: Mock.Random.date(),
})
const { const {
query: { page, pageSize, email }, query: { page, pageSize, email },
} = req } = req
let list = array(100).map(() => person()) let list = array(100).map(() => tableMock())
let length = list.length let length = list.length
if (!page || !pageSize) { if (!page || !pageSize) {

View File

@ -9,6 +9,22 @@
* @remark * @remark
*/ */
export function array(length: number) { import Mock from 'mockjs'
return new Array(length).fill(0)
/**
*
* @param option
*
*
*/
export function tableMock(option?: object) {
return {
...option,
id: Mock.Random.guid(),
address: Mock.Random.county(true),
email: Mock.Random.email(),
name: Mock.Random.cname(),
age: Mock.Random.integer(18, 60),
createDate: Mock.Random.date(),
}
} }

View File

@ -11,6 +11,10 @@
/* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable @typescript-eslint/no-explicit-any */
export function array(length: number) {
return new Array(length).fill(0)
}
/** /**
* *
* @param pageCurrent * @param pageCurrent

View File

@ -255,7 +255,6 @@ const RayTable = defineComponent({
} }
}, },
render() { render() {
console.log(this.action)
return ( return (
<NCard <NCard
class="ray-table" class="ray-table"

View File

@ -45,6 +45,9 @@ const MockDemo = defineComponent({
run: personFetchRun, run: personFetchRun,
} = useHookPlusRequest(getPersonList, { } = useHookPlusRequest(getPersonList, {
manual: true, manual: true,
onSuccess: (data) => {
console.log(data)
},
}) })
const columns = [ const columns = [
{ {

View File

@ -23,7 +23,9 @@
"@use-api/*": ["src/axios/api/*"], "@use-api/*": ["src/axios/api/*"],
"@use-images": ["src/assets/images"], "@use-images": ["src/assets/images"],
"@use-images/*": ["src/assets/images"], "@use-images/*": ["src/assets/images"],
"@use-micro/*": ["src/micro/*"] "@use-micro/*": ["src/micro/*"],
"@mock/*": ["mock/*"],
"@mock": ["mock/*"]
}, },
"suppressImplicitAnyIndexErrors": true, "suppressImplicitAnyIndexErrors": true,
"typeRoots": ["./src/types/app.d.ts", "./src/types/global.d.ts"], "typeRoots": ["./src/types/app.d.ts", "./src/types/global.d.ts"],
@ -38,6 +40,7 @@
"package.json", "package.json",
"vite-env.d.ts", "vite-env.d.ts",
"./unplugin/**/*", "./unplugin/**/*",
"src/**/*" "src/**/*",
"mock/**/*"
] ]
} }