wip: coding
This commit is contained in:
parent
537af57a0a
commit
1878c2ede7
|
@ -37,6 +37,7 @@
|
|||
"echarts-wordcloud": "^2.0.0",
|
||||
"element-plus": "2.2.6",
|
||||
"intro.js": "^5.1.0",
|
||||
"js-md5": "^0.7.3",
|
||||
"lodash-es": "^4.17.21",
|
||||
"mitt": "^3.0.0",
|
||||
"mockjs": "^1.1.0",
|
||||
|
@ -59,6 +60,7 @@
|
|||
"@intlify/vite-plugin-vue-i18n": "^3.4.0",
|
||||
"@purge-icons/generated": "^0.8.1",
|
||||
"@types/intro.js": "^3.0.2",
|
||||
"@types/js-md5": "^0.4.3",
|
||||
"@types/lodash-es": "^4.17.6",
|
||||
"@types/node": "^18.0.0",
|
||||
"@types/nprogress": "^0.2.0",
|
||||
|
|
|
@ -3,10 +3,17 @@ import { IUserModel } from '@/api-types/user'
|
|||
|
||||
const request = useAxios()
|
||||
|
||||
interface ICodeModel {
|
||||
url: string
|
||||
uuid: string
|
||||
}
|
||||
|
||||
export const getCodeApi = async () => {
|
||||
return (await request.get<IResponse<string>>({ url: 'user/captcha' })).data
|
||||
const res = await request.get<IResponse<ICodeModel>>({ url: 'user/captcha' })
|
||||
return res && res.data
|
||||
}
|
||||
|
||||
export const registerApi = async (data: Omit<IUserModel, 'is_admin'>) => {
|
||||
return (await request.post<IResponse<IUserModel>>({ url: 'user/register', data })).data
|
||||
const res = await request.post<IResponse<IUserModel>>({ url: 'user/register', data })
|
||||
return res && res.data
|
||||
}
|
||||
|
|
|
@ -7,6 +7,8 @@ import { ElButton, ElInput, FormRules, ElMessage } from 'element-plus'
|
|||
import { getCodeApi, registerApi } from '@/api/register'
|
||||
import { useValidator } from '@/hooks/web/useValidator'
|
||||
import { IUserModel } from '@/api-types/user'
|
||||
import md5 from 'js-md5'
|
||||
import { cloneDeep } from 'lodash-es'
|
||||
|
||||
const emit = defineEmits(['to-login'])
|
||||
|
||||
|
@ -99,7 +101,7 @@ const rules: FormRules = {
|
|||
required('密码不能为空'),
|
||||
{
|
||||
validator: (_, value, callback) =>
|
||||
lengthRange(value, callback, { min: 6, max: 20, message: '密码长度必须在6-20之间' })
|
||||
lengthRange(value, callback, { min: 5, max: 20, message: '密码长度必须在5-20之间' })
|
||||
},
|
||||
{
|
||||
validator: (_, value, callback) => notSpecialCharacters(value, callback, '密码不能是特殊字符')
|
||||
|
@ -109,7 +111,7 @@ const rules: FormRules = {
|
|||
required('确认密码不能为空'),
|
||||
{
|
||||
validator: (_, value, callback) =>
|
||||
lengthRange(value, callback, { min: 6, max: 20, message: '确认密码长度必须在6-20之间' })
|
||||
lengthRange(value, callback, { min: 5, max: 20, message: '确认密码长度必须在5-20之间' })
|
||||
},
|
||||
{
|
||||
validator: (_, value, callback) =>
|
||||
|
@ -130,9 +132,14 @@ const toLogin = () => {
|
|||
}
|
||||
|
||||
const codeUrl = ref('')
|
||||
const codeUuid = ref('')
|
||||
const getCode = async () => {
|
||||
const { result } = await getCodeApi()
|
||||
codeUrl.value = result
|
||||
const res = await getCodeApi()
|
||||
if (res) {
|
||||
const { url, uuid } = res.result
|
||||
codeUrl.value = url
|
||||
codeUuid.value = uuid
|
||||
}
|
||||
}
|
||||
getCode()
|
||||
|
||||
|
@ -145,8 +152,14 @@ const loginRegister = async () => {
|
|||
try {
|
||||
loading.value = true
|
||||
const formData = await getFormData<Omit<IUserModel, 'is_admin'>>()
|
||||
const { result } = await registerApi(formData)
|
||||
if (result) {
|
||||
const res = await registerApi(
|
||||
Object.assign(cloneDeep(formData), {
|
||||
uuid: codeUuid.value,
|
||||
password: md5(formData.password),
|
||||
check_password: md5(formData.check_password)
|
||||
})
|
||||
)
|
||||
if (res) {
|
||||
ElMessage.success('注册成功')
|
||||
toLogin()
|
||||
}
|
||||
|
@ -175,7 +188,7 @@ const loginRegister = async () => {
|
|||
<template #code="form">
|
||||
<div class="w-[100%] flex">
|
||||
<ElInput v-model="form['code']" :placeholder="t('login.codePlaceholder')" class="flex-2" />
|
||||
<div v-html="codeUrl" class="h-38px flex-1 cursor-pointer" @click="getCode"></div>
|
||||
<div v-html="codeUrl" class="h-38px flex-1 cursor-pointer w-150px" @click="getCode"></div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ function pathResolve(dir: string) {
|
|||
|
||||
// https://vitejs.dev/config/
|
||||
export default ({ command, mode }: ConfigEnv): UserConfig => {
|
||||
let env = null
|
||||
let env = {} as any
|
||||
const isBuild = command === 'build'
|
||||
if (!isBuild) {
|
||||
env = loadEnv((process.argv[3] === '--mode' ? process.argv[4] : process.argv[3]), root)
|
||||
|
@ -146,7 +146,8 @@ export default ({ command, mode }: ConfigEnv): UserConfig => {
|
|||
'intro.js',
|
||||
'qrcode',
|
||||
'@wangeditor/editor',
|
||||
'@wangeditor/editor-for-vue'
|
||||
'@wangeditor/editor-for-vue',
|
||||
'js-md5'
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue