From 36844a9229a157d58cf15d95e25e65cc6967e966 Mon Sep 17 00:00:00 2001 From: liuxiangfei Date: Tue, 29 Aug 2023 14:04:12 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=99=BB=E5=87=BA=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- fcat-vue/src/api/auth.js | 21 ----- fcat-vue/src/api/constant.js | 8 -- fcat-vue/src/api/request.js | 79 ------------------ .../src/core/services/store/auth.module.js | 14 +++- .../view/pages/auth/login_pages/Login-1.vue | 11 +-- settings.zip | Bin 0 -> 6396 bytes 6 files changed, 16 insertions(+), 117 deletions(-) delete mode 100644 fcat-vue/src/api/auth.js delete mode 100644 fcat-vue/src/api/constant.js delete mode 100644 fcat-vue/src/api/request.js create mode 100644 settings.zip diff --git a/fcat-vue/src/api/auth.js b/fcat-vue/src/api/auth.js deleted file mode 100644 index 8c5d68c..0000000 --- a/fcat-vue/src/api/auth.js +++ /dev/null @@ -1,21 +0,0 @@ -import request from './request' -import Qs from "qs"; -import constant from './constant' - - -export function userLogin(param) { - console.log(constant.userUrl+'/auth/login') - return request({ - url: constant.userUrl+'/auth/login', - method: 'post', - data: Qs.stringify(param) - }) -} -export function userGetByUsername() { - return request({ - url: constant.userUrl+'/user/getByUsername', - method: 'get', - }) -} - - diff --git a/fcat-vue/src/api/constant.js b/fcat-vue/src/api/constant.js deleted file mode 100644 index c9b2687..0000000 --- a/fcat-vue/src/api/constant.js +++ /dev/null @@ -1,8 +0,0 @@ -export default { - ProjectName: "meter-server", //项目名称 - userUrl: "/gateway/common-user/", - hesUrl: "/gateway/meter-server/", - fdfsUrl: "/gateway/common-fdfs/", - PageSize: 15,//默认每页数量 - fileAccessPrex:"http://fcat.liuxiangfei.fun:6008/fdfs/" -}; diff --git a/fcat-vue/src/api/request.js b/fcat-vue/src/api/request.js deleted file mode 100644 index bf85377..0000000 --- a/fcat-vue/src/api/request.js +++ /dev/null @@ -1,79 +0,0 @@ -import axios from 'axios' -import {Message} from 'element-ui' -import {getToken} from '@/utils/auth' -/*import {getCompanyId, getUsername} from "../utils/auth";*/ - -// create an axios instance -const service = axios.create({ - timeout: 0 // request timeout -}) - -// 请求前拦截 -service.interceptors.request.use(config => { - if (getToken()) { - config.headers['Authorization'] = getToken() // 让每个请求携带token-- ['X-Token']为自定义key 请根据实际情况自行修改 - } -/* if(getToken()){ - config.headers['username']=getUsername() //先测试使用 - config.headers['companyId']=getCompanyId() //先测试使用 - }*/ - return config -}, error => { - console.log(error) // for debug - Promise.reject(error) -}) -let toLoginTimeOut = undefined; -// 去请求后拦截 -service.interceptors.response.use( - response => { - const res = response.data - // console.log("service.interceptors.response.use"); - //超时等问题 - if (res.code === "-401" || - res.code === 401 || - res.code === "100" || - res.code === -401 || - res.code === -402 || - res.code === -403 - ) { - if (!toLoginTimeOut && window.location.pathname !== "/login") {//跳转到登录页面时不需要提示信息 - // element.Message({ - // showClose: true, - // message: res.msg, - // type: 'error' - // }); - toLoginTimeOut = window.setTimeout(() => { - window.location.href = "/login"; - }, 3 * 1000); - } - return res.msg - } - //文件下载直接返回 - if(response.config.responseType==='blob'){ - console.log('直接返回了') - return response - } - //后台进行了 code封装 - if(res.code==0){ - return response.data.data - }else{ - Message({ - message: res.msg, - type: 'error', - duration: 5 * 1000 - }) - return Promise.reject(res.msg) - } - - }, - error => { - console.log('err' + error) // for debug - Message({ - message: error.message, - type: 'error', - duration: 5 * 1000 - }) - return Promise.reject(error) - }) - -export default service diff --git a/fcat-vue/src/core/services/store/auth.module.js b/fcat-vue/src/core/services/store/auth.module.js index ee54395..6440da8 100644 --- a/fcat-vue/src/core/services/store/auth.module.js +++ b/fcat-vue/src/core/services/store/auth.module.js @@ -35,8 +35,13 @@ const actions = { return new Promise(resolve => { ApiService.post("/gateway/common-user/auth/login", Qs.stringify(credentials)) .then(({ data }) => { - context.commit(SET_AUTH, data); - resolve(data); + if(data.code==0){ + let user = {token:data.data,username:credentials.username}; + context.commit(SET_AUTH, user); + resolve(data); + }else{ + alert(data.msg); + } }) .catch(({ response }) => { context.commit(SET_ERROR, response.data.errors); @@ -44,6 +49,11 @@ const actions = { }); }, [LOGOUT](context) { + ApiService.post("/gateway/common-user/auth/logout") + .then(() => { + }) + .catch(() => { + }); context.commit(PURGE_AUTH); }, [REGISTER](context, credentials) { diff --git a/fcat-vue/src/view/pages/auth/login_pages/Login-1.vue b/fcat-vue/src/view/pages/auth/login_pages/Login-1.vue index d979359..82049d5 100644 --- a/fcat-vue/src/view/pages/auth/login_pages/Login-1.vue +++ b/fcat-vue/src/view/pages/auth/login_pages/Login-1.vue @@ -441,22 +441,19 @@ export default { let _param = { - mac: "11", + mac: "fcat-vue", username: this.form.username, password: this.form.password } - this.$store - .dispatch(LOGIN, _param) - // go to which page after successfully login - .then((e) => { + this.$store.dispatch(LOGIN, _param).then((e) => { if(e.code==0){ this.$router.push({ name: "dashboard" }) }else{ alert(e.msg); } - }) - .catch(() => { + .catch((e) => { + alert(e); }); submitButton.classList.remove( diff --git a/settings.zip b/settings.zip new file mode 100644 index 0000000000000000000000000000000000000000..bc0b55141f10767aed416d3a99ca36da54195280 GIT binary patch literal 6396 zcma)A3p|tm_g^ltxlBkRp;9*Yq6^(qnVI{o%eM@}n9Xb$LUJvaTq~gzMG{F7LP-om zgyb5EF3csY68_JW|7O2$^*vsDy&l_h&htLc=X~DheLluWZXR(EKR-Xn#7)Ku#AZ<7 zn&3vp67VE7Pdkz-#T8d(-e**)F5=I~v!1~xf8As+by+AjIPgu?miSwdcCBRBkGXHJ z6VCrI4~>!R^C=!Hou$)}+_xXSY(%}r=8d$J3Z}U5?>BSWNFocV(TX#=cl6s5(Fntr9fXjj^BRO7u87(gcWchvRnKA zk#H5nZz5aBH_(hSvk1}8GLRxmJAKyCPT>|^*EP9TpYi%NnCD8G=)O-y zyKi)qk1^;eJ7p6jA4p}MLi?RlnWW3B97|G-{C z`DKiNO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