diff --git a/src/router/index.js b/src/router/index.js index e4fb363..fec2c67 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -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, }, diff --git a/src/views/login/login.vue b/src/views/login/login.vue index 6ab558b..09e0a6f 100644 --- a/src/views/login/login.vue +++ b/src/views/login/login.vue @@ -26,7 +26,7 @@
provider - {{ T(option.name) }} + {{ T(option.name) }}
@@ -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(); // 组件挂载后调用登录选项加载函数 } }); + \ No newline at end of file + diff --git a/src/views/oauth/bind.vue b/src/views/oauth/bind.vue index 3e25c90..b87aba0 100644 --- a/src/views/oauth/bind.vue +++ b/src/views/oauth/bind.vue @@ -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 = () => {