Browse Source

账号密码登录版本

chengyang-zm
mk 3 weeks ago
parent
commit
31968a1f15
  1. 2
      .env.development
  2. 1
      .gitignore
  3. 42
      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.140/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_SERVER = http://219.146.91.110:30801/api219.146.91.110:30801
# VUE_APP_API_SERVER = https://epmet-yantai.elinkservice.cn/api

1
.gitignore

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

42
src/router/index.js

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

7
src/views/main-navbar.vue

@ -198,14 +198,15 @@ export default {
this.$http
.post('/auth/login/logout')
.then(({ data: res }) => {
clearLoginInfo();
if (res.code === 0) {
if (res.code !== 0) {
// 退
if (res.code !== 10007) {
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') {
// this.$router.push({ name: 'loginWork' })
// } 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");
module.exports = {
baseUrl: process.env.NODE_ENV === "production" ? "" : "/epmet-work-pc",
baseUrl: process.env.NODE_ENV === "production" ? "" : "/epmet-work-cy",
css: {
// 是否使用css分离插件 ExtractTextPlugin
extract: IS_PROD,
@ -25,7 +25,7 @@ module.exports = {
.loader("svg-sprite-loader");
},
productionSourceMap: false,
outputDir: "epmet-work-pc",
outputDir: "epmet-work-cy",
assetsDir: "static",
devServer: {
proxy: {
@ -36,7 +36,6 @@ module.exports = {
},
"/api": {
// target: " https://epmet-test.elinkservice.cn/",
target: "http://219.146.91.110:30801", // 测试地址
// target: "http://192.168.1.60:8080", // 本地地址
// target: "https://epmet-preview.elinkservice.cn", // 演示地址

Loading…
Cancel
Save