mirror of
https://github.com/XiaoDaiGua-Ray/ray-template.git
synced 2025-04-05 07:03:00 +08:00
v4.1.7细节更新
This commit is contained in:
parent
1be73da92a
commit
6f98e8fb0d
4
cfg.ts
4
cfg.ts
@ -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'),
|
||||||
|
},
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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) {
|
||||||
|
@ -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(),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -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 当前页码
|
||||||
|
@ -255,7 +255,6 @@ const RayTable = defineComponent({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
render() {
|
render() {
|
||||||
console.log(this.action)
|
|
||||||
return (
|
return (
|
||||||
<NCard
|
<NCard
|
||||||
class="ray-table"
|
class="ray-table"
|
||||||
|
@ -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 = [
|
||||||
{
|
{
|
||||||
|
@ -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/**/*"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user