|
|
@@ -82,6 +82,7 @@
|
|
|
import { ref, onMounted } from 'vue'
|
|
|
import { useAuthStore } from '@/stores/auth'
|
|
|
import { appApi } from '@/api/apps'
|
|
|
+import { authApi } from '@/api/auth'
|
|
|
import { ElMessage } from 'element-plus'
|
|
|
import {
|
|
|
OfficeBuilding,
|
|
|
@@ -165,13 +166,32 @@ const loadApps = async () => {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-const handleAppClick = (app: any) => {
|
|
|
+const handleAppClick = async (app: any) => {
|
|
|
const url = app.home_url || app.redirect_uri
|
|
|
- if (url) {
|
|
|
- window.open(url, '_blank')
|
|
|
- } else {
|
|
|
+ if (!url) {
|
|
|
ElMessage.warning('该应用未配置访问地址')
|
|
|
+ return
|
|
|
}
|
|
|
+
|
|
|
+ // 优先尝试 SSO 免登跳转(后端预签发 OAuth2 授权码)
|
|
|
+ try {
|
|
|
+ const response = await authApi.getSSORedirectUrl(app.id)
|
|
|
+ if (response.code === '000000' || response.code === 0) {
|
|
|
+ const redirectUrl = response.data?.redirect_url
|
|
|
+ if (redirectUrl) {
|
|
|
+ window.open(redirectUrl, '_blank')
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 接口返回业务错误,降级到直接打开
|
|
|
+ console.warn('SSO 免登接口返回错误:', response.message)
|
|
|
+ } catch (error: any) {
|
|
|
+ // 网络异常等,降级到直接打开
|
|
|
+ console.warn('SSO 免登请求失败,降级到直接打开:', error)
|
|
|
+ }
|
|
|
+
|
|
|
+ // 降级方案:直接打开应用首页
|
|
|
+ window.open(url, '_blank')
|
|
|
}
|
|
|
|
|
|
onMounted(() => {
|