diff --git a/src/router/index.ts b/src/router/index.ts index 534e859..893a84f 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -1,7 +1,8 @@ import { createRouter, createWebHashHistory } from "vue-router"; -import Nprogress from 'nprogress'; +import Nprogress from "nprogress"; import { useUserStore } from "@/stores/user"; import { isLogin } from "@/services/userApi"; + const router = createRouter({ history: createWebHashHistory(), routes: [ @@ -9,182 +10,191 @@ const router = createRouter({ path: "/", name: "home", component: () => import("../views/Home.vue"), - meta:{ - title:'主页——PeterAlbus的博客', - content:{ - keywords:'PeterAlbus,Vue,个人博客', - description:'PeterAlbus的博客主页' + meta: { + title: "主页——PeterAlbus的博客", + content: { + keywords: "PeterAlbus,Vue,个人博客", + description: "PeterAlbus的博客主页" } } }, { - path: '/login', - name: 'Login', - component: () => import("../views/Login.vue"), - meta:{ - title:'登录——PeterAlbus的博客', - content:{ - keywords:'PeterAlbus,Vue', - description:'PeterAlbus的博客登录页' + path: "/login", + name: "Login", + component: () => import("../views/user/Login.vue"), + meta: { + title: "登录——PeterAlbus的博客", + content: { + keywords: "PeterAlbus,Vue", + description: "PeterAlbus的博客登录页" } } }, { - path: '/register', - name: 'Register', - component: () => import("../views/Register.vue"), - meta:{ - title:'注册——PeterAlbus的博客', - content:{ - keywords:'PeterAlbus,Vue', - description:'PeterAlbus的博客注册页' + path: "/register", + name: "Register", + component: () => import("../views/user/Register.vue"), + meta: { + title: "注册——PeterAlbus的博客", + content: { + keywords: "PeterAlbus,Vue", + description: "PeterAlbus的博客注册页" } } }, { - path: '/userCenter', - name: 'UserCenter', - component: () => import("../views/UserCenter.vue"), - meta:{ - title:'用户中心——PeterAlbus的博客', - content:{ - keywords:'PeterAlbus,Vue', - description:'PeterAlbus的博客用户中心' + path: "/userCenter", + name: "UserCenter", + component: () => import("../views/user/UserCenter.vue"), + meta: { + title: "用户中心——PeterAlbus的博客", + content: { + keywords: "PeterAlbus,Vue", + description: "PeterAlbus的博客用户中心" } } }, { - path: '/blog', - name: 'Blog', - component: () => import("../views/Blog.vue"), - meta:{ - title:'博文——PeterAlbus的博客', - content:{ - keywords:'PeterAlbus,Vue', - description:'PeterAlbus的博客博文页' + path: "/blog", + name: "Blog", + component: () => import("../views/blog/Blog.vue"), + meta: { + title: "博文——PeterAlbus的博客", + content: { + keywords: "PeterAlbus,Vue", + description: "PeterAlbus的博客博文页" } } }, { - path: '/about', - name: 'About', - component: () => import("../views/About.vue"), - meta:{ - title:'关于我——PeterAlbus的博客', - content:{ - keywords:'PeterAlbus,Vue', - description:'PeterAlbus的个人介绍' + path: "/about", + name: "About", + component: () => import("../views/blog/About.vue"), + meta: { + title: "关于我——PeterAlbus的博客", + content: { + keywords: "PeterAlbus,Vue", + description: "PeterAlbus的个人介绍" } } }, { - path: '/document', - name: 'Document', - component: () => import("../views/Document.vue"), - meta:{ - title:'归档——PeterAlbus的博客', - content:{ - keywords:'PeterAlbus,Vue', - description:'PeterAlbus的博客归档页' + path: "/document", + name: "Document", + component: () => import("../views/blog/Document.vue"), + meta: { + title: "归档——PeterAlbus的博客", + content: { + keywords: "PeterAlbus,Vue", + description: "PeterAlbus的博客归档页" } } }, { - path: '/photo', - name: 'Photo', - component: () => import("../views/Photo.vue"), - meta:{ - title:'照片墙——PeterAlbus的博客', - content:{ - keywords:'PeterAlbus,Vue', - description:'PeterAlbus的照片墙' + path: "/photo", + name: "Photo", + component: () => import("../views/photo/Photo.vue"), + meta: { + title: "照片墙——PeterAlbus的博客", + content: { + keywords: "PeterAlbus,Vue", + description: "PeterAlbus的照片墙" } } }, { - path: '/types', - name: 'Types', - component: () => import("../views/Types.vue"), - meta:{ - title:'分类查看——PeterAlbus的博客', - content:{ - keywords:'PeterAlbus,Vue', - description:'PeterAlbus的博客列表' + path: "/types", + name: "Types", + component: () => import("../views/blog/Types.vue"), + meta: { + title: "分类查看——PeterAlbus的博客", + content: { + keywords: "PeterAlbus,Vue", + description: "PeterAlbus的博客列表" } } }, { - path: '/editBlog', - name: 'EditBlog', - component: () => import("../views/EditBlog.vue"), - meta:{ - title:'编辑/创建博客——PeterAlbus的博客', - content:{ - keywords:'PeterAlbus,Vue', - description:'PeterAlbus的博客编辑页' + path: "/editBlog", + name: "EditBlog", + component: () => import("../views/blog/EditBlog.vue"), + meta: { + title: "编辑/创建博客——PeterAlbus的博客", + content: { + keywords: "PeterAlbus,Vue", + description: "PeterAlbus的博客编辑页" } } }, { - path: '/uploadPhoto', - name: 'UploadPhoto', - component: () => import("../views/UploadPhoto.vue"), - meta:{ - title:'上传照片——PeterAlbus的博客', - content:{ - keywords:'PeterAlbus,Vue', - description:'PeterAlbus的博客' + path: "/uploadPhoto", + name: "UploadPhoto", + component: () => import("../views/photo/UploadPhoto.vue"), + meta: { + title: "上传照片——PeterAlbus的博客", + content: { + keywords: "PeterAlbus,Vue", + description: "PeterAlbus的博客" } } }, { - path: '/addFriendLink', - name: 'AddFriendLink', - component: () => import("../views/AddFriendLink.vue"), - meta:{ - title:'添加友情链接——PeterAlbus的博客', - content:{ - keywords:'PeterAlbus,Vue,个人博客', - description:'PeterAlbus的博客' + path: "/addFriendLink", + name: "AddFriendLink", + component: () => import("../views/user/AddFriendLink.vue"), + meta: { + title: "添加友情链接——PeterAlbus的博客", + content: { + keywords: "PeterAlbus,Vue,个人博客", + description: "PeterAlbus的博客" + } + } + }, + { + path: "/resetPassword", + name: "ResetPassword", + component: () => import("../views/user/ResetPassword.vue"), + meta: { + title: "重置密码——PeterAlbus的博客", + content: { + keywords: "PeterAlbus,Vue,个人博客", + description: "PeterAlbus的博客" } } } - ], + ] }); router.beforeEach((to, from, next) => { Nprogress.start(); const userStore = useUserStore(); - if (userStore.userId===''&&localStorage.getItem("token")) { + if (userStore.userId === "" && localStorage.getItem("token")) { isLogin().then(res => { - userStore.updateUser(res.data) + userStore.updateUser(res.data); }).catch(err => { - console.log(err) - localStorage.removeItem("token") - }) - } - else if (userStore.userId!=''&&!localStorage.getItem("token")) { - userStore.logout() - } - else if (userStore.userId!=''&&localStorage.getItem("token")) { + console.log(err); + localStorage.removeItem("token"); + }); + } else if (userStore.userId != "" && !localStorage.getItem("token")) { + userStore.logout(); + } else if (userStore.userId != "" && localStorage.getItem("token")) { isLogin().then(res => { - userStore.updateUser(res.data) + userStore.updateUser(res.data); }).catch(() => { - userStore.logout() - }) + userStore.logout(); + }); } - if((to.name=='Login'||to.name=='Register')&&userStore.userId!='') - { - next('/userCenter') - return + if ((to.name == "Login" || to.name == "Register") && userStore.userId != "") { + next("/userCenter"); + return; } - if(to.meta.content) { - const content = to.meta.content as any - document.querySelector('meta[name="keywords"]')?.setAttribute('content',content.keywords) - document.querySelector('meta[name="description"]')?.setAttribute('content',content.description) + if (to.meta.content) { + const content = to.meta.content as any; + document.querySelector("meta[name=\"keywords\"]")?.setAttribute("content", content.keywords); + document.querySelector("meta[name=\"description\"]")?.setAttribute("content", content.description); } - if(to.meta.title) { - document.title = to.meta.title as string + if (to.meta.title) { + document.title = to.meta.title as string; } next(); }); diff --git a/src/services/urlConfig.ts b/src/services/urlConfig.ts index c1016f7..f8796b3 100644 --- a/src/services/urlConfig.ts +++ b/src/services/urlConfig.ts @@ -1,7 +1,7 @@ const env:string=import.meta.env.VITE_APP_ENV export const BASE_URL:string|undefined = { - dev: "https://www.peteralbus.com:8089/", + dev: "http://localhost:8089/", prod: "https://www.peteralbus.com:8089/", test: "https://api.testserver.com/base/url", }[env] diff --git a/src/services/userApi.ts b/src/services/userApi.ts index b5785da..8d7631b 100644 --- a/src/services/userApi.ts +++ b/src/services/userApi.ts @@ -28,4 +28,10 @@ export const changePhone = (data:object) => http.get(data, userUrl.setPhone); export const changeMail = (data:object) => http.get(data, userUrl.setMail); +export const fetchResetPasswordVerifyCode = (account: string, type: string) => + http.get({ account, type }, userUrl.applyResetPasswordVerifyCode); + +export const resetPassword = (data:object) => + http.get(data, userUrl.resetPassword); + diff --git a/src/views/About.vue b/src/views/blog/About.vue similarity index 100% rename from src/views/About.vue rename to src/views/blog/About.vue diff --git a/src/views/Blog.vue b/src/views/blog/Blog.vue similarity index 100% rename from src/views/Blog.vue rename to src/views/blog/Blog.vue diff --git a/src/views/Document.vue b/src/views/blog/Document.vue similarity index 100% rename from src/views/Document.vue rename to src/views/blog/Document.vue diff --git a/src/views/EditBlog.vue b/src/views/blog/EditBlog.vue similarity index 100% rename from src/views/EditBlog.vue rename to src/views/blog/EditBlog.vue diff --git a/src/views/Types.vue b/src/views/blog/Types.vue similarity index 100% rename from src/views/Types.vue rename to src/views/blog/Types.vue diff --git a/src/views/Photo.vue b/src/views/photo/Photo.vue similarity index 100% rename from src/views/Photo.vue rename to src/views/photo/Photo.vue diff --git a/src/views/UploadPhoto.vue b/src/views/photo/UploadPhoto.vue similarity index 100% rename from src/views/UploadPhoto.vue rename to src/views/photo/UploadPhoto.vue diff --git a/src/views/AddFriendLink.vue b/src/views/user/AddFriendLink.vue similarity index 100% rename from src/views/AddFriendLink.vue rename to src/views/user/AddFriendLink.vue diff --git a/src/views/Login.vue b/src/views/user/Login.vue similarity index 93% rename from src/views/Login.vue rename to src/views/user/Login.vue index 485aaca..883a6a4 100644 --- a/src/views/Login.vue +++ b/src/views/user/Login.vue @@ -12,8 +12,8 @@

邮箱登录

手机登录

- 使用手机登录 - 使用邮箱登录 + 使用手机登录 + 使用邮箱登录
注册 +
忘记密码?
@@ -157,4 +158,11 @@ const submitForm = async (formEl: FormInstance | undefined) => { .switch:hover { color: #63a35c; } + +.reset_pass { + margin-top: 10px; + text-align: center; + font-size: 0.8em; + color: #4B6186; +} diff --git a/src/views/Register.vue b/src/views/user/Register.vue similarity index 99% rename from src/views/Register.vue rename to src/views/user/Register.vue index 1dce8f0..bb9ea72 100644 --- a/src/views/Register.vue +++ b/src/views/user/Register.vue @@ -64,8 +64,6 @@ import Banner from "@/components/Banner.vue"; import { computed, reactive, ref } from "vue"; import { ElMessage, ElMessageBox, FormInstance } from "element-plus"; -import axios from "axios"; -import qs from "qs"; import { useRouter } from "vue-router"; import { fetchMailVerifyCode, fetchPhoneVerifyCode, register } from "@/services/userApi"; diff --git a/src/views/user/ResetPassword.vue b/src/views/user/ResetPassword.vue new file mode 100644 index 0000000..b9f8c17 --- /dev/null +++ b/src/views/user/ResetPassword.vue @@ -0,0 +1,244 @@ + + + + + diff --git a/src/views/UserCenter.vue b/src/views/user/UserCenter.vue similarity index 99% rename from src/views/UserCenter.vue rename to src/views/user/UserCenter.vue index 5e22793..da592b3 100644 --- a/src/views/UserCenter.vue +++ b/src/views/user/UserCenter.vue @@ -493,6 +493,7 @@ const userIdentity = computed(() => { display: flex; justify-content: center; align-items: center; + flex-direction: row; } .user-center-info {