From 1e5c4894dc65f52dfead7017403e4e246930f048 Mon Sep 17 00:00:00 2001 From: fys <723107234@qq.com> Date: Thu, 2 Apr 2020 22:03:49 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=B8=AA=E4=BA=BA=E9=A1=B9=E7=9B=AE?= =?UTF-8?q?=E5=88=86=E6=94=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app.js | 6 ++++ routes/authorityRouter/index.js | 54 +++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 routes/authorityRouter/index.js diff --git a/app.js b/app.js index 46b5a50..fa2fb49 100644 --- a/app.js +++ b/app.js @@ -27,6 +27,9 @@ const adminUserRouter = require('./routes/adminUser'); const adminViewsRouter = require('./routes/adminViews'); const adminAuthorityRouter = require('./routes/adminAuthority'); +// authorityRouter +const authorityRouter = require('./routes/authorityRouter'); + const app = express(); // view engine setup @@ -55,6 +58,9 @@ app.use('/api/vue-blog/views', adminViewsRouter); app.use('/api/vue-blog/adminAuthority', adminAuthorityRouter); app.use('/api/vue-blog/column', columnRouter); +// authorityRouter +app.use('/api/authorityRouter', authorityRouter); + // catch 404 and forward to error handler app.use(function(req, res, next) { next(createError(404)); diff --git a/routes/authorityRouter/index.js b/routes/authorityRouter/index.js new file mode 100644 index 0000000..eb9afe4 --- /dev/null +++ b/routes/authorityRouter/index.js @@ -0,0 +1,54 @@ +const express = require('express') +const router = express.Router() + +router.post('/login', login) +router.post('/getRouter', getRouter) + +async function login(req, res, next) { + return res.json({ + isok: true, + msg: '', + data: {} + }); +} + +async function getRouter(req, res, next) { + let result + if (req.body.type == 0) { + result = [ + { + path: 'vip', + name: 'AdminVip', + meta: { + requiresAuth: true, + authority: 1 + } + }, + { + path: 'admin', + name: 'AdminAdmin', + meta: { + requiresAuth: true, + authority: 0 + } + } + ] + } else if (req.body.type == 1) { + result = [ + { + path: 'vip', + name: 'AdminVip', + meta: { + requiresAuth: true, + authority: 1 + } + } + ] + } + return res.json({ + isok: true, + msg: '', + data: result + }); +} +module.exports = router; \ No newline at end of file From 71174a9d8dd93850e2ce687fc250e57484e1fcc4 Mon Sep 17 00:00:00 2001 From: fxss <723107234@qq.com> Date: Sun, 5 Apr 2020 15:22:45 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E7=AC=AC=E4=B8=80=E6=AC=A1=E7=9A=84?= =?UTF-8?q?=E6=97=B6=E5=80=99=E4=B8=8D=E8=83=BD=E5=8A=A0404=EF=BC=8C?= =?UTF-8?q?=E4=B8=8D=E7=84=B6=E9=A6=96=E6=AC=A1=E6=89=93=E5=BC=80=E9=83=BD?= =?UTF-8?q?=E6=98=AF404?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- routes/authorityRouter/index.js | 69 +++++++++++++++++++++------------ 1 file changed, 44 insertions(+), 25 deletions(-) diff --git a/routes/authorityRouter/index.js b/routes/authorityRouter/index.js index eb9afe4..1063d12 100644 --- a/routes/authorityRouter/index.js +++ b/routes/authorityRouter/index.js @@ -13,42 +13,61 @@ async function login(req, res, next) { } async function getRouter(req, res, next) { - let result - if (req.body.type == 0) { - result = [ + let result = { + path: '/', + name: 'Admin', + component: 'Admin', + meta: { + title: '个人中心', + requiresAuth: true, + roles: [0, 1, 2] + }, + redirect: '/base', + children: [ { - path: 'vip', - name: 'AdminVip', + path: 'base', + name: 'AdminBase', + component: 'AdminBase', meta: { + title: '基本信息', requiresAuth: true, - authority: 1 - } - }, - { - path: 'admin', - name: 'AdminAdmin', - meta: { - requiresAuth: true, - authority: 0 + roles: [0, 1, 2] } } ] - } else if (req.body.type == 1) { - result = [ - { - path: 'vip', - name: 'AdminVip', - meta: { - requiresAuth: true, - authority: 1 - } + } + + if ([0, 1].includes(req.body.type * 1)) { + result.children.push({ + path: 'vip', + name: 'AdminVip', + component: 'AdminVip', + meta: { + title: 'Vip信息', + requiresAuth: true, + roles: [0, 1] } - ] + }) + } + + if (req.body.type * 1 === 0) { + result.children.push({ + path: 'admin', + name: 'AdminAdmin', + component: 'AdminAdmin', + meta: { + title: '管理员', + requiresAuth: true, + roles: [0] + } + }) } + return res.json({ isok: true, msg: '', data: result }); } -module.exports = router; \ No newline at end of file + +module.exports = router;