From ea0b545fc6224c7a0d247e0fa3d12673b5dde8f6 Mon Sep 17 00:00:00 2001 From: wuhongjian Date: Sat, 19 Nov 2022 10:58:42 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9C=BA=E6=99=AF=E9=97=AE=E9=A2=98=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + src/router/index.js | 106 +++++++++--------- src/utils/index.js | 36 +++--- src/views/main.vue | 20 ++-- src/views/pages/civilizedCity/index.vue | 2 +- .../components/RoadGovernancePop.vue | 49 ++++---- .../roadGovernance/components/RoadMain.vue | 6 +- 7 files changed, 115 insertions(+), 105 deletions(-) diff --git a/.gitignore b/.gitignore index eb952d7..de3a9dc 100644 --- a/.gitignore +++ b/.gitignore @@ -9994,3 +9994,4 @@ node_modules/async-validator/lib/validator/required.js node_modules/async-validator/lib/validator/string.js node_modules/async-validator/lib/validator/type.js node_modules +dist-场景.zip diff --git a/src/router/index.js b/src/router/index.js index 3b764b5..9a13943 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -3,7 +3,7 @@ import Router from 'vue-router' import http from '@/utils/request' import { isURL } from '@/utils/validate' import i18n, { messages } from '@/i18n' -import Cookies from 'js-cookie'; +import Cookies from 'js-cookie' Vue.use(Router) @@ -14,7 +14,7 @@ export const pageRoutes = [{ import('@/views/pages/404'), name: '404', meta: { title: '404未找到' }, - beforeEnter(to, from, next) { + beforeEnter (to, from, next) { // 拦截处理特殊业务场景 // 如果, 重定向路由包含__双下划线, 为临时添加路由 if (/__.*/.test(to.redirectedFrom)) { @@ -90,25 +90,29 @@ export const pageRoutes = [{ name: 'civilizedCity', meta: { title: '文明创城' } }, -{ path: '/construction', - component: () => import('@/views/pages/construction'), - name: 'construction', - meta: { title: '在建工地综合监管平台' } +{ + path: '/construction', + component: () => import('@/views/pages/construction'), + name: 'construction', + meta: { title: '在建工地综合监管平台' } }, -{ path: '/area', - component: () => import('@/views/pages/area'), - name: 'area', - meta: { title: '重点区域监控平台' } +{ + path: '/area', + component: () => import('@/views/pages/area'), + name: 'area', + meta: { title: '重点区域监控平台' } }, -{ path: '/point', - component: () => import('@/views/pages/civilizedCity/components/Point'), - name: 'point', - meta: { title: '' } +{ + path: '/point', + component: () => import('@/views/pages/civilizedCity/components/Point'), + name: 'point', + meta: { title: '' } }, -{ path: '/waterPoints', - component: () => import('@/views/pages/waterPoints'), - name: 'waterPoints', - meta: { title: '积水点' } +{ + path: '/waterPoints', + component: () => import('@/views/pages/waterPoints'), + name: 'waterPoints', + meta: { title: '积水点' } }, { path: '/forestControl', @@ -163,7 +167,7 @@ export const moduleRoutes = { ] } -export function addDynamicRoute(routeParams, router) { +export function addDynamicRoute (routeParams, router) { // 组装路由名称, 并判断是否已添加, 如是: 则直接跳转 var routeName = routeParams.routeName var dynamicRoute = window.SITE_CONFIG.dynamicRoutes.filter(item => item.name === routeName)[0] @@ -198,18 +202,20 @@ const router = new Router({ }) router.beforeEach((to, from, next) => { - - - const userName = Cookies.get('userCJZT'); + debugger + const userName = Cookies.get('userCJZT') console.log(userName) if (to.path === '/login' || to.path === '/' || to.path === '/waterPoints') { - return next(); - }else{ - if (!userName) { - return next(`/login?redirect=${to.path}`) + return next() + } else { + if (to.query.secDict === 'f0e04e21778407c96b8b4e5dd08617373041') { + return next() + } else { + if (!userName) { + return next(`/login?redirect=${to.path}`) + } } } - if (to.name == 'mapHome') { document.title = _global.config.sysTitle } else { @@ -217,29 +223,29 @@ router.beforeEach((to, from, next) => { } // 添加动态(菜单)路由 // 已添加或者当前路由为页面路由, 可直接访问 - if (window.SITE_CONFIG.dynamicMenuRoutesHasAdded || fnCurrentRouteIsPageRoute(to, pageRoutes)) { - return next() - } + // if (window.SITE_CONFIG.dynamicMenuRoutesHasAdded || fnCurrentRouteIsPageRoute(to, pageRoutes)) { + // return next() + // } + next() // 获取字典列表, 添加并全局变量保存 - http.get('/sys/dict/type/all').then(({ data: res }) => { - if (res.code !== 0) { - return - } - window.SITE_CONFIG.dictList = res.data - }).catch(() => { }) + // http.get('/sys/dict/type/all').then(({ data: res }) => { + // if (res.code !== 0) { + // return + // } + // window.SITE_CONFIG.dictList = res.data + // }).catch(() => { }) // 获取菜单列表, 添加并全局变量保存 - http.get('/sys/menu/nav').then(({ data: res }) => { - if (res.code !== 0) { - Vue.prototype.$message.error(res.msg) - return next({ name: 'login' }) - } - window.SITE_CONFIG.menuList = res.data - fnAddDynamicMenuRoutes(window.SITE_CONFIG.menuList) - next({ ...to, replace: true }) - }).catch(() => { - next({ name: 'login' }) - }) - + // http.get('/sys/menu/nav').then(({ data: res }) => { + // if (res.code !== 0) { + // Vue.prototype.$message.error(res.msg) + // return next({ name: 'login' }) + // } + // window.SITE_CONFIG.menuList = res.data + // fnAddDynamicMenuRoutes(window.SITE_CONFIG.menuList) + // next({ ...to, replace: true }) + // }).catch(() => { + // next({ name: 'login' }) + // }) }) /** @@ -247,7 +253,7 @@ router.beforeEach((to, from, next) => { * @param {*} route 当前路由 * @param {*} pageRoutes 页面路由 */ -function fnCurrentRouteIsPageRoute(route, pageRoutes = []) { +function fnCurrentRouteIsPageRoute (route, pageRoutes = []) { var temp = [] for (var i = 0; i < pageRoutes.length; i++) { if (route.path === pageRoutes[i].path) { @@ -265,7 +271,7 @@ function fnCurrentRouteIsPageRoute(route, pageRoutes = []) { * @param {*} menuList 菜单列表 * @param {*} routes 递归创建的动态(菜单)路由 */ -function fnAddDynamicMenuRoutes(menuList = [], routes = []) { +function fnAddDynamicMenuRoutes (menuList = [], routes = []) { var temp = [] for (var i = 0; i < menuList.length; i++) { if (menuList[i].children && menuList[i].children.length >= 1) { diff --git a/src/utils/index.js b/src/utils/index.js index ab6c920..5e10b55 100644 --- a/src/utils/index.js +++ b/src/utils/index.js @@ -6,7 +6,7 @@ import store from '@/store' * @param {*} key */ export function hasPermission (key) { - return window.SITE_CONFIG['permissions'].indexOf(key) !== -1 || false + return window.SITE_CONFIG.permissions.indexOf(key) !== -1 || false } /** @@ -14,7 +14,7 @@ export function hasPermission (key) { * @param dictType 字典类型 */ export function getDictDataList (dictType) { - const type = window.SITE_CONFIG['dictList'].find((element) => (element.dictType === dictType)) + const type = window.SITE_CONFIG.dictList.find((element) => (element.dictType === dictType)) if (type) { return type.dataList } else { @@ -28,7 +28,7 @@ export function getDictDataList (dictType) { * @param dictValue 字典值 */ export function getDictLabel (dictType, dictValue) { - const type = window.SITE_CONFIG['dictList'].find((element) => (element.dictType === dictType)) + const type = window.SITE_CONFIG.dictList.find((element) => (element.dictType === dictType)) if (type) { const val = type.dataList.find((element) => (element.dictValue === dictValue + '')) if (val) { @@ -47,7 +47,7 @@ export function getDictLabel (dictType, dictValue) { export function clearLoginInfo () { store.commit('resetStore') Cookies.remove('token') - window.SITE_CONFIG['dynamicMenuRoutesHasAdded'] = false + window.SITE_CONFIG.dynamicMenuRoutesHasAdded = false } /** @@ -89,34 +89,34 @@ export function treeDataTranslate (data, id = 'id', pid = 'pid') { res.push(data[k]) continue } - if (!temp[data[k][pid]]['children']) { - temp[data[k][pid]]['children'] = [] + if (!temp[data[k][pid]].children) { + temp[data[k][pid]].children = [] } - temp[data[k][pid]]['children'].push(data[k]) - data[k]['_level'] = (temp[data[k][pid]]._level || 0) + 1 + temp[data[k][pid]].children.push(data[k]) + data[k]._level = (temp[data[k][pid]]._level || 0) + 1 } return res } // 计算字符串中包含的双字符个数 -export function getDoubleCharCount(str) { - let len = 0; +export function getDoubleCharCount (str) { + let len = 0 for (let i = 0; i < str.length; i++) { - const c = str.charCodeAt(i); + const c = str.charCodeAt(i) if (!((c >= 0x0001 && c <= 0x007e) || (c >= 0xff60 && c <= 0xff9f))) { - len++; + len++ } } - return len; + return len } // 计算字符串中包含单字符个数 -export function getSingleCharCount(str) { - let len = 0; +export function getSingleCharCount (str) { + let len = 0 for (let i = 0; i < str.length; i++) { - const c = str.charCodeAt(i); + const c = str.charCodeAt(i) // 单字节加1 if ((c >= 0x0001 && c <= 0x007e) || (c >= 0xff60 && c <= 0xff9f)) { - len++; + len++ } } - return len; + return len } diff --git a/src/views/main.vue b/src/views/main.vue index c3d3095..1fa18d1 100644 --- a/src/views/main.vue +++ b/src/views/main.vue @@ -57,9 +57,9 @@ export default { methods: { // 窗口改变大小 windowResizeHandle () { - this.$store.state.sidebarFold = document.documentElement['clientWidth'] <= 992 || false + this.$store.state.sidebarFold = document.documentElement.clientWidth <= 992 || false window.addEventListener('resize', debounce(() => { - this.$store.state.sidebarFold = document.documentElement['clientWidth'] <= 992 || false + this.$store.state.sidebarFold = document.documentElement.clientWidth <= 992 || false }, 150)) }, // 路由, 监听 @@ -69,13 +69,13 @@ export default { } let tab = {} let routeName = route.name - let routeMeta = route.meta + const routeMeta = route.meta if (route.name === 'iframe') { - let url = route.query.url || '' + const url = route.query.url || '' if (!isURL(url)) { return false } - let key = route.query.key || new Date().getTime() + const key = route.query.key || new Date().getTime() routeName = `${routeName}_${key}` routeMeta.title = key.toString() routeMeta.menuId = route.query.menuId || '' @@ -84,11 +84,11 @@ export default { tab = this.$store.state.contentTabs.filter(item => item.name === routeName)[0] if (!tab) { tab = { - ...window.SITE_CONFIG['contentTabDefault'], + ...window.SITE_CONFIG.contentTabDefault, ...routeMeta, - 'name': routeName, - 'params': { ...route.params }, - 'query': { ...route.query } + name: routeName, + params: { ...route.params }, + query: { ...route.query } } this.$store.state.contentTabs = this.$store.state.contentTabs.concat(tab) } @@ -112,7 +112,7 @@ export default { if (res.code !== 0) { return this.$message.error(res.msg) } - window.SITE_CONFIG['permissions'] = res.data + window.SITE_CONFIG.permissions = res.data }).catch(() => {}) } } diff --git a/src/views/pages/civilizedCity/index.vue b/src/views/pages/civilizedCity/index.vue index 4c76b68..2e8c1de 100644 --- a/src/views/pages/civilizedCity/index.vue +++ b/src/views/pages/civilizedCity/index.vue @@ -313,7 +313,7 @@ import { // 时间轴 import HorizonTimeLine from './components/HorizonTimeLine' import { valueOf } from 'screenfull' - +import Cookies from 'js-cookie' export default { data () { return { diff --git a/src/views/pages/roadGovernance/components/RoadGovernancePop.vue b/src/views/pages/roadGovernance/components/RoadGovernancePop.vue index 2ecf6b5..ce95198 100644 --- a/src/views/pages/roadGovernance/components/RoadGovernancePop.vue +++ b/src/views/pages/roadGovernance/components/RoadGovernancePop.vue @@ -18,38 +18,39 @@