Merge branch 'master' into changeOwnPasswd
This commit is contained in:
+15
-17
@@ -15,6 +15,7 @@
|
||||
|
||||
<el-form-item>
|
||||
<el-button @click="login" type="primary" class="login-button">{{ T('Login') }}</el-button>
|
||||
<el-button v-if="allowRegister" @click="register" class="login-button">{{ T('Register') }}</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
@@ -26,7 +27,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>
|
||||
@@ -103,23 +104,13 @@ const getProviderImage = (provider) => {
|
||||
return providerImageMap[provider] || providerImageMap.default;
|
||||
};
|
||||
|
||||
const allowRegister = ref(false)
|
||||
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.ops.map(option => (options.push({ name: option }))); // 创建新的对象数组
|
||||
allowRegister.value = res.data.register
|
||||
} catch (error) {
|
||||
console.error('Error loading login options:', error.message);
|
||||
}
|
||||
@@ -141,6 +132,10 @@ onMounted(async () => {
|
||||
loadLoginOptions(); // 组件挂载后调用登录选项加载函数
|
||||
}
|
||||
});
|
||||
|
||||
const register = () => {
|
||||
router.push('/register')
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
@@ -151,6 +146,7 @@ onMounted(async () => {
|
||||
height: 100vh;
|
||||
background-color: #2d3a4b;
|
||||
padding: 20px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.login-card {
|
||||
@@ -180,6 +176,7 @@ h1 {
|
||||
width: 100%;
|
||||
height: 40px;
|
||||
margin-bottom: 20px;
|
||||
margin-left: 0;
|
||||
}
|
||||
|
||||
.divider {
|
||||
@@ -230,6 +227,7 @@ h1 {
|
||||
.oidc-icon {
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
.login-logo {
|
||||
@@ -255,4 +253,4 @@ h1 {
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user