init
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
import { defineEventHandler } from 'h3'
|
||||
|
||||
export default defineEventHandler((event) => {
|
||||
// setResponseStatus(event, 401)
|
||||
event.res.status = 401
|
||||
return {
|
||||
code: 401,
|
||||
msg: '请先登录',
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,9 @@
|
||||
import { defineEventHandler } from 'h3'
|
||||
|
||||
export default defineEventHandler((event) => {
|
||||
event.res.status = 403
|
||||
return {
|
||||
code: 403,
|
||||
msg: '请先登录',
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,9 @@
|
||||
import { defineEventHandler } from 'h3'
|
||||
|
||||
export default defineEventHandler((event) => {
|
||||
event.res.status = 500
|
||||
return {
|
||||
code: 500,
|
||||
msg: '服务器错误',
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,5 @@
|
||||
import { defineEventHandler } from 'h3'
|
||||
|
||||
export default defineEventHandler(() => {
|
||||
return { nitro: 'Hello Antdv Pro' }
|
||||
})
|
||||
@@ -0,0 +1,16 @@
|
||||
import { defineEventHandler } from 'h3'
|
||||
|
||||
export default defineEventHandler((event) => {
|
||||
const id = event.context.params?.id as any
|
||||
if (typeof id !== 'number') {
|
||||
event.res.status = 403
|
||||
return {
|
||||
code: 403,
|
||||
msg: '删除失败',
|
||||
}
|
||||
}
|
||||
return {
|
||||
code: 200,
|
||||
msg: '删除成功',
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,80 @@
|
||||
import dayjs from 'dayjs'
|
||||
import { defineEventHandler } from 'h3'
|
||||
import { cloneDeep } from 'lodash-es'
|
||||
|
||||
export default defineEventHandler(async (_event) => {
|
||||
const dataList = [
|
||||
{
|
||||
title: 'Aipay',
|
||||
link: 'https://gw.alipayobjects.com/zos/rmsportal/WdGqmHpayyMjiEhcKoVE.png',
|
||||
percent: 57,
|
||||
content: '一生那么短,遗忘又那么漫长',
|
||||
},
|
||||
{
|
||||
title: 'Ant Design Vue',
|
||||
link: 'https://www.antdv.com/assets/logo.1ef800a8.svg',
|
||||
percent: 60,
|
||||
status: 'active',
|
||||
content: '只有在梦想中,人才能真正自由',
|
||||
},
|
||||
{
|
||||
title: 'Vue',
|
||||
link: 'https://gw.alipayobjects.com/zos/rmsportal/ComBAopevLwENQdKWiIn.png',
|
||||
percent: 70,
|
||||
status: 'exception',
|
||||
content: '生命就像一盒巧克力,结果往往出人意料',
|
||||
},
|
||||
{
|
||||
title: 'Vite',
|
||||
link: 'https://cn.vitejs.dev/logo.svg',
|
||||
percent: 100,
|
||||
status: 'active',
|
||||
content: '有时,你必须进入别人的世界去发现自己的世界缺少什么',
|
||||
},
|
||||
{
|
||||
title: 'React',
|
||||
link: 'https://gw.alipayobjects.com/zos/rmsportal/kZzEzemZyKLKFsojXItE.png',
|
||||
percent: 50,
|
||||
status: 'exception',
|
||||
content: '希望是件美丽的东西,也许是最好的东西',
|
||||
},
|
||||
{
|
||||
title: 'Antdv Pro',
|
||||
link: '/logo.svg',
|
||||
percent: 80,
|
||||
status: 'active',
|
||||
content: '人并非生来就伟大,而是越活越伟大',
|
||||
},
|
||||
{
|
||||
title: 'Webpack',
|
||||
link: 'https://gw.alipayobjects.com/zos/rmsportal/nxkuOJlFJuAUhzlMTCEe.png',
|
||||
percent: 58,
|
||||
content: '不管何时何地,做你想做的事永远都不嫌晚',
|
||||
},
|
||||
{
|
||||
title: 'Angular',
|
||||
link: 'https://gw.alipayobjects.com/zos/rmsportal/zOsKZmFRdUtvpqCImOVY.png',
|
||||
percent: 70,
|
||||
status: 'active',
|
||||
content: '你要一直不停地往前走,不然你不会知道生活还会给你什么',
|
||||
},
|
||||
]
|
||||
|
||||
const data: any[] = []
|
||||
|
||||
// 数据复制
|
||||
for (let i = 0; i < 1000; i++) {
|
||||
const arr = cloneDeep(dataList)
|
||||
data.push(...arr)
|
||||
}
|
||||
|
||||
// 配置任务时间
|
||||
for (let i = 0; i < data.length; i++)
|
||||
data[i].start = dayjs().subtract(i, 'hour').format('YYYY-MM-DD HH:mm')
|
||||
|
||||
return {
|
||||
code: 200,
|
||||
msg: '获取成功',
|
||||
data,
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,82 @@
|
||||
import dayjs from 'dayjs'
|
||||
import { defineEventHandler, readBody } from 'h3'
|
||||
|
||||
enum STATUS {
|
||||
OFF = '0',
|
||||
RUNNING = '1',
|
||||
ONLINE = '2',
|
||||
ERROR = '3',
|
||||
}
|
||||
|
||||
export default defineEventHandler(async (_event) => {
|
||||
const body = (await readBody(_event)) as { name?: string }
|
||||
|
||||
const dataList = [
|
||||
{
|
||||
id: 1,
|
||||
name: '第一个任务',
|
||||
callNo: 2000,
|
||||
desc: '一生那么短,遗忘又那么漫长',
|
||||
status: STATUS.ONLINE,
|
||||
updatedAt: dayjs().format('YYYY-MM-DD HH:mm'),
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
name: 'Ant Design Vue',
|
||||
callNo: 200,
|
||||
desc: '有时,你必须进入别人的世界去发现自己的世界缺少什么',
|
||||
status: STATUS.OFF,
|
||||
updatedAt: dayjs().format('YYYY-MM-DD HH:mm'),
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
name: 'Vue',
|
||||
callNo: 2010,
|
||||
desc: '一生那么短,遗忘又那么漫长',
|
||||
status: STATUS.ERROR,
|
||||
updatedAt: dayjs().format('YYYY-MM-DD HH:mm'),
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
name: 'Vite',
|
||||
callNo: 20300,
|
||||
desc: '希望是件美丽的东西,也许是最好的东西',
|
||||
status: STATUS.ERROR,
|
||||
updatedAt: dayjs().format('YYYY-MM-DD HH:mm'),
|
||||
},
|
||||
{
|
||||
id: 5,
|
||||
name: 'React',
|
||||
callNo: 2000,
|
||||
desc: '人并非生来就伟大,而是越活越伟大',
|
||||
status: STATUS.ONLINE,
|
||||
updatedAt: dayjs().format('YYYY-MM-DD HH:mm'),
|
||||
},
|
||||
{
|
||||
id: 6,
|
||||
name: 'Antdv Pro',
|
||||
callNo: 2000,
|
||||
desc: '不管何时何地,做你想做的事永远都不嫌晚',
|
||||
status: STATUS.OFF,
|
||||
updatedAt: dayjs().format('YYYY-MM-DD HH:mm'),
|
||||
},
|
||||
{
|
||||
id: 7,
|
||||
name: 'Webpack',
|
||||
callNo: 2000,
|
||||
desc: '你要一直不停地往前走,不然你不会知道生活还会给你什么',
|
||||
status: STATUS.ONLINE,
|
||||
updatedAt: dayjs().format('YYYY-MM-DD HH:mm'),
|
||||
},
|
||||
]
|
||||
const data = dataList.filter((i) => {
|
||||
if (body.name)
|
||||
return body.name === i.name
|
||||
else return true
|
||||
})
|
||||
return {
|
||||
code: 200,
|
||||
msg: '获取成功',
|
||||
data,
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,10 @@
|
||||
import { defineEventHandler, readBody } from 'h3'
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
const body = await readBody(event)
|
||||
console.log(body)
|
||||
return {
|
||||
code: 200,
|
||||
msg: '创建成功',
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,63 @@
|
||||
import { defineEventHandler, readBody } from 'h3'
|
||||
|
||||
export default defineEventHandler(async (_event) => {
|
||||
const body = await readBody(_event)
|
||||
|
||||
const dataList = [
|
||||
{
|
||||
id: 1,
|
||||
name: '第一个任务',
|
||||
value: '2000',
|
||||
remark: '一生那么短,遗忘又那么漫长',
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
name: 'Ant Design Vue',
|
||||
value: '200',
|
||||
remark: '有时,你必须进入别人的世界去发现自己的世界缺少什么',
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
name: 'Vue',
|
||||
value: '2010',
|
||||
remark: '一生那么短,遗忘又那么漫长',
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
name: 'Vite',
|
||||
value: '20300',
|
||||
remark: '希望是件美丽的东西,也许是最好的东西',
|
||||
},
|
||||
{
|
||||
id: 5,
|
||||
name: 'React',
|
||||
value: '2000',
|
||||
remark: '人并非生来就伟大,而是越活越伟大',
|
||||
},
|
||||
{
|
||||
id: 6,
|
||||
name: 'Antdv Pro',
|
||||
value: '2000',
|
||||
remark: '不管何时何地,做你想做的事永远都不嫌晚',
|
||||
},
|
||||
{
|
||||
id: 7,
|
||||
name: 'Webpack',
|
||||
value: '2000',
|
||||
remark: '你要一直不停地往前走,不然你不会知道生活还会给你什么',
|
||||
},
|
||||
]
|
||||
const data = dataList.filter((i) => {
|
||||
if (body.name)
|
||||
return body.name === i.name
|
||||
else return true
|
||||
})
|
||||
return {
|
||||
code: 200,
|
||||
msg: '获取成功',
|
||||
data: {
|
||||
records: data,
|
||||
total: data.length,
|
||||
},
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,22 @@
|
||||
import { defineEventHandler, readBody } from 'h3'
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
const body = await readBody(event)
|
||||
|
||||
const dataList = []
|
||||
for (let i = 0; i < 10; i++) {
|
||||
const item = {
|
||||
id: i + 1,
|
||||
title: `${body.title ?? '测试'}_${i}`,
|
||||
username: `${body.username ?? 'test'}_${i}`,
|
||||
password: `${body.username ?? 'test'}_pass_${i}`,
|
||||
}
|
||||
dataList.push(item)
|
||||
}
|
||||
|
||||
return {
|
||||
code: 200,
|
||||
msg: '获取成功',
|
||||
data: dataList,
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,8 @@
|
||||
import { defineEventHandler } from 'h3'
|
||||
|
||||
export default defineEventHandler(async (_event) => {
|
||||
return {
|
||||
code: 200,
|
||||
msg: '编辑成功',
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,33 @@
|
||||
import { defineEventHandler, readBody } from 'h3'
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
const body: any = await readBody(event)
|
||||
const { type } = body
|
||||
const success = {
|
||||
code: 200,
|
||||
data: {
|
||||
token: '1234567890',
|
||||
},
|
||||
msg: '登录成功',
|
||||
}
|
||||
if (type !== 'mobile') {
|
||||
// eslint-disable-next-line node/prefer-global/buffer
|
||||
success.data.token = Buffer.from(body.username).toString('base64')
|
||||
// 判断用户名密码是否正确
|
||||
if (body.username === 'admin' && body.password === 'admin')
|
||||
return success
|
||||
|
||||
if (body.username === 'user' && body.password === 'user')
|
||||
return success
|
||||
}
|
||||
else {
|
||||
return success
|
||||
}
|
||||
|
||||
// setResponseStatus(event, 403)
|
||||
event.res.status = 403
|
||||
return {
|
||||
code: 401,
|
||||
msg: '用户名或密码错误',
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,8 @@
|
||||
import { defineEventHandler } from 'h3'
|
||||
|
||||
export default defineEventHandler(() => {
|
||||
return {
|
||||
code: 200,
|
||||
msg: 'success',
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,474 @@
|
||||
import { defineEventHandler } from 'h3'
|
||||
|
||||
const menuData = [
|
||||
{
|
||||
id: 2,
|
||||
parentId: null,
|
||||
title: '分析页',
|
||||
icon: 'DashboardOutlined',
|
||||
component: '/dashboard/analysis',
|
||||
path: '/dashboard/analysis',
|
||||
name: 'DashboardAnalysis',
|
||||
keepAlive: true,
|
||||
locale: 'menu.dashboard.analysis',
|
||||
},
|
||||
{
|
||||
id: 1,
|
||||
parentId: null,
|
||||
title: '仪表盘',
|
||||
icon: 'DashboardOutlined',
|
||||
component: 'RouteView',
|
||||
redirect: '/dashboard/analysis',
|
||||
path: '/dashboard',
|
||||
name: 'Dashboard',
|
||||
locale: 'menu.dashboard',
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
parentId: null,
|
||||
title: '表单页',
|
||||
icon: 'FormOutlined',
|
||||
component: 'RouteView',
|
||||
redirect: '/form/basic',
|
||||
path: '/form',
|
||||
name: 'Form',
|
||||
locale: 'menu.form',
|
||||
},
|
||||
{
|
||||
id: 5,
|
||||
parentId: null,
|
||||
title: '链接',
|
||||
icon: 'LinkOutlined',
|
||||
component: 'RouteView',
|
||||
redirect: '/link/iframe',
|
||||
path: '/link',
|
||||
name: 'Link',
|
||||
locale: 'menu.link',
|
||||
|
||||
},
|
||||
{
|
||||
id: 6,
|
||||
parentId: 5,
|
||||
title: 'AntDesign',
|
||||
url: 'https://ant.design/',
|
||||
component: 'Iframe',
|
||||
path: '/link/iframe',
|
||||
name: 'LinkIframe',
|
||||
keepAlive: true,
|
||||
locale: 'menu.link.iframe',
|
||||
},
|
||||
{
|
||||
id: 7,
|
||||
parentId: 5,
|
||||
title: 'AntDesignVue',
|
||||
url: 'https://antdv.com/',
|
||||
component: 'Iframe',
|
||||
path: '/link/antdv',
|
||||
name: 'LinkAntdv',
|
||||
keepAlive: true,
|
||||
locale: 'menu.link.antdv',
|
||||
},
|
||||
{
|
||||
id: 8,
|
||||
parentId: 5,
|
||||
path: 'https://www.baidu.com',
|
||||
name: 'LinkExternal',
|
||||
title: '跳转百度',
|
||||
locale: 'menu.link.external',
|
||||
},
|
||||
{
|
||||
id: 9,
|
||||
parentId: null,
|
||||
title: '菜单',
|
||||
icon: 'BarsOutlined',
|
||||
component: 'RouteView',
|
||||
path: '/menu',
|
||||
redirect: '/menu/menu1',
|
||||
name: 'Menu',
|
||||
locale: 'menu.menu',
|
||||
},
|
||||
{
|
||||
id: 10,
|
||||
parentId: 9,
|
||||
title: '菜单1',
|
||||
component: '/menu/menu1',
|
||||
path: '/menu/menu1',
|
||||
name: 'MenuMenu11',
|
||||
keepAlive: true,
|
||||
locale: 'menu.menu.menu1',
|
||||
},
|
||||
{
|
||||
id: 11,
|
||||
parentId: 9,
|
||||
title: '菜单2',
|
||||
component: '/menu/menu2',
|
||||
path: '/menu/menu2',
|
||||
keepAlive: true,
|
||||
locale: 'menu.menu.menu2',
|
||||
},
|
||||
{
|
||||
id: 12,
|
||||
parentId: 9,
|
||||
path: '/menu/menu3',
|
||||
redirect: '/menu/menu3/menu1',
|
||||
title: '菜单1-1',
|
||||
component: 'RouteView',
|
||||
locale: 'menu.menu.menu3',
|
||||
},
|
||||
{
|
||||
id: 13,
|
||||
parentId: 12,
|
||||
path: '/menu/menu3/menu1',
|
||||
component: '/menu/menu-1-1/menu1',
|
||||
title: '菜单1-1-1',
|
||||
keepAlive: true,
|
||||
locale: 'menu.menu3.menu1',
|
||||
},
|
||||
{
|
||||
id: 14,
|
||||
parentId: 12,
|
||||
path: '/menu/menu3/menu2',
|
||||
component: '/menu/menu-1-1/menu2',
|
||||
title: '菜单1-1-2',
|
||||
keepAlive: true,
|
||||
locale: 'menu.menu3.menu2',
|
||||
},
|
||||
{
|
||||
id: 15,
|
||||
path: '/access',
|
||||
component: 'RouteView',
|
||||
redirect: '/access/common',
|
||||
title: '权限模块',
|
||||
name: 'Access',
|
||||
parentId: null,
|
||||
icon: 'ClusterOutlined',
|
||||
locale: 'menu.access',
|
||||
},
|
||||
{
|
||||
id: 16,
|
||||
parentId: 15,
|
||||
path: '/access/common',
|
||||
title: '通用权限',
|
||||
name: 'AccessCommon',
|
||||
component: '/access/common',
|
||||
locale: 'menu.access.common',
|
||||
},
|
||||
{
|
||||
id: 17,
|
||||
parentId: 15,
|
||||
path: '/access/user',
|
||||
title: '普通用户',
|
||||
name: 'AccessUser',
|
||||
component: '/access/user',
|
||||
locale: 'menu.access.user',
|
||||
},
|
||||
{
|
||||
id: 19,
|
||||
parentId: null,
|
||||
title: '异常页',
|
||||
icon: 'WarningOutlined',
|
||||
component: 'RouteView',
|
||||
redirect: '/exception/403',
|
||||
path: '/exception',
|
||||
name: 'Exception',
|
||||
locale: 'menu.exception',
|
||||
},
|
||||
{
|
||||
id: 20,
|
||||
parentId: 19,
|
||||
path: '/exception/403',
|
||||
title: '403',
|
||||
name: '403',
|
||||
component: '/exception/403',
|
||||
locale: 'menu.exception.not-permission',
|
||||
},
|
||||
{
|
||||
id: 21,
|
||||
parentId: 19,
|
||||
path: '/exception/404',
|
||||
title: '404',
|
||||
name: '404',
|
||||
component: '/exception/404',
|
||||
locale: 'menu.exception.not-find',
|
||||
},
|
||||
{
|
||||
id: 22,
|
||||
parentId: 19,
|
||||
path: '/exception/500',
|
||||
title: '500',
|
||||
name: '500',
|
||||
component: '/exception/500',
|
||||
locale: 'menu.exception.server-error',
|
||||
},
|
||||
{
|
||||
id: 23,
|
||||
parentId: null,
|
||||
title: '结果页',
|
||||
icon: 'CheckCircleOutlined',
|
||||
component: 'RouteView',
|
||||
redirect: '/result/success',
|
||||
path: '/result',
|
||||
name: 'Result',
|
||||
locale: 'menu.result',
|
||||
},
|
||||
{
|
||||
id: 24,
|
||||
parentId: 23,
|
||||
path: '/result/success',
|
||||
title: '成功页',
|
||||
name: 'ResultSuccess',
|
||||
component: '/result/success',
|
||||
locale: 'menu.result.success',
|
||||
},
|
||||
{
|
||||
id: 25,
|
||||
parentId: 23,
|
||||
path: '/result/fail',
|
||||
title: '失败页',
|
||||
name: 'ResultFail',
|
||||
component: '/result/fail',
|
||||
locale: 'menu.result.fail',
|
||||
},
|
||||
{
|
||||
id: 26,
|
||||
parentId: null,
|
||||
title: '列表页',
|
||||
icon: 'TableOutlined',
|
||||
component: 'RouteView',
|
||||
redirect: '/list/card-list',
|
||||
path: '/list',
|
||||
name: 'List',
|
||||
locale: 'menu.list',
|
||||
},
|
||||
{
|
||||
id: 27,
|
||||
parentId: 26,
|
||||
path: '/list/card-list',
|
||||
title: '卡片列表',
|
||||
name: 'ListCard',
|
||||
component: '/list/card-list',
|
||||
locale: 'menu.list.card-list',
|
||||
},
|
||||
{
|
||||
id: 28,
|
||||
parentId: null,
|
||||
title: '详情页',
|
||||
icon: 'ProfileOutlined',
|
||||
component: 'RouteView',
|
||||
redirect: '/profile/basic',
|
||||
path: '/profile',
|
||||
name: 'Profile',
|
||||
locale: 'menu.profile',
|
||||
},
|
||||
{
|
||||
id: 29,
|
||||
parentId: 28,
|
||||
path: '/profile/basic',
|
||||
title: '基础详情页',
|
||||
name: 'ProfileBasic',
|
||||
component: '/profile/basic/index',
|
||||
locale: 'menu.profile.basic',
|
||||
},
|
||||
{
|
||||
id: 30,
|
||||
parentId: 26,
|
||||
path: '/list/search-list',
|
||||
title: '搜索列表',
|
||||
name: 'SearchList',
|
||||
component: '/list/search-list',
|
||||
locale: 'menu.list.search-list',
|
||||
},
|
||||
{
|
||||
id: 31,
|
||||
parentId: 30,
|
||||
path: '/list/search-list/articles',
|
||||
title: '搜索列表(文章)',
|
||||
name: 'SearchListArticles',
|
||||
component: '/list/search-list/articles',
|
||||
locale: 'menu.list.search-list.articles',
|
||||
},
|
||||
{
|
||||
id: 32,
|
||||
parentId: 30,
|
||||
path: '/list/search-list/projects',
|
||||
title: '搜索列表(项目)',
|
||||
name: 'SearchListProjects',
|
||||
component: '/list/search-list/projects',
|
||||
locale: 'menu.list.search-list.projects',
|
||||
},
|
||||
{
|
||||
id: 33,
|
||||
parentId: 30,
|
||||
path: '/list/search-list/applications',
|
||||
title: '搜索列表(应用)',
|
||||
name: 'SearchListApplications',
|
||||
component: '/list/search-list/applications',
|
||||
locale: 'menu.list.search-list.applications',
|
||||
},
|
||||
{
|
||||
id: 34,
|
||||
parentId: 26,
|
||||
path: '/list/basic-list',
|
||||
title: '标准列表',
|
||||
name: 'BasicCard',
|
||||
component: '/list/basic-list',
|
||||
locale: 'menu.list.basic-list',
|
||||
},
|
||||
{
|
||||
id: 35,
|
||||
parentId: 28,
|
||||
path: '/profile/advanced',
|
||||
title: '高级详细页',
|
||||
name: 'ProfileAdvanced',
|
||||
component: '/profile/advanced/index',
|
||||
locale: 'menu.profile.advanced',
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
parentId: 3,
|
||||
title: '基础表单',
|
||||
component: '/form/basic-form/index',
|
||||
path: '/form/basic-form',
|
||||
name: 'FormBasic',
|
||||
keepAlive: false,
|
||||
locale: 'menu.form.basic-form',
|
||||
},
|
||||
{
|
||||
id: 36,
|
||||
parentId: null,
|
||||
title: '个人页',
|
||||
icon: 'UserOutlined',
|
||||
component: 'RouteView',
|
||||
redirect: '/account/center',
|
||||
path: '/account',
|
||||
name: 'Account',
|
||||
locale: 'menu.account',
|
||||
},
|
||||
{
|
||||
id: 37,
|
||||
parentId: 36,
|
||||
path: '/account/center',
|
||||
title: '个人中心',
|
||||
name: 'AccountCenter',
|
||||
component: '/account/center',
|
||||
locale: 'menu.account.center',
|
||||
},
|
||||
{
|
||||
id: 38,
|
||||
parentId: 36,
|
||||
path: '/account/settings',
|
||||
title: '个人设置',
|
||||
name: 'AccountSettings',
|
||||
component: '/account/settings',
|
||||
locale: 'menu.account.settings',
|
||||
},
|
||||
{
|
||||
id: 39,
|
||||
parentId: 3,
|
||||
title: '分步表单',
|
||||
component: '/form/step-form/index',
|
||||
path: '/form/step-form',
|
||||
name: 'FormStep',
|
||||
keepAlive: false,
|
||||
locale: 'menu.form.step-form',
|
||||
},
|
||||
{
|
||||
id: 40,
|
||||
parentId: 3,
|
||||
title: '高级表单',
|
||||
component: '/form/advanced-form/index',
|
||||
path: '/form/advanced-form',
|
||||
name: 'FormAdvanced',
|
||||
keepAlive: false,
|
||||
locale: 'menu.form.advanced-form',
|
||||
},
|
||||
{
|
||||
id: 41,
|
||||
parentId: 26,
|
||||
path: '/list/table-list',
|
||||
title: '查询表格',
|
||||
name: 'ConsultTable',
|
||||
component: '/list/table-list',
|
||||
locale: 'menu.list.consult-table',
|
||||
},
|
||||
{
|
||||
id: 42,
|
||||
parentId: 1,
|
||||
title: '监控页',
|
||||
component: '/dashboard/monitor',
|
||||
path: '/dashboard/monitor',
|
||||
name: 'DashboardMonitor',
|
||||
keepAlive: true,
|
||||
locale: 'menu.dashboard.monitor',
|
||||
},
|
||||
{
|
||||
id: 43,
|
||||
parentId: 1,
|
||||
title: '工作台',
|
||||
component: '/dashboard/workplace',
|
||||
path: '/dashboard/workplace',
|
||||
name: 'DashboardWorkplace',
|
||||
keepAlive: true,
|
||||
locale: 'menu.dashboard.workplace',
|
||||
},
|
||||
{
|
||||
id: 44,
|
||||
parentId: 26,
|
||||
path: '/list/crud-table',
|
||||
title: '增删改查表格',
|
||||
name: 'CrudTable',
|
||||
component: '/list/crud-table',
|
||||
locale: 'menu.list.crud-table',
|
||||
},
|
||||
{
|
||||
id: 45,
|
||||
parentId: 9,
|
||||
path: '/menu/menu4',
|
||||
redirect: '/menu/menu4/menu1',
|
||||
title: '菜单2-1',
|
||||
component: 'RouteView',
|
||||
locale: 'menu.menu.menu4',
|
||||
},
|
||||
{
|
||||
id: 46,
|
||||
parentId: 45,
|
||||
path: '/menu/menu4/menu1',
|
||||
component: '/menu/menu-2-1/menu1',
|
||||
title: '菜单2-1-1',
|
||||
keepAlive: true,
|
||||
locale: 'menu.menu4.menu1',
|
||||
},
|
||||
{
|
||||
id: 47,
|
||||
parentId: 45,
|
||||
path: '/menu/menu4/menu2',
|
||||
component: '/menu/menu-2-1/menu2',
|
||||
title: '菜单2-1-2',
|
||||
keepAlive: true,
|
||||
locale: 'menu.menu4.menu2',
|
||||
},
|
||||
]
|
||||
|
||||
export const accessMenuData = [
|
||||
{
|
||||
id: 18,
|
||||
parentId: 15,
|
||||
path: '/access/admin',
|
||||
title: '管理员',
|
||||
name: 'AccessAdmin',
|
||||
component: '/access/admin',
|
||||
locale: 'menu.access.admin',
|
||||
},
|
||||
|
||||
]
|
||||
|
||||
export default defineEventHandler((event) => {
|
||||
const token = event.req.headers.get('Authorization')
|
||||
// eslint-disable-next-line node/prefer-global/buffer
|
||||
const username = Buffer.from(token as any, 'base64').toString('utf-8')
|
||||
return {
|
||||
code: 200,
|
||||
msg: '获取成功',
|
||||
data: [...menuData, ...(username === 'admin' ? accessMenuData : [])],
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,8 @@
|
||||
import { defineEventHandler } from 'h3'
|
||||
|
||||
export default defineEventHandler(() => {
|
||||
return {
|
||||
code: 200,
|
||||
msg: 'delete',
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,8 @@
|
||||
import { defineEventHandler } from 'h3'
|
||||
|
||||
export default defineEventHandler(() => {
|
||||
return {
|
||||
code: 200,
|
||||
msg: 'post',
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,8 @@
|
||||
import { defineEventHandler } from 'h3'
|
||||
|
||||
export default defineEventHandler(() => {
|
||||
return {
|
||||
code: 200,
|
||||
msg: 'put',
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,24 @@
|
||||
import { defineEventHandler } from 'h3'
|
||||
|
||||
export default defineEventHandler((event) => {
|
||||
const token = event.req.headers.get('Authorization')
|
||||
// eslint-disable-next-line node/prefer-global/buffer
|
||||
const username = Buffer.from(token, 'base64').toString('utf-8')
|
||||
if (!token) {
|
||||
return {
|
||||
code: 401,
|
||||
msg: '登录失效',
|
||||
}
|
||||
}
|
||||
return {
|
||||
code: 200,
|
||||
msg: '获取成功',
|
||||
data: {
|
||||
id: 1,
|
||||
username,
|
||||
nickname: username === 'admin' ? '超级管理员' : '普通用户',
|
||||
avatar: 'https://gw.alipayobjects.com/zos/rmsportal/BiazfanxmamNRoxxVxka.png',
|
||||
roles: username === 'admin' ? ['ADMIN'] : ['USER'],
|
||||
},
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user