From 1c8c8264c2ffbe2f18f73ada0553f3e827f4cf9a Mon Sep 17 00:00:00 2001 From: simple321vip Date: Tue, 12 Apr 2022 00:12:35 +0800 Subject: [PATCH] =?UTF-8?q?md=E5=8A=9F=E8=83=BD=E5=AE=9E=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/user.ts | 10 ++++ src/components/layout/NavBar.vue | 11 ++++- src/components/login/login.vue | 80 ++++++++++++++++++++++++++++---- src/main.ts | 8 +++- src/router/index.ts | 6 ++- src/view/blog/mdview.vue | 3 +- 6 files changed, 103 insertions(+), 15 deletions(-) create mode 100644 src/api/user.ts diff --git a/src/api/user.ts b/src/api/user.ts new file mode 100644 index 0000000..cebb207 --- /dev/null +++ b/src/api/user.ts @@ -0,0 +1,10 @@ +import request from '../utils/request' +const authorize = (params: any) => { + return request({ + url: '/api/vi/authorize', + method: 'post', + data: {} + }) +} + +export { authorize } \ No newline at end of file diff --git a/src/components/layout/NavBar.vue b/src/components/layout/NavBar.vue index 0e647d6..6cd100e 100644 --- a/src/components/layout/NavBar.vue +++ b/src/components/layout/NavBar.vue @@ -12,13 +12,13 @@ 删除 --> - 小管 - + 登录 \ No newline at end of file + +const resetForm = (formEl: FormInstance | undefined) => { + if (!formEl) return + formEl.resetFields() +} + + diff --git a/src/main.ts b/src/main.ts index 1f78b34..ad4a326 100644 --- a/src/main.ts +++ b/src/main.ts @@ -15,13 +15,13 @@ app.use(router) app.use(ElementPlus) app.use(store) - +import { getToken } from './utils/auth' const whiteList = ['/', '/blog'] let url = window.location.href console.log(url) if (url != 'http://localhost:3000/' && url.search("blog=") != -1) { let blog = { - blog_id: 1 + blog_id: url.split("=")[1] } router.push({ path: '/feedback', @@ -30,6 +30,10 @@ if (url != 'http://localhost:3000/' && url.search("blog=") != -1) { } router.beforeEach((to, from, next) => { console.log(to.path, from.path) + if (to.path === '/login') { + next() + } + if (whiteList.includes(to.path)) { diff --git a/src/router/index.ts b/src/router/index.ts index 1699036..cd165d4 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -73,7 +73,11 @@ const routes: Array = [ { path: "/feedback", component: () => import('../view/blog/mdview.vue') - } + }, + { + path: "/login", + component: () => import('../components/login/login.vue') + }, ] diff --git a/src/view/blog/mdview.vue b/src/view/blog/mdview.vue index ce7150a..73b2cc3 100644 --- a/src/view/blog/mdview.vue +++ b/src/view/blog/mdview.vue @@ -4,13 +4,14 @@