ljw 1 год назад
Родитель
Сommit
31dbe5c8e2
3 измененных файлов с 20 добавлено и 21 удалено
  1. 2 0
      src/router/index.js
  2. 7 17
      src/views/login/login.vue
  3. 11 4
      src/views/oauth/bind.vue

+ 2 - 0
src/router/index.js

@@ -15,11 +15,13 @@ const constantRoutes = [
15 15
   },
16 16
   {
17 17
     path: '/oauth/:code',
18
+    meta: { title: 'OauthLogin' },
18 19
     component: () => import('@/views/oauth/login.vue'),
19 20
     hidden: true,
20 21
   },
21 22
   {
22 23
     path: '/oauth/bind/:code',
24
+    meta: { title: 'OauthBind' },
23 25
     component: () => import('@/views/oauth/bind.vue'),
24 26
     hidden: true,
25 27
   },

+ 7 - 17
src/views/login/login.vue

@@ -26,7 +26,7 @@
26 26
         <div v-for="(option, index) in options" :key="index" class="oidc-option">
27 27
           <el-button @click="handleOIDCLogin(option.name)" class="oidc-btn">
28 28
             <img :src="getProviderImage(option.name)" alt="provider" class="oidc-icon" />
29
-            {{ T(option.name) }}
29
+            <span>{{ T(option.name) }}</span>
30 30
           </el-button>
31 31
         </div>
32 32
       </div>
@@ -105,21 +105,9 @@ const getProviderImage = (provider) => {
105 105
 
106 106
 const loadLoginOptions = async () => {
107 107
   try {
108
-    const res = await loginOptions().catch(() => []);
109
-    if (!Array.isArray(res) || !res.length) return console.warn('No valid response received');
110
-
111
-    const jsonPart = res[0].split('/')[1];
112
-    if (!jsonPart) return console.error('Invalid input string:', res[0]);
113
-
114
-    // const ops = JSON.parse(jsonPart).map(option => ({ name: option.name }));
115
-    // 不确定怎么处理webauth,不显示
116
-    // 解析 JSON,并过滤掉 "webauth" 类型的选项
117
-    const ops = JSON.parse(jsonPart)
118
-      .filter(option => option.name !== "webauth") // 排除 "webauth" 类型的选项
119
-      .map(option => ({ name: option.name })); // 创建新的对象数组
120
-    if (!ops.length) return;
121
-
122
-    options.push(...ops);
108
+    const res = await loginOptions().catch(_ => false);
109
+    if(!res || !res.data) return console.error('No valid response received');
110
+    res.data.map(option => (options.push({ name: option }))); // 创建新的对象数组
123 111
   } catch (error) {
124 112
     console.error('Error loading login options:', error.message);
125 113
   }
@@ -141,6 +129,7 @@ onMounted(async () => {
141 129
     loadLoginOptions(); // 组件挂载后调用登录选项加载函数
142 130
   }
143 131
 });
132
+
144 133
 </script>
145 134
 
146 135
 <style scoped lang="scss">
@@ -230,6 +219,7 @@ h1 {
230 219
 .oidc-icon {
231 220
   width: 24px;
232 221
   height: 24px;
222
+  margin-right: 10px;
233 223
 }
234 224
 
235 225
 .login-logo {
@@ -255,4 +245,4 @@ h1 {
255 245
     }
256 246
   }
257 247
 }
258
-</style>
248
+</style>

+ 11 - 4
src/views/oauth/bind.vue

@@ -49,10 +49,17 @@
49 49
     const res = await bindConfirm({ code }).catch(_ => false)
50 50
     if (res) {
51 51
       resStatus.value = 1
52
-      ElMessage.success(T('OperationSuccessAndCloseAfter3Seconds'))
53
-      setTimeout(_ => {
54
-        out()
55
-      }, 3000)
52
+      if (res.data.device_type === 'webadmin') {
53
+        ElMessage.success(T('OperationSuccess'))
54
+        //后台登录
55
+        router.push('/')
56
+      } else {
57
+        ElMessage.success(T('OperationSuccessAndCloseAfter3Seconds'))
58
+        setTimeout(_ => {
59
+          out()
60
+        }, 3000)
61
+      }
62
+
56 63
     }
57 64
   }
58 65
   const out = () => {