This commit is contained in:
ljw
2024-10-31 14:02:34 +08:00
parent a40324a4a9
commit 31dbe5c8e2
3 changed files with 20 additions and 21 deletions
+2
View File
@@ -15,11 +15,13 @@ const constantRoutes = [
},
{
path: '/oauth/:code',
meta: { title: 'OauthLogin' },
component: () => import('@/views/oauth/login.vue'),
hidden: true,
},
{
path: '/oauth/bind/:code',
meta: { title: 'OauthBind' },
component: () => import('@/views/oauth/bind.vue'),
hidden: true,
},
+6 -16
View File
@@ -26,7 +26,7 @@
<div v-for="(option, index) in options" :key="index" class="oidc-option">
<el-button @click="handleOIDCLogin(option.name)" class="oidc-btn">
<img :src="getProviderImage(option.name)" alt="provider" class="oidc-icon" />
{{ T(option.name) }}
<span>{{ T(option.name) }}</span>
</el-button>
</div>
</div>
@@ -105,21 +105,9 @@ const getProviderImage = (provider) => {
const loadLoginOptions = async () => {
try {
const res = await loginOptions().catch(() => []);
if (!Array.isArray(res) || !res.length) return console.warn('No valid response received');
const jsonPart = res[0].split('/')[1];
if (!jsonPart) return console.error('Invalid input string:', res[0]);
// const ops = JSON.parse(jsonPart).map(option => ({ name: option.name }));
// 不确定怎么处理webauth,不显示
// 解析 JSON,并过滤掉 "webauth" 类型的选项
const ops = JSON.parse(jsonPart)
.filter(option => option.name !== "webauth") // 排除 "webauth" 类型的选项
.map(option => ({ name: option.name })); // 创建新的对象数组
if (!ops.length) return;
options.push(...ops);
const res = await loginOptions().catch(_ => false);
if(!res || !res.data) return console.error('No valid response received');
res.data.map(option => (options.push({ name: option }))); // 创建新的对象数组
} catch (error) {
console.error('Error loading login options:', error.message);
}
@@ -141,6 +129,7 @@ onMounted(async () => {
loadLoginOptions(); // 组件挂载后调用登录选项加载函数
}
});
</script>
<style scoped lang="scss">
@@ -230,6 +219,7 @@ h1 {
.oidc-icon {
width: 24px;
height: 24px;
margin-right: 10px;
}
.login-logo {
+7
View File
@@ -49,11 +49,18 @@
const res = await bindConfirm({ code }).catch(_ => false)
if (res) {
resStatus.value = 1
if (res.data.device_type === 'webadmin') {
ElMessage.success(T('OperationSuccess'))
//后台登录
router.push('/')
} else {
ElMessage.success(T('OperationSuccessAndCloseAfter3Seconds'))
setTimeout(_ => {
out()
}, 3000)
}
}
}
const out = () => {
window.close()