From 4c44ccbdcbe25de7dc0725bf53f1290fba10edf7 Mon Sep 17 00:00:00 2001
From: WXL (wul) <wl_5969728@163.com>
Date: 星期五, 05 九月 2025 11:33:41 +0800
Subject: [PATCH] 测试完成
---
vue.config.js | 4
src/views/loginSSO.vue | 123 +++++++++++++++++++++++++++++++++++++++++
2 files changed, 125 insertions(+), 2 deletions(-)
diff --git a/src/views/loginSSO.vue b/src/views/loginSSO.vue
new file mode 100644
index 0000000..21f7317
--- /dev/null
+++ b/src/views/loginSSO.vue
@@ -0,0 +1,123 @@
+<template>
+ <div class="sso-redirect">
+ <div class="loading-container">
+ <el-alert
+ v-if="errorMessage"
+ :title="errorMessage"
+ type="error"
+ :closable="false"
+ show-icon
+ ></el-alert>
+ <div v-else class="loading-content">
+ <i class="el-icon-loading"></i>
+ <p>鍗曠偣鐧诲綍涓紝璇风◢鍊�...</p>
+ </div>
+ </div>
+ </div>
+</template>
+
+<script>
+import { setToken } from '@/utils/auth'
+
+export default {
+ name: 'SSORedirect',
+ data() {
+ return {
+ errorMessage: '',
+ loading: true
+ }
+ },
+ created() {
+ this.handleSSORedirect()
+ },
+ methods: {
+ async handleSSORedirect() {
+ try {
+ // 浠嶶RL鍙傛暟涓幏鍙杢oken鍜屾満鏋勪俊鎭�
+ const { token, orgid, orgname, ZuHuID, deptCode, redirect } = this.$route.query
+
+ // 楠岃瘉蹇呰鍙傛暟
+ if (!token) {
+ throw new Error('缂哄皯璁よ瘉浠ょ墝(token)')
+ }
+ setToken(token)
+ this.$store.commit('SET_TOKEN', token)
+
+ // 瀛樺偍鏈烘瀯淇℃伅鍒發ocalStorage
+ if (orgid) {
+ localStorage.setItem('orgid', orgid)
+ this.$store.dispatch('UpdateOrgId', orgid)
+ }
+ if (orgname) localStorage.setItem('orgname', orgname)
+ if (ZuHuID) localStorage.setItem('ZuHuID', ZuHuID)
+ if (deptCode) localStorage.setItem('deptCode', deptCode)
+
+ // 鑾峰彇鐢ㄦ埛淇℃伅
+ await this.$store.dispatch('GetInfo')
+
+ // 纭畾閲嶅畾鍚戣矾寰�
+ let redirectPath = '/index'
+ if (redirect) {
+ redirectPath = decodeURIComponent(redirect)
+ } else {
+ // 鏍规嵁鐢ㄦ埛瑙掕壊鍐冲畾榛樿璺宠浆椤甸潰
+ const roles = this.$store.state.user.roles
+ const username = this.$store.state.user.name
+
+ if (roles.includes('admin') || username === 'admin') {
+ redirectPath = '/index'
+ } else {
+ redirectPath = '/followvisit/discharge'
+ }
+ }
+
+ // 璺宠浆鍒扮洰鏍囬〉闈�
+ this.$router.replace({ path: redirectPath })
+
+ } catch (error) {
+ console.error('SSO鐧诲綍澶辫触:', error)
+ this.errorMessage = `鍗曠偣鐧诲綍澶辫触: ${error.message || '鏈煡閿欒'}`
+ this.loading = false
+
+ // 5绉掑悗璺宠浆鍒版櫘閫氱櫥褰曢〉
+ setTimeout(() => {
+ this.$router.replace('/login')
+ }, 5000)
+ }
+ }
+ }
+}
+</script>
+
+<style scoped>
+.sso-redirect {
+ display: flex;
+ justify-content: center;
+ align-items: center;
+ height: 100vh;
+ background-color: #f5f7fa;
+}
+
+.loading-container {
+ text-align: center;
+ padding: 20px;
+ background: white;
+ border-radius: 4px;
+ box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
+}
+
+.loading-content {
+ padding: 20px;
+}
+
+.el-icon-loading {
+ font-size: 40px;
+ color: #409EFF;
+ margin-bottom: 10px;
+}
+
+p {
+ margin: 0;
+ color: #606266;
+}
+</style>
diff --git a/vue.config.js b/vue.config.js
index 5fab797..e16f02a 100644
--- a/vue.config.js
+++ b/vue.config.js
@@ -38,8 +38,8 @@
// target: `https://www.health-y.cn/lssf`,
// target: `http://10.202.20.185:8095`,
// target: `http://192.168.100.195:8095`,
- // target:`http://localhost:8095`,
- target:`http://35z1t16164.qicp.vip`,
+ target:`http://localhost:8095`,
+ // target:`http://35z1t16164.qicp.vip`,
// target: `http://192.168.100.193:8095`,
// target: `http://192.168.101.166:8093`,
// target: `http://192.168.191.181:8095`,
--
Gitblit v1.9.3