Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@sweetui/sweet-mobile

Package Overview
Dependencies
Maintainers
2
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sweetui/sweet-mobile - npm Package Compare versions

Comparing version 2.0.1 to 2.0.2

2

package.json
{
"name": "@sweetui/sweet-mobile",
"version": "2.0.1",
"version": "2.0.2",
"description": "Sweet Mobile Core",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -1,8 +0,7 @@

import Vue from 'vue';
import axios from 'axios';
const SWXHR = function (options, store, tool) {
const SWXHR = function(Vue, options, store, tool) {
this.Vue = Vue;
// 注册
this._reg(store, tool);
var that = this,

@@ -14,6 +13,3 @@ deOptions = {

headers: {},
maxStatus: 500,
validateStatus: function (status) {
return that._catchStatus(status);
}
maxStatus: 500
},

@@ -36,5 +32,2 @@ intercept: {

this.OPTIONS = this.SWTOOL.object.extend(true, deOptions, options);
// 注册全局message
this.$message = Vue.prototype.$message;
that.axios = axios.create(this.OPTIONS.config);

@@ -46,4 +39,8 @@ // 添加请求拦截器

SWXHR.prototype = {
install(Vue) {
if (this.install.installed) return;
this.install.installed = true;
Vue.prototype.SWXHR = this;
},
_reg(store, tool) {
Vue.prototype.SWXHR = this;
// 注册工具类

@@ -62,3 +59,3 @@ if (tool) {

response = intercept.response,
defaultError = function (error) {
defaultError = function(error) {
// 对请求错误做些什么

@@ -68,59 +65,8 @@ return Promise.reject(error);

if (request && typeof (request) === 'function') this.axios.interceptors.request.use(request, defaultError);
if (request && typeof request === 'function')
this.axios.interceptors.request.use(request, defaultError);
if (response && typeof (response) === 'function') this.axios.interceptors.response.use(response, defaultError);
if (response && typeof response === 'function')
this.axios.interceptors.response.use(response, defaultError);
},
_statusCode(statusCode) {
var codes = {
400: {
text: '<p>错误编码:400</p>'
},
401: {
text: '对不起,您没有权限,请重新登录后再打开。<p>错误编码:401</p>'
},
403: {
text: '<p>错误编码:403</p>'
},
404: {
text: '<p>对不起,没有找到页面或者数据</p><p>错误编码:404</p>'
},
409: {
text: '对不起,资源冲突<p>错误编码:409</p>'
},
500: {
text: '<p>错误编码:500</p>'
},
503: {
text: '<p>错误编码:503</p>'
}
};
if (codes[statusCode]) {
// 托管给使用者调用
if (typeof (this.OPTIONS.catchStatus) === 'function') {
this.OPTIONS.catchStatus(statusCode, codes[statusCode]);
} else {
this.$message({
message: '状态码:' + statusCode + ',信息:' + codes[statusCode].text,
type: 'error'
});
}
}
},
_catchStatus(status) {
this._statusCode(status);
return status < this.OPTIONS.config.maxStatus;
},
_getError(error) {
if (error.response) {
// 请求已发出,但服务器响应的状态码不在 2xx 范围内
console.log('请求已发出');
console.log(error.response.data);
console.log(error.response.status);
console.log(error.response.headers);
} else {
// Something happened in setting up the request that triggered an Error
console.log('Error', error.message);
}
},
_getAxios(type, args) {

@@ -127,0 +73,0 @@ var url = args[0],

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc