Browse Source

账号密码登录版本

chengyang-zm
mk 3 weeks ago
parent
commit
31968a1f15
  1. 2
      .env.development
  2. 1
      .gitignore
  3. 44
      src/router/index.js
  4. 7
      src/views/main-navbar.vue
  5. 5
      vue.config.js

2
.env.development

@ -3,7 +3,7 @@ NODE_ENV=development
# VUE_APP_API_SERVER = http://192.168.1.60:8080/api # VUE_APP_API_SERVER = http://192.168.1.60:8080/api
# # VUE_APP_API_SERVER = http://192.168.1.140/api # # VUE_APP_API_SERVER = http://192.168.1.140/api
# VUE_APP_API_SERVER = http://219.146.91.110:30801/api # VUE_APP_API_SERVER = http://219.146.91.110:30801/api
VUE_APP_API_SERVER = http://119.167.67.163:10081/api VUE_APP_API_SERVER = http://192.168.1.140/api
VUE_APP_API_LIVE = http://192.168.1.140/live/ VUE_APP_API_LIVE = http://192.168.1.140/live/
# VUE_APP_API_SERVER = http://219.146.91.110:30801/api219.146.91.110:30801 # VUE_APP_API_SERVER = http://219.146.91.110:30801/api219.146.91.110:30801
# VUE_APP_API_SERVER = https://epmet-yantai.elinkservice.cn/api # VUE_APP_API_SERVER = https://epmet-yantai.elinkservice.cn/api

1
.gitignore

@ -19,6 +19,7 @@ node_modules*
dist dist
epmet-oper epmet-oper
epmet-work-pc epmet-work-pc
epmet-work-cy
package-lock.json package-lock.json
.idea/ .idea/
report.20240923.092213.21116.0.001.json report.20240923.092213.21116.0.001.json

44
src/router/index.js

@ -979,28 +979,28 @@ const router = new Router({
}); });
router.beforeEach((to, from, next) => { router.beforeEach((to, from, next) => {
if (to.name == 'login') { // if (to.name == 'login') {
// 新增 token 存在性检查 // // 新增 token 存在性检查
const match = location.href.match(/[?&]ticket=([^&#]+)/); // const match = location.href.match(/[?&]ticket=([^&#]+)/);
const existingToken = localStorage.getItem('token'); // const existingToken = localStorage.getItem('token');
if (!existingToken && match) { // if (!existingToken && match) {
http.get(`/auth/xiaZhuangLogin/dealUserInfo?ticket=${match[1]}`) // http.get(`/auth/xiaZhuangLogin/dealUserInfo?ticket=${match[1]}`)
.then(({ data: res }) => { // .then(({ data: res }) => {
localStorage.setItem('token', res.data.token) // localStorage.setItem('token', res.data.token)
next({ name: 'home' }) // next({ name: 'home' })
}).catch(err=>{ // }).catch(err=>{
localStorage.removeItem('token') // localStorage.removeItem('token')
alert('登录失败,请重新登录') // alert('登录失败,请重新登录')
// window.location.href = 'http://172.16.100.23:40281/login?client_id=0587341d116149adaa36ca1d45dd16af&redirect=http://119.167.67.163:10081/epmet-work-pc/#/login' // // window.location.href = 'http://172.16.100.23:40281/login?client_id=0587341d116149adaa36ca1d45dd16af&redirect=http://119.167.67.163:10081/epmet-work-pc/#/login'
}) // })
return; // return;
}else if(existingToken){ // }else if(existingToken){
next({ name: 'home' }) // next({ name: 'home' })
}else{ // }else{
window.location.href = 'http://172.16.100.23:40281/login?client_id=0587341d116149adaa36ca1d45dd16af&redirect=http://119.167.67.163:10081/epmet-work-pc/#/login' // window.location.href = 'http://172.16.100.23:40281/login?client_id=0587341d116149adaa36ca1d45dd16af&redirect=http://119.167.67.163:10081/epmet-work-pc/#/login'
} // }
return; // return;
} // }
if (to.name === "caiji") { if (to.name === "caiji") {
return next(); return next();

7
src/views/main-navbar.vue

@ -198,14 +198,15 @@ export default {
this.$http this.$http
.post('/auth/login/logout') .post('/auth/login/logout')
.then(({ data: res }) => { .then(({ data: res }) => {
clearLoginInfo(); if (res.code !== 0) {
if (res.code === 0) {
// 退 // 退
if (res.code !== 10007) { if (res.code !== 10007) {
this.$message.error(res.msg); this.$message.error(res.msg);
} }
location.href = `http://172.16.100.23:40281/sso-logout?client_id=0587341d116149adaa36ca1d45dd16af`
} }
clearLoginInfo();
this.$router.replace({ name: 'login' });
// if (localStorage.getItem('userType') === 'work') { // if (localStorage.getItem('userType') === 'work') {
// this.$router.push({ name: 'loginWork' }) // this.$router.push({ name: 'loginWork' })
// } else { // } else {

5
vue.config.js

@ -5,7 +5,7 @@ const IS_PROD = ["production", "test"].includes(process.env.NODE_ENV);
const TerserPlugin = require("terser-webpack-plugin"); const TerserPlugin = require("terser-webpack-plugin");
module.exports = { module.exports = {
baseUrl: process.env.NODE_ENV === "production" ? "" : "/epmet-work-pc", baseUrl: process.env.NODE_ENV === "production" ? "" : "/epmet-work-cy",
css: { css: {
// 是否使用css分离插件 ExtractTextPlugin // 是否使用css分离插件 ExtractTextPlugin
extract: IS_PROD, extract: IS_PROD,
@ -25,7 +25,7 @@ module.exports = {
.loader("svg-sprite-loader"); .loader("svg-sprite-loader");
}, },
productionSourceMap: false, productionSourceMap: false,
outputDir: "epmet-work-pc", outputDir: "epmet-work-cy",
assetsDir: "static", assetsDir: "static",
devServer: { devServer: {
proxy: { proxy: {
@ -36,7 +36,6 @@ module.exports = {
}, },
"/api": { "/api": {
// target: " https://epmet-test.elinkservice.cn/", // target: " https://epmet-test.elinkservice.cn/",
target: "http://219.146.91.110:30801", // 测试地址 target: "http://219.146.91.110:30801", // 测试地址
// target: "http://192.168.1.60:8080", // 本地地址 // target: "http://192.168.1.60:8080", // 本地地址
// target: "https://epmet-preview.elinkservice.cn", // 演示地址 // target: "https://epmet-preview.elinkservice.cn", // 演示地址

Loading…
Cancel
Save