1 Star 0 Fork 54

玉和秀Love/arco-work

forked from 清清玄/arco-work 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
api.config.ts 18.85 KB
一键复制 编辑 原始数据 按行查看 历史
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840
import Mock, { Random } from "mockjs"
import { path, method } from 'vite-plugin-api-serve/decorator'
const adminRoutes = [
{
menuUrl: '/index',
menuName: 'Dashborad',
routeName: 'dashborad',
icon: 'icon-dashboard',
parentPath: '',
children: [
{
parentPath: '/index',
menuUrl: '/index/home',
menuName: '主控台',
routeName: 'home',
},
{
parentPath: '/index',
menuUrl: '/index/work-place',
menuName: '工作台',
routeName: 'workPlace',
isRootPath: true,
},
],
},
{
menuUrl: '/system',
menuName: '系统管理',
icon: 'icon-settings',
parentPath: '',
routeName: 'system',
children: [
{
parentPath: '/system',
menuUrl: '/system/department',
menuName: '部门管理',
badge: 'new',
routeName: 'department',
localFilePath: '/system/local-path/department',
},
{
parentPath: '/system',
menuUrl: '/system/user',
menuName: '用户管理',
badge: 'dot',
routeName: 'user',
},
{
parentPath: '/system',
menuUrl: '/system/role',
menuName: '角色管理',
badge: '12',
},
{
parentPath: '/system',
menuUrl: '/system/menu',
menuName: '菜单管理',
},
],
},
{
menuUrl: '/list',
menuName: '表格demo',
icon: 'icon-list',
parentPath: '',
children: [
{
parentPath: '/list',
menuUrl: '/list/table-with-search',
menuName: '表格搜索',
},
{
parentPath: '/list',
menuUrl: '/list/table-custom',
menuName: '自定义表格',
},
{
parentPath: '/list',
menuUrl: '/list/list',
menuName: '普通列表',
},
{
parentPath: '/list',
menuUrl: '/list/card-list',
menuName: '卡片列表',
},
],
},
{
menuUrl: '/form',
menuName: '表单demo',
badge: 'dot',
icon: 'icon-edit',
parentPath: '',
children: [
{
parentPath: '/form',
menuUrl: '/form/base-form-view',
menuName: '基本表单',
cacheable: true,
},
],
},
{
menuUrl: '/other',
menuName: '功能/组件',
icon: 'icon-apps',
parentPath: '',
children: [
{
parentPath: '/other',
menuUrl: '/other/chart',
menuName: '图表',
children: [
{
parentPath: '/other/chart',
menuUrl: '/other/chart/icons',
menuName: '图标',
},
{
parentPath: '/other/chart',
menuUrl: '/other/chart/echarts',
menuName: 'echarts',
},
{
parentPath: '/other/chart',
menuUrl: '/other/chart/icon-select',
menuName: '图标选择器',
},
],
},
{
parentPath: '/other',
menuUrl: '/other/print',
menuName: '打印',
},
{
parentPath: '/other',
menuUrl: '/other/badge',
menuName: '消息提示',
},
{
parentPath: '/other',
menuUrl: '/other/clipboard',
menuName: '剪贴板',
},
{
parentPath: '/other',
menuUrl: 'http://qingqingxuan.gitee.io/work-p-site',
menuName: '外链',
},
{
parentPath: '/other',
menuUrl: '/other/qrcode',
menuName: '二维码',
},
{
parentPath: '/other',
menuUrl: '/other/css-animation',
menuName: 'CSS动画',
},
{
parentPath: '/other',
menuUrl: '/other/flow',
menuName: '流程图',
},
{
parentPath: '/other',
menuUrl: '/other/player',
menuName: '视频播放器',
},
{
parentPath: '/other',
menuUrl: '/other/password-strong-page',
menuName: '密码强度',
},
{
parentPath: '/other',
menuUrl: '/other/cropper',
menuName: '图片裁剪',
},
{
parentPath: '/other',
menuUrl: '/other/iframe',
menuName: '内嵌iframe',
},
{
parentPath: '/other',
menuUrl: '/other/big-preview',
menuName: '大图预览',
},
],
},
{
menuUrl: '/route-params',
menuName: '路由参数',
icon: 'icon-file',
parentPath: '',
children: [
{
parentPath: '/route-params',
menuUrl: '/route-params/query',
menuName: 'query参数',
},
{
parentPath: '/route-params',
menuUrl: '/route-params/params',
menuName: 'params参数',
},
],
},
{
menuUrl: '/result',
menuName: '结果页面',
icon: 'icon-file',
parentPath: '',
children: [
{
parentPath: '/result',
menuUrl: '/result/success',
menuName: '成功页面',
},
{
parentPath: '/result',
menuUrl: '/result/fail',
menuName: '失败页面',
},
],
},
{
menuUrl: '/editor',
menuName: '编辑器',
badge: '12',
icon: 'icon-edit',
parentPath: '',
children: [
{
parentPath: '/editor',
menuUrl: '/editor/rich-text',
menuName: '富文本',
},
{
parentPath: '/editor',
menuUrl: '/editor/markdown',
menuName: 'markdown',
},
],
},
{
menuUrl: '/excel',
menuName: 'Excel',
icon: 'icon-nav',
parentPath: '',
children: [
{
parentPath: '/excel',
menuUrl: '/excel/export-excel',
menuName: '导出Excel',
},
{
parentPath: '/excel',
menuUrl: '/excel/export-rows-excel',
menuName: '导出选中行',
},
],
},
{
menuUrl: '/draggable',
menuName: '拖拽',
icon: 'icon-drag-arrow',
parentPath: '',
children: [
// {
// parentPath: '/draggable',
// menuUrl: '/draggable/dialog-draggable',
// menuName: '拖拽对话框',
// },
{
parentPath: '/draggable',
menuUrl: '/draggable/card-draggable',
menuName: '卡片拖拽',
cacheable: true,
},
],
},
{
menuUrl: '/next',
menuName: '多级菜单',
icon: 'icon-share-alt',
parentPath: '',
children: [
{
parentPath: '/next',
menuUrl: '/next/menu1',
menuName: 'menu-1',
cacheable: true,
},
{
parentPath: '/next',
menuUrl: '/next/menu2',
menuName: 'menu-2',
children: [
{
parentPath: '/next/menu2',
menuUrl: '/next/menu2/menu-2-1',
menuName: 'menu-2-1',
children: [
{
parentPath: '/next/menu2/menu-2-1',
menuUrl: '/next/menu2/menu-2-1/menu-2-1-1',
menuName: 'menu-2-1-1',
cacheable: true,
},
{
parentPath: '/next/menu2/menu-2-1',
menuUrl: '/next/menu2/menu-2-1/menu-2-1-2',
menuName: 'menu-2-1-2',
},
],
},
{
parentPath: '/next/menu2',
menuUrl: '/next/menu2/menu-2-2',
menuName: 'menu-2-2',
cacheable: true,
},
],
},
],
},
{
menuUrl: '/map',
menuName: '地图',
icon: 'icon-location',
children: [
{
parentPath: '/map',
menuUrl: '/map/gaode',
menuName: '高德地图',
},
{
parentPath: '/map',
menuUrl: '/map/baidu',
menuName: '百度地图',
},
],
},
{
menuUrl: '/project',
menuName: '项目信息',
icon: 'icon-mind-mapping',
isSingle: true,
children: [
{
parentPath: '/project',
menuUrl: '/project/infomation',
menuName: '项目依赖',
},
],
},
]
const editorRoutes = [
{
menuUrl: '/other',
menuName: '功能/组件',
iconPrefix: 'iconfont',
icon: 'appstore',
parentPath: '',
children: [
{
parentPath: '/other',
menuUrl: '/other/chart',
menuName: '图表',
children: [
{
parentPath: '/other/chart',
menuUrl: '/other/chart/icon',
menuName: '图标',
children: [
{
parentPath: '/other/chart/icon',
menuUrl: '/other/chart/icon/icon-font',
menuName: 'IconFont',
},
{
parentPath: '/other/chart/icon',
menuUrl: '/other/chart/icon/xicons',
menuName: 'xicons',
},
],
},
{
parentPath: '/other/chart',
menuUrl: '/other/chart/echarts',
menuName: 'echarts',
},
{
parentPath: '/other/chart',
menuUrl: '/other/chart/icon-selector',
menuName: '图标选择器',
},
],
},
{
parentPath: '/other',
menuUrl: '/other/print',
menuName: '打印',
},
{
parentPath: '/other',
menuUrl: '/other/badge',
menuName: '消息提示',
},
{
parentPath: '/other',
menuUrl: '/other/clipboard',
menuName: '剪贴板',
},
{
parentPath: '/other',
menuUrl: 'http://qingqingxuan.gitee.io/work-p-site',
menuName: '外链',
},
{
parentPath: '/other',
menuUrl: '/other/qrcode',
menuName: '二维码',
},
{
parentPath: '/other',
menuUrl: '/other/css-animation',
menuName: 'CSS动画',
},
{
parentPath: '/other',
menuUrl: '/other/flow',
menuName: '流程图',
},
{
parentPath: '/other',
menuUrl: '/other/player',
menuName: '视频播放器',
},
{
parentPath: '/other',
menuUrl: '/other/password-strong',
menuName: '密码强度',
},
{
parentPath: '/other',
menuUrl: '/other/cropper',
menuName: '图片裁剪',
},
{
parentPath: '/other',
menuUrl: '/other/iframe',
menuName: '内嵌iframe',
},
{
parentPath: '/other',
menuUrl: '/other/big-preview',
menuName: '大图预览',
},
{
parentPath: '/other',
menuUrl: '/other/city-selector',
menuName: '省市区选择器',
},
],
},
{
menuUrl: '/next',
menuName: '多级菜单',
iconPrefix: 'iconfont',
icon: 'Partition',
parentPath: '',
children: [
{
parentPath: '/next',
menuUrl: '/next/menu1',
menuName: 'menu-1',
cacheable: true,
},
{
parentPath: '/next',
menuUrl: '/next/menu2',
menuName: 'menu-2',
children: [
{
parentPath: '/next/menu2',
menuUrl: '/next/menu2/menu-2-1',
menuName: 'menu-2-1',
children: [
{
parentPath: '/next/menu2/menu-2-1',
menuUrl: '/next/menu2/menu-2-1/menu-2-1-1',
menuName: 'menu-2-1-1',
cacheable: true,
},
{
parentPath: '/next/menu2/menu-2-1',
menuUrl: '/next/menu2/menu-2-1/menu-2-1-2',
menuName: 'menu-2-1-2',
},
],
},
{
parentPath: '/next/menu2',
menuUrl: '/next/menu2/menu-2-2',
menuName: 'menu-2-2',
cacheable: true,
},
],
},
],
},
{
menuUrl: '/map',
menuName: '地图',
iconPrefix: 'iconfont',
icon: 'location',
children: [
{
parentPath: '/map',
menuUrl: '/map/gaode',
menuName: '高德地图',
},
{
parentPath: '/map',
menuUrl: '/map/baidu',
menuName: '百度地图',
},
],
},
{
menuUrl: '/project',
menuName: '项目信息',
iconPrefix: 'iconfont',
icon: 'detail',
children: [
{
parentPath: '/project',
menuUrl: '/project/infomation',
menuName: '项目依赖',
},
],
},
]
function randomString(length: number) {
const str = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
let result = ''
for (let i = length; i > 0; --i) {
result += str[Math.floor(Math.random() * str.length)]
}
return result
}
function computePageSize(totalSize: number, page: number, pageSize: number) {
return Math.abs(totalSize - pageSize * page >= 0 ? pageSize : totalSize - pageSize * page)
}
const totalSize = 30
export default class DevApiServeController {
/**
* 用户登录
* @returns
*/
@path('/login')
@method('POST')
onLogin({ body }: any) {
const username = body.username
const data: any = {}
const baseData: any = {}
if (username === 'admin') {
baseData.code = 200
baseData.msg = '登录成功'
data.nickName = '超级管理员'
data.userName = 'admin'
data.userId = 1
data.roleId = 1
data.token = randomString(100)
data.roles = [
{
roleCode: 'ROLE_admin',
roleId: 1,
roleName: '超级管理员',
},
]
baseData.data = data
} else if (username === 'editor') {
baseData.code = 200
baseData.msg = '登录成功'
data.nickName = '编辑员'
data.userName = 'editor'
data.userId = 2
data.roleId = 2
data.token = randomString(100)
data.roles = [
{
roleCode: 'ROLE_editor',
roleId: 2,
roleName: '网站编辑人员',
},
]
baseData.data = data
} else {
baseData.code = 500
baseData.data = ''
baseData.msg = '用户名或密码错误'
}
return baseData
}
/**
* 根据用户角色获取菜单权限列表
* @returns
*/
@path('/getMenusByRoleId')
@method('POST')
onGetMenuListByRoleId({ body }: any) {
const roleId = body.roleId
if (parseInt(roleId) === 1) {
return { code: 200, data: adminRoutes, msg: '获取菜单列表成功' }
} else if (parseInt(roleId) === 2) {
// 编辑
return {
code: 200,
data: editorRoutes,
msg: '获取菜单列表成功',
}
} else {
throw new Error('获取菜单失败')
}
}
/**
* 获取部门管理列表数据
* @returns
*/
@path('/getDepartmentList')
@method('POST')
onGetDepartmentList() {
return {
code: 200,
msg: 'success',
totalSize: 30,
data: [
{
id: 1,
name: '总裁办',
depCode: 'dp_code_manager', // 0男 1女
order: 1,
createTime: Date.now(),
status: 0, // 0 禁用 1正常
},
{
id: 2,
name: '市场部',
depCode: 'dp_code_marketing', // 0男 1女
order: 1,
createTime: Date.now(),
status: 1, // 0 禁用 1正常,
children: [
{
id: 3,
parentId: 2,
name: '市场一部',
depCode: 'dp_code_marketing_1', // 0男 1女
order: 1,
createTime: Date.now(),
status: 1, // 0 禁用 1正常
},
{
id: 4,
parentId: 2,
name: '市场二部',
depCode: 'dp_code_marketing_2', // 0男 1女
order: 1,
createTime: Date.now(),
status: 1, // 0 禁用 1正常
},
],
},
{
id: 5,
name: '技术部',
depCode: 'dp_code_technology', // 0男 1女
order: 1,
createTime: Date.now(),
status: 1, // 0 禁用 1正常
},
{
id: 6,
name: '销售部',
depCode: 'dp_code_sale', // 0男 1女
order: 1,
createTime: Date.now(),
status: 1, // 0 禁用 1正常
},
],
}
}
/**
* 获取角色列表数据
* @returns
*/
@path('/getRoleList')
@method('POST')
onGetRoleList() {
return {
code: 200,
msg: 'success',
totalSize: 30,
data: [
{
id: 1,
name: '超级管理员',
roleCode: 'ROLE_admin',
description: '超级管理员',
createTime: Date.now(),
},
{
id: 2,
name: '编辑员',
roleCode: 'ROLE_editor',
description: '编辑员',
createTime: Date.now(),
},
],
}
}
/**
* 获取菜单列表数据
* @returns
*/
@path('/getMenuList')
@method('POST')
onGetMenuList() {
return {
code: 200,
msg: 'success',
data: adminRoutes,
}
}
/**
* 获取菜单列表数据
* @returns
*/
@path('/getAllMenuByRoleId')
@method('POST')
onGetAllMenuByRoleId() {
return {
code: 200,
msg: 'success',
data: adminRoutes,
}
}
/**
* 获取用户列表数据
* @returns
*/
@path('/getUserList')
@method('POST')
onGetUserList({ body }: any) {
const { page, pageSize = 10 } = body
const size = computePageSize(totalSize, page, pageSize)
return Mock.mock({
code: 200,
msg: 'success',
pageInfo: {
totalSize,
page,
},
[`data|${size}`]: [
{
'id|+1': 1,
nickName: () => {
return Random.name()
},
'gender|0-1': 0, // 0男 1女
'departmentId|1-6': 1,
'roleId|1-2': 1,
mobile: '18800000000',
email: '123456789@123.com',
lastLoginTime: Random.now('yyyy-MM-dd HH:mm:ss'),
lastLoginIp: function () {
return Random.ip()
},
'status|0-1': 1, // 0 禁用 1正常
},
],
})
}
/**
* 获取表格列表数据
* @returns
*/
@path('/getTableList')
@method('POST')
onGetTableList({ body }: any) {
const { page, pageSize = 10 } = body
const size = computePageSize(totalSize, page, pageSize)
return Mock.mock({
code: 200,
msg: 'success',
pageInfo: {
totalSize,
page,
},
[`data|${size}`]: [
{
'id|+1': 1,
nickName: function () {
return Random.name()
},
'age|0-100': 50,
avatar: '/static/images/img_avatar_01.jpeg',
'gender|0-1': 0, // 0男 1女
'vip|0-1': 0, // 0不是 1是
address: function () {
return Random.city(true)
},
lastLoginTime: Random.now('yyyy-MM-dd HH:mm:ss'),
lastLoginIp: function () {
return Random.ip()
},
'status|0-1': 1, // 0 禁用 1正常
},
],
})
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/yuhexiu/arco-work.git
git@gitee.com:yuhexiu/arco-work.git
yuhexiu
arco-work
arco-work
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385