辽宁单点登录

This commit is contained in:
cdf
2026-06-15 17:57:14 +08:00
parent 9224ea17b8
commit 765507398e
4 changed files with 237 additions and 181 deletions

View File

@@ -1,5 +1,5 @@
<template>
<div @keyup.enter="onSubmit(formRef)">
<div v-if='!VITE_FLAG' @keyup.enter="onSubmit(formRef)">
<div @contextmenu.stop="" id="bubble" class="bubble">
<canvas id="bubble-canvas" class="bubble-canvas"></canvas>
</div>
@@ -67,7 +67,6 @@
<script setup lang="ts">
import { onMounted, onBeforeUnmount, reactive, ref, nextTick } from 'vue'
import * as pageBubble from '@/utils/pageBubble'
import { ElMessage } from 'element-plus'
import { gongkey, login, getSysConfig, loginLNqr } from '@/api/user-boot/user'
import { useAdminInfo } from '@/stores/adminInfo'
import type { FormInstance, InputInstance, FormRules } from 'element-plus'
@@ -78,6 +77,7 @@ import { getTheme } from '@/api/systerm'
import { useConfig } from '@/stores/config'
import PopupUpdatePwd from './popupUpdatePwd.vue'
const VITE_FLAG = import.meta.env.VITE_NAME == 'LNqr'
const router = useRouter()
let timer: number
const configStore = useConfig()
@@ -185,33 +185,84 @@ const onSubmit = async (formEl: FormInstance | undefined) => {
}
})
}
const LNonSubmit = async () => {
/*const LNonSubmit = async () => {
state.submitLoading = true
loginLNqr()
.then(res => {
//返回 a
//拿到token了可以正常操作页面
userInfo.dataFill(res.data)
state.submitLoading = false
getSysConfig().then(res => {
window.localStorage.setItem('sysdata', JSON.stringify(res.data))
})
router.push({
path: '/'
})
})
.catch(err => {
console.log("---------")
console.log(err)
//
window.location.href = "http://privilege-epri.dcloud.ln.dc.sgcc.com.cn/cas/login"
})
lnToken().then(res => {
console.log(555)
loginLNqr().then(res => {
//拿到token了可以正常操作页面
userInfo.dataFill(res.data)
state.submitLoading = false
getSysConfig().then(res => {
window.localStorage.setItem('sysdata', JSON.stringify(res.data))
})
router.push({
path: '/'
})
}).catch(err => {
console.log("---------")
console.log(err)
//
//window.location.href = "http://privilege-epri.dcloud.ln.dc.sgcc.com.cn/cas/login"
})
})
setTimeout(() => {
state.submitLoading = false
}, 500)
}*/
// ========== 修改CAS 无感登录 ==========
const LNonSubmit = async () => {
// 先检查是否是 CAS 回调
if (handleCasCallback()) {
console.log("进入回调")
return
}
// 没有 token触发 CAS 登录流程
console.log('无 token触发 CAS 登录')
// 跳转到后端 CAS 认证入口
window.location.href = '/api/pqs-auth/oauth/lnCheck'
}
// ========== 新增:处理 CAS 回调 ==========
const handleCasCallback = () => {
const hash = window.location.hash
const queryIndex = hash.indexOf('?')
if (queryIndex === -1) return false
console.log(hash)
const hashParams = new URLSearchParams(hash.substring(queryIndex + 1))
if (hashParams.get('flag') !== '1') return false
// 清理 URL 中的 flag 参数,防止刷新重复触发
const cleanHash = hash.substring(0, queryIndex)
window.history.replaceState(null, '', cleanHash)
if(hashParams && hashParams.get("flag") == 1){
state.submitLoading = true
let data = {clientId:"njcn",clientSecret:"njcnpqs"}
loginLNqr(data).then(res => {
//拿到token了可以正常操作页面
userInfo.dataFill(res.data)
state.submitLoading = false
getSysConfig().then(res => {
window.localStorage.setItem('sysdata', JSON.stringify(res.data))
})
router.push({
path: '/'
})
}).catch(err => {
console.log("---------")
console.log(err)
state.submitLoading = false
})
}else {
return false
}
return true
}
defineExpose({ VITE_FLAG })
</script>
<style scoped lang="scss">
@@ -367,3 +418,5 @@ const LNonSubmit = async () => {
}
}
</style>