提交 50349fa8 authored 作者: jianglw's avatar jianglw

添加token

上级 d17c16d7
......@@ -2,7 +2,7 @@
ENV = 'development'
# 若依管理系统/开发环境
VUE_APP_BASE_API = '/'
VUE_APP_BASE_API = '/dev-api'
# 路由懒加载
VUE_CLI_BABEL_TRANSPILE_MODULES = true
......@@ -2,9 +2,7 @@
ENV = 'production'
# 若依管理系统/生产环境
VUE_APP_BASE_API = '/'
VUE_APP_BASE_API = ''
#端口
PORT = '8080'
#{{ window._CONFIG['domianURL'] }}/jmreport/list?token=${token}
#layouts/IframePageView
......@@ -281,7 +281,7 @@
params.setteeTag = setteeTag;
axios({
method: 'get',
url: '/params/show',
url: '/topology/params/show',
params
}).then(res=>{
if(res.data.code===200){
......
import request from '@/utils/request'
export function upload(data) {
return request({
url: '/images/upload',
url: '/topology/images/upload',
method: 'post',
data: data
})
}
export function deleteImages(id) {
return request({
url: '/images/delete/'+id,
url: '/topology/images/delete/'+id,
method: 'delete'
})
}
export function list(){
return request({
url: '/images/list',
url: '/topology/images/list',
method: 'get'
})
}
\ No newline at end of file
......@@ -55,12 +55,12 @@
@click="selectImage(baseapi + item.url)"
>选择图片</el-button
>
<a-button
<el-button
type="text"
class="button"
style="color: red"
@click="deleteImage(item.id)"
>删除</a-button
>删除</el-button
>
</div>
</div>
......
......@@ -10,7 +10,7 @@ VueRouter.prototype.push = function push(location) {
}
const routes = [
{
path: '/topologyView/list',
path: '/',
name: 'Index',
component: () =>import('@/views/configuration/ParamsConfig.vue')
},
......
import axios from 'axios'
import errorCode from '@/utils/errorCode'
import { Notification, MessageBox, Message } from 'element-ui'
import {urlParse} from '@/utils/ruoyi'
axios.defaults.headers['Content-Type'] = 'application/json;charset=utf-8'
// 创建axios实例
......@@ -11,18 +13,17 @@ const service = axios.create({
})
// request拦截器
service.interceptors.request.use(config => {
// // 是否需要设置 token
// const isToken = (config.headers || {}).isToken === false
// if (getToken() && !isToken) {
// config.headers['Authorization'] = 'Bearer ' + getToken() // 让每个请求携带自定义token 请根据实际情况自行修改
// }
let token=urlParse();
if(token){
config.headers['X-Access-Token'] = token;
}
// get请求映射params参数
if (config.method === 'get' && config.params) {
let url = config.url + '?';
for (const propName of Object.keys(config.params)) {
const value = config.params[propName];
var part = encodeURIComponent(propName) + "=";
if (value !== null && typeof(value) !== "undefined") {
if (value !== null && typeof (value) !== "undefined") {
if (typeof value === 'object') {
for (const key of Object.keys(value)) {
let params = propName + '[' + key + ']';
......@@ -40,7 +41,6 @@ service.interceptors.request.use(config => {
}
return config
}, error => {
console.log(error)
Promise.reject(error)
})
......@@ -51,21 +51,21 @@ service.interceptors.response.use(res => {
// 获取错误信息
const msg = errorCode[code] || res.data.msg || errorCode['default']
if (code === 401) {
// MessageBox.confirm('登录状态已过期,您可以继续留在该页面,或者重新登录', '系统提示', {
// confirmButtonText: '重新登录',
// cancelButtonText: '取消',
// type: 'warning'
// }
// ).then(() => {
// store.dispatch('LogOut').then(() => {
// location.href = '/index';
// })
// })
MessageBox.confirm('登录状态已过期,您可以继续留在该页面,或者重新登录', '系统提示', {
confirmButtonText: '重新登录',
cancelButtonText: '取消',
type: 'warning'
}
).then(() => {
store.dispatch('LogOut').then(() => {
location.href = '/index';
})
})
} else if (code === 500) {
// Message({
// message: msg,
// type: 'error'
// })
Message({
message: msg,
type: 'error'
})
return Promise.reject(new Error(msg))
} else if (code !== 200) {
Notification.error({
......@@ -75,7 +75,7 @@ service.interceptors.response.use(res => {
} else {
return res.data
}
},
},
error => {
console.log('err' + error)
let { message } = error;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论