up oauth
This commit is contained in:
@@ -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,
|
||||
},
|
||||
|
||||
@@ -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 {
|
||||
@@ -255,4 +245,4 @@ h1 {
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
|
||||
@@ -49,10 +49,17 @@
|
||||
const res = await bindConfirm({ code }).catch(_ => false)
|
||||
if (res) {
|
||||
resStatus.value = 1
|
||||
ElMessage.success(T('OperationSuccessAndCloseAfter3Seconds'))
|
||||
setTimeout(_ => {
|
||||
out()
|
||||
}, 3000)
|
||||
if (res.data.device_type === 'webadmin') {
|
||||
ElMessage.success(T('OperationSuccess'))
|
||||
//后台登录
|
||||
router.push('/')
|
||||
} else {
|
||||
ElMessage.success(T('OperationSuccessAndCloseAfter3Seconds'))
|
||||
setTimeout(_ => {
|
||||
out()
|
||||
}, 3000)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
const out = () => {
|
||||
|
||||
Reference in New Issue
Block a user