@@ -193,10 +193,10 @@ const loginData = reactive({
193
193
})
194
194
195
195
const socialList = [
196
- { icon: ' ant-design:github-filled' , type: 0 },
197
196
{ icon: ' ant-design:wechat-filled' , type: 30 },
198
- { icon: ' ant-design:alipay-circle-filled' , type: 0 },
199
- { icon: ' ant-design:dingtalk-circle-filled' , type: 20 }
197
+ { icon: ' ant-design:dingtalk-circle-filled' , type: 20 },
198
+ { icon: ' ant-design:github-filled' , type: 0 },
199
+ { icon: ' ant-design:alipay-circle-filled' , type: 0 }
200
200
]
201
201
202
202
// 获取验证码
@@ -210,7 +210,7 @@ const getCode = async () => {
210
210
verify .value .show ()
211
211
}
212
212
}
213
- // 获取租户ID
213
+ // 获取租户 ID
214
214
const getTenantId = async () => {
215
215
if (loginData .tenantEnable === ' true' ) {
216
216
const res = await LoginApi .getTenantIdByName (loginData .loginForm .tenantName )
@@ -230,6 +230,15 @@ const getCookie = () => {
230
230
}
231
231
}
232
232
}
233
+ // 根据域名,获得租户信息
234
+ const getTenantByWebsite = async () => {
235
+ const website = location .host
236
+ const res = await LoginApi .getTenantByWebsite (website )
237
+ if (res ) {
238
+ loginData .loginForm .tenantName = res .name
239
+ authUtil .setTenantId (res .id )
240
+ }
241
+ }
233
242
const loading = ref () // ElLoading.service 返回的实例
234
243
// 登录
235
244
const handleLogin = async (params ) => {
@@ -278,10 +287,15 @@ const doSocialLogin = async (type: number) => {
278
287
} else {
279
288
loginLoading .value = true
280
289
if (loginData .tenantEnable === ' true' ) {
281
- await message .prompt (' 请输入租户名称' , t (' common.reminder' )).then (async ({ value }) => {
282
- const res = await LoginApi .getTenantIdByName (value )
283
- authUtil .setTenantId (res )
284
- })
290
+ // 尝试先通过 tenantName 获取租户
291
+ await getTenantId ()
292
+ // 如果获取不到,则需要弹出提示,进行处理
293
+ if (! authUtil .getTenantId ()) {
294
+ await message .prompt (' 请输入租户名称' , t (' common.reminder' )).then (async ({ value }) => {
295
+ const res = await LoginApi .getTenantIdByName (value )
296
+ authUtil .setTenantId (res )
297
+ })
298
+ }
285
299
}
286
300
// 计算 redirectUri
287
301
// tricky: type、redirect需要先encode一次,否则钉钉回调会丢失。
@@ -307,6 +321,7 @@ watch(
307
321
)
308
322
onMounted (() => {
309
323
getCookie ()
324
+ getTenantByWebsite ()
310
325
})
311
326
</script >
312
327
0 commit comments