功能:统一账号输入校验并调整首页轮播图
This commit is contained in:
@@ -28,6 +28,7 @@
|
||||
size="large"
|
||||
placeholder="请输入用户名"
|
||||
:prefix-icon="UserOutlined"
|
||||
@input="handleAccountInput"
|
||||
/>
|
||||
</a-form-item>
|
||||
|
||||
@@ -82,6 +83,7 @@ import { message } from 'ant-design-vue'
|
||||
import type { FormInstance } from 'ant-design-vue'
|
||||
import { UserOutlined, LockOutlined } from '@ant-design/icons-vue'
|
||||
import { adminAuthApi, type LoginShopSelectionResponse } from '@/api/admin'
|
||||
import { ACCOUNT_REGEX, ACCOUNT_RULE_MESSAGE, sanitizeAccountInput } from '@/utils/account'
|
||||
import { usePermission } from '@/utils/permission'
|
||||
|
||||
const router = useRouter()
|
||||
@@ -100,6 +102,13 @@ const formState = reactive({
|
||||
})
|
||||
let loginShopTimer: number | undefined
|
||||
|
||||
const handleAccountInput = () => {
|
||||
const normalized = sanitizeAccountInput(formState.account)
|
||||
if (normalized !== formState.account) {
|
||||
formState.account = normalized
|
||||
}
|
||||
}
|
||||
|
||||
const getShopIdValue = (shop: { id: number | string; shopName: string }) => String(shop.id ?? '')
|
||||
const getShopLabel = (shop: { id: number | string; shopName: string }) => String(shop.shopName || `店铺 ${shop.id}`)
|
||||
|
||||
@@ -127,7 +136,7 @@ const shopPlaceholder = computed(() => {
|
||||
const formRules = {
|
||||
account: [
|
||||
{ required: true, message: '请输入用户名', trigger: 'blur' },
|
||||
{ pattern: /^[a-zA-Z0-9_\-@.]+$/, message: '账号只能包含数字、字母、下划线、连字符、@和点号', trigger: 'blur' }
|
||||
{ pattern: ACCOUNT_REGEX, message: ACCOUNT_RULE_MESSAGE, trigger: 'blur' }
|
||||
],
|
||||
password: [{ required: true, message: '请输入密码', trigger: 'blur' }],
|
||||
shopId: [{
|
||||
|
||||
Reference in New Issue
Block a user