Browse Source

sso登录兼容

test
dai 3 years ago
parent
commit
d45217807c
  1. 5
      .env.development
  2. 1
      .env.production
  3. 3
      .env.production.sit
  4. 3
      .env.production.uat
  5. 3
      .env.shibei_production
  6. 8
      src/router/index.js
  7. 73
      src/views/pages/login-sso.vue
  8. 4
      src/views/pages/login.vue

5
.env.development

@ -9,4 +9,7 @@ VUE_APP_API_SERVER = http://192.168.1.140/api
# VUE_APP_API_SERVER = https://epmet-dev.elinkservice.cn/api
VUE_APP_NODE_ENV=dev
#项目根路径
VUE_APP_PUBLIC_PATH=epmet-oper
VUE_APP_PUBLIC_PATH=epmet-oper
#是否使用另外一种登录方式
VUE_APP_SSO_LOGIN=off

1
.env.production

@ -2,3 +2,4 @@ NODE_ENV=production
VUE_APP_API_SERVER = https://epmet-cloud.elinkservice.cn/api
VUE_APP_NODE_ENV=prod
VUE_APP_PUBLIC_PATH=epmet-oper
VUE_APP_SSO_LOGIN=off

3
.env.production.sit

@ -2,4 +2,5 @@ NODE_ENV=production
# VUE_APP_API_SERVER = https://epmet-test.elinkservice.cn/api
VUE_APP_API_SERVER = http://192.168.1.140/api
VUE_APP_NODE_ENV=prod:sit
VUE_APP_PUBLIC_PATH=epmet-oper
VUE_APP_PUBLIC_PATH=epmet-oper
VUE_APP_SSO_LOGIN=off

3
.env.production.uat

@ -2,4 +2,5 @@ NODE_ENV=production
# VUE_APP_API_SERVER = http://120.27.18.76/api
VUE_APP_API_SERVER = https://epmet-test.elinkservice.cn/api
VUE_APP_NODE_ENV=prod:uat
VUE_APP_PUBLIC_PATH=epmet-oper
VUE_APP_PUBLIC_PATH=epmet-oper
VUE_APP_SSO_LOGIN=off

3
.env.shibei_production

@ -1,4 +1,5 @@
NODE_ENV=production
VUE_APP_API_SERVER = https://epdc-shibei.elinkservice.cn/api
VUE_APP_NODE_ENV=shibei_prod
VUE_APP_PUBLIC_PATH=epmet-oper
VUE_APP_PUBLIC_PATH=epmet-oper
VUE_APP_SSO_LOGIN=off

8
src/router/index.js

@ -32,6 +32,14 @@ export const pageRoutes = [
title: "登录",
},
},
{
path: "/login-sso",
component: () => import("@/views/pages/login-sso"),
name: "login-sso",
meta: {
title: "登录",
},
},
{
path: "/",
name: "index",

73
src/views/pages/login-sso.vue

@ -0,0 +1,73 @@
<template>
<div class="g-app">
<div class="m-hint">登录中...</div>
</div>
</template>
<script>
import { requestGet, requestPost } from "@/js/dai/request";
import getQueryPara from "dai-js/modules/getQueryPara";
export default {
data() {
return {};
},
components: {},
computed: {},
created() {
let ticket = getQueryPara("ticket");
if (ticket) {
this.loginByTicket(ticket);
} else {
this.getAuthUrl();
}
},
mounted() {},
methods: {
async getAuthUrl() {
const url = "/auth/sso/ssoAuthUrl";
const { data, code, msg } = await requestGet(url, {
clientLoginUrl: location.href,
});
if (code === 0) {
location.href = data.authUrl + "&mode=ticket";
} else {
this.$message.error(msg);
}
},
async loginByTicket(ticket) {
const url = "/auth/sso/login?ticket=" + ticket;
const { data, code, msg } = await requestPost(url, {
ticket,
});
if (code === 0) {
localStorage.setItem("token", data.token);
this.$router.replace({ name: "index" });
}
},
},
};
</script>
<style lang="scss" scoped>
.g-app {
width: 100vw;
height: 100vh;
background-color: #f7f7f7;
.m-hint {
text-align: center;
font-size: 36px;
line-height: 100vh;
color: #999999;
font-weight: bold;
}
}
</style>

4
src/views/pages/login.vue

@ -140,6 +140,10 @@ export default {
},
},
created() {
if (process.env.VUE_APP_SSO_LOGIN == "on") {
this.$router.replace({ name: "login-sso" });
}
//
if (this.$route.query.platformToken) {
this.isShowLogin = false;

Loading…
Cancel
Save