From 745f347c9166a371a1239a3508800818db5656a4 Mon Sep 17 00:00:00 2001 From: zhangjun1 Date: Tue, 26 Apr 2022 17:52:46 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=BE=E5=BC=80=E7=99=BB=E5=BD=95=E9=99=90?= =?UTF-8?q?=E5=88=B6=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .beagle.yml | 2 +- build/conf.yaml | 3 ++- build/dockerfile | 14 +++++++++++--- src/router/index.js | 27 ++++++++++++++++++++++++++- 4 files changed, 40 insertions(+), 6 deletions(-) diff --git a/.beagle.yml b/.beagle.yml index 54adff9..476641e 100644 --- a/.beagle.yml +++ b/.beagle.yml @@ -50,7 +50,7 @@ pipeline: dns: 223.5.5.5 volumes: - /var/run/docker.sock:/var/run/docker.sock - base: hub.wodcloud.com/wod/ui-base:2.0-apaasv3 + base: registry.cn-qingdao.aliyuncs.com/wod-devops/ui-base:2.0-sjjy dockerfile: .beagle/dockerfile repo: gzgajzapi/apaas-ui version: v3.0.1 diff --git a/build/conf.yaml b/build/conf.yaml index 48474f1..db393a8 100644 --- a/build/conf.yaml +++ b/build/conf.yaml @@ -1,3 +1,4 @@ index: /apaas/ui/ login: /iam/login/#/login -logout: /iam/api/logout \ No newline at end of file +logout: /iam/api/logout +exts: ["/services_shop","/shop"] \ No newline at end of file diff --git a/build/dockerfile b/build/dockerfile index 7a41e8c..798acf3 100644 --- a/build/dockerfile +++ b/build/dockerfile @@ -1,5 +1,13 @@ -FROM {{ BASEIMAGE }} -MAINTAINER {{ AUTHOR }} -LABEL Author={{ AUTHOR }} Name={{ PROJECT }} Version={{ VERSION }} +ARG BASE + +FROM $BASE + +ARG AUTHOR +ARG VERSION +LABEL maintainer=${AUTHOR} version=${VERSION} + +ARG TARGETOS +ARG TARGETARCH + ADD ./dist /www ADD ./build/conf.yaml /www/conf.yaml \ No newline at end of file diff --git a/src/router/index.js b/src/router/index.js index 1d2432e..fcfc431 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -1,5 +1,6 @@ import Vue from "vue"; import Router from "vue-router"; +import {getCookie} from '../utils/common' Vue.use(Router); @@ -10,7 +11,7 @@ Router.prototype.push = function push(location, onResolve, onReject) { return originalPush.call(this, location).catch((err) => err); }; -export default new Router({ +var router = new Router({ scrollBehavior (to, from, savedPosition) { return { x: 0, y: 0 } }, @@ -848,3 +849,27 @@ export default new Router({ }, ], }); + +router.beforeEach(async (to, from, next) => { + let _user = getCookie('bgToken') + let _path = to.path; // 访问的页面 + if (_user) { + next(); + } else if ( + _path === "" || + _path === "/" || + _path === "/home" || + _path === "/search" || + _path === "/cart" || + _path.indexOf("/services_shop") === 0 || + _path.indexOf("/shop") === 0 + ) { + next(); + } else { + // ElementUI.Message.error(`未登录无法访问该页面`); + + next("/"); + } +}); // 导航守卫 + +export default router -- 2.26.0