From bcb850eef005d9a625716685f09c887bf1a1e09e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=8A=B2=E9=BE=99?= <2860996570@qq.com> Date: Thu, 26 Oct 2023 11:25:32 +0800 Subject: [PATCH 1/3] token --- .env.development | 2 +- src/api/index.js | 7 +++++++ src/api/myAPI/login.js | 29 +++++++++++++++++++++++++++++ src/main.js | 12 ++++++++++++ 4 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 src/api/index.js create mode 100644 src/api/myAPI/login.js diff --git a/.env.development b/.env.development index 6f47003..600b1ac 100644 --- a/.env.development +++ b/.env.development @@ -5,7 +5,7 @@ VUE_APP_TITLE = 若依管理系统 ENV = 'development' # 若依管理系统/开发环境 -VUE_APP_BASE_API = 'https://vue.ruoyi.vip/prod-api' +VUE_APP_BASE_API = https://dev-mssm-liaoning.imian.org.cn/ggfw-api # 路由懒加载 VUE_CLI_BABEL_TRANSPILE_MODULES = true diff --git a/src/api/index.js b/src/api/index.js new file mode 100644 index 0000000..50aafd3 --- /dev/null +++ b/src/api/index.js @@ -0,0 +1,7 @@ +// 召回 +import login from "./myAPI/login.js"; + + +export default { + login +}; diff --git a/src/api/myAPI/login.js b/src/api/myAPI/login.js new file mode 100644 index 0000000..901e9d2 --- /dev/null +++ b/src/api/myAPI/login.js @@ -0,0 +1,29 @@ +import request from "@/utils/request"; +// 本地 +// let api = "API" +// 线上 + +let api = location.origin +export default { + + + frimLogin() { + return request({ + baseURL: process.env.VUE_APP_USER_LOGIN, + url: "/pharmaceuticals/login", + headers: { + "Content-Type": "application/json", + isToken: true, + repeatSubmit: false, + }, + method: "POST", + timeout: 60000, + data: { + pdma: "MTExMTEx", + urne: "2112042170015", + }, + }); + }, + + +}; diff --git a/src/main.js b/src/main.js index 6abd3d7..4e9e94f 100644 --- a/src/main.js +++ b/src/main.js @@ -39,6 +39,8 @@ import VueMeta from 'vue-meta' import DictData from '@/components/DictData' //计算rem基准 import '@/utils/rem.js' +// 引用api +import API from '@/api/index.js' // 全局方法挂载 @@ -51,6 +53,7 @@ Vue.prototype.selectDictLabel = selectDictLabel Vue.prototype.selectDictLabels = selectDictLabels Vue.prototype.download = download Vue.prototype.handleTree = handleTree +Vue.prototype.$api = API // 全局组件挂载 Vue.component('DictTag', DictTag) @@ -66,6 +69,15 @@ Vue.use(plugins) Vue.use(VueMeta) DictData.install() + // 临时获取token + let token = async()=>{ + let Authentication = await API.login.frimLogin(); + localStorage.setItem( + "MSSM-LIAONING__TOKEN", + Authentication.data.result.userToken + ); + } + token() /** * If you don't want to use mock-server * you want to use MockJs for mock api From da94fbe1300f49c7491c679c644c193aaff4855e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=8A=B2=E9=BE=99?= <2860996570@qq.com> Date: Thu, 26 Oct 2023 11:27:03 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E6=9B=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/auth.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/auth.js b/src/utils/auth.js index 88d7b6c..ec38560 100644 --- a/src/utils/auth.js +++ b/src/utils/auth.js @@ -1,6 +1,6 @@ import Cookies from 'js-cookie' -const TokenKey = 'Admin-Token' +const TokenKey = 'MSSM-LIAONING__TOKEN' export function getToken() { return Cookies.get(TokenKey) From 5b75c7f184157744951f2697db8482d7a4bcdcd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=8A=B2=E9=BE=99?= <2860996570@qq.com> Date: Thu, 26 Oct 2023 11:28:15 +0800 Subject: [PATCH 3/3] token --- src/permission.js | 3 ++- src/utils/request.js | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/permission.js b/src/permission.js index 81cafdf..c0d24f2 100644 --- a/src/permission.js +++ b/src/permission.js @@ -3,7 +3,7 @@ import store from './store' import { Message } from 'element-ui' import NProgress from 'nprogress' import 'nprogress/nprogress.css' -import { getToken } from '@/utils/auth' +import { setToken } from '@/utils/auth' import { isRelogin } from '@/utils/request' NProgress.configure({ showSpinner: false }) @@ -11,6 +11,7 @@ NProgress.configure({ showSpinner: false }) const whiteList = ['/login', '/register'] router.beforeEach((to, from, next) => { + setToken() NProgress.start() next() }) diff --git a/src/utils/request.js b/src/utils/request.js index 48298ec..9ca1fa3 100644 --- a/src/utils/request.js +++ b/src/utils/request.js @@ -27,7 +27,7 @@ service.interceptors.request.use(config => { // 是否需要防止数据重复提交 const isRepeatSubmit = (config.headers || {}).repeatSubmit === false if (getToken() && !isToken) { - config.headers['Authorization'] = 'Bearer ' + getToken() // 让每个请求携带自定义token 请根据实际情况自行修改 + config.headers['Authentication'] = getToken() // 让每个请求携带自定义token 请根据实际情况自行修改 } // get请求映射params参数 if (config.method === 'get' && config.params) {