Explorar o código

1、添加扫码登录功能,并添加跳转

fuwb hai 3 meses
pai
achega
e58eb11222

+ 3 - 1
client/.env.dev

@@ -5,6 +5,7 @@ VITE_DEV=false
 
 # 请求路径
 VITE_BASE_URL='http://60.191.110.205:28080'
+# VITE_BASE_URL='http://127.0.0.1:48080'
 
 # 上传路径
 VITE_UPLOAD_URL='/infra/file/upload'
@@ -19,7 +20,8 @@ VITE_UPLOAD_CLIENT_ID=20
 VITE_FILE_BASE_URI='/infra/file'
 
 # 流程详情页面路径
-VITE_PROCESS_DETAIL_URI = 'http:/60.191.110.205:48080/workflow'
+VITE_PROCESS_DETAIL_URI = 'http://60.191.110.205:28080/workflow'
+# VITE_PROCESS_DETAIL_URI = 'http://127.0.0.1:48080/workflow'
 
 # 接口前缀
 VITE_API_BASEPATH=/dev-api

+ 40 - 8
client/src/views/Login/OALogin.vue

@@ -51,10 +51,13 @@
 import * as LoginApi from '@/api/login'
 import { useRouter } from 'vue-router'
 import { useAppStore } from '@/store/modules/app'
+import * as authUtil from '@/utils/auth'
 defineOptions({ name: 'OALogin' })
 const appStore = useAppStore()
 const oaLoginTitle = ref(appStore.title)
 const dingCodeLogin = ref()
+const loading = ref()
+const loginLoading = ref(false)
 const redirect = ref<string>('')
 const { currentRoute, push } = useRouter()
 import { usePermissionStore } from '@/store/modules/permission'
@@ -68,13 +71,42 @@ const init = async (type) => {
     dingCodeLogin.value = res
   }
 }
-const handleMessage = (event) => {
-  var origin = event.origin
-  let loginBox: any = document.querySelector('.loginBox')
-  if (loginBox) {
-    loginBox.style = 'width:100%;height:100%;top:0;right:0;margin:0'
-    let iframe: any = document.querySelector('#iframe')
-    iframe.style = 'height:100%'
+const handleMessage = async (event) => {
+  try {
+    var origin = event.origin
+    const res = await LoginApi.socialLogin({
+      type: 20,
+      code: event.data.code,
+      state: event.data.state
+    })
+    if (!res) {
+      return
+    }
+    // socialLoading.value = ElLoading.service({
+    //   lock: true,
+    //   text: '正在加载系统中...',
+    //   background: 'rgba(0, 0, 0, 0.7)'
+    // })
+    authUtil.setToken(res)
+    if (!redirect.value) {
+      redirect.value = '/'
+    }
+    // 判断是否为SSO登录
+    if (redirect.value.indexOf('sso') !== -1) {
+      window.location.href = window.location.href.replace('/login?redirect=', '')
+    } else {
+      // push({ path: redirect.value || permissionStore.addRouters[0].path })
+      window.parent.pushWin() //触发iframe父页面的方法
+    }
+    // let loginBox: any = document.querySelector('.qr_login')
+    // if (loginBox) {
+    //   loginBox.style = 'width:100%;height:100%;top:0;right:0;margin:0'
+    //   let iframe: any = document.querySelector('#iframe')
+    //   iframe.style = 'height:100%'
+    // }
+  } finally {
+    loginLoading.value = false
+    loading.value.close()
   }
 }
 onMounted(() => {
@@ -201,7 +233,7 @@ onMounted(() => {
         &.qr_login {
           flex: 1;
           > .qr_box {
-            height: 200px;
+            height: 300px;
             iframe {
               height: 100%;
             }

+ 5 - 5
client/src/views/OaSystem/oaLayout/menus.vue

@@ -65,9 +65,9 @@ const userName = user.user.nickname ? user.user.nickname : 'Admin'
 
 const deptName = user.user.deptName ? user.user.deptName : '部门信息'
 const userId = user.user.id // 当前登录的编号
-const { data } = useQuery(['fetch-staff-detail-left', userId], async () => {
-  return await getRecordsDetail({ userId })
-})
+// const { data } = useQuery(['fetch-staff-detail-left', userId], async () => {
+//   return await getRecordsDetail({ userId })
+// })
 // 获取assets静态资源
 const getAssetsFile = (url: string) => {
   return new URL(`../../../assets/imgs/menu/${url}`, import.meta.url).href
@@ -123,14 +123,14 @@ const reactiveData: any = reactive({
 const initMenus = async () => {
   let locals: any = localStorage.getItem('roleRouters')
   let roleRouters = JSON.parse(JSON.parse(locals).v)?.[0]?.children
-
+  console.log(roleRouters)
   let childArr = roleRouters?.slice(0, roleRouters?.length)
   reactiveData.routes = childArr
 }
 
 const menuClick = (item: any, idx: any) => {
   if (item.children == null) {
-    push('/oaSystem/' + item.path)
+    push('/OaSystem/' + item.path)
   } else {
     return
   }