From 57d44bc461c28d695ee9ecb58a46ccf784b0935e Mon Sep 17 00:00:00 2001 From: congzc Date: Wed, 25 Oct 2023 17:43:30 +0800 Subject: [PATCH] 1 --- .env.development | 6 +- README.md | 2 +- index.html | 2 +- src/apis/login.js | 19 +-- src/lang/package/en.ts | 4 +- src/lang/package/zh-cn.ts | 4 +- src/types/auto-imports.d.ts | 2 - src/types/components.d.ts | 12 -- src/utils/request.js | 4 +- src/views/login/index.vue | 274 ++++-------------------------------- vite.config.ts | 9 +- 11 files changed, 46 insertions(+), 292 deletions(-) diff --git a/.env.development b/.env.development index a42f23a..6a26b80 100644 --- a/.env.development +++ b/.env.development @@ -5,6 +5,8 @@ NODE_ENV='development' VITE_APP_TITLE = 'Metavatar-PC' VITE_APP_PORT = 3000 -## VITE_APP_BASE_API = 'https://photo.metavatar.cc/C' -VITE_APP_BASE_API = 'https://test.metavatar.cc/C' +## VITE_APP_BASE_API = 'https://photo.metavatar.cc/C' alitest 123456 +VITE_APP_BASE_API = 'https://mtest.metavatar.cc/A' + + diff --git a/README.md b/README.md index 96e5c7c..403c569 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ - + git commit -m "feat: " git commit --no-verify -m "提交时的注释" 跳过检验 git merge origin/dev_ \ No newline at end of file diff --git a/index.html b/index.html index c884133..c039722 100644 --- a/index.html +++ b/index.html @@ -5,7 +5,7 @@ - Metavatar-慧影 + Metavatar-邃芒管理端 diff --git a/src/apis/login.js b/src/apis/login.js index ba0a12c..4a2dc8b 100644 --- a/src/apis/login.js +++ b/src/apis/login.js @@ -2,29 +2,16 @@ import request from "@/utils/request.js"; const baseURL = import.meta.env.VITE_APP_BASE_API -/** - * @description 注册 - * @params email,password - * @returns data - */ -export function register(data) { - return request({ - // url: `/api/user/doRegisterByEmail`, - url: `/api/user/doRegisterByPhone`, - method: 'post', - data - }) -} /** * @description 登录 * @params email,password,code * @returns data */ -export function login(data) { +export function loginApi(data) { return request({ // url: `/api/user/loginByEmail`, - url: `/api/user/login`, + url: `/doLogin`, method: 'post', data }) @@ -175,5 +162,5 @@ export function resetPwdFormApi(data) { * @description:获取图形验证码 * @return: 验证码地址 */ -export const getCodeImgUrl = baseURL + '/api/user/captcha.jpg' +export const getCodeImgUrl = baseURL + '/captcha.jpg' diff --git a/src/lang/package/en.ts b/src/lang/package/en.ts index 172ad70..8011723 100644 --- a/src/lang/package/en.ts +++ b/src/lang/package/en.ts @@ -15,7 +15,7 @@ export default { // 登录页面国际化 login: { // title: "Metavatar-MetaTalker", - title: "MetaTalker", + title: "MetaTalker-Admin", username: "Username", email: "Phone", password: "Password", @@ -24,7 +24,7 @@ export default { register: "Sign up", loginBtn: "Sign in", registerBtn: "Sign up", - verifyCode: "Verify code", + captcha: "Verify code", signIn: "Already got an account? Sign in here", signUp: "Don't have an account? Sign up here", forgetPwd: "I forgot my password", diff --git a/src/lang/package/zh-cn.ts b/src/lang/package/zh-cn.ts index 7b7ac1c..bba6a79 100644 --- a/src/lang/package/zh-cn.ts +++ b/src/lang/package/zh-cn.ts @@ -14,7 +14,7 @@ export default { }, // 登录页面国际化 login: { - title: "慧影", + title: "邃芒管理端", username: "用户名", email: "手机号", password: "密码", @@ -23,7 +23,7 @@ export default { register: "注册", loginBtn: "登 录", registerBtn: "注 册", - verifyCode: "验证码", + captcha: "验证码", // signIn: "已有账号?现在登录!", // signUp: "没有账号?现在加入!", signIn: "立即登录", diff --git a/src/types/auto-imports.d.ts b/src/types/auto-imports.d.ts index e5c7bdb..53bb615 100644 --- a/src/types/auto-imports.d.ts +++ b/src/types/auto-imports.d.ts @@ -4,7 +4,6 @@ declare global { const EffectScope: typeof import('vue')['EffectScope'] const ElForm: typeof import('element-plus/es')['ElForm'] const ElMessage: typeof import('element-plus/es')['ElMessage'] - const ElMessageBox: typeof import('element-plus/es')['ElMessageBox'] const asyncComputed: typeof import('@vueuse/core')['asyncComputed'] const autoResetRef: typeof import('@vueuse/core')['autoResetRef'] const computed: typeof import('vue')['computed'] @@ -273,7 +272,6 @@ declare module 'vue' { readonly EffectScope: UnwrapRef readonly ElForm: UnwrapRef readonly ElMessage: UnwrapRef - readonly ElMessageBox: UnwrapRef readonly asyncComputed: UnwrapRef readonly autoResetRef: UnwrapRef readonly computed: UnwrapRef diff --git a/src/types/components.d.ts b/src/types/components.d.ts index b95cf41..6fa6b5c 100644 --- a/src/types/components.d.ts +++ b/src/types/components.d.ts @@ -24,7 +24,6 @@ declare module '@vue/runtime-core' { ElInput: typeof import('element-plus/es')['ElInput'] ElInputNumber: typeof import('element-plus/es')['ElInputNumber'] ElOption: typeof import('element-plus/es')['ElOption'] - ElPagination: typeof import('element-plus/es')['ElPagination'] ElSelect: typeof import('element-plus/es')['ElSelect'] ElSwitch: typeof import('element-plus/es')['ElSwitch'] ElTooltip: typeof import('element-plus/es')['ElTooltip'] @@ -32,19 +31,8 @@ declare module '@vue/runtime-core' { GithubCorner: typeof import('./../components/GithubCorner/index.vue')['default'] Hamburger: typeof import('./../components/Hamburger/index.vue')['default'] IconSelect: typeof import('./../components/IconSelect/index.vue')['default'] - IEpCloseBold: typeof import('~icons/ep/close-bold')['default'] - IEpDelete: typeof import('~icons/ep/delete')['default'] IEpDocumentAdd: typeof import('~icons/ep/document-add')['default'] - IEpDownload: typeof import('~icons/ep/download')['default'] IEpEdit: typeof import('~icons/ep/edit')['default'] - IEpGoods: typeof import('~icons/ep/goods')['default'] - IEpLoading: typeof import('~icons/ep/loading')['default'] - IEpLock: typeof import('~icons/ep/lock')['default'] - IEpMenu: typeof import('~icons/ep/menu')['default'] - IEpPhone: typeof import('~icons/ep/phone')['default'] - IEpSearch: typeof import('~icons/ep/search')['default'] - IEpUser: typeof import('~icons/ep/user')['default'] - IEpVideoPlay: typeof import('~icons/ep/video-play')['default'] LangSelect: typeof import('./../components/LangSelect/index.vue')['default'] MultiUpload: typeof import('./../components/Upload/MultiUpload.vue')['default'] MyLoading: typeof import('./../components/myLoading.vue')['default'] diff --git a/src/utils/request.js b/src/utils/request.js index 35d630f..acf9585 100644 --- a/src/utils/request.js +++ b/src/utils/request.js @@ -11,8 +11,8 @@ const appStore = useAppStore(store); //pinia const userInfoPinia = userInfoModules(store); //pinia // const userInfoPinia = userInfoModules(store); //pinia // 开发环境需以 "/api" 拼接,其他环境需以 "/C" 拼接 -const env = process.env.NODE_ENV == 'development' ? "/api" : "/C" -// const env = process.env.NODE_ENV == 'development' ? "" : "" +// const env = process.env.NODE_ENV == 'development' ? "/api" : "/C" +const env = process.env.NODE_ENV == 'development' ? "/A" : "/A" console.log(env) /** diff --git a/src/views/login/index.vue b/src/views/login/index.vue index eaa0d2a..f53e09c 100644 --- a/src/views/login/index.vue +++ b/src/views/login/index.vue @@ -31,7 +31,7 @@ - +
@@ -39,8 +39,8 @@ class="flex-1" ref="email" size="large" - v-model="loginData.email" - :placeholder="$t('login.email')" + v-model="loginData.username" + :placeholder="$t('login.username')" name="email" />
@@ -67,14 +67,14 @@
- + @@ -111,9 +111,6 @@
-
- {{ $t("login.signUp") }} -
{{ $t("login.SMSLogin") @@ -126,188 +123,8 @@
- - -
-
- {{ $t("login.signUp") }} -
{{ $t("login.pwsLogin") @@ -786,8 +600,7 @@ import LangSelect from "@/components/LangSelect/index.vue"; import SvgIcon from "@/components/SvgIcon/index.vue"; import { - register, - login, + loginApi, sendRegisterEmail, getCodeImgUrl, sendUpdPwdEmailApi, @@ -848,9 +661,9 @@ const isLogining = ref(false); const isRegistering = ref(false); const loginData = ref({ - email: "", + username: "", password: "", - verifyCode: "", + captcha: "", }); const loginData2 = ref({ @@ -882,6 +695,13 @@ const loginData8 = ref({ invitatioCode: "", }); const loginRules = ref({ + username: [ + { + required: true, + trigger: "blur", + validator: passwordValidator, + }, + ], email: [ { required: true, @@ -894,13 +714,13 @@ const loginRules = ref({ confirmPassword: [ { required: true, trigger: "blur", validator: confirmPasswordValidator }, ], - verifyCode: [ + captcha: [ { required: true, trigger: "blur", message: currentLan.value == "zh-cn" - ? "请输入验证码" + ? "请输入验证码2" : "Please input verifyCode", }, ], @@ -928,8 +748,8 @@ const loginRules = ref({ watch(currentLan, (newValue, oldValue) => { const loginRule = loginRules.value; - loginRule.verifyCode[0].message = - newValue == "zh-cn" ? "请输入验证码" : "Please input verifyCode"; + loginRule.captcha[0].message = + newValue == "zh-cn" ? "请输入验证码1" : "Please input verifyCode"; setTimeout(() => { loginFormRef.value.resetFields(); getInfo(); @@ -973,7 +793,7 @@ function getInfo() { const deCodeUserInfo = decodeURI(data as any); const userInfo = JSON.parse(deCodeUserInfo); if (userInfo) { - loginData.value.email = userInfo.email ? userInfo.email : ""; + loginData.value.username = userInfo.email ? userInfo.email : ""; loginData.value.password = userInfo.password ? userInfo.password : ""; } } @@ -1096,9 +916,9 @@ function handleLogin() { loginFormRef.value.validate((val: any) => { if (val) { const data = { - phone: loginData.value.email, + username: loginData.value.username, password: loginData.value.password, - code: loginData.value.verifyCode, + captcha: loginData.value.captcha, }; isLogining.value = true; doLogin(data); @@ -1114,25 +934,6 @@ function handleLogin() { } // 注册行为 -function handleRegister() { - loginFormRef.value.validate((val: any) => { - if (val) { - const data = { - phone: loginData2.value.email, - password: loginData2.value.password, - }; - isRegistering.value = true; - doRegister(data); - } else { - const msg = - currentLan.value == "zh-cn" - ? "请检查信息格式!" - : "Please check the format !"; - ElMessage.error(msg); - return; - } - }); -} //#region 忘记密码 表单3 function sendEmailforgetPwd() { @@ -1376,33 +1177,6 @@ function getCode() { }); } -/** - * @description:注册 - * @param {Object} data - * @return: data - */ -async function doRegister(data: object) { - const msg = - currentLan.value == "zh-cn" ? "注册成功!" : "Registered successfully"; - await register(data) - .then((res) => { - console.log(res, "res"); - isRegistering.value = false; - ElMessage.success(msg); - isLogin.value = 1; - // 注册成功将账号密码保存到本地 - saveInfo(data); - router.go(0); - }) - .catch((err) => { - // 注册失败刷新验证码 - getCode(); - isRegistering.value = false; - console.log(err, "err"); - ElMessage.error(err.message); - }); -} - /** * @description:登录 * @param {Object} data @@ -1411,7 +1185,7 @@ async function doRegister(data: object) { async function doLogin(data: any) { const msg = currentLan.value == "zh-cn" ? "登录成功!" : "Welcome to Metavatar!"; - await login(data) + await loginApi(data) .then(async (res) => { console.log(res, "res"); localStorage.setItem("AccessToken", res.data.token); diff --git a/vite.config.ts b/vite.config.ts index e0e9a13..db5fba2 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -49,12 +49,17 @@ export default defineConfig(({ mode }: ConfigEnv): UserConfig => { host: "0.0.0.0", port: Number(env.VITE_APP_PORT), open: true, // 运行是否自动打开浏览器 + // "/api": { + // target: env.VITE_APP_BASE_API, // 线上接口地址 + // changeOrigin: true, + // rewrite: (path) => path.replace(/^\/api/, ""), + // }, proxy: { // 反向代理解决跨域 - "/api": { + "/A": { target: env.VITE_APP_BASE_API, // 线上接口地址 changeOrigin: true, - rewrite: (path) => path.replace(/^\/api/, ""), + rewrite: (path) => path.replace(/^\/A/, ""), }, }, },