diff --git a/src/api/sys/user.ts b/src/api/sys/user.ts index 76c340b5..1f87fa6c 100644 --- a/src/api/sys/user.ts +++ b/src/api/sys/user.ts @@ -26,7 +26,19 @@ export function loginApi(params: LoginParams, mode: ErrorMessageMode = 'modal') }, { errorMessageMode: mode, - apiUrl: 'http://localhost:10088', + apiUrl: url, + }, + ); +} +export function registerApi(params: LoginParams, mode: ErrorMessageMode = 'modal') { + return defHttp.post( + { + url: Api.Register, + params, + }, + { + errorMessageMode: mode, + apiUrl: url, }, ); } diff --git a/src/views/sys/login/LoginForm.vue b/src/views/sys/login/LoginForm.vue index e418544c..da81151c 100644 --- a/src/views/sys/login/LoginForm.vue +++ b/src/views/sys/login/LoginForm.vue @@ -106,10 +106,10 @@ const formRef = ref(); const loading = ref(false); const rememberMe = ref(false); - const formData = reactive({ - account: 'admin', - password: '123456', - }); +const formData = reactive({ + account: '', + password: '', +}); const { validForm } = useFormValid(formRef); @@ -117,33 +117,33 @@ const { validForm } = useFormValid(formRef); const getShow = computed(() => unref(getLoginState) === LoginStateEnum.LOGIN); - async function handleLogin() { - const data = await validForm(); - if (!data) return; - try { - loading.value = true; - const userInfo = await userStore.login( - toRaw({ - password: data.password, - username: data.account, - mode: 'none', //不要默认的错误提示 - }), - ); - if (userInfo) { - notification.success({ - message: t('sys.login.loginSuccessTitle'), - description: `${t('sys.login.loginSuccessDesc')}: ${userInfo.username}`, - duration: 3, - }); - } - } catch (error) { - createErrorModal({ - title: t('sys.api.errorTip'), - content: error.message || t('sys.api.networkExceptionMsg'), - getContainer: () => document.body.querySelector(`.${prefixCls}`) || document.body, +async function handleLogin() { + const data = await validForm(); + if (!data) return; + try { + loading.value = true; + const userInfo = await userStore.login( + toRaw({ + password: data.password, + username: data.account, + mode: 'none', //不要默认的错误提示 + }), + ); + if (userInfo) { + notification.success({ + message: t('sys.login.loginSuccessTitle'), + description: `${t('sys.login.loginSuccessDesc')}: ${userInfo.username}`, + duration: 3, }); - } finally { - loading.value = false; } + } catch (error) { + createErrorModal({ + title: t('sys.api.errorTip'), + content: error.message || t('sys.api.networkExceptionMsg'), + getContainer: () => document.body.querySelector(`.${prefixCls}`) || document.body, + }); + } finally { + loading.value = false; } +}