|
|
@@ -7,19 +7,22 @@
|
|
|
|
|
|
<a-form size="large" :model="form" :rules="[]" class="form" @submit="handleSubmit">
|
|
|
<div class="uniLoginButton">
|
|
|
- <div class="button">
|
|
|
+ <div class="button" v-if="isTypeEnabled('qq')">
|
|
|
<a-tooltip content="QQ登录" mini>
|
|
|
<a-avatar :size="64" :style="{ backgroundColor: '#FE82A5' }"
|
|
|
@click="GetLoginUrl('qq')"><icon-qq /></a-avatar>
|
|
|
</a-tooltip>
|
|
|
</div>
|
|
|
- <div class="button">
|
|
|
+ <div class="button" v-if="isTypeEnabled('wx')">
|
|
|
<a-tooltip content="微信登录" mini>
|
|
|
<a-avatar :size="64" :style="{ backgroundColor: '#FE82A5' }"
|
|
|
@click="GetLoginUrl('wx')"><icon-wechat /></a-avatar>
|
|
|
</a-tooltip>
|
|
|
</div>
|
|
|
</div>
|
|
|
+ <a-alert v-if="!optionsLoading && enabledTypes.length === 0" type="warning" class="disabled-tip">
|
|
|
+ 快捷登录暂未开启,请使用账号密码登录
|
|
|
+ </a-alert>
|
|
|
<div class="tip">未注册的第三方账号登录后将自动注册</div>
|
|
|
<a-button type="text" class="forgetpass" @click="emit('changeMode', 'login')">账号密码登录</a-button>
|
|
|
</a-form>
|
|
|
@@ -34,7 +37,7 @@
|
|
|
</template>
|
|
|
|
|
|
<script setup>
|
|
|
-import { getLoginUrl } from '@/api/login'
|
|
|
+import { getLoginUrl, getUniLoginOptions } from '@/api/login'
|
|
|
import { timeFix } from '@/utils/util'
|
|
|
import { useRoute, useRouter } from 'vue-router'
|
|
|
import { ref, onMounted } from 'vue'
|
|
|
@@ -45,13 +48,33 @@ import { isElectron } from '@/utils/electron'
|
|
|
const userStore = useUserStore()
|
|
|
|
|
|
const loading = ref(false)
|
|
|
+const optionsLoading = ref(false)
|
|
|
+const enabledTypes = ref(['qq', 'wx'])
|
|
|
const route = useRoute()
|
|
|
const router = useRouter()
|
|
|
const emit = defineEmits(['changeMode', 'changeLoading'])
|
|
|
|
|
|
const from = route.query.from
|
|
|
|
|
|
+const isTypeEnabled = (type) => enabledTypes.value.includes(type)
|
|
|
+
|
|
|
+const loadOptions = async () => {
|
|
|
+ try {
|
|
|
+ optionsLoading.value = true
|
|
|
+ const res = await getUniLoginOptions()
|
|
|
+ if (res?.code === 0 && Array.isArray(res.data?.enabledTypes))
|
|
|
+ enabledTypes.value = res.data.enabledTypes
|
|
|
+ } catch (error) {
|
|
|
+ console.log(error)
|
|
|
+ } finally {
|
|
|
+ optionsLoading.value = false
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
const GetLoginUrl = async (type) => {
|
|
|
+ if (!isTypeEnabled(type))
|
|
|
+ return requestFailed('该登录方式已关闭')
|
|
|
+
|
|
|
try {
|
|
|
changeLoading(true)
|
|
|
const res = await getLoginUrl({ type })
|
|
|
@@ -131,6 +154,7 @@ const requestFailed = (msg) => {
|
|
|
}
|
|
|
|
|
|
onMounted(() => {
|
|
|
+ loadOptions()
|
|
|
if (route.query.type && route.query.code) {
|
|
|
if (route.query.action === 'bind')
|
|
|
BindSocial(route.query.type, route.query.code)
|
|
|
@@ -180,6 +204,11 @@ onMounted(() => {
|
|
|
margin-left: -8px;
|
|
|
}
|
|
|
|
|
|
+.disabled-tip {
|
|
|
+ margin-bottom: 16px;
|
|
|
+ text-align: left;
|
|
|
+}
|
|
|
+
|
|
|
.uniLoginButton {
|
|
|
display: flex;
|
|
|
gap: 40px;
|
|
|
@@ -196,4 +225,4 @@ onMounted(() => {
|
|
|
margin-top: -10px;
|
|
|
margin-left: -15px;
|
|
|
}
|
|
|
-</style>
|
|
|
+</style>
|