chore: 默认密码登录

This commit is contained in:
xiaojunnuo
2026-01-04 23:45:55 +08:00
parent 26ac081182
commit 8374a4f5bf
7 changed files with 55 additions and 21 deletions

View File

@@ -21,6 +21,7 @@ export class SysPublicSettings extends BaseSettings {
usernameRegisterEnabled = true;
mobileRegisterEnabled = false;
smsLoginEnabled = false;
useSmsLoginDefault = true;
emailRegisterEnabled = false;
selfServicePasswordRetrievalEnabled = false;

View File

@@ -53,6 +53,10 @@ export default {
alignLeft: "Align Left",
alignRight: "Align Right",
},
loginType: {
password: "Password Login",
sms: "Mobile Login",
},
usernamePlaceholder: "Please enter username/email/phone number",
passwordPlaceholder: "Please enter your password",
mobilePlaceholder: "Please enter your mobile number",

View File

@@ -53,6 +53,10 @@ export default {
alignLeft: "居左",
alignRight: "居右",
},
loginType: {
password: "密码登录",
sms: "手机号登录",
},
usernamePlaceholder: "请输入用户名/邮箱/手机号",
passwordPlaceholder: "请输入密码",
mobilePlaceholder: "请输入手机号",

View File

@@ -620,6 +620,7 @@ export default {
proFeature: "专业版功能",
emailServerSetup: "设置邮箱服务器",
enableSmsLoginRegister: "开启手机号登录、注册",
defaultLoginType: "默认登录方式",
commFeature: "商业版功能",
smsProvider: "短信提供商",
aliyunSms: "阿里云短信",

View File

@@ -36,6 +36,7 @@ export type SysPublicSetting = {
emailRegisterEnabled?: boolean;
passwordLoginEnabled?: boolean;
smsLoginEnabled?: boolean;
defaultLoginType?: string;
selfServicePasswordRetrievalEnabled?: boolean;
limitUserPipelineCount?: number;

View File

@@ -4,25 +4,6 @@
<!-- <div class="login-title">登录</div>-->
<template v-if="!isOauthOnly">
<a-tabs v-model:active-key="formState.loginType" :tab-bar-style="{ textAlign: 'center', borderBottom: 'unset' }">
<a-tab-pane v-if="sysPublicSettings.smsLoginEnabled === true" key="sms" :tab="t('authentication.smsTab')">
<template v-if="formState.loginType === 'sms'">
<a-form-item has-feedback name="mobile" :rules="rules.mobile">
<a-input v-model:value="formState.mobile" :placeholder="t('authentication.mobilePlaceholder')" autocomplete="off">
<template #prefix>
<fs-icon icon="ion:phone-portrait-outline"></fs-icon>
</template>
</a-input>
</a-form-item>
<a-form-item has-feedback name="smsCaptcha">
<CaptchaInput v-model:model-value="formState.smsCaptcha" @keydown.enter="handleFinish"></CaptchaInput>
</a-form-item>
<a-form-item name="smsCode" :rules="rules.smsCode">
<sms-code v-model:value="formState.smsCode" :captcha="formState.smsCaptcha" :mobile="formState.mobile" :phone-code="formState.phoneCode" @error="formState.smsCaptcha = null" />
</a-form-item>
</template>
</a-tab-pane>
<a-tab-pane key="password" :tab="t('authentication.passwordTab')" :disabled="sysPublicSettings.passwordLoginEnabled !== true">
<template v-if="formState.loginType === 'password'">
<!-- <div class="login-title">登录</div>-->
@@ -46,6 +27,25 @@
</a-form-item>
</template>
</a-tab-pane>
<a-tab-pane v-if="sysPublicSettings.smsLoginEnabled === true" key="sms" :tab="t('authentication.smsTab')">
<template v-if="formState.loginType === 'sms'">
<a-form-item has-feedback name="mobile" :rules="rules.mobile">
<a-input v-model:value="formState.mobile" :placeholder="t('authentication.mobilePlaceholder')" autocomplete="off">
<template #prefix>
<fs-icon icon="ion:phone-portrait-outline"></fs-icon>
</template>
</a-input>
</a-form-item>
<a-form-item has-feedback name="smsCaptcha">
<CaptchaInput v-model:model-value="formState.smsCaptcha" @keydown.enter="handleFinish"></CaptchaInput>
</a-form-item>
<a-form-item name="smsCode" :rules="rules.smsCode">
<sms-code v-model:value="formState.smsCode" :captcha="formState.smsCaptcha" :mobile="formState.mobile" :phone-code="formState.phoneCode" @error="formState.smsCaptcha = null" />
</a-form-item>
</template>
</a-tab-pane>
</a-tabs>
<a-form-item>
<a-button type="primary" size="large" html-type="button" :loading="loading" class="login-button" @click="handleFinish">
@@ -120,12 +120,18 @@ export default defineComponent({
const userStore = useUserStore();
const settingStore = useSettingStore();
const formRef = ref();
let defaultLoginType = settingStore.sysPublic.defaultLoginType || "password";
if (defaultLoginType === "sms") {
if (!settingStore.sysPublic.smsLoginEnabled || !settingStore.isComm) {
defaultLoginType = "password";
}
}
const formState = reactive({
username: "",
phoneCode: "86",
mobile: "",
password: "",
loginType: urlLoginType || settingStore.sysPublic.smsLoginEnabled ? "sms" : "password", //password
loginType: urlLoginType || settingStore.sysPublic.defaultLoginType, //password
smsCode: "",
captcha: null,
smsCaptcha: null,

View File

@@ -28,6 +28,11 @@
<router-link to="/sys/settings/email">{{ t("certd.emailServerSetup") }}</router-link>
</div>
</a-form-item>
<a-form-item :label="t('certd.defaultLoginType')" :name="['public', 'defaultLoginType']" required>
<div class="flex-o">
<a-radio-group v-model:value="formState.public.defaultLoginType" :options="loginTypeOptions" :title="t('certd.commFeature')" />
</div>
</a-form-item>
<a-form-item :label="t('certd.enableSmsLoginRegister')" :name="['public', 'smsLoginEnabled']">
<div class="flex-o">
<a-switch v-model:checked="formState.public.smsLoginEnabled" :disabled="!settingsStore.isComm" :title="t('certd.commFeature')" />
@@ -65,7 +70,7 @@
<script setup lang="tsx">
import { notification } from "ant-design-vue";
import { merge } from "lodash-es";
import { reactive, ref, Ref } from "vue";
import { computed, reactive, ref, Ref } from "vue";
import { useSettingStore } from "/@/store/settings";
import * as api from "/@/views/sys/settings/api";
import { SysSettings } from "/@/views/sys/settings/api";
@@ -187,6 +192,18 @@ const onFinish = async (form: any) => {
saveLoading.value = false;
}
};
const loginTypeOptions = computed(() => [
{
label: t("authentication.loginType.password"),
value: "password",
},
{
label: t("authentication.loginType.sms"),
value: "sms",
disabled: !formState.public.smsLoginEnabled,
},
]);
</script>
<style lang="less">
.sys-settings-register {