From 3e8d83a41e70f6ef4d9e1a432d8578278bd2cbf9 Mon Sep 17 00:00:00 2001 From: xingyu Date: Tue, 19 Jul 2022 18:31:41 +0800 Subject: [PATCH] =?UTF-8?q?refactor=EF=BC=9Alogin?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- yudao-ui-admin-vue3/src/config/axios/index.ts | 5 - yudao-ui-admin-vue3/src/store/modules/user.ts | 1 - .../views/Login/components/LoginFormOld.vue | 279 ------------------ .../src/views/Login/components/MobileForm.vue | 18 +- .../src/views/Login/components/index.ts | 9 +- .../src/views/Login/components/useLogin.ts | 25 -- .../src/views/infra/codegen/EditTable.vue | 1 - 7 files changed, 12 insertions(+), 326 deletions(-) delete mode 100644 yudao-ui-admin-vue3/src/views/Login/components/LoginFormOld.vue diff --git a/yudao-ui-admin-vue3/src/config/axios/index.ts b/yudao-ui-admin-vue3/src/config/axios/index.ts index a8e710b38..c2496d437 100644 --- a/yudao-ui-admin-vue3/src/config/axios/index.ts +++ b/yudao-ui-admin-vue3/src/config/axios/index.ts @@ -56,11 +56,6 @@ const transform: AxiosTransform = { // 这里 code,result,message为 后台统一的字段,需要在 types.ts内修改为项目自己的接口返回格式 const { code, msg } = data const result = data.data - // TODO 输出res 方便调试,完成后删除 - // console.info('data') - // console.info(data) - // console.info('result') - // console.info(result) // TODO 芋艿:文件下载,需要特殊处理 if (code === undefined) { console.log(res) diff --git a/yudao-ui-admin-vue3/src/store/modules/user.ts b/yudao-ui-admin-vue3/src/store/modules/user.ts index aaa3a2017..9d5c0764e 100644 --- a/yudao-ui-admin-vue3/src/store/modules/user.ts +++ b/yudao-ui-admin-vue3/src/store/modules/user.ts @@ -27,7 +27,6 @@ export const useUserStore = defineStore({ } }), actions: { - // TODO 设置store刷新页面就消失 async getUserInfoAction() { if (!getAccessToken()) { this.resetState() diff --git a/yudao-ui-admin-vue3/src/views/Login/components/LoginFormOld.vue b/yudao-ui-admin-vue3/src/views/Login/components/LoginFormOld.vue deleted file mode 100644 index 6bc1ab7cf..000000000 --- a/yudao-ui-admin-vue3/src/views/Login/components/LoginFormOld.vue +++ /dev/null @@ -1,279 +0,0 @@ - - - - - diff --git a/yudao-ui-admin-vue3/src/views/Login/components/MobileForm.vue b/yudao-ui-admin-vue3/src/views/Login/components/MobileForm.vue index 7d29387ff..09ede7748 100644 --- a/yudao-ui-admin-vue3/src/views/Login/components/MobileForm.vue +++ b/yudao-ui-admin-vue3/src/views/Login/components/MobileForm.vue @@ -40,9 +40,6 @@ const rules = { } const loginData = reactive({ codeImg: '', - // TODO @jinz:多余的变量 isShowPassword、captchaEnable - isShowPassword: false, - captchaEnable: true, tenantEnable: true, token: '', loading: { @@ -55,8 +52,7 @@ const loginData = reactive({ code: '' } }) -// TODO @jinz:smsVO 小写哈 -const SmsVO = reactive({ +const smsVO = reactive({ smsCode: { mobile: '', scene: 21 @@ -70,9 +66,9 @@ const mobileCodeTimer = ref(0) const redirect = ref('') const getSmsCode = async () => { await getTenantId() - SmsVO.smsCode.mobile = loginData.loginForm.mobileNumber - console.log('getSmsCode begin:', SmsVO.smsCode) - await sendSmsCodeApi(SmsVO.smsCode) + smsVO.smsCode.mobile = loginData.loginForm.mobileNumber + console.log('getSmsCode begin:', smsVO.smsCode) + await sendSmsCodeApi(smsVO.smsCode) .then(async (res) => { // 提示验证码发送成功 ElMessage({ @@ -119,9 +115,9 @@ const signIn = async () => { const data = await validForm() if (!data) return loginLoading.value = true - SmsVO.loginSms.mobile = loginData.loginForm.mobileNumber - SmsVO.loginSms.code = loginData.loginForm.code - await smsLoginApi(SmsVO.loginSms) + smsVO.loginSms.mobile = loginData.loginForm.mobileNumber + smsVO.loginSms.code = loginData.loginForm.code + await smsLoginApi(smsVO.loginSms) .then(async (res) => { setToken(res?.token) await userStore.getUserInfoAction() diff --git a/yudao-ui-admin-vue3/src/views/Login/components/index.ts b/yudao-ui-admin-vue3/src/views/Login/components/index.ts index d97896dd8..cec812e11 100644 --- a/yudao-ui-admin-vue3/src/views/Login/components/index.ts +++ b/yudao-ui-admin-vue3/src/views/Login/components/index.ts @@ -1,4 +1,5 @@ -export { default as LoginForm } from './LoginForm.vue' -export { default as MobileForm } from './MobileForm.vue' -export { default as LoginFormOld } from './LoginFormOld.vue' // TODO jinz:old 是不是可以删除哈,git 可以管理的 -export { default as LoginFormTitle } from './LoginFormTitle.vue' +import LoginForm from './LoginForm.vue' +import MobileForm from './MobileForm.vue' +import LoginFormTitle from './LoginFormTitle.vue' + +export {LoginForm, MobileForm, LoginFormTitle} diff --git a/yudao-ui-admin-vue3/src/views/Login/components/useLogin.ts b/yudao-ui-admin-vue3/src/views/Login/components/useLogin.ts index d3c610db6..b57b6470a 100644 --- a/yudao-ui-admin-vue3/src/views/Login/components/useLogin.ts +++ b/yudao-ui-admin-vue3/src/views/Login/components/useLogin.ts @@ -41,31 +41,6 @@ export function useFormValid(formRef: Ref) { } } -// TODO @jinz:多余的,是不是可以删除哈 -export function useFormRules(formData?: Recordable) { - const { t } = useI18n() - - const getAccountFormRule = computed(() => createRule(t('sys.login.accountPlaceholder'))) - const getPasswordFormRule = computed(() => createRule(t('sys.login.passwordPlaceholder'))) - const getSmsFormRule = computed(() => createRule(t('sys.login.smsPlaceholder'))) - const getMobileFormRule = computed(() => createRule(t('sys.login.mobilePlaceholder'))) - - const validatePolicy = async (_: RuleObject, value: boolean) => { - return !value ? Promise.reject(t('sys.login.policyPlaceholder')) : Promise.resolve() - } - - const validateConfirmPassword = (password: string) => { - return async (_: RuleObject, value: string) => { - if (!value) { - return Promise.reject(t('sys.login.passwordPlaceholder')) - } - if (value !== password) { - return Promise.reject(t('sys.login.diffPwd')) - } - return Promise.resolve() - } - } - const getFormRules = computed( (): { [k: string]: ValidationRule | ValidationRule[] diff --git a/yudao-ui-admin-vue3/src/views/infra/codegen/EditTable.vue b/yudao-ui-admin-vue3/src/views/infra/codegen/EditTable.vue index 5fe852562..07dfa5221 100644 --- a/yudao-ui-admin-vue3/src/views/infra/codegen/EditTable.vue +++ b/yudao-ui-admin-vue3/src/views/infra/codegen/EditTable.vue @@ -27,7 +27,6 @@ const loading = ref(false) const activeName = ref('cloum') const basicInfoRef = ref>() const genInfoRef = ref>() -// TODO: 提交 const submitForm = async () => { const basicInfo = unref(basicInfoRef) const genInfo = unref(genInfoRef)