up oauth
This commit is contained in:
@@ -15,11 +15,13 @@ const constantRoutes = [
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/oauth/:code',
|
path: '/oauth/:code',
|
||||||
|
meta: { title: 'OauthLogin' },
|
||||||
component: () => import('@/views/oauth/login.vue'),
|
component: () => import('@/views/oauth/login.vue'),
|
||||||
hidden: true,
|
hidden: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/oauth/bind/:code',
|
path: '/oauth/bind/:code',
|
||||||
|
meta: { title: 'OauthBind' },
|
||||||
component: () => import('@/views/oauth/bind.vue'),
|
component: () => import('@/views/oauth/bind.vue'),
|
||||||
hidden: true,
|
hidden: true,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
<div v-for="(option, index) in options" :key="index" class="oidc-option">
|
<div v-for="(option, index) in options" :key="index" class="oidc-option">
|
||||||
<el-button @click="handleOIDCLogin(option.name)" class="oidc-btn">
|
<el-button @click="handleOIDCLogin(option.name)" class="oidc-btn">
|
||||||
<img :src="getProviderImage(option.name)" alt="provider" class="oidc-icon" />
|
<img :src="getProviderImage(option.name)" alt="provider" class="oidc-icon" />
|
||||||
{{ T(option.name) }}
|
<span>{{ T(option.name) }}</span>
|
||||||
</el-button>
|
</el-button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -105,21 +105,9 @@ const getProviderImage = (provider) => {
|
|||||||
|
|
||||||
const loadLoginOptions = async () => {
|
const loadLoginOptions = async () => {
|
||||||
try {
|
try {
|
||||||
const res = await loginOptions().catch(() => []);
|
const res = await loginOptions().catch(_ => false);
|
||||||
if (!Array.isArray(res) || !res.length) return console.warn('No valid response received');
|
if(!res || !res.data) return console.error('No valid response received');
|
||||||
|
res.data.map(option => (options.push({ name: option }))); // 创建新的对象数组
|
||||||
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);
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error loading login options:', error.message);
|
console.error('Error loading login options:', error.message);
|
||||||
}
|
}
|
||||||
@@ -141,6 +129,7 @@ onMounted(async () => {
|
|||||||
loadLoginOptions(); // 组件挂载后调用登录选项加载函数
|
loadLoginOptions(); // 组件挂载后调用登录选项加载函数
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
@@ -230,6 +219,7 @@ h1 {
|
|||||||
.oidc-icon {
|
.oidc-icon {
|
||||||
width: 24px;
|
width: 24px;
|
||||||
height: 24px;
|
height: 24px;
|
||||||
|
margin-right: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.login-logo {
|
.login-logo {
|
||||||
@@ -255,4 +245,4 @@ h1 {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -49,10 +49,17 @@
|
|||||||
const res = await bindConfirm({ code }).catch(_ => false)
|
const res = await bindConfirm({ code }).catch(_ => false)
|
||||||
if (res) {
|
if (res) {
|
||||||
resStatus.value = 1
|
resStatus.value = 1
|
||||||
ElMessage.success(T('OperationSuccessAndCloseAfter3Seconds'))
|
if (res.data.device_type === 'webadmin') {
|
||||||
setTimeout(_ => {
|
ElMessage.success(T('OperationSuccess'))
|
||||||
out()
|
//后台登录
|
||||||
}, 3000)
|
router.push('/')
|
||||||
|
} else {
|
||||||
|
ElMessage.success(T('OperationSuccessAndCloseAfter3Seconds'))
|
||||||
|
setTimeout(_ => {
|
||||||
|
out()
|
||||||
|
}, 3000)
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const out = () => {
|
const out = () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user