From 423e4e1ec52c5a50c4018364539d7c5330bd8df1 Mon Sep 17 00:00:00 2001 From: guixu0320 <3488249364@qq.com> Date: Thu, 14 Nov 2024 15:16:14 +0800 Subject: [PATCH] =?UTF-8?q?=E7=99=BB=E5=BD=95=E5=92=8C=E6=B3=A8=E5=86=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/package.json | 2 +- frontend/src/View/Login.vue | 153 +++++++++++----------------- frontend/src/View/Register.vue | 179 ++++++++++++++++----------------- frontend/src/main.js | 24 ++++- frontend/src/router.js | 27 ++--- frontend/yarn.lock | 2 +- 6 files changed, 173 insertions(+), 214 deletions(-) diff --git a/frontend/package.json b/frontend/package.json index 39449c9..d5eea57 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -14,7 +14,7 @@ "pinia": "2.0.27", "save": "^2.9.0", "vue": "^3.4.37", - "vue-router": "^4.4.5" + "vue-router": "4" }, "devDependencies": { "@vitejs/plugin-vue": "^5.1.2", diff --git a/frontend/src/View/Login.vue b/frontend/src/View/Login.vue index dc9bbfb..ae8b090 100644 --- a/frontend/src/View/Login.vue +++ b/frontend/src/View/Login.vue @@ -1,114 +1,75 @@ - - \ No newline at end of file + diff --git a/frontend/src/View/Register.vue b/frontend/src/View/Register.vue index e9388ca..0e2d0a5 100644 --- a/frontend/src/View/Register.vue +++ b/frontend/src/View/Register.vue @@ -1,97 +1,88 @@ - - - + + diff --git a/frontend/src/main.js b/frontend/src/main.js index 31b294d..33f88e7 100644 --- a/frontend/src/main.js +++ b/frontend/src/main.js @@ -16,4 +16,26 @@ app.use(ElementPlus) const pinia=createPinia() app.use(pinia) //挂载整个应用 -app.mount('#app') \ No newline at end of file +app.mount('#app') +app.post('/View/login', (req, res) => { + const { username, password } = req.body; + + // 验证用户名和密码 + if (username === 'test' && password === '123456') { + res.json({ success: true }); + } else { + res.json({ success: false, message: '用户名或密码错误' }); + } +}); +app.post('/View/register', (req, res) => { + const { username, email, password } = req.body; + + // 进行用户名、邮箱的检查并保存用户 + // 这里只是简单的示例,实际需要加密密码并存储到数据库 + + if (username && email && password) { + res.json({ success: true }); + } else { + res.json({ success: false, message: '信息不完整' }); + } +}); diff --git a/frontend/src/router.js b/frontend/src/router.js index 9013a66..e3661e4 100644 --- a/frontend/src/router.js +++ b/frontend/src/router.js @@ -17,6 +17,11 @@ const router = createRouter({ name: 'Login', component: () => import('./View/Login.vue') }, + { + path:'/register', + name:'Register', + component:()=>import ('./View/Register.vue') + }, { path: '/user', name: 'User', @@ -36,30 +41,10 @@ const router = createRouter({ component: () => import('./View/user/ExpressForm.vue'), } ] - }, - { - path: '/register', - name: 'Register', - component: () => import('./View/Register.vue') } ] }) -router.beforeEach((to,from,next)=>{ - const store = userStore() - const {loginState} = storeToRefs(store) - console.log("路由守卫:",loginState.value) - if(to.name == "Login"){ - next() - }else{ - if(loginState.value){ - next() - }else{ - next({ - name:'Login' - }) - } - } -}) + export default router \ No newline at end of file diff --git a/frontend/yarn.lock b/frontend/yarn.lock index cc1380e..d7b541b 100644 --- a/frontend/yarn.lock +++ b/frontend/yarn.lock @@ -729,7 +729,7 @@ vue-demi@*: resolved "https://registry.yarnpkg.com/vue-demi/-/vue-demi-0.14.10.tgz#afc78de3d6f9e11bf78c55e8510ee12814522f04" integrity sha512-nMZBOwuzabUO0nLgIcc6rycZEebF6eeUfaiQx9+WSk8e29IbLvPU9feI6tqW4kTo3hvoYAJkMh8n8D0fuISphg== -vue-router@^4.4.5: +vue-router@4: version "4.4.5" resolved "https://registry.yarnpkg.com/vue-router/-/vue-router-4.4.5.tgz#bdf535e4cf32414ebdea6b4b403593efdb541388" integrity sha512-4fKZygS8cH1yCyuabAXGUAsyi1b2/o/OKgu/RUb+znIYOxPRxdkytJEx+0wGcpBE1pX6vUgh5jwWOKRGvuA/7Q==