feat: 针对大模型 sso 改造
parent
0f9f99063e
commit
88c59ff076
|
@ -26,6 +26,7 @@ declare module 'vue' {
|
||||||
ASwitch: typeof import('ant-design-vue/es')['Switch']
|
ASwitch: typeof import('ant-design-vue/es')['Switch']
|
||||||
ATextarea: typeof import('ant-design-vue/es')['Textarea']
|
ATextarea: typeof import('ant-design-vue/es')['Textarea']
|
||||||
ATooltip: typeof import('ant-design-vue/es')['Tooltip']
|
ATooltip: typeof import('ant-design-vue/es')['Tooltip']
|
||||||
|
ElEmpty: typeof import('element-plus/es')['ElEmpty']
|
||||||
ElScrollbar: typeof import('element-plus/es')['ElScrollbar']
|
ElScrollbar: typeof import('element-plus/es')['ElScrollbar']
|
||||||
Empty: typeof import('./src/components/empty/Empty.vue')['default']
|
Empty: typeof import('./src/components/empty/Empty.vue')['default']
|
||||||
ImageCropper: typeof import('./src/components/image-cropper/index.vue')['default']
|
ImageCropper: typeof import('./src/components/image-cropper/index.vue')['default']
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
<template>
|
<template>
|
||||||
<a-layout class="app-wrapper" :class="[{ hideSidebar: isCollapsed }, { 'font-big': isFontBig }, { 'expire-top': expire }]" @click="setTime">
|
<a-layout class="app-wrapper" :class="[{ hideSidebar: isCollapsed }, { 'font-big': isFontBig }, { 'expire-top': expire }]" @click="setTime">
|
||||||
<SystemTip />
|
<SystemTip />
|
||||||
<Header :match-path="matchPath"></Header>
|
<Header :match-path="matchPath" v-if="isNotIframeChild"></Header>
|
||||||
<TagsView v-if="addRoutes"></TagsView>
|
<TagsView v-if="addRoutes && isNotIframeChild"></TagsView>
|
||||||
<a-layout style="overflow: hidden">
|
<a-layout style="overflow: hidden">
|
||||||
<Sidebar v-if="showSidebar" @toggleCollapsed="toggleCollapsed" :isCollapsed="isCollapsed" :menuData="menuData" :isLimitLevel="true" :matchPath="matchPath" :basePath="basePath"></Sidebar>
|
<Sidebar v-if="showSidebar && isNotIframeChild" @toggleCollapsed="toggleCollapsed" :isCollapsed="isCollapsed" :menuData="menuData" :isLimitLevel="true" :matchPath="matchPath" :basePath="basePath"></Sidebar>
|
||||||
<a-layout class="main-container">
|
<a-layout class="main-container">
|
||||||
<ThirdMenu :menuData="thirdMenuData" v-if="thirdMenuData.children"></ThirdMenu>
|
<ThirdMenu :menuData="thirdMenuData" v-if="thirdMenuData.children && isNotIframeChild"></ThirdMenu>
|
||||||
<a-layout-content class="main-body">
|
<a-layout-content class="main-body">
|
||||||
<el-scrollbar class="custom-scrollbar" style="flex: 1">
|
<el-scrollbar class="custom-scrollbar" style="flex: 1">
|
||||||
<transition enter-active-class="fadeInUp" mode="out-in">
|
<transition enter-active-class="fadeInUp" mode="out-in">
|
||||||
|
@ -42,7 +42,9 @@ export default {
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
matchPath: ''
|
matchPath: '',
|
||||||
|
// 被嵌入
|
||||||
|
isNotIframeChild: window.top === window.self
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
setup() {
|
setup() {
|
||||||
|
|
|
@ -7,6 +7,16 @@ import { wrapperParams } from 'utils'
|
||||||
export function login(params) {
|
export function login(params) {
|
||||||
return request.post('/sms/v1/users/login', params)
|
return request.post('/sms/v1/users/login', params)
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* IDP登录 返回数据结构和 login 接口一致
|
||||||
|
* @param ticket 票据
|
||||||
|
* @returns 用户信息
|
||||||
|
*/
|
||||||
|
export const idpLogin = (ticket) => {
|
||||||
|
// token 作为 url query 拼接
|
||||||
|
return request.post(`/sms/v1/login/idp?token=${ticket}`)
|
||||||
|
}
|
||||||
|
|
||||||
export function getTokenInfo(params) {
|
export function getTokenInfo(params) {
|
||||||
return request.post('/sms/v1/sso/token/info', params)
|
return request.post('/sms/v1/sso/token/info', params)
|
||||||
}
|
}
|
||||||
|
@ -21,12 +31,12 @@ export function logout() {
|
||||||
}
|
}
|
||||||
export function getConfig(params) {
|
export function getConfig(params) {
|
||||||
return request.get('/sms/v1/logo', {
|
return request.get('/sms/v1/logo', {
|
||||||
params: wrapperParams(params),
|
params: wrapperParams(params)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
export function getDict(data) {
|
export function getDict(data) {
|
||||||
return request.get('/dict/children', {
|
return request.get('/dict/children', {
|
||||||
params: wrapperParams(data),
|
params: wrapperParams(data)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
export function getSysconf() {
|
export function getSysconf() {
|
||||||
|
@ -48,7 +58,7 @@ export function getPortal(params) {
|
||||||
}
|
}
|
||||||
export function getServiceQuota(tenantId, data) {
|
export function getServiceQuota(tenantId, data) {
|
||||||
return request.get(`/cos/v1/tenants/${tenantId}/quotas`, {
|
return request.get(`/cos/v1/tenants/${tenantId}/quotas`, {
|
||||||
params: wrapperParams(data),
|
params: wrapperParams(data)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
export function replaceToken(params) {
|
export function replaceToken(params) {
|
||||||
|
@ -69,7 +79,7 @@ export function getSystemTreeConfigs(params) {
|
||||||
// 更新系统配置信息
|
// 更新系统配置信息
|
||||||
export function updateSystemConfigs(params) {
|
export function updateSystemConfigs(params) {
|
||||||
return request.put('/sms/v1/system-configs', params, {
|
return request.put('/sms/v1/system-configs', params, {
|
||||||
headers: { 'Content-Type': 'multipart/form-data', BsmAjaxHeader: true, options: { noSeri: true } },
|
headers: { 'Content-Type': 'multipart/form-data', BsmAjaxHeader: true, options: { noSeri: true } }
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
// 测试连接
|
// 测试连接
|
||||||
|
|
|
@ -167,7 +167,9 @@ const actions = {
|
||||||
// 重置标签信息
|
// 重置标签信息
|
||||||
dispatch('tagsView/delAllViews', null, { root: true })
|
dispatch('tagsView/delAllViews', null, { root: true })
|
||||||
removeToken()
|
removeToken()
|
||||||
if (redirectToLogin) window.location.href = '/login'
|
// 正常云管环境
|
||||||
|
const isNotIframeChild = window.top === window.self
|
||||||
|
if (redirectToLogin && isNotIframeChild) window.location.href = '/login'
|
||||||
resolve()
|
resolve()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,15 +1,39 @@
|
||||||
<template>
|
<template>
|
||||||
<div></div>
|
<el-empty v-if="isError" :description="description" />
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import { ref } from 'vue'
|
||||||
import { setToken } from 'utils/auth'
|
import { setToken } from 'utils/auth'
|
||||||
import { useRoute, useRouter } from 'vue-router'
|
import { useRoute, useRouter } from 'vue-router'
|
||||||
|
import { idpLogin } from 'services/index'
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
|
const isError = ref(false)
|
||||||
|
const description = ref('')
|
||||||
|
const init = async () => {
|
||||||
|
// sso?ticket=11&redirect=/cop-web/host-resource/vm
|
||||||
|
const { token, ticket, redirect = '/home' } = route.query
|
||||||
|
const path = decodeURIComponent(redirect as string)
|
||||||
|
if (token) {
|
||||||
|
setToken(token as string)
|
||||||
|
router.replace(path)
|
||||||
|
} else if (ticket) {
|
||||||
|
const res = await idpLogin(ticket).catch((err) => {
|
||||||
|
description.value = err.message
|
||||||
|
isError.value = true
|
||||||
|
return err
|
||||||
|
})
|
||||||
|
if (!res.success) {
|
||||||
|
isError.value = true
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const userInfo = res.data
|
||||||
|
const { token } = userInfo
|
||||||
|
setToken(token)
|
||||||
|
router.replace(path)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const { token, redirect = '/home' } = route.query
|
init()
|
||||||
setToken(token)
|
|
||||||
router.push(redirect as string)
|
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -12,7 +12,7 @@ function resolve(dir: string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const httpType = 'https://'
|
const httpType = 'https://'
|
||||||
const proxyUrl = '10.10.33.172:60006' // EFC 3.0 代理地址设置
|
const proxyUrl = '10.10.33.214:60006' // AI_OPS
|
||||||
|
|
||||||
// https://vitejs.dev/config/
|
// https://vitejs.dev/config/
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
|
|
Loading…
Reference in New Issue