From cbb2e6174d4806854c43397a7bcfb1770b51d346 Mon Sep 17 00:00:00 2001 From: chenkai0520 Date: Fri, 17 Dec 2021 18:24:11 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BC=98=E5=8C=96=E6=9D=83=E9=99=90?= =?UTF-8?q?=E8=B7=AF=E7=94=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/assets/style/index.scss | 4 ++-- src/main.js | 1 + src/router/index.js | 10 ++++++++-- src/views/About.vue | 11 +++++++++++ vite.config.js | 2 +- 5 files changed, 23 insertions(+), 5 deletions(-) create mode 100644 src/views/About.vue diff --git a/src/assets/style/index.scss b/src/assets/style/index.scss index 1c0a8d3..f64b10a 100644 --- a/src/assets/style/index.scss +++ b/src/assets/style/index.scss @@ -1,5 +1,5 @@ -@import "./variable.scss"; -@import "./mixin.scss"; +@use "./variable.scss"; +@use "./mixin.scss"; @tailwind base; @tailwind components; diff --git a/src/main.js b/src/main.js index 54460a5..b389a3d 100644 --- a/src/main.js +++ b/src/main.js @@ -5,6 +5,7 @@ import App from '@/App.vue'; import router from '@/router'; import { userAPI } from '@/api'; import { checkRes } from '@/utils/helpers'; +import '@/assets/style/index.scss'; async function getUserInfo() { const userRes = await userAPI.info(); diff --git a/src/router/index.js b/src/router/index.js index aac80e0..980bb01 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -1,6 +1,7 @@ import { createRouter, createWebHashHistory } from 'vue-router'; import Home from '@/views/Home.vue'; import Sign from '@/views/Sign.vue'; +import About from '@/views/About.vue'; import { ROLE } from '@/constant'; const ADMIN = [ROLE.ADMIN]; @@ -18,6 +19,11 @@ const routes = [ name: 'Sign', component: Sign, }, + { + path: '/about', + name: 'About', + component: About, + }, { path: '/chat', name: 'Chat', @@ -42,14 +48,14 @@ const router = createRouter({ }); router.beforeEach(async (to, from, next) => { + const { meta } = to; const userInfo = router.$user; - if (to.name !== 'Sign' && !userInfo) { + if ((meta && meta.role) && !userInfo) { next({ name: 'Sign', }); } if (userInfo) { - const { meta } = to; if (meta && meta.role) { if (meta.role.indexOf(userInfo.role) === -1) { router.push({ diff --git a/src/views/About.vue b/src/views/About.vue new file mode 100644 index 0000000..36bd4c1 --- /dev/null +++ b/src/views/About.vue @@ -0,0 +1,11 @@ + + + diff --git a/vite.config.js b/vite.config.js index 461c589..914b3e1 100644 --- a/vite.config.js +++ b/vite.config.js @@ -24,7 +24,7 @@ export default defineConfig({ css: { preprocessorOptions: { scss: { - additionalData: '@use "@/assets/style/index.scss" as *;', + additionalData: '@use "@/assets/style/mixin.scss" as *;\n@use "@/assets/style/variable.scss" as *;', }, }, },