diff --git a/src/api/eventPage/index.js b/src/api/eventPage/index.js index f7a1518..8a1a499 100644 --- a/src/api/eventPage/index.js +++ b/src/api/eventPage/index.js @@ -91,4 +91,29 @@ export function getErrorMsg(){ url: '/earlyWarningAudit/massEvents/getErrorMsg', method: 'get', }) +} + +// 登录 +// export function login(data){ +// return request({ +// url: '/earlyWarningAudit/massEvents/login', +// method: 'psot', +// data +// }) +// } + +export function login(username, password) { + const data = { + username, + password, + } + return request({ + url: '/earlyWarningAudit/massEvents/login', + headers: { + isToken: false, + repeatSubmit: false + }, + method: 'post', + data: data + }) } \ No newline at end of file diff --git a/src/main.js b/src/main.js index aaf842a..843c205 100644 --- a/src/main.js +++ b/src/main.js @@ -1,11 +1,3 @@ -/* - * @Descripttion: - * @version: - * @Author: JC9527 - * @Date: 2024-03-12 17:24:11 - * @LastEditors: JC9527 - * @LastEditTime: 2024-09-23 10:01:04 - */ import Vue from 'vue' import Cookies from 'js-cookie' @@ -82,6 +74,11 @@ Vue.directive('removeAriaHiddent', { } }) +/** + * 还原只需还原路由拦截文件里和注释掉本地路由配置,单页面mounted里登录去掉即可 + * + */ + /** * If you don't want to use mock-server * you want to use MockJs for mock api diff --git a/src/permission.js b/src/permission.js index c568979..e002761 100644 --- a/src/permission.js +++ b/src/permission.js @@ -12,45 +12,47 @@ const whiteList = ['/login', '/register'] router.beforeEach((to, from, next) => { NProgress.start() - if (getToken()) { - to.meta.title && store.dispatch('settings/setTitle', to.meta.title) - /* has token*/ - if (to.path === '/login') { - next({ path: '/' }) - NProgress.done() - } else if (whiteList.indexOf(to.path) !== -1) { - next() - } else { - if (store.getters.roles.length === 0) { - isRelogin.show = true - // 判断当前用户是否已拉取完user_info信息 - store.dispatch('GetInfo').then(() => { - isRelogin.show = false - store.dispatch('GenerateRoutes').then(accessRoutes => { - // 根据roles权限生成可访问的路由表 - router.addRoutes(accessRoutes) // 动态添加可访问路由表 - next({ ...to, replace: true }) // hack方法 确保addRoutes已完成 - }) - }).catch(err => { - store.dispatch('LogOut').then(() => { - Message.error(err) - next({ path: '/' }) - }) - }) - } else { - next() - } - } - } else { - // 没有token - if (whiteList.indexOf(to.path) !== -1) { - // 在免登录白名单,直接进入 - next() - } else { - next(`/login?redirect=${encodeURIComponent(to.fullPath)}`) // 否则全部重定向到登录页 - NProgress.done() - } - } + next(); + NProgress.done() + // if (getToken()) { + // to.meta.title && store.dispatch('settings/setTitle', to.meta.title) + // /* has token*/ + // if (to.path === '/login') { + // next({ path: '/' }) + // NProgress.done() + // } else if (whiteList.indexOf(to.path) !== -1) { + // next() + // } else { + // if (store.getters.roles.length === 0) { + // isRelogin.show = true + // // 判断当前用户是否已拉取完user_info信息 + // store.dispatch('GetInfo').then(() => { + // isRelogin.show = false + // store.dispatch('GenerateRoutes').then(accessRoutes => { + // // 根据roles权限生成可访问的路由表 + // router.addRoutes(accessRoutes) // 动态添加可访问路由表 + // next({ ...to, replace: true }) // hack方法 确保addRoutes已完成 + // }) + // }).catch(err => { + // store.dispatch('LogOut').then(() => { + // Message.error(err) + // next({ path: '/' }) + // }) + // }) + // } else { + // next() + // } + // } + // } else { + // // 没有token + // if (whiteList.indexOf(to.path) !== -1) { + // // 在免登录白名单,直接进入 + // next() + // } else { + // next(`/login?redirect=${encodeURIComponent(to.fullPath)}`) // 否则全部重定向到登录页 + // NProgress.done() + // } + // } }) router.afterEach(() => { diff --git a/src/router/index.js b/src/router/index.js index d71a1ce..30b8b7d 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -74,54 +74,54 @@ export const constantRoutes = [ // }, // ] }, - // { - // path: '/index', - // component: () => import('@/views/index'), - // name: 'Index', - // meta: { title: '算法运行监测', icon: '', affix: true } - // }, - // { - // path: '/warningAppear', - // component: () => import('@/views/warningManage/warningAppear'), - // name: 'WarningAppear', - // meta: { title: '预警呈现', icon: '', affix: true } - // }, - // { - // path: '/groupEvent', - // component: () => import('@/views/warningManage/warningAudit/groupEvent'), - // name: 'GroupEvent', - // meta: { title: '驾驶舱群体事件', icon: '', affix: true } - // }, - // { - // path: '/instancyEvent', - // component: () => import('@/views/warningManage/warningAudit/instancyEvent'), - // name: 'InstancyEvent', - // meta: { title: '驾驶舱紧急事件', icon: '', affix: true } - // }, - // { - // path: '/oneToManyEvent', - // component: () => import('@/views/warningManage/warningAudit/oneToManyEvent'), - // name: 'OneToManyEvent', - // meta: { title: '驾驶舱一人多诉事件', icon: '', affix: true } - // }, - // { - // path: '/oneToOneEvent', - // component: () => import('@/views/warningManage/warningAudit/oneToOneEvent'), - // name: 'OneToOneEvent', - // meta: { title: '驾驶舱同人同诉事件', icon: '', affix: true } - // }, - // { - // path: '/emphasisEvent', - // component: () => import('@/views/warningManage/warningAudit/emphasisEvent'), - // name: 'EmphasisEvent', - // meta: { title: '驾驶舱重点人员事件', icon: '', affix: true } - // }, - // { - // path: '/similarity', - // component: () => import('@/views/warningManage/warningAudit/similarity'), - // name: 'Similarity', - // meta: { title: '驾驶舱相似同类事件', icon: '', affix: true } - // }, + { + path: '/index', + component: () => import('@/views/index'), + name: 'Index', + meta: { title: '算法运行监测', icon: '', affix: true } + }, + { + path: '/warningAppear', + component: () => import('@/views/warningManage/warningAppear'), + name: 'WarningAppear', + meta: { title: '预警呈现', icon: '', affix: true } + }, + { + path: '/groupEvent', + component: () => import('@/views/warningManage/warningAudit/groupEvent'), + name: 'GroupEvent', + meta: { title: '驾驶舱群体事件', icon: '', affix: true } + }, + { + path: '/instancyEvent', + component: () => import('@/views/warningManage/warningAudit/instancyEvent'), + name: 'InstancyEvent', + meta: { title: '驾驶舱紧急事件', icon: '', affix: true } + }, + { + path: '/oneToManyEvent', + component: () => import('@/views/warningManage/warningAudit/oneToManyEvent'), + name: 'OneToManyEvent', + meta: { title: '驾驶舱一人多诉事件', icon: '', affix: true } + }, + { + path: '/oneToOneEvent', + component: () => import('@/views/warningManage/warningAudit/oneToOneEvent'), + name: 'OneToOneEvent', + meta: { title: '驾驶舱同人同诉事件', icon: '', affix: true } + }, + { + path: '/emphasisEvent', + component: () => import('@/views/warningManage/warningAudit/emphasisEvent'), + name: 'EmphasisEvent', + meta: { title: '驾驶舱重点人员事件', icon: '', affix: true } + }, + { + path: '/similarity', + component: () => import('@/views/warningManage/warningAudit/similarity'), + name: 'Similarity', + meta: { title: '驾驶舱相似同类事件', icon: '', affix: true } + }, { path: '/user', diff --git a/src/utils/jsencrypt.js b/src/utils/jsencrypt.js index 78d9523..23a2fbf 100644 --- a/src/utils/jsencrypt.js +++ b/src/utils/jsencrypt.js @@ -2,17 +2,16 @@ import JSEncrypt from 'jsencrypt/bin/jsencrypt.min' // 密钥对生成 http://web.chacuo.net/netrsakeypair -const publicKey = 'MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAKoR8mX0rGKLqzcWmOzbfj64K8ZIgOdH\n' + - 'nzkXSOVOZbFu/TJhZ7rFAN+eaGkl3C4buccQd/EjEsj9ir7ijT7h96MCAwEAAQ==' +const publicKey = 'MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAJ2wJTZWLnLZuRppAOevdiloiXfXE3i9rAr1rBg31sj1xAnhfRuDChoo63kMyZBifeiOcNCr49GeO3j+7NlY+yMCAwEAAQ==' -const privateKey = 'MIIBVAIBADANBgkqhkiG9w0BAQEFAASCAT4wggE6AgEAAkEAqhHyZfSsYourNxaY\n' + - '7Nt+PrgrxkiA50efORdI5U5lsW79MmFnusUA355oaSXcLhu5xxB38SMSyP2KvuKN\n' + - 'PuH3owIDAQABAkAfoiLyL+Z4lf4Myxk6xUDgLaWGximj20CUf+5BKKnlrK+Ed8gA\n' + - 'kM0HqoTt2UZwA5E2MzS4EI2gjfQhz5X28uqxAiEA3wNFxfrCZlSZHb0gn2zDpWow\n' + - 'cSxQAgiCstxGUoOqlW8CIQDDOerGKH5OmCJ4Z21v+F25WaHYPxCFMvwxpcw99Ecv\n' + - 'DQIgIdhDTIqD2jfYjPTY8Jj3EDGPbH2HHuffvflECt3Ek60CIQCFRlCkHpi7hthh\n' + - 'YhovyloRYsM+IS9h/0BzlEAuO0ktMQIgSPT3aFAgJYwKpqRYKlLDVcflZFCKY7u3\n' + - 'UP8iWi1Qw0Y=' +const privateKey = 'MIIBVQIBADANBgkqhkiG9w0BAQEFAASCAT8wggE7AgEAAkEAnbAlNlYuctm5GmkA\n'+ +'5692KWiJd9cTeL2sCvWsGDfWyPXECeF9G4MKGijreQzJkGJ96I5w0Kvj0Z47eP7s\n'+ +'2Vj7IwIDAQABAkEAgbPrR+BnYEy5toF8HxXx6Wl0+T/NYlkQ9ArTPTBg2PYTXSvT\n'+ +'LoJqrWss688w7WIwUz5lyVKKeRFWkxe9T4RIUQIhAM6BMCzJybFtAszEgBBDdtxj\n'+ +'eDiXAk3zcsqcltHE/i/PAiEAw3ulbhgLYnXJIfymCsMgnyrESOyQxKDhQOm2Pnj/\n'+ +'YG0CICx9Corroic2S/8falOWpTnPuCvA5L80bouV9qwUm4pjAiEAkJ4U0NHw+jJx\n'+ +'Tjd/D08z/wzAkcKRhyYN/tvn+2fAZjECICkVQ6VWohPiibqIdVffCwXK3jSi5SJ3\n'+ +'ddcmzYQBJFLv' // 加密 export function encrypt(txt) { diff --git a/src/views/index.vue b/src/views/index.vue index 445b0bc..fa67233 100644 --- a/src/views/index.vue +++ b/src/views/index.vue @@ -63,6 +63,9 @@ // import tabContent from "./components/algorithmTime" import { getEventLogs } from "@/api/platform/index" import { mapState, mapGetters } from 'vuex' +import { login } from "@/api/eventPage" +import { setToken } from '@/utils/auth' +import { encrypt } from '@/utils/jsencrypt' export default { // components:{ // tabContent @@ -89,9 +92,12 @@ export default { ...mapGetters(['debugTime']), }, mounted() { - this.getList(); - this.cancalDebounce(); - window.addEventListener('resize', this.cancalDebounce); + login("admin",encrypt("Suanfa@2024//**...")).then(res=>{ + setToken(res.token) + this.getList(); + this.cancalDebounce(); + window.addEventListener('resize', this.cancalDebounce); + }) }, destroyed() { window.removeEventListener('resize', this.cancalDebounce); diff --git a/src/views/warningManage/warningAppear.vue b/src/views/warningManage/warningAppear.vue index b2b86fd..dd598a3 100644 --- a/src/views/warningManage/warningAppear.vue +++ b/src/views/warningManage/warningAppear.vue @@ -85,7 +85,9 @@ import "proj4"; import "proj4leaflet"; import "@/utils/lib/leaflet.ChineseTmsProviders.js"; import "@/utils/lib/leaflet.mapCorrection.min.js"; -import { new100Page, colonyPage } from "@/api/eventPage" +import { new100Page, colonyPage, login } from "@/api/eventPage" +import { setToken } from '@/utils/auth' +import { encrypt } from '@/utils/jsencrypt' import urgencyAudit from '@/views/components/urgencyAudit.vue' import EventAudit from '@/views/components/eventAudit.vue' export default { @@ -147,10 +149,13 @@ export default { } }, mounted() { - this.$nextTick(() => { - this.initMap(); - }); - this.getList(); + login("admin",encrypt("Suanfa@2024//**...")).then(res=>{ + setToken(res.token) + this.$nextTick(() => { + this.initMap(); + }); + this.getList(); + }) }, methods:{ mountedMethods(){ diff --git a/src/views/warningManage/warningAudit/emphasisEvent.vue b/src/views/warningManage/warningAudit/emphasisEvent.vue index 0df4371..d09bf01 100644 --- a/src/views/warningManage/warningAudit/emphasisEvent.vue +++ b/src/views/warningManage/warningAudit/emphasisEvent.vue @@ -89,7 +89,9 @@