yxuse 3.0.90 → 3.0.91
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/lib/index.cjs12.js +1 -1
- package/lib/index.es12.js +18 -0
- package/lib/index.es12.js.gz +0 -0
- package/package.json +1 -1
- package/types/components/CommonPage/index.d.ts +3 -0
- package/types/components/CommonPage/page.d.ts +64 -0
- package/types/components/CommonPage/pagination.d.ts +9 -0
- package/types/components/CommonPage/props.d.ts +36 -0
- package/types/components/CommonPage/search.d.ts +4 -0
- package/types/components/CommonPage/table.d.ts +3 -0
- package/types/components/CommonPage/type.d.ts +1 -0
- package/types/utils/http/index.d.ts +8 -0
package/lib/index.cjs12.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=Object.defineProperty,t=(t,s,r)=>((t,s,r)=>s in t?e(t,s,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[s]=r)(t,"symbol"!=typeof s?s+"":s,r);const s=require("./vendor-axios.cjs.js"),r=require("element-plus");require("element-plus/es/components/notification/style/index"),require("element-plus/es/components/message/style/index"),require("element-plus/es/components/message/style/css"),require("element-plus/es/components/notification/style/css"),require("element-plus/es/components/message-box/style/index"),require("./vendor-dayjs.cjs.js"),require("element-plus/es/components/loading/style/index"),require("element-plus/es/components/loading/style/css"),require("./vendor-mqtt.cjs.js");const o={ttc:{LOGIN_URL:`${window.location.origin}/ttc/cloud/#/login`,HOME_URL:`${window.location.origin}/ttc/cloud/#/cloud`,INTEGRATED_BASE_URL:"/gateway/integrated-management/api/v1"}},n=(e="ttc")=>{p({token:""})},a=(e="ttc")=>{const t=`${e}GlobalState`,s=localStorage.getItem(t)??"{}";return JSON.parse(s)?JSON.parse(s).token:null},i=async({userName:e,password:t},s="ttc")=>{const o=d("loginApiUrl"),{data:n}=await N.post(o,{userName:e,password:t});n.tokenValue&&r.ElMessage.success("登录成功"),p({token:n.tokenValue,userInfo:n})},l=()=>{if(
|
|
1
|
+
"use strict";var e=Object.defineProperty,t=(t,s,r)=>((t,s,r)=>s in t?e(t,s,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[s]=r)(t,"symbol"!=typeof s?s+"":s,r);const s=require("./vendor-axios.cjs.js"),r=require("element-plus");require("element-plus/es/components/notification/style/index"),require("element-plus/es/components/message/style/index"),require("element-plus/es/components/message/style/css"),require("element-plus/es/components/notification/style/css"),require("element-plus/es/components/message-box/style/index"),require("./vendor-dayjs.cjs.js"),require("element-plus/es/components/loading/style/index"),require("element-plus/es/components/loading/style/css"),require("./vendor-mqtt.cjs.js");const o={ttc:{LOGIN_URL:`${window.location.origin}/ttc/cloud/#/login`,HOME_URL:`${window.location.origin}/ttc/cloud/#/cloud`,INTEGRATED_BASE_URL:"/gateway/integrated-management/api/v1"}},n=(e="ttc")=>{p({token:""})},a=(e="ttc")=>{const t=`${e}GlobalState`,s=localStorage.getItem(t)??"{}";return JSON.parse(s)?JSON.parse(s).token:null},i=async({userName:e,password:t},s="ttc")=>{const o=d("loginApiUrl"),{data:n}=await N.post(o,{userName:e,password:t});n.tokenValue&&r.ElMessage.success("登录成功"),p({token:n.tokenValue,userInfo:n})},l=()=>{if(h()){n();if(location.pathname.includes(u()))return;location.replace(u())}else{const e=window.prompt("当前系统处于开发环境,当前登录过期,请输入登录账号","");if(null!==e){const t=window.prompt("请输入登录密码","");null!==t&&""!=t||window.prompt("请输入登录密码",""),i({userName:e,password:t})}}},c=()=>{window.location.replace(g())},u=()=>d("loginUrl"),g=()=>d("homeUrl"),p=(e,t="ttc")=>{const s=localStorage.getItem(`${t}GlobalState`)??"{}",r={...JSON.parse(s),...e};localStorage.setItem(`${t}GlobalState`,JSON.stringify(r))},m=(e,t,s="ttc")=>{const r=localStorage.getItem(`${s}GlobalState`)??"{}",o={...JSON.parse(r),[e]:t};localStorage.setItem(`${s}GlobalState`,JSON.stringify(o))},d=(e,t="ttc")=>JSON.parse(localStorage.getItem(`${t}GlobalState`)??"{}")[e]??"",h=()=>"production"===d("environment"),R=e=>{if(!e)return!1;const t=sessionStorage.getItem("ttcUserBtnList")??"[]";return JSON.parse(t).includes(e)};let S=null;const f=async()=>{if(S)return S;const e=await N.get(d("userConfigApiUrl"),{},{headers:{noLoading:!0},customResHandler:e=>e});return S=e,e},E=Object.freeze(Object.defineProperty({__proto__:null,autoLogin:i,changeSystemConfig:m,getHomeUrl:g,getLoginUrl:u,getSystemConfig:d,getToken:a,getUserConfig:f,getUserInfo:(e="ttc")=>{const t=`${e}GlobalState`,s=localStorage.getItem(t)??"{}";return JSON.parse(s)?JSON.parse(s).userInfo:null},getUserIsHaveBtnPower:R,getUserPermissions:async(e,t=!0,s)=>{if(!a()&&t)return l();try{const{data:t}=await((e="ttc")=>N.get(`${o[e].INTEGRATED_BASE_URL}/account/auth/route/list`))(s),r=t.filter((t=>t.routeTag.startsWith(e))),n=r.filter((e=>"VIEW"===e.routeType)),a=r.filter((e=>"BTN"===e.routeType));return sessionStorage.setItem("ttcUserBtnList",JSON.stringify(a.map((e=>e.routeTag)))),{userMenuList:n,userBtnList:a}}catch(r){}},getUserRouteList:async()=>{if(!a())return[];return await((e="ttc")=>N.get(`${o[e].INTEGRATED_BASE_URL}/account/home/menu`))()},getUserRouter:(e,t)=>{let s=[];return e.forEach((e=>{const r=`/src/views${e.routeView}/index.vue`;if(t[r]){const o=(null==e?void 0:e.reservedRouteInfo)&&JSON.parse((null==e?void 0:e.reservedRouteInfo)??"{}"),n={path:e.routeView,name:e.routeView.split("/")[1],meta:{title:e.routeName,icon:null==o?void 0:o.routeIcon},component:t[r]};s.push(n)}})),s},isProduction:h,jumpToHome:c,jumpToLogin:l,removeToken:n,setSystemConfig:p,setSystemInfo:(e,t)=>{const s=`${e}GlobalState`;localStorage.setItem(s,JSON.stringify(t))},setUserInfo:(e,t)=>{const s=`${e}GlobalState`,r=localStorage.getItem(s)??"{}",o={...JSON.parse(r),userInfo:t};localStorage.setItem(s,JSON.stringify(o))}},Symbol.toStringTag,{value:"Module"}));let I;const b={lock:!0,text:"loading...",fullscreen:!0,background:"rgba(0, 0, 0, 0.6)"};let v=0;const M=()=>{0===v&&(I=r.ElLoading.service(b)),v++},w=()=>{v<=0||(v--,0===v&&I.close())};var y=(e=>(e[e.SUCCESS=200]="SUCCESS",e[e.ERROR=500]="ERROR",e[e.OVERDUE=401]="OVERDUE",e[e.TIMEOUT=3e4]="TIMEOUT",e))(y||{});const U=(e,t)=>{switch(e){case 400:r.ElMessage.error(t||"请求失败!请您稍后重试");break;case 401:r.ElMessage.error(t||"登录失效!请您重新登录"),location.href.includes(u())||l();break;case 403:r.ElMessage.error(t||"当前账号无权限访问!");break;case 404:r.ElMessage.error("你所访问的资源不存在");break;case 405:r.ElMessage.error(t||"请求方式错误!请您稍后重试");break;case 408:r.ElMessage.error(t||"请求超时!请您稍后重试");break;case 500:r.ElMessage.error(t||"服务异常!");break;case 502:r.ElMessage.error(t||"网关错误!");break;case 503:r.ElMessage.error(t||"服务不可用");break;case 504:r.ElMessage.error(t||"网关超时!");break;default:r.ElMessage.error(t||"请求失败!请您稍后重试!")}};d("isTranslateApi");const N=new class{constructor(e){t(this,"service"),t(this,"customResMap"),t(this,"customResquestInterceptors"),t(this,"customResponseInterceptors"),t(this,"customGlobalResHandler"),this.service=s.axios.create(e),this.setupInterceptors(),this.customResMap={}}setupInterceptors(){this.service.interceptors.request.use((e=>{var t;return(null==(t=e.headers)?void 0:t.noLoading)||M(),e.headers.token=a(),(null==e?void 0:e.customResHandler)&&(null==e?void 0:e.url)&&(this.customResMap[null==e?void 0:e.url]=e.customResHandler),this.customResquestInterceptors&&this.customResquestInterceptors(e),e}),(e=>Promise.reject(e))),this.service.interceptors.response.use((async e=>{const{config:t}=e;let s=e.data;if(w(),this.customResponseInterceptors)return this.customResponseInterceptors(e);if(this.customGlobalResHandler){if(!this.customGlobalResHandler(e))return}const r=e.status;return t.url&&this.customResMap[t.url]?this.customResMap[t.url](s,e):(r==y.OVERDUE||s.code===y.OVERDUE?this.handleOverdueResponse(s):s.code!==y.SUCCESS&&this.handleErrorResponse(s),s)}),(e=>{w();const t=e.response,{config:s}=e;if(this.customResponseInterceptors)return this.customResponseInterceptors(t);if(this.customGlobalResHandler){if(!this.customGlobalResHandler(t))return}return(null==s?void 0:s.url)&&this.customResMap[s.url]?this.customResMap[s.url](e.response):(e.message.includes("timeout")?r.ElMessage.error("请求超时!请稍后重试"):e.message.includes("Network Error")&&r.ElMessage.error("网络错误!请稍后重试"),t&&U(t.status,this.getResMessage(t.data)),window.navigator.onLine||r.ElNotification({title:"提示",message:"当前网络似乎开小差了",type:"warning",duration:5e3}),Promise.reject(e))}))}getResMessage(e){return(null==e?void 0:e.resultMsg)??(null==e?void 0:e.message)??(null==e?void 0:e.msg)??null}handleOverdueResponse(e){return r.ElNotification({title:"登录过期提醒",message:this.getResMessage(e)||"当前登录失效",type:"warning",duration:5e3}),l(),Promise.reject(e)}handleErrorResponse(e){return this.getResMessage(e)?r.ElMessage.error(this.getResMessage(e)):U(e.status),Promise.reject(e)}get(e,t,s={}){return this.service.get(e,{params:t,...s})}post(e,t,s={}){return this.service.post(e,t,s)}put(e,t,s={}){return this.service.put(e,t,s)}delete(e,t,s={}){return this.service.delete(e,{params:t,...s})}interceptorsRequestCallback(e){this.customResquestInterceptors=e}interceptorsResponseCallback(e){this.customResponseInterceptors=e}customGlobalResHandlerCallback(e){this.customGlobalResHandler=e}}({timeout:3e4,withCredentials:!0});exports.BC_LANG_NAME="LANG",exports.BC_THEME_NAME="THEME",exports.URL=o,exports.changeSystemConfig=m,exports.checkStatus=U,exports.getSystemConfig=d,exports.getToken=a,exports.getUserConfig=f,exports.getUserIsHaveBtnPower=R,exports.hideFullScreenLoading=w,exports.http=N,exports.index=E,exports.jumpToHome=c,exports.setSystemConfig=p,exports.showFullScreenLoading=M;
|
package/lib/index.es12.js
CHANGED
|
@@ -278,6 +278,8 @@ class YxHttp {
|
|
|
278
278
|
__publicField(this, "customResquestInterceptors");
|
|
279
279
|
/**自定义响应拦截器逻辑 */
|
|
280
280
|
__publicField(this, "customResponseInterceptors");
|
|
281
|
+
/** 自定义全局响应处理回调*/
|
|
282
|
+
__publicField(this, "customGlobalResHandler");
|
|
281
283
|
this.service = axios.create(config2);
|
|
282
284
|
this.setupInterceptors();
|
|
283
285
|
this.customResMap = {};
|
|
@@ -306,6 +308,10 @@ class YxHttp {
|
|
|
306
308
|
let data = response.data;
|
|
307
309
|
hideFullScreenLoading();
|
|
308
310
|
if (this.customResponseInterceptors) return this.customResponseInterceptors(response);
|
|
311
|
+
if (this.customGlobalResHandler) {
|
|
312
|
+
const isContinue = this.customGlobalResHandler(response);
|
|
313
|
+
if (!isContinue) return;
|
|
314
|
+
}
|
|
309
315
|
const code = response.status;
|
|
310
316
|
if (config2.url && this.customResMap[config2.url]) {
|
|
311
317
|
return this.customResMap[config2.url](data, response);
|
|
@@ -322,6 +328,10 @@ class YxHttp {
|
|
|
322
328
|
const response = error.response;
|
|
323
329
|
const { config: config2 } = error;
|
|
324
330
|
if (this.customResponseInterceptors) return this.customResponseInterceptors(response);
|
|
331
|
+
if (this.customGlobalResHandler) {
|
|
332
|
+
const isContinue = this.customGlobalResHandler(response);
|
|
333
|
+
if (!isContinue) return;
|
|
334
|
+
}
|
|
325
335
|
if ((config2 == null ? void 0 : config2.url) && this.customResMap[config2.url]) {
|
|
326
336
|
return this.customResMap[config2.url](error.response);
|
|
327
337
|
}
|
|
@@ -418,6 +428,14 @@ class YxHttp {
|
|
|
418
428
|
interceptorsResponseCallback(callback) {
|
|
419
429
|
this.customResponseInterceptors = callback;
|
|
420
430
|
}
|
|
431
|
+
/**
|
|
432
|
+
* 自定义请求拦截器回调
|
|
433
|
+
* @param url
|
|
434
|
+
* @param callback
|
|
435
|
+
*/
|
|
436
|
+
customGlobalResHandlerCallback(callback) {
|
|
437
|
+
this.customGlobalResHandler = callback;
|
|
438
|
+
}
|
|
421
439
|
}
|
|
422
440
|
const http = new YxHttp(config);
|
|
423
441
|
export {
|
package/lib/index.es12.js.gz
CHANGED
|
Binary file
|
package/package.json
CHANGED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
declare const _default: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
|
|
2
|
+
searchProps: {
|
|
3
|
+
type: ObjectConstructor;
|
|
4
|
+
default: () => {};
|
|
5
|
+
};
|
|
6
|
+
tableProps: {
|
|
7
|
+
type: ObjectConstructor;
|
|
8
|
+
default: () => {};
|
|
9
|
+
};
|
|
10
|
+
pageInfo: {
|
|
11
|
+
type: ObjectConstructor;
|
|
12
|
+
default: () => {
|
|
13
|
+
pageSize: number;
|
|
14
|
+
pageIndex: number;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
pageConfig: {
|
|
18
|
+
type: ObjectConstructor;
|
|
19
|
+
default: () => {
|
|
20
|
+
isPage: boolean;
|
|
21
|
+
gap: number;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
requestConfig: {
|
|
25
|
+
type: ObjectConstructor;
|
|
26
|
+
default: () => {};
|
|
27
|
+
};
|
|
28
|
+
}>, () => import('vue').VNode<import('vue').RendererNode, import('vue').RendererElement, {
|
|
29
|
+
[key: string]: any;
|
|
30
|
+
}>, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
|
|
31
|
+
searchProps: {
|
|
32
|
+
type: ObjectConstructor;
|
|
33
|
+
default: () => {};
|
|
34
|
+
};
|
|
35
|
+
tableProps: {
|
|
36
|
+
type: ObjectConstructor;
|
|
37
|
+
default: () => {};
|
|
38
|
+
};
|
|
39
|
+
pageInfo: {
|
|
40
|
+
type: ObjectConstructor;
|
|
41
|
+
default: () => {
|
|
42
|
+
pageSize: number;
|
|
43
|
+
pageIndex: number;
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
pageConfig: {
|
|
47
|
+
type: ObjectConstructor;
|
|
48
|
+
default: () => {
|
|
49
|
+
isPage: boolean;
|
|
50
|
+
gap: number;
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
requestConfig: {
|
|
54
|
+
type: ObjectConstructor;
|
|
55
|
+
default: () => {};
|
|
56
|
+
};
|
|
57
|
+
}>> & Readonly<{}>, {
|
|
58
|
+
pageInfo: Record<string, any>;
|
|
59
|
+
searchProps: Record<string, any>;
|
|
60
|
+
tableProps: Record<string, any>;
|
|
61
|
+
pageConfig: Record<string, any>;
|
|
62
|
+
requestConfig: Record<string, any>;
|
|
63
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
|
|
64
|
+
export default _default;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @Author: wangxin wangxin@emposat.com
|
|
3
|
+
* @Date: 2025-08-12 16:18:41
|
|
4
|
+
* @LastEditors: wangxin wangxin@emposat.com
|
|
5
|
+
* @LastEditTime: 2025-08-12 16:23:18
|
|
6
|
+
* @FilePath: packages/components/CommonPage/pagination.tsx
|
|
7
|
+
* @Description: 这是默认设置,可以在设置》工具》File Description中进行配置
|
|
8
|
+
*/
|
|
9
|
+
export declare const paginationRender: (pageInfo: any, updatePage: any) => import("vue/jsx-runtime").JSX.Element | null;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @Author: wangxin wangxin@emposat.com
|
|
3
|
+
* @Date: 2025-08-12 15:42:00
|
|
4
|
+
* @LastEditors: wangxin wangxin@emposat.com
|
|
5
|
+
* @LastEditTime: 2025-08-12 16:09:56
|
|
6
|
+
* @FilePath: packages/components/CommonPage/props.ts
|
|
7
|
+
* @Description: 这是默认设置,可以在设置》工具》File Description中进行配置
|
|
8
|
+
*/
|
|
9
|
+
export declare const pageProps: {
|
|
10
|
+
searchProps: {
|
|
11
|
+
type: ObjectConstructor;
|
|
12
|
+
default: () => {};
|
|
13
|
+
};
|
|
14
|
+
tableProps: {
|
|
15
|
+
type: ObjectConstructor;
|
|
16
|
+
default: () => {};
|
|
17
|
+
};
|
|
18
|
+
pageInfo: {
|
|
19
|
+
type: ObjectConstructor;
|
|
20
|
+
default: () => {
|
|
21
|
+
pageSize: number;
|
|
22
|
+
pageIndex: number;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
pageConfig: {
|
|
26
|
+
type: ObjectConstructor;
|
|
27
|
+
default: () => {
|
|
28
|
+
isPage: boolean;
|
|
29
|
+
gap: number;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
requestConfig: {
|
|
33
|
+
type: ObjectConstructor;
|
|
34
|
+
default: () => {};
|
|
35
|
+
};
|
|
36
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -14,6 +14,8 @@ declare class YxHttp {
|
|
|
14
14
|
customResquestInterceptors?: any;
|
|
15
15
|
/**自定义响应拦截器逻辑 */
|
|
16
16
|
customResponseInterceptors?: Function;
|
|
17
|
+
/** 自定义全局响应处理回调*/
|
|
18
|
+
customGlobalResHandler?: (res: any) => boolean;
|
|
17
19
|
constructor(config: CustomAxiosRequestConfig);
|
|
18
20
|
private setupInterceptors;
|
|
19
21
|
private getResMessage;
|
|
@@ -59,6 +61,12 @@ declare class YxHttp {
|
|
|
59
61
|
* @param callback
|
|
60
62
|
*/
|
|
61
63
|
interceptorsResponseCallback(callback: Function): void;
|
|
64
|
+
/**
|
|
65
|
+
* 自定义请求拦截器回调
|
|
66
|
+
* @param url
|
|
67
|
+
* @param callback
|
|
68
|
+
*/
|
|
69
|
+
customGlobalResHandlerCallback(callback: Function): void;
|
|
62
70
|
}
|
|
63
71
|
declare const _default: YxHttp;
|
|
64
72
|
export default _default;
|