@uomp/uomp-ipmanage 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1 -0
- package/package.json +24 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import e from"axios";class t{constructor(t={}){this.beforeRequest=t.beforeRequest||null,this.onError=t.onError||null,this._axios=e.create({baseURL:t.baseURL||"",headers:{"Content-Type":"application/json",...t.headers},paramsSerializer:{indexes:null}}),this._setupInterceptors()}_setupInterceptors(){this._axios.interceptors.request.use(e=>(this.beforeRequest&&this.beforeRequest({method:e.method?.toUpperCase(),url:e.url,body:e.data,headers:e.headers}),e),e=>Promise.reject(e)),this._axios.interceptors.response.use(e=>204===e.status?null:e.data,e=>{if(e.response){const{status:t,data:r}=e.response,s=new Error(r?.detail||r?.message||`请求失败: ${t}`);throw s.status=t,s.data=r,this.onError&&this.onError(s),s}const t=new Error(`网络请求失败: ${e.message}`);throw this.onError&&this.onError(t),t})}get(e,t){return this._request("GET",e,t)}post(e,t){return this._request("POST",e,t)}put(e,t){return this._request("PUT",e,t)}patch(e,t){return this._request("PATCH",e,t)}delete(e,t){return this._request("DELETE",e,t)}_request(e,t,r={}){const{params:s,body:o,headers:u}=r,i={method:e,url:t};return s&&(i.params=s),o&&(i.data=o),u&&(i.headers=u),this._axios.request(i)}}class r{constructor(e){this.request=e,this.resource="master_regin"}list(e={}){return this.request.get(`${this.resource}/`,{params:e})}create(e){return this.request.post(`${this.resource}/`,{body:e})}detail(e){return this.request.get(`${this.resource}/${e}/`)}update(e,t){return this.request.put(`${this.resource}/${e}/`,{body:t})}patch(e,t){return this.request.patch(`${this.resource}/${e}/`,{body:t})}delete(e){return this.request.delete(`${this.resource}/${e}/`)}batchDelete(e){return this.request.delete(`${this.resource}/`,{body:{ids:e}})}}function s(e={}){const s=new t(e);return{masterRegin:new r(s)}}export{r as MasterReginAPI,t as RequestClient,s as createClient};
|
package/package.json
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@uomp/uomp-ipmanage",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "UOMP IP 管理前端 API 库",
|
|
5
|
+
"license": "ISC",
|
|
6
|
+
"author": "",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"main": "./dist/index.js",
|
|
9
|
+
"module": "./dist/index.js",
|
|
10
|
+
"files": [
|
|
11
|
+
"dist"
|
|
12
|
+
],
|
|
13
|
+
"scripts": {
|
|
14
|
+
"build": "rollup -c",
|
|
15
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
16
|
+
},
|
|
17
|
+
"devDependencies": {
|
|
18
|
+
"@rollup/plugin-terser": "^1.0.0",
|
|
19
|
+
"rollup": "^4.62.0"
|
|
20
|
+
},
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"axios": "^1.17.0"
|
|
23
|
+
}
|
|
24
|
+
}
|