1
0
mirror of https://github.com/fumiama/paper-manager.git synced 2026-06-10 19:10:25 +08:00
Files
paper-manager/frontend/vben/mock/demo/tree-demo.ts
2023-03-16 14:03:58 +08:00

39 lines
884 B
TypeScript

import { MockMethod } from 'vite-plugin-mock'
import { resultSuccess } from '../_util'
const demoTreeList = (keyword: string) => {
const result = {
list: [] as Recordable[],
}
for (let index = 0; index < 5; index++) {
const children: Recordable[] = []
for (let j = 0; j < 3; j++) {
children.push({
title: `${keyword ?? ''}选项${index}-${j}`,
value: `${index}-${j}`,
key: `${index}-${j}`,
})
}
result.list.push({
title: `${keyword ?? ''}选项${index}`,
value: `${index}`,
key: `${index}`,
children,
})
}
return result
}
export default [
{
url: '/api/tree/getDemoOptions',
timeout: 1000,
method: 'get',
response: ({ query }) => {
const { keyword } = query
console.log(keyword)
return resultSuccess(demoTreeList(keyword))
},
},
] as MockMethod[]