5 files modified
1 files deleted
| | |
| | | <template> |
| | | <basic-container> |
| | | <iframe :src="src" |
| | | class="iframe" |
| | | ref="iframe"></iframe> |
| | | <iframe :src="src" class="iframe" ref="iframe"></iframe> |
| | | </basic-container> |
| | | </template> |
| | | |
| | | <script> |
| | | import {mapGetters} from "vuex"; |
| | | import NProgress from "nprogress"; // progress bar |
| | | import "nprogress/nprogress.css"; // progress bar style |
| | | export default { |
| | | name: "AvueIframe", |
| | | data() { |
| | | return { |
| | | urlPath: this.getUrlPath() //iframe src 路径 |
| | | import { mapGetters } from "vuex"; |
| | | import NProgress from "nprogress"; // progress bar |
| | | import "nprogress/nprogress.css"; // progress bar style |
| | | export default { |
| | | name: "AvueIframe", |
| | | data() { |
| | | return { |
| | | urlPath: this.getUrlPath(), //iframe src 路径 |
| | | }; |
| | | }, |
| | | created() { |
| | | NProgress.configure({ showSpinner: false }); |
| | | }, |
| | | mounted() { |
| | | this.load(); |
| | | this.resize(); |
| | | }, |
| | | props: ["routerPath"], |
| | | watch: { |
| | | $route: function () { |
| | | this.load(); |
| | | }, |
| | | routerPath: function () { |
| | | // 监听routerPath变化,改变src路径 |
| | | this.urlPath = this.getUrlPath(); |
| | | }, |
| | | }, |
| | | computed: { |
| | | ...mapGetters(["screen"]), |
| | | src() { |
| | | return this.$route.query.src |
| | | ? this.$route.query.src.replace("$", "#") |
| | | : this.urlPath; |
| | | }, |
| | | }, |
| | | methods: { |
| | | // 显示等待框 |
| | | show() { |
| | | NProgress.start(); |
| | | }, |
| | | // 隐藏等待狂 |
| | | hide() { |
| | | NProgress.done(); |
| | | }, |
| | | // 加载浏览器窗口变化自适应 |
| | | resize() { |
| | | window.onresize = () => { |
| | | this.iframeInit(); |
| | | }; |
| | | }, |
| | | created() { |
| | | NProgress.configure({showSpinner: false}); |
| | | }, |
| | | mounted() { |
| | | this.load(); |
| | | this.resize(); |
| | | }, |
| | | props: ["routerPath"], |
| | | watch: { |
| | | $route: function () { |
| | | this.load(); |
| | | }, |
| | | routerPath: function () { |
| | | // 监听routerPath变化,改变src路径 |
| | | this.urlPath = this.getUrlPath(); |
| | | // 加载组件 |
| | | load() { |
| | | this.show(); |
| | | var flag = true; //URL是否包含问号 |
| | | if ( |
| | | this.$route.query.src !== undefined && |
| | | this.$route.query.src.indexOf("?") === -1 |
| | | ) { |
| | | flag = false; |
| | | } |
| | | }, |
| | | computed: { |
| | | ...mapGetters(["screen"]), |
| | | src() { |
| | | return this.$route.query.src |
| | | ? this.$route.query.src.replace("$", "#") |
| | | : this.urlPath; |
| | | var list = []; |
| | | for (var key in this.$route.query) { |
| | | if (key !== "src" && key !== "name" && key !== "i18n") { |
| | | list.push(`${key}= this.$route.query[key]`); |
| | | } |
| | | } |
| | | list = list.join("&").toString(); |
| | | if (flag) { |
| | | this.$route.query.src = `${this.$route.query.src}${ |
| | | list.length > 0 ? `&list` : "" |
| | | }`; |
| | | } else { |
| | | this.$route.query.src = `${this.$route.query.src}${ |
| | | list.length > 0 ? `?list` : "" |
| | | }`; |
| | | } |
| | | //超时3s自动隐藏等待狂,加强用户体验 |
| | | let time = 3; |
| | | const timeFunc = setInterval(() => { |
| | | time--; |
| | | if (time === 0) { |
| | | this.hide(); |
| | | clearInterval(timeFunc); |
| | | } |
| | | }, 1000); |
| | | this.iframeInit(); |
| | | }, |
| | | methods: { |
| | | // 显示等待框 |
| | | show() { |
| | | NProgress.start(); |
| | | }, |
| | | // 隐藏等待狂 |
| | | hide() { |
| | | NProgress.done(); |
| | | }, |
| | | // 加载浏览器窗口变化自适应 |
| | | resize() { |
| | | window.onresize = () => { |
| | | this.iframeInit(); |
| | | //iframe窗口初始化 |
| | | iframeInit() { |
| | | const iframe = this.$refs.iframe; |
| | | const clientHeight = |
| | | document.documentElement.clientHeight - (screen > 1 ? 200 : 130); |
| | | if (!iframe) return; |
| | | iframe.style.height = `${clientHeight}px`; |
| | | if (iframe.attachEvent) { |
| | | iframe.attachEvent("onload", () => { |
| | | this.hide(); |
| | | }); |
| | | } else { |
| | | iframe.onload = () => { |
| | | this.hide(); |
| | | }; |
| | | }, |
| | | // 加载组件 |
| | | load() { |
| | | this.show(); |
| | | var flag = true; //URL是否包含问号 |
| | | if (this.$route.query.src !== undefined && this.$route.query.src.indexOf("?") === -1) { |
| | | flag = false; |
| | | } |
| | | var list = []; |
| | | for (var key in this.$route.query) { |
| | | if (key !== "src" && key !== "name" && key !== "i18n") { |
| | | list.push(`${key}= this.$route.query[key]`); |
| | | } |
| | | } |
| | | list = list.join("&").toString(); |
| | | if (flag) { |
| | | this.$route.query.src = `${this.$route.query.src}${ |
| | | list.length > 0 ? `&list` : "" |
| | | }`; |
| | | } else { |
| | | this.$route.query.src = `${this.$route.query.src}${ |
| | | list.length > 0 ? `?list` : "" |
| | | }`; |
| | | } |
| | | //超时3s自动隐藏等待狂,加强用户体验 |
| | | let time = 3; |
| | | const timeFunc = setInterval(() => { |
| | | time--; |
| | | if (time === 0) { |
| | | this.hide(); |
| | | clearInterval(timeFunc); |
| | | } |
| | | }, 1000); |
| | | this.iframeInit(); |
| | | }, |
| | | //iframe窗口初始化 |
| | | iframeInit() { |
| | | const iframe = this.$refs.iframe; |
| | | const clientHeight = |
| | | document.documentElement.clientHeight - (screen > 1 ? 200 : 130); |
| | | if (!iframe) return; |
| | | iframe.style.height = `${clientHeight}px`; |
| | | if (iframe.attachEvent) { |
| | | iframe.attachEvent("onload", () => { |
| | | this.hide(); |
| | | }); |
| | | } else { |
| | | iframe.onload = () => { |
| | | this.hide(); |
| | | }; |
| | | } |
| | | }, |
| | | getUrlPath: function () { |
| | | //获取 iframe src 路径 |
| | | let url = window.location.href; |
| | | url = url.replace("/myiframe", ""); |
| | | return url; |
| | | } |
| | | } |
| | | }; |
| | | }, |
| | | getUrlPath: function () { |
| | | //获取 iframe src 路径 |
| | | let url = window.location.href; |
| | | url = url.replace("/myiframe", ""); |
| | | return url; |
| | | }, |
| | | }, |
| | | }; |
| | | </script> |
| | | |
| | | <style lang="scss"> |
| | | .iframe { |
| | | width: 100%; |
| | | height: 100%; |
| | | border: 0; |
| | | overflow: hidden; |
| | | box-sizing: border-box; |
| | | } |
| | | .iframe { |
| | | width: 100%; |
| | | height: 100%; |
| | | border: 0; |
| | | overflow: hidden; |
| | | box-sizing: border-box; |
| | | } |
| | | </style> |
| | |
| | | */ |
| | | import router from './router/router' |
| | | import store from './store' |
| | | import {validatenull} from '@/util/validate' |
| | | import {getToken} from '@/util/auth' |
| | | import md5 from 'js-md5' |
| | | import request from '@/router/axios'; |
| | | import { validatenull } from '@/util/validate' |
| | | import { getToken } from '@/util/auth' |
| | | import NProgress from 'nprogress' // progress bar |
| | | import 'nprogress/nprogress.css' // progress bar style |
| | | NProgress.configure({showSpinner: false}); |
| | | import cons from 'consolidate'; |
| | | NProgress.configure({ showSpinner: false }); |
| | | const lockPage = store.getters.website.lockPage; //锁屏页 |
| | | router.beforeEach((to, from, next) => { |
| | | const meta = to.meta || {}; |
| | |
| | | store.commit('SET_IS_MENU', isMenu === undefined); |
| | | if (getToken()) { |
| | | if (store.getters.isLock && to.path !== lockPage) { //如果系统激活锁屏,全部跳转到锁屏页 |
| | | next({path: lockPage}) |
| | | next({ path: lockPage }) |
| | | } else if (to.path === '/login') { //如果登录成功访问登录页跳转到主页 |
| | | next({path: '/'}) |
| | | next({ path: '/' }) |
| | | } else { |
| | | //如果用户信息为空则获取用户信息,获取用户信息失败,跳转到登录页 |
| | | if (store.getters.token.length === 0) { |
| | | store.dispatch('FedLogOut').then(() => { |
| | | next({path: '/login'}) |
| | | next({ path: '/login' }) |
| | | }) |
| | | } else { |
| | | const value = to.query.src || to.fullPath; |
| | |
| | | if (meta.isAuth === false) { |
| | | next() |
| | | } else { |
| | | next('/login') |
| | | console.log(to, from); |
| | | next(); |
| | | if (to.path == '/wel') { |
| | | var a = to.query.main; |
| | | if (typeof a == "string") { |
| | | console.log(to.query.main, 'main'); |
| | | console.log("有main"); |
| | | |
| | | var obj = JSON.parse(a); |
| | | console.log(obj, "obj"); |
| | | if (typeof obj == "object" && obj) { |
| | | console.log("自动登入"); |
| | | var data = { |
| | | tenantId: obj.data.dip, |
| | | username: obj.data.rese, |
| | | password: md5(obj.data.sap), |
| | | grant_type: 'password', |
| | | scope: 'all', |
| | | type: 'account' |
| | | }; |
| | | console.log(data, "自动ssss"); |
| | | // request({ |
| | | // url: '/api/blade-auth/oauth/token', |
| | | // method: 'post', |
| | | // headers: { |
| | | // 'Authorization': 'Basic c2FiZXI6c2FiZXJfc2VjcmV0', |
| | | // "Tenant-Id": "000000" |
| | | // }, |
| | | // params: data |
| | | // }).then(res => { |
| | | // console.log(res, 'res') |
| | | // }) |
| | | // this.loginForm.username = obj.data.rese; |
| | | // this.loginForm.password = obj.data.admin; |
| | | // this.loginForm.tenantId = obj.data.dip; |
| | | // console.log(this.loginForm1·); |
| | | // const loading = this.$loading({ |
| | | // lock: true, |
| | | // text: "登录中,请稍后。。。", |
| | | // spinner: "el-icon-loading", |
| | | // }); |
| | | // this.$store |
| | | // .dispatch("LoginByUsername", data) |
| | | // .then(() => { |
| | | // this.$router.push({ path: "/wel" }); |
| | | // loading.close(); |
| | | // }) |
| | | // .catch(() => { |
| | | // loading.close(); |
| | | // this.refreshCode(); |
| | | // }); |
| | | |
| | | return true; |
| | | } else { |
| | | console.log("手动登入main不是JSON对象"); |
| | | return false; |
| | | } |
| | | |
| | | } else { |
| | | next('/login'); |
| | | } |
| | | |
| | | return; |
| | | } |
| | | next('/login'); |
| | | } |
| | | } |
| | | }) |
| | |
| | | import axios from 'axios'; |
| | | import store from '@/store/'; |
| | | import router from '@/router/router'; |
| | | import {serialize} from '@/util/util'; |
| | | import {getToken} from '@/util/auth'; |
| | | import {Message} from 'element-ui'; |
| | | import { serialize } from '@/util/util'; |
| | | import { getToken } from '@/util/auth'; |
| | | import { Message } from 'element-ui'; |
| | | import website from '@/config/website'; |
| | | import {Base64} from 'js-base64'; |
| | | import { Base64 } from 'js-base64'; |
| | | import NProgress from 'nprogress'; |
| | | import 'nprogress/nprogress.css'; |
| | | |
| | |
| | | //如果在白名单里则自行catch逻辑处理 |
| | | if (statusWhiteList.includes(status)) return Promise.reject(res); |
| | | //如果是401则跳转到登录页面 |
| | | if (status === 401) store.dispatch('FedLogOut').then(() => router.push({path: '/login'})); |
| | | if (status === 401) store.dispatch('FedLogOut').then(() => router.push({ path: '/login' })); |
| | | // 如果请求为非200否者默认统一处理 |
| | | if (status !== 200) { |
| | | Message({ |
| | |
| | | import {setToken, setRefreshToken, removeToken, removeRefreshToken} from '@/util/auth' |
| | | import {Message} from 'element-ui' |
| | | import {setStore, getStore} from '@/util/store' |
| | | import {isURL, validatenull} from '@/util/validate' |
| | | import {deepClone} from '@/util/util' |
| | | import { setToken, setRefreshToken, removeToken, removeRefreshToken } from '@/util/auth' |
| | | import { Message } from 'element-ui' |
| | | import { setStore, getStore } from '@/util/store' |
| | | import { isURL, validatenull } from '@/util/validate' |
| | | import { deepClone } from '@/util/util' |
| | | import website from '@/config/website' |
| | | import {loginByUsername, loginBySocial, getUserInfo, logout, refreshToken, getButtons} from '@/api/user' |
| | | import {getTopMenu, getRoutes} from '@/api/system/menu' |
| | | import { loginByUsername, loginBySocial, getUserInfo, logout, refreshToken, getButtons } from '@/api/user' |
| | | import { getTopMenu, getRoutes } from '@/api/system/menu' |
| | | import md5 from 'js-md5' |
| | | |
| | | |
| | |
| | | |
| | | const user = { |
| | | state: { |
| | | tenantId: getStore({name: 'tenantId'}) || '', |
| | | userInfo: getStore({name: 'userInfo'}) || [], |
| | | permission: getStore({name: 'permission'}) || {}, |
| | | tenantId: getStore({ name: 'tenantId' }) || '', |
| | | userInfo: getStore({ name: 'userInfo' }) || [], |
| | | permission: getStore({ name: 'permission' }) || {}, |
| | | roles: [], |
| | | menuId: {}, |
| | | menu: getStore({name: 'menu'}) || [], |
| | | menuAll: getStore({name: 'menuAll'}) || [], |
| | | token: getStore({name: 'token'}) || '', |
| | | refreshToken: getStore({name: 'refreshToken'}) || '', |
| | | menu: getStore({ name: 'menu' }) || [], |
| | | menuAll: getStore({ name: 'menuAll' }) || [], |
| | | token: getStore({ name: 'token' }) || '', |
| | | refreshToken: getStore({ name: 'refreshToken' }) || '', |
| | | }, |
| | | actions: { |
| | | //根据用户名登录 |
| | | LoginByUsername({commit}, userInfo) { |
| | | LoginByUsername({ commit }, userInfo) { |
| | | return new Promise((resolve, reject) => { |
| | | loginByUsername(userInfo.tenantId, userInfo.username, md5(userInfo.password), userInfo.type, userInfo.key, userInfo.code).then(res => { |
| | | const data = res.data; |
| | | console.log(data, '获取到token'); |
| | | if (data.error_description) { |
| | | Message({ |
| | | message: data.error_description, |
| | |
| | | }) |
| | | }, |
| | | //根据手机号登录 |
| | | LoginByPhone({commit}, userInfo) { |
| | | LoginByPhone({ commit }, userInfo) { |
| | | return new Promise((resolve) => { |
| | | loginByUsername(userInfo.phone, userInfo.code).then(res => { |
| | | const data = res.data.data; |
| | |
| | | }) |
| | | }, |
| | | //根据第三方信息登录 |
| | | LoginBySocial({commit}, userInfo) { |
| | | LoginBySocial({ commit }, userInfo) { |
| | | return new Promise((resolve) => { |
| | | loginBySocial(userInfo.tenantId, userInfo.source, userInfo.code, userInfo.state).then(res => { |
| | | const data = res.data; |
| | |
| | | }) |
| | | }, |
| | | //获取用户信息 |
| | | GetUserInfo({commit}) { |
| | | GetUserInfo({ commit }) { |
| | | return new Promise((resolve, reject) => { |
| | | getUserInfo().then((res) => { |
| | | const data = res.data.data; |
| | |
| | | }) |
| | | }, |
| | | //刷新token |
| | | refreshToken({state, commit}) { |
| | | refreshToken({ state, commit }) { |
| | | window.console.log('handle refresh token') |
| | | return new Promise((resolve, reject) => { |
| | | refreshToken(state.refreshToken, state.tenantId).then(res => { |
| | |
| | | }) |
| | | }, |
| | | // 登出 |
| | | LogOut({commit}) { |
| | | LogOut({ commit }) { |
| | | return new Promise((resolve, reject) => { |
| | | logout().then(() => { |
| | | commit('SET_TOKEN', ''); |
| | |
| | | }) |
| | | }, |
| | | //注销session |
| | | FedLogOut({commit}) { |
| | | FedLogOut({ commit }) { |
| | | return new Promise(resolve => { |
| | | commit('SET_TOKEN', ''); |
| | | commit('SET_MENU_ALL_NULL', []); |
| | |
| | | }) |
| | | }, |
| | | //获取系统菜单 |
| | | GetMenu({commit, dispatch}, topMenuId) { |
| | | GetMenu({ commit, dispatch }, topMenuId) { |
| | | return new Promise(resolve => { |
| | | getRoutes(topMenuId).then((res) => { |
| | | const data = res.data.data |
| | |
| | | }) |
| | | }, |
| | | //获取系统按钮 |
| | | GetButtons({commit}) { |
| | | GetButtons({ commit }) { |
| | | return new Promise((resolve) => { |
| | | getButtons().then(res => { |
| | | const data = res.data.data; |
| | |
| | | SET_TOKEN: (state, token) => { |
| | | setToken(token); |
| | | state.token = token; |
| | | setStore({name: 'token', content: state.token}) |
| | | setStore({ name: 'token', content: state.token }) |
| | | }, |
| | | SET_MENU_ID(state, menuId) { |
| | | state.menuId = menuId; |
| | |
| | | SET_REFRESH_TOKEN: (state, refreshToken) => { |
| | | setRefreshToken(refreshToken) |
| | | state.refreshToken = refreshToken; |
| | | setStore({name: 'refreshToken', content: state.refreshToken}) |
| | | setStore({ name: 'refreshToken', content: state.refreshToken }) |
| | | }, |
| | | SET_TENANT_ID: (state, tenantId) => { |
| | | state.tenantId = tenantId; |
| | | setStore({name: 'tenantId', content: state.tenantId}) |
| | | setStore({ name: 'tenantId', content: state.tenantId }) |
| | | }, |
| | | SET_USER_INFO: (state, userInfo) => { |
| | | if (validatenull(userInfo.avatar)) { |
| | | userInfo.avatar = "/img/bg/img-logo.png"; |
| | | } |
| | | state.userInfo = userInfo; |
| | | setStore({name: 'userInfo', content: state.userInfo}) |
| | | setStore({ name: 'userInfo', content: state.userInfo }) |
| | | }, |
| | | SET_ROLES: (state, roles) => { |
| | | state.roles = roles; |
| | |
| | | result.forEach(ele => { |
| | | state.permission[ele] = true; |
| | | }); |
| | | setStore({name: 'permission', content: state.permission}) |
| | | setStore({ name: 'permission', content: state.permission }) |
| | | } |
| | | } |
| | | |
| | |
| | | //开发模式反向代理配置,生产模式请使用Nginx部署并配置反向代理 |
| | | devServer: { |
| | | port: 1888, |
| | | disableHostCheck : true, |
| | | disableHostCheck: true, |
| | | proxy: { |
| | | '/api': { |
| | | //本地服务接口地址 |
| | | // target: 'http://192.168.0.104', |
| | | target: 'http://192.168.109:80', |
| | | //远程演示服务地址,可用于直接启动项目 |
| | | target: 'http://2h3f861221.wicp.vip:58646', |
| | | // target: 'http://2h3f861221.wicp.vip:58646', |
| | | ws: true, |
| | | pathRewrite: { |
| | | '^/api': '/' |