diff --git a/yudao-ui-admin/.env.demo1024 b/yudao-ui-admin/.env.demo1024 index 21f48d031..93ee78843 100644 --- a/yudao-ui-admin/.env.demo1024 +++ b/yudao-ui-admin/.env.demo1024 @@ -19,3 +19,6 @@ VUE_APP_TENANT_ENABLE = true # 文档的开关 VUE_APP_DOC_ENABLE = true + +# 百度统计 +VUE_APP_BAIDU_CODE = fadc1bd5db1a1d6f581df60a1807f8ab diff --git a/yudao-ui-admin/.env.development b/yudao-ui-admin/.env.development index e7841a631..2c9b7fd98 100644 --- a/yudao-ui-admin/.env.development +++ b/yudao-ui-admin/.env.development @@ -16,3 +16,6 @@ VUE_APP_TENANT_ENABLE = true # 文档的开关 VUE_APP_DOC_ENABLE = true + +# 百度统计 +VUE_APP_BAIDU_CODE = fadc1bd5db1a1d6f581df60a1807f8ab diff --git a/yudao-ui-admin/.env.production b/yudao-ui-admin/.env.production index 377f92f1b..5deaf75fc 100644 --- a/yudao-ui-admin/.env.production +++ b/yudao-ui-admin/.env.production @@ -17,3 +17,6 @@ VUE_APP_TENANT_ENABLE = true # 文档的开关 VUE_APP_DOC_ENABLE = false + +# 百度统计 +VUE_APP_BAIDU_CODE = fadc1bd5db1a1d6f581df60a1807f8ab diff --git a/yudao-ui-admin/.env.staging b/yudao-ui-admin/.env.staging index cb7b007b1..7526f2680 100644 --- a/yudao-ui-admin/.env.staging +++ b/yudao-ui-admin/.env.staging @@ -17,3 +17,6 @@ VUE_APP_TENANT_ENABLE = true # 文档的开关 VUE_APP_DOC_ENABLE = false + +# 百度统计 +VUE_APP_BAIDU_CODE = fadc1bd5db1a1d6f581df60a1807f8ab diff --git a/yudao-ui-admin/src/main.js b/yudao-ui-admin/src/main.js index 8252a97b2..f5d264908 100644 --- a/yudao-ui-admin/src/main.js +++ b/yudao-ui-admin/src/main.js @@ -15,6 +15,7 @@ import plugins from './plugins' // plugins import './assets/icons' // icon import './permission' // permission control +import './tongji' // 百度统计 import { getDicts } from "@/api/system/dict/data"; import { getConfigKey } from "@/api/infra/config"; import { parseTime, resetForm, addDateRange, addBeginAndEndTime, handleTree} from "@/utils/ruoyi"; diff --git a/yudao-ui-admin/src/permission.js b/yudao-ui-admin/src/permission.js index 0dc85ed2f..57cad56f3 100644 --- a/yudao-ui-admin/src/permission.js +++ b/yudao-ui-admin/src/permission.js @@ -4,9 +4,11 @@ import { Message } from 'element-ui' import NProgress from 'nprogress' import 'nprogress/nprogress.css' import { getToken } from '@/utils/auth' +import { isRelogin } from '@/utils/request' NProgress.configure({ showSpinner: false }) +// 增加三方登陆 update by 芋艿 const whiteList = ['/login', '/social-login', '/auth-redirect', '/bind', '/register', '/oauthLogin/gitee'] router.beforeEach((to, from, next) => { @@ -19,21 +21,23 @@ router.beforeEach((to, from, next) => { NProgress.done() } else { if (store.getters.roles.length === 0) { - // 获取字典数据 + isRelogin.show = true + // 获取字典数据 add by 芋艿 store.dispatch('dict/loadDictDatas') // 判断当前用户是否已拉取完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: '/' }) - }) + store.dispatch('LogOut').then(() => { + Message.error(err) + next({ path: '/' }) }) + }) } else { next() } diff --git a/yudao-ui-admin/src/tongji.js b/yudao-ui-admin/src/tongji.js new file mode 100644 index 000000000..0f24bb0b6 --- /dev/null +++ b/yudao-ui-admin/src/tongji.js @@ -0,0 +1,21 @@ +// Baidu 统计 integration +import router from './router' + +window._hmt = window._hmt || []; // 用于 router push +const HM_ID = process.env.VUE_APP_BAIDU_CODE || ''; // 有值的时候,才开启 +(function() { + if (!HM_ID) { + return; + } + const hm = document.createElement("script") + hm.src = "https://hm.baidu.com/hm.js?" + HM_ID + const s = document.getElementsByTagName("script")[0] + s.parentNode.insertBefore(hm, s) +})() + +router.afterEach(function (to) { + if (!HM_ID) { + return; + } + _hmt.push(['_trackPageview', to.fullPath]) +}) diff --git a/yudao-ui-admin/src/utils/dict.js b/yudao-ui-admin/src/utils/dict.js index 2e7d0a090..fd3efe512 100644 --- a/yudao-ui-admin/src/utils/dict.js +++ b/yudao-ui-admin/src/utils/dict.js @@ -96,7 +96,7 @@ export function getDictDatas2(dictType, values) { } } // debugger - console.log(results); + // console.log(results); return results; } diff --git a/yudao-ui-admin/src/utils/request.js b/yudao-ui-admin/src/utils/request.js index 0ea9c69f4..cf716e6d3 100644 --- a/yudao-ui-admin/src/utils/request.js +++ b/yudao-ui-admin/src/utils/request.js @@ -7,7 +7,7 @@ import Cookies from "js-cookie"; import {getTenantEnable} from "@/utils/ruoyi"; // 是否显示重新登录 -let isReloginShow; +export let isRelogin = { show: false }; axios.defaults.headers['Content-Type'] = 'application/json;charset=utf-8' // 创建axios实例 @@ -66,23 +66,20 @@ service.interceptors.response.use(res => { // 获取错误信息 const msg = errorCode[code] || res.data.msg || errorCode['default'] if (code === 401) { - if (!isReloginShow) { - isReloginShow = true; + if (!isRelogin.show) { + isRelogin.show = true; MessageBox.confirm('登录状态已过期,您可以继续留在该页面,或者重新登录', '系统提示', { confirmButtonText: '重新登录', cancelButtonText: '取消', type: 'warning' } ).then(() => { - isReloginShow = false; + isRelogin.show = false; store.dispatch('LogOut').then(() => { - // 如果是登录页面不需要重新加载 - if (window.location.hash.indexOf("#/login") !== 0) { - location.href = '/index'; - } + location.href = '/index'; }) }).catch(() => { - isReloginShow = false; + isRelogin.show = false; }); } return Promise.reject('无效的会话,或者会话已过期,请重新登录。') diff --git a/yudao-ui-admin/src/views/socialLogin.vue b/yudao-ui-admin/src/views/socialLogin.vue index 6f8aee945..01d19578f 100644 --- a/yudao-ui-admin/src/views/socialLogin.vue +++ b/yudao-ui-admin/src/views/socialLogin.vue @@ -28,7 +28,6 @@