From 4045c9b91231242a4b70ee5217e99f49868f4f1c Mon Sep 17 00:00:00 2001 From: Zhao Qiqi <1287235164@qq.com> Date: Sat, 2 Jul 2022 18:07:17 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=84=E4=B8=AA=E9=A1=B9=E7=9B=AE=E7=9A=84ma?= =?UTF-8?q?in.js=E6=96=87=E4=BB=B6=E5=81=9A=E5=87=BA=E6=9B=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- anrui-base/anrui-base-ui/src/main.js | 25 +++++--- .../anrui-buscenter-ui/src/main.js | 61 ++++++++++--------- .../anrui-finmanage-ui/src/main.js | 50 ++++++++------- .../anrui-management-ui/src/main.js | 21 +++++-- anrui-scm/anrui-scm-ui/src/main.js | 7 +-- 5 files changed, 96 insertions(+), 68 deletions(-) diff --git a/anrui-base/anrui-base-ui/src/main.js b/anrui-base/anrui-base-ui/src/main.js index e0e4662728..bfdeadced1 100644 --- a/anrui-base/anrui-base-ui/src/main.js +++ b/anrui-base/anrui-base-ui/src/main.js @@ -32,16 +32,27 @@ let token = null token = GetQueryString('token') if (token) { -setStorage(token) -let href = window.location.href -href = href.split(`token=${token}`)[0] -window.location.href = href.slice(0, href.length - 1) + setStorage(token) + let href = window.location.href +// href = href.split(`token=${token}`)[0] +// window.location.href = href.slice(0, href.length - 1) } function GetQueryString(name) { - var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)') - var r = window.location.search.substr(1).match(reg) - if (r != null) return unescape(r[2]); return null + var one = window.location.href.indexOf('?token=') + 7 + var two = window.location.href.lastIndexOf('&') //+ 1 + var data = window.location.href.substr(one) + if (two > one) { + data = window.location.href.slice(one, two) + console.log('token', data) + } + if (data) { + return data + } + return null + // var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)') + // var r = window.location.search.substr(1).match(reg) + // if (r != null) return unescape(r[2]); return null } // 获取登录用户信息 diff --git a/anrui-buscenter/anrui-buscenter-ui/src/main.js b/anrui-buscenter/anrui-buscenter-ui/src/main.js index a399788daf..73eb43e628 100644 --- a/anrui-buscenter/anrui-buscenter-ui/src/main.js +++ b/anrui-buscenter/anrui-buscenter-ui/src/main.js @@ -1,62 +1,67 @@ import 'babel-polyfill' import Vue from 'vue' import 'normalize.css/normalize.css' // A modern alternative to CSS resets - import ElementUI from 'element-ui' import 'element-ui/lib/theme-chalk/index.css' - -Vue.use(ElementUI) - import '@/styles/index.scss' // global css - import App from './App' import store from './store' import router from './router' import '@/icons' // icon +// 全局自定义组件 +import Pagination from '@/components/pagination/index.vue' +import tabsearch from '@/components/tab-search/index.vue' +import eimage from '@/components/E-image/index.vue' +import Print from '@/utils/print' // 引入附件的js文件 +import {setStorage} from './utils/auth.js' +import VueAMap from 'vue-amap' +import request from "@/utils/request" + +Vue.use(ElementUI) + // import '@/permission' //权限控制 Vue.prototype.$userInfo = null // 用户信息 -// 全局自定义组件 -import Pagination from '@/components/pagination/index.vue' Vue.component('Pagination', Pagination) -import tabsearch from '@/components/tab-search/index.vue' Vue.component('tab-search', tabsearch) -import eimage from '@/components/E-image/index.vue' Vue.component('eimage', eimage) -import Print from '@/utils/print' // 引入附件的js文件 Vue.use(Print) // 注册 -import {setStorage, getStorage} from './utils/auth.js' - let token = null -// token = GetQueryString('token') -token = getQueryVariable('token') +token = GetQueryString('token') +// token = getQueryVariable('token') if (token) { setStorage(token) let href = window.location.href - href = href.split(`token=${token}`)[0] - window.location.href = href.slice(0, href.length - 1) + // href = href.split(`token=${token}`)[0] + // window.location.href = href.slice(0, href.length - 1) } function GetQueryString(name) { - console.log('main', name) - var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)') - console.log('main:reg', reg) - console.log('main:window.location', window.location) - var se = window.location.search.substr(1) - console.log(se) - var hr = window.location.href.substr(window.location.href.indexOf("?")+1) - var r = hr.match( reg) - console.log('main:r', r) - if (r != null) - return unescape(r[2]); + var one = window.location.href.indexOf('?token=') + 7 + var two = window.location.href.lastIndexOf('&') //+ 1 + var data = window.location.href.substr(one) + if (two > one) { + data = window.location.href.slice(one, two) + console.log('token', data) + } + if (data) { + return data + } return null + // var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)') + // var se = window.location.search.substr(1) + // var hr = window.location.href.substr(window.location.href.indexOf("?")+1) + // var r = hr.match( reg) + // if (r != null) + // return unescape(r[2]); + // return null } function getQueryVariable(variable) { @@ -114,8 +119,6 @@ function getUserInfo() { } getUserInfo(); -import VueAMap from 'vue-amap' -import request from "@/utils/request" Vue.use(VueAMap) VueAMap.initAMapApiLoader({ diff --git a/anrui-buscenter/anrui-finmanage-ui/src/main.js b/anrui-buscenter/anrui-finmanage-ui/src/main.js index 55ea2b86ce..38289de09f 100644 --- a/anrui-buscenter/anrui-finmanage-ui/src/main.js +++ b/anrui-buscenter/anrui-finmanage-ui/src/main.js @@ -1,48 +1,59 @@ import 'babel-polyfill' import Vue from 'vue' import 'normalize.css/normalize.css' // A modern alternative to CSS resets - import ElementUI from 'element-ui' import 'element-ui/lib/theme-chalk/index.css' -Vue.use(ElementUI) - import '@/styles/index.scss' // global css - import App from './App' import store from './store' import router from './router' import '@/icons' // icon +// 全局自定义组件 +import Pagination from '@/components/pagination/index.vue' +import tabsearch from '@/components/tab-search/index.vue' +import eimage from '@/components/E-image/index.vue' +import Print from '@/utils/print' // 引入附件的js文件 +import {setStorage} from './utils/auth.js' +import VueAMap from 'vue-amap' +import request from "@/utils/request"; + +Vue.use(ElementUI) + // import '@/permission' //权限控制 Vue.prototype.$userInfo = null // 用户信息 -// 全局自定义组件 -import Pagination from '@/components/pagination/index.vue' Vue.component('Pagination', Pagination) -import tabsearch from '@/components/tab-search/index.vue' Vue.component('tab-search', tabsearch) -import eimage from '@/components/E-image/index.vue' Vue.component('eimage', eimage) -import Print from '@/utils/print' // 引入附件的js文件 Vue.use(Print) // 注册 - -import { setStorage, getStorage } from './utils/auth.js' let token = null token = GetQueryString('token') if (token) { -setStorage(token) -let href = window.location.href -href = href.split(`token=${token}`)[0] -window.location.href = href.slice(0, href.length - 1) + setStorage(token) + let href = window.location.href +// href = href.split(`token=${token}`)[0] +// window.location.href = href.slice(0, href.length - 1) } function GetQueryString(name) { - var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)') - var r = window.location.search.substr(1).match(reg) - if (r != null) return unescape(r[2]); return null + var one = window.location.href.indexOf('?token=') + 7 + var two = window.location.href.lastIndexOf('&') //+ 1 + var data = window.location.href.substr(one) + if (two > one) { + data = window.location.href.slice(one, two) + console.log('token', data) + } + if (data) { + return data + } + return null + // var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)') + // var r = window.location.search.substr(1).match(reg) + // if (r != null) return unescape(r[2]); return null } //获取登录用户信息 @@ -83,9 +94,6 @@ function getUserInfo(){ getUserInfo(); -import VueAMap from 'vue-amap' -import request from "@/utils/request"; -import qs from "qs"; Vue.use(VueAMap); VueAMap.initAMapApiLoader({ key: 'ccda12d8bffc72e9f1a32c599323a876', // 此处的key,在高德开放平台申请 diff --git a/anrui-management/anrui-management-ui/src/main.js b/anrui-management/anrui-management-ui/src/main.js index 98f0fa21a5..266b115ba6 100644 --- a/anrui-management/anrui-management-ui/src/main.js +++ b/anrui-management/anrui-management-ui/src/main.js @@ -34,14 +34,25 @@ token = GetQueryString('token') if (token) { setStorage(token) let href = window.location.href -href = href.split(`token=${token}`)[0] -window.location.href = href.slice(0, href.length - 1) +// href = href.split(`token=${token}`)[0] +// window.location.href = href.slice(0, href.length - 1) } function GetQueryString(name) { - var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)') - var r = window.location.search.substr(1).match(reg) - if (r != null) return unescape(r[2]); return null + var one = window.location.href.indexOf('?token=') + 7 + var two = window.location.href.lastIndexOf('&') //+ 1 + var data = window.location.href.substr(one) + if (two > one) { + data = window.location.href.slice(one, two) + console.log('token', data) + } + if (data) { + return data + } + return null + // var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)') + // var r = window.location.search.substr(1).match(reg) + // if (r != null) return unescape(r[2]); return null } import VueAMap from 'vue-amap' diff --git a/anrui-scm/anrui-scm-ui/src/main.js b/anrui-scm/anrui-scm-ui/src/main.js index 5d21c3c847..a78344dfc7 100644 --- a/anrui-scm/anrui-scm-ui/src/main.js +++ b/anrui-scm/anrui-scm-ui/src/main.js @@ -98,12 +98,7 @@ function GetQueryString(name) { } return null // var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)') - // var rrr = window.location.href.?token= - // console.log('rrr',rrr) - // var rr = rrr.substr(1) - // console.log('rr',rr) - // var r = rr.match(reg) - // console.log('r',r) + // var r = window.location.search.substr(1).match(reg) // if (r != null) return unescape(r[2]); return null }