fix: 单点登录优化与环境变量完善
This commit is contained in:
@@ -56,6 +56,8 @@ function onAfterLeave() {
|
||||
}
|
||||
|
||||
function handleThirdPartyLogin() {
|
||||
console.log('SSO_SEVER_URL', SSO_SEVER_URL);
|
||||
console.log('import.meta.env', import.meta.env);
|
||||
const redirectUri = encodeURIComponent(`${window.location.origin}/chat`);
|
||||
const popup = window.open(
|
||||
`${SSO_SEVER_URL}/login?client_id=${SSO_CLIENT_ID}&redirect_uri=${redirectUri}`,
|
||||
@@ -68,23 +70,19 @@ function handleThirdPartyLogin() {
|
||||
|
||||
const messageHandler = async (event: any) => {
|
||||
if (event.origin === new URL(SSO_SEVER_URL).origin
|
||||
|| event.data.type === 'SSO_LOGIN_SUCCESS'
|
||||
|| !isHandled) {
|
||||
&& event.data.type === 'SSO_LOGIN_SUCCESS'
|
||||
&& !isHandled) {
|
||||
isHandled = true;
|
||||
try {
|
||||
// 清理监听
|
||||
window.removeEventListener('message', messageHandler);
|
||||
const { token } = event.data;
|
||||
userStore.setToken(token);
|
||||
|
||||
const resUserInfo = await getUserInfo();
|
||||
userStore.setUserInfo(resUserInfo.data);
|
||||
|
||||
// 关闭弹窗
|
||||
if (popup && !popup.closed)
|
||||
popup.close();
|
||||
|
||||
// 清理监听
|
||||
window.removeEventListener('message', messageHandler);
|
||||
|
||||
// 后续逻辑
|
||||
ElMessage.success('登录成功');
|
||||
userStore.closeLoginDialog();
|
||||
@@ -96,9 +94,6 @@ function handleThirdPartyLogin() {
|
||||
ElMessage.error('登录失败');
|
||||
}
|
||||
}
|
||||
else {
|
||||
console.log('2222-', event);
|
||||
}
|
||||
};
|
||||
|
||||
// 先移除旧监听,再添加新监听
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// 三方登录
|
||||
// export const SSO_SEVER_URL: string = 'https://ccnetcore.com';
|
||||
export const SSO_SEVER_URL: string = import.meta.env.SSO_SEVER_URL || 'http://ccnetcore.com';
|
||||
export const SSO_CLIENT_ID: string = import.meta.env.SSO_CLIENT_ID || 'YiXin-Ai';
|
||||
export const SSO_SEVER_URL: string = import.meta.env.VITE_SSO_SEVER_URL || 'http://ccnetcore.com';
|
||||
export const SSO_CLIENT_ID: string = import.meta.env.VITE_SSO_CLIENT_ID || 'YiXin-Ai';
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
// 公共的图表按钮样式
|
||||
.btn-icon-btn {
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
display: inline-block;
|
||||
border: 1px solid transparent;
|
||||
border-radius: 30%;
|
||||
padding: 4px;
|
||||
cursor: pointer;
|
||||
transition: all 0.3s ease;
|
||||
|
||||
// 鼠标移入
|
||||
&:hover {
|
||||
background-color: rgb(0, 0, 0, .05);
|
||||
|
||||
.svg-icon {
|
||||
color: rgb(0, 0, 0, .6);
|
||||
}
|
||||
}
|
||||
|
||||
// 鼠标按下
|
||||
&:active {
|
||||
background-color: rgb(0, 0, 0, .08);
|
||||
|
||||
.svg-icon {
|
||||
color: rgb(0, 0, 0, .7);
|
||||
}
|
||||
}
|
||||
|
||||
// 图标
|
||||
.svg-icon {
|
||||
user-select: none;
|
||||
color: rgb(0, 0, 0, .5);
|
||||
}
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
.el-form{
|
||||
.el-form-item{
|
||||
&:nth-last-child(1){
|
||||
margin-bottom: 0px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// el 弹框不知道为啥宽度会变大
|
||||
.el-popup-parent--hidden {
|
||||
overflow: hidden;
|
||||
width: 100% !important;
|
||||
}
|
||||
|
||||
|
||||
// messagebox 样式
|
||||
.is-message-box {
|
||||
.el-message-box {
|
||||
border-radius: 16px;
|
||||
}
|
||||
}
|
||||
|
||||
// rounded-tooltip 提示框样式
|
||||
.rounded-tooltip {
|
||||
border-radius: 10px !important;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
height: fit-content;
|
||||
}
|
||||
|
||||
.rounded-tooltip-enter-from {
|
||||
transform: scale(0.9); /* 进入前:缩小隐藏 */
|
||||
opacity: 0;
|
||||
}
|
||||
.rounded-tooltip-enter-active,
|
||||
.rounded-tooltip-leave-active {
|
||||
transition: transform 0.3s, opacity 0.3s; /* 缓入动画 */
|
||||
}
|
||||
.rounded-tooltip-enter-to {
|
||||
transform: scale(1); /* 进入后:正常大小 */
|
||||
opacity: 1;
|
||||
}
|
||||
.rounded-tooltip-leave-from {
|
||||
transform: scale(1); /* 离开前:正常大小 */
|
||||
opacity: 1;
|
||||
}
|
||||
.rounded-tooltip-leave-to {
|
||||
transform: scale(0.9); /* 离开后:缩小隐藏 */
|
||||
opacity: 0;
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
// 覆盖一些 elx 组件样式
|
||||
|
||||
// attachments 图片组件的 1.2.0 版本样式 bug
|
||||
.image-preview-container {
|
||||
flex: none !important;
|
||||
}
|
||||
|
||||
.elx-files-card-content {
|
||||
gap: 8px;
|
||||
.elx-files-card-description {
|
||||
line-height: 1.35;
|
||||
}
|
||||
}
|
||||
|
||||
.prev-next-btn {
|
||||
position: absolute;
|
||||
top: calc(50% + 3px);
|
||||
transform: translateY(-50%);
|
||||
z-index: 10;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.elx-attachments-file-card-wrap {
|
||||
padding-top: 6px;
|
||||
}
|
||||
|
||||
.elx-attachments-card {
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
// 隐藏 elx-sender-header 组件的底部边框
|
||||
.el-sender-header {
|
||||
border-bottom-color: transparent !important;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
@use './media.scss';
|
||||
@use './btn-style.scss';
|
||||
@use 'reset-css';
|
||||
@use './element-plus.scss';
|
||||
@use './elx.scss';
|
||||
|
||||
body{
|
||||
overflow: hidden;
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
:root {
|
||||
/* 头部高度 */
|
||||
--header-container-default-heigth: 56px;
|
||||
|
||||
/* 左侧侧边栏背景色 */
|
||||
--sidebar-background-color: #f3f4f6;
|
||||
|
||||
|
||||
/* 登录弹框变量 */
|
||||
--login-dialog-width: 738px;
|
||||
--login-dialog-height: 416px;
|
||||
--login-dialog-padding: 0px;
|
||||
--login-dialog-section-padding: 0px;
|
||||
--login-dialog-border-radius: 24px;
|
||||
--login-dialog-mode-toggle-color: #409eff;
|
||||
--login-dialog-logo-background: #fff;
|
||||
--login-dialog-logo-text-color: #191919;
|
||||
|
||||
|
||||
|
||||
/* 覆盖 element-plus 样式 */
|
||||
--el-border-radius-base: 12px !important;
|
||||
--el-messagebox-border-radius: 16px !important;
|
||||
}
|
||||
Reference in New Issue
Block a user