From 58f545aee674e60311956f6d43ca34de3e97afd9 Mon Sep 17 00:00:00 2001 From: zhangjun1 Date: Thu, 5 May 2022 16:21:32 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=8D=E7=99=BB=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .beagle.yml | 3 +- .beagle/dockerfile | 10 +---- build/nginx.conf | 75 ++++++++++++++++++++++++++++++++++++++ src/main.js | 16 ++++++++ src/router/index.js | 6 ++- static/config/configmap.js | 1 + 6 files changed, 99 insertions(+), 12 deletions(-) create mode 100644 build/nginx.conf diff --git a/.beagle.yml b/.beagle.yml index ca22dd6..e21d793 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: registry.cn-qingdao.aliyuncs.com/wod-devops/ui-base:2.0-jzapi + base: registry.cn-qingdao.aliyuncs.com/wod/nginx:1.19.5 dockerfile: .beagle/dockerfile repo: gzgajzapi/apaas-ui version: v3.0.1 @@ -65,7 +65,6 @@ pipeline: when: branch: - dev - ## 更换dev生成镜像的名称 harbor: image: registry.cn-qingdao.aliyuncs.com/wod/devops-docker-tag:1.0 diff --git a/.beagle/dockerfile b/.beagle/dockerfile index 798acf3..d4edd16 100644 --- a/.beagle/dockerfile +++ b/.beagle/dockerfile @@ -1,13 +1,7 @@ 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 +ADD ./dist /usr/share/nginx/html +ADD ./build/nginx.conf /etc/nginx/nginx.conf \ No newline at end of file diff --git a/build/nginx.conf b/build/nginx.conf new file mode 100644 index 0000000..3adfa26 --- /dev/null +++ b/build/nginx.conf @@ -0,0 +1,75 @@ +user nginx; +worker_processes 1; + +error_log /var/log/nginx/error.log warn; +pid /var/run/nginx.pid; + + +events { + worker_connections 1024; +} + + +http { + include /etc/nginx/mime.types; + default_type application/octet-stream; + + server { + listen 80; + listen [::]:80; + server_name localhost; + + absolute_redirect off; #取消绝对路径的重定向 + #charset koi8-r; + #access_log /var/log/nginx/host.access.log main; + + #error_page 404 /404.html; + + # redirect server error pages to the static page /50x.html + # + error_page 500 502 503 504 /50x.html; + location /klmy/ui { + + root /usr/share/nginx/html; + index index.html index.htm; + try_files $uri $uri/ /klmy/ui/index.html; + } + } + + # 开启gzip + gzip off; + + # 启用gzip压缩的最小文件,小于设置值的文件将不会压缩 + gzip_min_length 1k; + + # gzip 压缩级别,1-10,数字越大压缩的越好,也越占用CPU时间,后面会有详细说明 + gzip_comp_level 6; + + # 进行压缩的文件类型。javascript有多种形式。其中的值可以在 mime.types 文件中找到。 + # 由于jpg,jpeg,png本来就是压缩格式,再行压缩只会消耗cpu资源,帮助并不大 + gzip_types text/plain application/javascript application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/gif; + + # 是否在http header中添加Vary: Accept-Encoding,建议开启 + gzip_vary on; + + #压缩版本(默认1.1,前端如果是squid2.5请使用1.0) + gzip_http_version 1.0; + + # 禁用IE 6 gzip + gzip_disable "MSIE [1-6]\."; + + log_format main '$remote_addr - $remote_user [$time_local] "$request" ' + '$status $body_bytes_sent "$http_referer" ' + '"$http_user_agent" "$http_x_forwarded_for"'; + + access_log /var/log/nginx/access.log main; + + sendfile on; + #tcp_nopush on; + + keepalive_timeout 65; + + #gzip on; + + include /etc/nginx/conf.d/*.conf; +} \ No newline at end of file diff --git a/src/main.js b/src/main.js index 9c50083..30b257f 100644 --- a/src/main.js +++ b/src/main.js @@ -75,6 +75,20 @@ Vue.use(SuperFlow) import api from './request/api' Vue.prototype.$api = api; +function getCurrent(){ + api.user.getNowUser().then(({ data }) => { + if (data.success == 1) { + store.commit("userInfofun", data.data); + } else { + console.log(data.errMsg); + } + + + }); +} + +// getCurrent() + new Vue({ el: "#app", router, @@ -83,3 +97,5 @@ new Vue({ components: { App }, template: "" }); + + diff --git a/src/router/index.js b/src/router/index.js index fcfc431..8e58b08 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -1,6 +1,7 @@ import Vue from "vue"; import Router from "vue-router"; import {getCookie} from '../utils/common' +import store from "@/store"; Vue.use(Router); @@ -850,10 +851,11 @@ var router = new Router({ ], }); + router.beforeEach(async (to, from, next) => { - let _user = getCookie('bgToken') + console.log(window.serviceConfig); let _path = to.path; // 访问的页面 - if (_user) { + if (store.state.userInfo) { next(); } else if ( _path === "" || diff --git a/static/config/configmap.js b/static/config/configmap.js index b58a084..d1efa19 100644 --- a/static/config/configmap.js +++ b/static/config/configmap.js @@ -3,4 +3,5 @@ window.serviceConfig = { gisPortalSiteName: "portal", state: "needLogin", // needLogin / notNeedLogin cloudServiceRoot: 'https://cloud4.wodcloud.com/awecloud/login/#/', + noNeedLoginUrl:['/','shop'] }; \ No newline at end of file -- 2.26.0