mirror of
https://github.com/continew-org/continew-admin-ui.git
synced 2025-09-25 06:57:12 +08:00
refactor: 调整 eslint.config.js,优化代码格式
This commit is contained in:
@@ -1,17 +1,23 @@
|
||||
<template>
|
||||
<a-modal v-model:visible="visible" :title="title" :mask-closable="false" :esc-to-close="false"
|
||||
:width="width >= 500 ? 500 : '100%'" draggable @before-ok="save" @ok="saveAfter" @close="reset">
|
||||
<a-modal
|
||||
v-model:visible="visible" :title="title" :mask-closable="false" :esc-to-close="false"
|
||||
:width="width >= 500 ? 500 : '100%'" draggable @before-ok="save" @ok="saveAfter" @close="reset"
|
||||
>
|
||||
<GiForm ref="formRef" v-model="form" :options="options" :columns="columns">
|
||||
<template #captcha>
|
||||
<a-input v-model="form.captcha" placeholder="请输入验证码" :max-length="6" allow-clear style="flex: 1 1" />
|
||||
<a-button class="captcha-btn" :loading="captchaLoading" :disabled="captchaDisable" size="large"
|
||||
@click="onCaptcha">
|
||||
<a-button
|
||||
class="captcha-btn" :loading="captchaLoading" :disabled="captchaDisable" size="large"
|
||||
@click="onCaptcha"
|
||||
>
|
||||
{{ captchaBtnName }}
|
||||
</a-button>
|
||||
</template>
|
||||
</GiForm>
|
||||
<Verify ref="VerifyRef" :captcha-type="captchaType" :mode="captchaMode"
|
||||
:img-size="{ width: '330px', height: '155px' }" @success="getCaptcha" />
|
||||
<Verify
|
||||
ref="VerifyRef" :captcha-type="captchaType" :mode="captchaMode"
|
||||
:img-size="{ width: '330px', height: '155px' }" @success="getCaptcha"
|
||||
/>
|
||||
</a-modal>
|
||||
</template>
|
||||
|
||||
@@ -34,13 +40,13 @@ const userInfo = computed(() => userStore.userInfo)
|
||||
|
||||
const verifyType = ref()
|
||||
const title = computed(
|
||||
() => `修改${verifyType.value === 'phone' ? '手机号' : verifyType.value === 'email' ? '邮箱' : '密码'}`
|
||||
() => `修改${verifyType.value === 'phone' ? '手机号' : verifyType.value === 'email' ? '邮箱' : '密码'}`,
|
||||
)
|
||||
const formRef = ref<InstanceType<typeof GiForm>>()
|
||||
|
||||
const options: Options = {
|
||||
form: { size: 'large' },
|
||||
btns: { hide: true }
|
||||
btns: { hide: true },
|
||||
}
|
||||
|
||||
const { form, resetForm } = useForm({
|
||||
@@ -49,7 +55,7 @@ const { form, resetForm } = useForm({
|
||||
captcha: '',
|
||||
oldPassword: '',
|
||||
newPassword: '',
|
||||
rePassword: ''
|
||||
rePassword: '',
|
||||
})
|
||||
|
||||
const columns: Columns = reactive([
|
||||
@@ -59,11 +65,11 @@ const columns: Columns = reactive([
|
||||
type: 'input',
|
||||
rules: [
|
||||
{ required: true, message: '请输入手机号' },
|
||||
{ match: Regexp.Phone, message: '请输入正确的手机号' }
|
||||
{ match: Regexp.Phone, message: '请输入正确的手机号' },
|
||||
],
|
||||
hide: () => {
|
||||
return verifyType.value !== 'phone'
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '邮箱',
|
||||
@@ -71,11 +77,11 @@ const columns: Columns = reactive([
|
||||
type: 'input',
|
||||
rules: [
|
||||
{ required: true, message: '请输入邮箱' },
|
||||
{ match: Regexp.Email, message: '请输入正确的邮箱' }
|
||||
{ match: Regexp.Email, message: '请输入正确的邮箱' },
|
||||
],
|
||||
hide: () => {
|
||||
return verifyType.value !== 'email'
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '验证码',
|
||||
@@ -84,7 +90,7 @@ const columns: Columns = reactive([
|
||||
rules: [{ required: true, message: '请输入验证码' }],
|
||||
hide: () => {
|
||||
return !['phone', 'email'].includes(verifyType.value)
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '当前密码',
|
||||
@@ -93,7 +99,7 @@ const columns: Columns = reactive([
|
||||
rules: [{ required: true, message: '请输入当前密码' }],
|
||||
hide: () => {
|
||||
return !userInfo.value.pwdResetTime
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '新密码',
|
||||
@@ -108,19 +114,19 @@ const columns: Columns = reactive([
|
||||
} else {
|
||||
callback()
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
],
|
||||
hide: () => {
|
||||
return verifyType.value !== 'password'
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '确认新密码',
|
||||
field: 'rePassword',
|
||||
type: 'input-password',
|
||||
props: {
|
||||
placeholder: '请再次输入新密码'
|
||||
placeholder: '请再次输入新密码',
|
||||
},
|
||||
rules: [
|
||||
{ required: true, message: '请再次输入新密码' },
|
||||
@@ -131,13 +137,13 @@ const columns: Columns = reactive([
|
||||
} else {
|
||||
callback()
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
],
|
||||
hide: () => {
|
||||
return verifyType.value !== 'password'
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
])
|
||||
|
||||
const VerifyRef = ref<InstanceType<any>>()
|
||||
@@ -210,14 +216,14 @@ const save = async () => {
|
||||
await updateUserPhone({
|
||||
phone: form.phone,
|
||||
captcha: form.captcha,
|
||||
oldPassword: encryptByRsa(form.oldPassword) as string
|
||||
oldPassword: encryptByRsa(form.oldPassword) as string,
|
||||
})
|
||||
Message.success('修改成功')
|
||||
} else if (verifyType.value === 'email') {
|
||||
await updateUserEmail({
|
||||
email: form.email,
|
||||
captcha: form.captcha,
|
||||
oldPassword: encryptByRsa(form.oldPassword) as string
|
||||
oldPassword: encryptByRsa(form.oldPassword) as string,
|
||||
})
|
||||
Message.success('修改成功')
|
||||
} else if (verifyType.value === 'password') {
|
||||
@@ -231,7 +237,7 @@ const save = async () => {
|
||||
}
|
||||
await updateUserPassword({
|
||||
oldPassword: encryptByRsa(form.oldPassword) || '',
|
||||
newPassword: encryptByRsa(form.newPassword) || ''
|
||||
newPassword: encryptByRsa(form.newPassword) || '',
|
||||
})
|
||||
}
|
||||
return true
|
||||
@@ -252,7 +258,7 @@ const saveAfter = async () => {
|
||||
const userStore = useUserStore()
|
||||
await userStore.logoutCallBack()
|
||||
await router.replace('/login')
|
||||
}
|
||||
},
|
||||
})
|
||||
} else {
|
||||
// 修改成功后,重新获取用户信息
|
||||
|
Reference in New Issue
Block a user