|
|
|
@ -11,9 +11,9 @@ class ServerSentEvents {
|
|
|
|
data: undefined, // 请求正文
|
|
|
|
data: undefined, // 请求正文
|
|
|
|
params: undefined, // 请求参数
|
|
|
|
params: undefined, // 请求参数
|
|
|
|
method: 'get', // 提交方式
|
|
|
|
method: 'get', // 提交方式
|
|
|
|
auth: false, // 是否携带token
|
|
|
|
auth: true, // 是否携带token
|
|
|
|
json: true, // 是否返回json
|
|
|
|
json: true, // 是否返回json
|
|
|
|
returnData: true, // json数据是否返回data属性
|
|
|
|
returnData: false, // json数据是否返回data属性
|
|
|
|
reconnect: true, //是否重连
|
|
|
|
reconnect: true, //是否重连
|
|
|
|
headers: {
|
|
|
|
headers: {
|
|
|
|
'Content-Type': 'application/json'
|
|
|
|
'Content-Type': 'application/json'
|
|
|
|
@ -54,7 +54,7 @@ class ServerSentEvents {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
init() {
|
|
|
|
init() {
|
|
|
|
if (this.config.auth) {
|
|
|
|
if (this.config.auth) {
|
|
|
|
this.headers.Authorization = 'Bearer ' + new useAuthStore().token
|
|
|
|
this.config.headers.Authorization = 'Bearer ' + useAuthStore().token
|
|
|
|
}
|
|
|
|
}
|
|
|
|
let url = this.config.url
|
|
|
|
let url = this.config.url
|
|
|
|
// 如果url不含协议
|
|
|
|
// 如果url不含协议
|
|
|
|
|