辽宁单点登录
This commit is contained in:
@@ -44,13 +44,30 @@ export async function login(params: any) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
//辽宁嵌入登录获取token
|
//辽宁嵌入登录获取token
|
||||||
export async function loginLNqr() {
|
export async function loginLNqr(data: any) {
|
||||||
return request({
|
return request({
|
||||||
url: '/pqs-auth/oauth/lnLogin',
|
url: '/pqs-auth/oauth/lnLogin',
|
||||||
method: 'get',
|
method: 'get',
|
||||||
|
params: data
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function lnRefreshToken(data: any) {
|
||||||
|
return request({
|
||||||
|
url: '/pqs-auth/oauth/lnRefreshToken',
|
||||||
|
method: 'get',
|
||||||
|
params: data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function logout() {
|
||||||
|
return request({
|
||||||
|
url: '/pqs-auth/oauth/logout',
|
||||||
|
method: 'DELETE',
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//获取用户信息
|
//获取用户信息
|
||||||
export function getUserById() {
|
export function getUserById() {
|
||||||
const adminInfo = useAdminInfo()
|
const adminInfo = useAdminInfo()
|
||||||
@@ -77,6 +94,17 @@ export function refreshToken(): Promise<any> {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export function lnRefreshTokenTo(): Promise<any> {
|
||||||
|
// 调用useAdminInfo函数获取管理员信息,并将其赋值给adminInfo变量
|
||||||
|
const adminInfo = useAdminInfo()
|
||||||
|
return lnRefreshToken({
|
||||||
|
refreshToken: adminInfo.refresh_token,
|
||||||
|
clientId: "njcn",
|
||||||
|
clientSecret:"njcnpqs"
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取营销用户列表
|
* 获取营销用户列表
|
||||||
* @returns {AxiosPromise}
|
* @returns {AxiosPromise}
|
||||||
|
|||||||
@@ -8,41 +8,17 @@
|
|||||||
name="el-icon-BellFilled"
|
name="el-icon-BellFilled"
|
||||||
size="18"
|
size="18"
|
||||||
/>
|
/>
|
||||||
<span class="nav-menu-text" v-if="globalPopUpRef?.eventList.length != 0">
|
<span
|
||||||
{{ (globalPopUpRef?.eventList.length>99? '99+':globalPopUpRef?.eventList.length) || 0 }}
|
class="nav-menu-text"
|
||||||
|
v-if="globalPopUpRef?.eventList?.length > 0"
|
||||||
|
>
|
||||||
|
{{ globalPopUpRef.eventList.length > 99 ? '99+' : globalPopUpRef.eventList.length }}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</el-tooltip>
|
</el-tooltip>
|
||||||
<!-- <el-tooltip effect="dark" content="截图" placement="bottom">
|
|
||||||
<div @click="savePng" class="nav-menu-item">
|
|
||||||
<Icon
|
|
||||||
:color="configStore.getColorVal('headerBarTabColor')"
|
|
||||||
class="nav-menu-icon"
|
|
||||||
name="el-icon-Camera"
|
|
||||||
size="18"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</el-tooltip>
|
|
||||||
<el-tooltip effect="dark" :content="state.isFullScreen ? '缩小' : '放大'" placement="bottom">
|
|
||||||
<div @click="onFullScreen" class="nav-menu-item" :class="state.isFullScreen ? 'hover' : ''">
|
|
||||||
<Icon
|
|
||||||
:color="configStore.getColorVal('headerBarTabColor')"
|
|
||||||
class="nav-menu-icon"
|
|
||||||
v-if="state.isFullScreen"
|
|
||||||
name="fa-solid fa-compress"
|
|
||||||
size="18"
|
|
||||||
/>
|
|
||||||
<Icon
|
|
||||||
:color="configStore.getColorVal('headerBarTabColor')"
|
|
||||||
class="nav-menu-icon"
|
|
||||||
v-else
|
|
||||||
name="fa-solid fa-expand"
|
|
||||||
size="18"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</el-tooltip> -->
|
|
||||||
<el-dropdown style="height: 100%" @command="handleCommand">
|
<el-dropdown style="height: 100%" @command="handleCommand">
|
||||||
<div class="admin-info" :class="state.currentNavMenu == 'adminInfo' ? 'hover' : ''">
|
<div class="admin-info" :class="state.currentNavMenu === 'adminInfo' ? 'hover' : ''">
|
||||||
<el-avatar :size="25" fit="fill">
|
<el-avatar :size="25" fit="fill">
|
||||||
<img src="@/assets/avatar.png" alt="" />
|
<img src="@/assets/avatar.png" alt="" />
|
||||||
</el-avatar>
|
</el-avatar>
|
||||||
@@ -52,104 +28,114 @@
|
|||||||
<el-dropdown-menu>
|
<el-dropdown-menu>
|
||||||
<el-dropdown-item command="adminInfo">个人资料</el-dropdown-item>
|
<el-dropdown-item command="adminInfo">个人资料</el-dropdown-item>
|
||||||
<el-dropdown-item command="changePwd">修改密码</el-dropdown-item>
|
<el-dropdown-item command="changePwd">修改密码</el-dropdown-item>
|
||||||
<el-dropdown-item command="layout">退出登录</el-dropdown-item>
|
<el-dropdown-item command="logout">退出登录</el-dropdown-item>
|
||||||
</el-dropdown-menu>
|
</el-dropdown-menu>
|
||||||
</template>
|
</template>
|
||||||
</el-dropdown>
|
</el-dropdown>
|
||||||
<!-- <div @click="configStore.setLayout('showDrawer', true)" class="nav-menu-item">
|
|
||||||
<Icon
|
|
||||||
:color="configStore.getColorVal('headerBarTabColor')"
|
|
||||||
class="nav-menu-icon"
|
|
||||||
name="fa fa-cogs"
|
|
||||||
size="18"
|
|
||||||
/>
|
|
||||||
</div> -->
|
|
||||||
<Config />
|
<Config />
|
||||||
<PopupPwd ref="popupPwd" />
|
<PopupPwd ref="popupPwd" />
|
||||||
<AdminInfo ref="popupAdminInfo" />
|
<AdminInfo ref="popupAdminInfo" />
|
||||||
<!-- <TerminalVue /> -->
|
|
||||||
<!-- 全局暂降事件 -->
|
|
||||||
<globalPopUp ref="globalPopUpRef" />
|
<globalPopUp ref="globalPopUpRef" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { reactive, ref } from 'vue'
|
import { reactive, ref } from 'vue'
|
||||||
import screenfull from 'screenfull'
|
|
||||||
import { useConfig } from '@/stores/config'
|
import { useConfig } from '@/stores/config'
|
||||||
import { ElMessage } from 'element-plus'
|
|
||||||
import Config from './config.vue'
|
|
||||||
import { useAdminInfo } from '@/stores/adminInfo'
|
import { useAdminInfo } from '@/stores/adminInfo'
|
||||||
import router from '@/router'
|
import { useNavTabs } from '@/stores/navTabs'
|
||||||
import globalPopUp from './globalPopUp.vue'
|
import { logout } from '@/api/user-boot/user'
|
||||||
import { routePush } from '@/utils/router'
|
import Config from './config.vue'
|
||||||
import html2canvas from 'html2canvas'
|
|
||||||
import PopupPwd from './popup/password.vue'
|
import PopupPwd from './popup/password.vue'
|
||||||
import AdminInfo from './popup/adminInfo.vue'
|
import AdminInfo from './popup/adminInfo.vue'
|
||||||
import { useNavTabs } from '@/stores/navTabs'
|
|
||||||
|
// 环境标识
|
||||||
|
const IS_LNQR = import.meta.env.VITE_NAME === 'LNqr'
|
||||||
|
|
||||||
const adminInfo = useAdminInfo()
|
const adminInfo = useAdminInfo()
|
||||||
const navTabs = useNavTabs()
|
const navTabs = useNavTabs()
|
||||||
const configStore = useConfig()
|
const configStore = useConfig()
|
||||||
|
|
||||||
|
// 引用
|
||||||
const popupPwd = ref()
|
const popupPwd = ref()
|
||||||
const popupAdminInfo = ref()
|
const popupAdminInfo = ref()
|
||||||
const state = reactive({
|
|
||||||
isFullScreen: false,
|
|
||||||
currentNavMenu: '',
|
|
||||||
showLayoutDrawer: false,
|
|
||||||
showAdminInfoPopover: false
|
|
||||||
})
|
|
||||||
const globalPopUpRef = ref()
|
const globalPopUpRef = ref()
|
||||||
const savePng = () => {
|
|
||||||
html2canvas(document.body, {
|
// 状态
|
||||||
scale: 1,
|
const state = reactive({
|
||||||
useCORS: true
|
currentNavMenu: '',
|
||||||
}).then(function (canvas) {
|
})
|
||||||
var link = document.createElement('a')
|
|
||||||
link.href = canvas.toDataURL('image/png')
|
// 打开暂降事件
|
||||||
link.download = 'screenshot.png'
|
const temporaryLandingEvent = () => {
|
||||||
link.click()
|
if (globalPopUpRef.value) {
|
||||||
})
|
globalPopUpRef.value.open()
|
||||||
}
|
|
||||||
const onFullScreen = () => {
|
|
||||||
if (!screenfull.isEnabled) {
|
|
||||||
ElMessage.warning('layouts.Full screen is not supported')
|
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
screenfull.toggle()
|
|
||||||
screenfull.onchange(() => {
|
|
||||||
state.isFullScreen = screenfull.isFullscreen
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleCommand = async(key: string) => {
|
// 下拉菜单命令
|
||||||
console.log(key)
|
const handleCommand = async (key: string) => {
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case 'adminInfo':
|
case 'adminInfo':
|
||||||
popupAdminInfo.value.open()
|
popupAdminInfo.value?.open()
|
||||||
break
|
break
|
||||||
case 'changePwd':
|
case 'changePwd':
|
||||||
popupPwd.value.open()
|
popupPwd.value?.open()
|
||||||
break
|
break
|
||||||
case 'layout':
|
case 'logout':
|
||||||
await window.location.reload()
|
await handleLogout()
|
||||||
setTimeout(() => {
|
|
||||||
navTabs.closeTabs()
|
|
||||||
window.localStorage.clear()
|
|
||||||
adminInfo.reset()
|
|
||||||
router.push({ name: 'login' })
|
|
||||||
}, 0)
|
|
||||||
// navTabs.closeTabs()
|
|
||||||
// window.localStorage.clear()
|
|
||||||
// adminInfo.reset()
|
|
||||||
// router.push({ name: 'login' })
|
|
||||||
break
|
|
||||||
default:
|
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const temporaryLandingEvent = () => {
|
|
||||||
globalPopUpRef.value.open()
|
// 统一登出逻辑
|
||||||
|
const handleLogout = async () => {
|
||||||
|
try {
|
||||||
|
// 1. 调用后端登出接口
|
||||||
|
await logout()
|
||||||
|
console.log('✅ 后端登出成功')
|
||||||
|
} catch (err) {
|
||||||
|
console.error('❌ 登出接口异常', err)
|
||||||
|
} finally {
|
||||||
|
// 2. 清理本地所有数据
|
||||||
|
clearLocalData()
|
||||||
|
|
||||||
|
// 3. LNqr 环境跳 CAS 登出
|
||||||
|
if (IS_LNQR) {
|
||||||
|
redirectToCasLogout()
|
||||||
|
} else {
|
||||||
|
// 普通环境直接跳登录页
|
||||||
|
window.location.href = '/login'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 清理本地数据
|
||||||
|
const clearLocalData = () => {
|
||||||
|
// 清空 localStorage
|
||||||
|
window.localStorage.clear()
|
||||||
|
|
||||||
|
// 清空用户状态
|
||||||
|
adminInfo.reset()
|
||||||
|
|
||||||
|
// 清空标签页
|
||||||
|
navTabs.closeTabs()
|
||||||
|
|
||||||
|
// 清 Cookie
|
||||||
|
document.cookie.split(';').forEach(cookie => {
|
||||||
|
const name = cookie.split('=')[0].trim()
|
||||||
|
document.cookie = `${name}=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;`
|
||||||
|
})
|
||||||
|
|
||||||
|
console.log('✅ 本地数据已全部清空')
|
||||||
|
}
|
||||||
|
|
||||||
|
// CAS 登出跳转
|
||||||
|
const redirectToCasLogout = () => {
|
||||||
|
const casLogoutUrl =
|
||||||
|
'http://privilege-epri.dcloud.ln.dc.sgcc.com.cn/cas/logout?service=http://privilege-epri.dcloud.ln.dc.sgcc.com.cn/cas/login?service=http://PQMonitoring.dcloud.ln.dc.sgcc.com.cn'
|
||||||
|
window.location.href = casLogoutUrl
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -163,7 +149,6 @@ const temporaryLandingEvent = () => {
|
|||||||
height: 60px;
|
height: 60px;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
// height: 100%;
|
|
||||||
margin-left: auto;
|
margin-left: auto;
|
||||||
background-color: v-bind('configStore.getColorVal("headerBarBackground")');
|
background-color: v-bind('configStore.getColorVal("headerBarBackground")');
|
||||||
|
|
||||||
@@ -219,59 +204,20 @@ const temporaryLandingEvent = () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.dropdown-menu-box :deep(.el-dropdown-menu__item) {
|
|
||||||
justify-content: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.admin-info-base {
|
|
||||||
display: flex;
|
|
||||||
justify-content: center;
|
|
||||||
flex-wrap: wrap;
|
|
||||||
padding-top: 10px;
|
|
||||||
|
|
||||||
.admin-info-other {
|
|
||||||
display: block;
|
|
||||||
width: 100%;
|
|
||||||
text-align: center;
|
|
||||||
padding: 10px 0;
|
|
||||||
|
|
||||||
.admin-info-name {
|
|
||||||
font-size: var(--el-font-size-large);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.admin-info-footer {
|
|
||||||
padding: 10px 0;
|
|
||||||
margin: 0 -12px -12px -12px;
|
|
||||||
display: flex;
|
|
||||||
justify-content: space-around;
|
|
||||||
}
|
|
||||||
|
|
||||||
.pt2 {
|
|
||||||
padding-top: 2px;
|
|
||||||
}
|
|
||||||
|
|
||||||
@keyframes twinkle {
|
|
||||||
0% {
|
|
||||||
transform: scale(0);
|
|
||||||
}
|
|
||||||
80% {
|
|
||||||
transform: scale(1.2);
|
|
||||||
}
|
|
||||||
100% {
|
|
||||||
transform: scale(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.nav-menu-text {
|
.nav-menu-text {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 13px;
|
top: 13px;
|
||||||
left: 20px;
|
left: 20px;
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
display: inline-block;
|
background: #ff0000;
|
||||||
background-color: #ff0000;
|
|
||||||
color: #fff;
|
color: #fff;
|
||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
padding: 0 3px;
|
padding: 0 3px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@keyframes twinkle {
|
||||||
|
0% { transform: scale(0); }
|
||||||
|
80% { transform: scale(1.2); }
|
||||||
|
100% { transform: scale(1); }
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
import type { AxiosRequestConfig, Method } from 'axios'
|
import type { AxiosRequestConfig, Method } from 'axios'
|
||||||
import axios from 'axios'
|
import axios from 'axios'
|
||||||
import { ElLoading, ElNotification, type LoadingOptions } from 'element-plus'
|
import { ElLoading, ElNotification, type LoadingOptions } from 'element-plus'
|
||||||
import { refreshToken } from '@/api/user-boot/user'
|
import { lnRefreshToken, lnRefreshTokenTo, refreshToken } from '@/api/user-boot/user'
|
||||||
import router from '@/router/index'
|
import router from '@/router/index'
|
||||||
import { useAdminInfo } from '@/stores/adminInfo'
|
import { useAdminInfo } from '@/stores/adminInfo'
|
||||||
import { debounce } from 'lodash-es'
|
import { debounce } from 'lodash-es'
|
||||||
|
const IS_LN_VERSION = import.meta.env.VITE_NAME === 'LNqr'
|
||||||
let loginExpireTimer: any = null
|
let loginExpireTimer: any = null
|
||||||
window.requests = []
|
window.requests = []
|
||||||
window.tokenRefreshing = false
|
window.tokenRefreshing = false
|
||||||
@@ -110,7 +111,8 @@ function createAxios<Data = any, T = ApiPromise<Data>>(
|
|||||||
if (
|
if (
|
||||||
config.url == '/user-boot/user/generateSm2Key' ||
|
config.url == '/user-boot/user/generateSm2Key' ||
|
||||||
config.url == '/pqs-auth/oauth/token' ||
|
config.url == '/pqs-auth/oauth/token' ||
|
||||||
config.url == '/LNapi/pqs-auth/oauth/lnLogin'
|
config.url == '/pqs-auth/oauth/lnLogin'||
|
||||||
|
config.url == '/pqs-auth/oauth/lnRefreshToken'
|
||||||
) {
|
) {
|
||||||
config.headers.Authorization = 'Basic bmpjbjpuamNucHFz'
|
config.headers.Authorization = 'Basic bmpjbjpuamNucHFz'
|
||||||
}
|
}
|
||||||
@@ -146,6 +148,24 @@ function createAxios<Data = any, T = ApiPromise<Data>>(
|
|||||||
if (!window.tokenRefreshing) {
|
if (!window.tokenRefreshing) {
|
||||||
window.tokenRefreshing = true
|
window.tokenRefreshing = true
|
||||||
|
|
||||||
|
if(IS_LN_VERSION){
|
||||||
|
//辽宁版本
|
||||||
|
return lnRefreshTokenTo().then(res => {
|
||||||
|
adminInfo.setToken(res.data.access_token, 'auth')
|
||||||
|
adminInfo.setToken(res.data.refresh_token, 'refresh')
|
||||||
|
window.requests.forEach(cb => cb(res.data.access_token))
|
||||||
|
window.requests = []
|
||||||
|
|
||||||
|
return Axios(response.config)
|
||||||
|
}).catch(err => {
|
||||||
|
// refresh_token + CAS 都过期 → 重新走CAS登录
|
||||||
|
window.location.href = '/api/pqs-auth/oauth/lnCheck'
|
||||||
|
return Promise.reject(err)
|
||||||
|
}).finally(() => {
|
||||||
|
window.tokenRefreshing = false
|
||||||
|
})
|
||||||
|
}else {
|
||||||
|
//通用版本
|
||||||
return refreshToken()
|
return refreshToken()
|
||||||
.then(res => {
|
.then(res => {
|
||||||
adminInfo.setToken(res.data.access_token, 'auth')
|
adminInfo.setToken(res.data.access_token, 'auth')
|
||||||
@@ -164,6 +184,8 @@ function createAxios<Data = any, T = ApiPromise<Data>>(
|
|||||||
.finally(() => {
|
.finally(() => {
|
||||||
window.tokenRefreshing = false
|
window.tokenRefreshing = false
|
||||||
})
|
})
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
// 用函数形式将 resolve 存入,等待刷新后再执行
|
// 用函数形式将 resolve 存入,等待刷新后再执行
|
||||||
@@ -188,6 +210,13 @@ function createAxios<Data = any, T = ApiPromise<Data>>(
|
|||||||
router.push({ name: 'login' })
|
router.push({ name: 'login' })
|
||||||
loginExpireTimer = null // 执行后清空定时器
|
loginExpireTimer = null // 执行后清空定时器
|
||||||
}, 100) // 可根据实际情况调整延迟时间
|
}, 100) // 可根据实际情况调整延迟时间
|
||||||
|
return Promise.reject(response.data)
|
||||||
|
} else if (response.data.code == 'A0121') {
|
||||||
|
//统一认证过期
|
||||||
|
const casLogoutUrl =
|
||||||
|
'http://privilege-epri.dcloud.ln.dc.sgcc.com.cn/cas/login?service=http://PQMonitoring.dcloud.ln.dc.sgcc.com.cn'
|
||||||
|
window.location.href = casLogoutUrl
|
||||||
|
|
||||||
return Promise.reject(response.data)
|
return Promise.reject(response.data)
|
||||||
} else {
|
} else {
|
||||||
if (options.showCodeMessage) {
|
if (options.showCodeMessage) {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<div @keyup.enter="onSubmit(formRef)">
|
<div v-if='!VITE_FLAG' @keyup.enter="onSubmit(formRef)">
|
||||||
<div @contextmenu.stop="" id="bubble" class="bubble">
|
<div @contextmenu.stop="" id="bubble" class="bubble">
|
||||||
<canvas id="bubble-canvas" class="bubble-canvas"></canvas>
|
<canvas id="bubble-canvas" class="bubble-canvas"></canvas>
|
||||||
</div>
|
</div>
|
||||||
@@ -67,7 +67,6 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { onMounted, onBeforeUnmount, reactive, ref, nextTick } from 'vue'
|
import { onMounted, onBeforeUnmount, reactive, ref, nextTick } from 'vue'
|
||||||
import * as pageBubble from '@/utils/pageBubble'
|
import * as pageBubble from '@/utils/pageBubble'
|
||||||
import { ElMessage } from 'element-plus'
|
|
||||||
import { gongkey, login, getSysConfig, loginLNqr } from '@/api/user-boot/user'
|
import { gongkey, login, getSysConfig, loginLNqr } from '@/api/user-boot/user'
|
||||||
import { useAdminInfo } from '@/stores/adminInfo'
|
import { useAdminInfo } from '@/stores/adminInfo'
|
||||||
import type { FormInstance, InputInstance, FormRules } from 'element-plus'
|
import type { FormInstance, InputInstance, FormRules } from 'element-plus'
|
||||||
@@ -78,6 +77,7 @@ import { getTheme } from '@/api/systerm'
|
|||||||
import { useConfig } from '@/stores/config'
|
import { useConfig } from '@/stores/config'
|
||||||
import PopupUpdatePwd from './popupUpdatePwd.vue'
|
import PopupUpdatePwd from './popupUpdatePwd.vue'
|
||||||
const VITE_FLAG = import.meta.env.VITE_NAME == 'LNqr'
|
const VITE_FLAG = import.meta.env.VITE_NAME == 'LNqr'
|
||||||
|
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
let timer: number
|
let timer: number
|
||||||
const configStore = useConfig()
|
const configStore = useConfig()
|
||||||
@@ -185,12 +185,62 @@ const onSubmit = async (formEl: FormInstance | undefined) => {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
const LNonSubmit = async () => {
|
/*const LNonSubmit = async () => {
|
||||||
state.submitLoading = true
|
state.submitLoading = true
|
||||||
loginLNqr()
|
lnToken().then(res => {
|
||||||
.then(res => {
|
console.log(555)
|
||||||
//返回 a
|
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了,可以正常操作页面
|
//拿到token了,可以正常操作页面
|
||||||
userInfo.dataFill(res.data)
|
userInfo.dataFill(res.data)
|
||||||
state.submitLoading = false
|
state.submitLoading = false
|
||||||
@@ -201,17 +251,18 @@ const LNonSubmit = async () => {
|
|||||||
path: '/'
|
path: '/'
|
||||||
})
|
})
|
||||||
|
|
||||||
})
|
}).catch(err => {
|
||||||
.catch(err => {
|
|
||||||
console.log("---------")
|
console.log("---------")
|
||||||
console.log(err)
|
console.log(err)
|
||||||
//
|
|
||||||
window.location.href = "http://privilege-epri.dcloud.ln.dc.sgcc.com.cn/cas/login"
|
|
||||||
})
|
|
||||||
setTimeout(() => {
|
|
||||||
state.submitLoading = false
|
state.submitLoading = false
|
||||||
}, 500)
|
})
|
||||||
|
}else {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
defineExpose({ VITE_FLAG })
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
@@ -367,3 +418,5 @@ const LNonSubmit = async () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user