diff --git a/src/router/index.js b/src/router/index.js index 403b7af..9af116a 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -96,7 +96,7 @@ router.beforeEach((to, from, next) => { method: 'get', params: http.adornParams() }).then(({ data }) => { - sessionStorage.setItem('Authorization', JSON.stringify(data.authorities || '[]')) + sessionStorage.setItem('Authorities', JSON.stringify(data.authorities || '[]')) fnAddDynamicMenuRoutes(data.menuList) router.options.isAddDynamicMenuRoutes = true const rList = [] @@ -168,7 +168,7 @@ function fnCurrentRouteType (route, globalRoutes = []) { */ function fnAddDynamicMenuRoutes (menuList = [], routes = []) { let temp = [] - const modules = import.meta.glob('../views/modules/**/**.vue') + const modules = import.meta.glob('../views/modules/**/index.vue') for (let i = 0; i < menuList.length; i++) { if (menuList[i].list && menuList[i].list.length >= 1) { temp = temp.concat(menuList[i].list) @@ -193,7 +193,7 @@ function fnAddDynamicMenuRoutes (menuList = [], routes = []) { route.meta.iframeUrl = menuList[i].url } else { try { - route.component = modules[`../views/modules/${menuList[i].url}.vue`] || null + route.component = modules[`../views/modules/${menuList[i].url}/index.vue`] || null } catch (e) {} } routes.push(route) diff --git a/src/utils/http.js b/src/utils/http.js index 954f5d8..109564e 100644 --- a/src/utils/http.js +++ b/src/utils/http.js @@ -20,7 +20,6 @@ const http = axios.create({ http.interceptors.request.use( config => { config.headers.Authorization = cookie.get('Authorization') // 请求头带上token - config.headers.locale = localStorage.getItem('b2cLang') || 'zh_CN' // 只针对get方式进行序列化 if (config.method === 'get' || config.method === 'GET') { config.paramsSerializer = function (params) { @@ -68,7 +67,7 @@ http.interceptors.response.use( // eslint-disable-next-line no-console console.error('============== 请求异常 ==============', '\n', `接口地址: ${response.config.url.replace(import.meta.env.VITE_APP_BASE_API, '')}`, '\n', `异常信息: ${res}`, '\n', '============== 请求异常 end ==========') ElMessage({ - message: $t('utils.serverErr'), + message: '服务器出了点小差,请稍后再试', type: 'error', duration: 1.5 * 1000, customClass: 'element-error-message-zindex' @@ -94,7 +93,7 @@ http.interceptors.response.use( break case 405: ElMessage({ - message: $t('utils.requestErr'), + message: 'http请求方式有误', type: 'error', duration: 1500, customClass: 'element-error-message-zindex' @@ -102,7 +101,7 @@ http.interceptors.response.use( break case 500: ElMessage({ - message: $t('utils.serverErr'), + message: '服务器出了点小差,请稍后再试', type: 'error', duration: 1500, customClass: 'element-error-message-zindex' @@ -110,7 +109,7 @@ http.interceptors.response.use( break case 501: ElMessage({ - message: $t('utils.serverNoSupp'), + message: '服务器不支持当前请求所需要的某个功能', type: 'error', duration: 1500, customClass: 'element-error-message-zindex' diff --git a/src/utils/index.js b/src/utils/index.js index 800adc1..a85198a 100644 --- a/src/utils/index.js +++ b/src/utils/index.js @@ -14,7 +14,7 @@ export function getUUID () { * @param {*} key */ export function isAuth (key) { - const authorities = JSON.parse(sessionStorage.getItem('b2cAuthorities') || '[]') + const authorities = JSON.parse(sessionStorage.getItem('Authorities') || '[]') if (authorities.length) { for (const i in authorities) { const element = authorities[i] @@ -33,3 +33,57 @@ export function clearLoginInfo () { cookie.remove('Authorization') router.options.isAddDynamicMenuRoutes = false } + +/** + * 树形数据转换 + * @param {*} data + * @param {*} id + * @param {*} pid + */ +export function treeDataTranslate (data, id = 'id', pid = 'parentId') { + const res = [] + const temp = {} + for (let i = 0; i < data.length; i++) { + temp[data[i][id]] = data[i] + } + for (let k = 0; k < data.length; k++) { + if (temp[data[k][pid]] && data[k][id] !== data[k][pid]) { + if (!temp[data[k][pid]].children) { + temp[data[k][pid]].children = [] + } + if (!temp[data[k][pid]]._level) { + temp[data[k][pid]]._level = 1 + } + data[k]._level = temp[data[k][pid]]._level + 1 + temp[data[k][pid]].children.push(data[k]) + } else { + res.push(data[k]) + } + } + return res +} + +function idListFromTree (data, val, res = [], id = 'id', children = 'children') { + for (let i = 0; i < data.length; i++) { + const element = data[i] + if (element[children]) { + if (idListFromTree(element[children], val, res, id, children)) { + res.push(element[id]) + return true + } + } + if (element[id] === val) { + res.push(element[id]) + return true + } + } +} +/** + * 将数组中的parentId列表取出,倒序排列 + */ +// eslint-disable-next-line no-unused-vars +export function idList (data, val, id = 'id', children = 'children') { + const res = [] + idListFromTree(data, val, res, id) + return res +} diff --git a/src/views/common/login/index.vue b/src/views/common/login/index.vue index 8142276..4e9a745 100644 --- a/src/views/common/login/index.vue +++ b/src/views/common/login/index.vue @@ -146,40 +146,49 @@ const getCaptcha = () => { background: url('../../../assets/img/login-bg.png') no-repeat; background-size: cover; position: fixed; -} -.login .login-box { - position: absolute; - left: 50%; - transform: translateX(-50%); - height: 100%; - padding-top: 10%; -} -.login .login-box .top { - margin-bottom: 30px; - text-align: center; -} -.login .login-box .top .logo { - font-size: 0; - max-width: 50%; - margin: 0 auto; -} -.login .login-box .top :deep(.company) { - font-size: 16px; - margin-top: 10px; -} -.login .login-box .mid { - font-size: 14px; -} -.login .login-box .mid .item-btn { - margin-top: 20px; -} -.login .login-box .mid .item-btn input { - border: 0; - width: 100%; - height: 40px; - background: #1f87e8; - color: #fff; - border-radius: 3px; + .login-box { + position: absolute; + left: 50%; + transform: translateX(-50%); + height: 100%; + padding-top: 10%; + .top { + margin-bottom: 30px; + text-align: center; + .logo { + font-size: 0; + max-width: 50%; + margin: 0 auto; + } + &:deep(.company) { + font-size: 16px; + margin-top: 10px; + } + } + .mid { + font-size: 14px; + .item-btn { + width: 410px; + margin-top: 20px; + input { + border: 0; + width: 100%; + height: 40px; + background: #1f87e8; + color: #fff; + border-radius: 3px; + } + } + } + .bottom { + position: absolute; + bottom: 10%; + width: 100%; + color: #999; + font-size: 12px; + text-align: center; + } + } } .info { width: 410px; @@ -187,12 +196,4 @@ const getCaptcha = () => { :deep(.login-captcha) { height: 40px; } -.login .login-box .bottom { - position: absolute; - bottom: 10%; - width: 100%; - color: #999; - font-size: 12px; - text-align: center; -} diff --git a/src/views/modules/sys/menu/add-or-update.vue b/src/views/modules/sys/menu/add-or-update.vue new file mode 100644 index 0000000..c6594b1 --- /dev/null +++ b/src/views/modules/sys/menu/add-or-update.vue @@ -0,0 +1,290 @@ + + + + + + + {{ type }} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 全站推荐使用SVG Sprite, 详细请参考:icons/index.js 描述 + + + + + + + + + + 取消 + + 确定 + + + + + + + diff --git a/src/views/modules/sys/menu/index.vue b/src/views/modules/sys/menu/index.vue new file mode 100644 index 0000000..dcac128 --- /dev/null +++ b/src/views/modules/sys/menu/index.vue @@ -0,0 +1,196 @@ + + + + + + 新增 + + + + + + + + + + + + + + 目录 + + + 菜单 + + + 按钮 + + + + + + + {{ scope.row.url || '-' }} + + + + + {{ scope.row.perms || '-' }} + + + + + + 修改 + + + 删除 + + + + + + + + + +