yxuse 3.0.102 → 3.0.104
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/README.md +89 -89
- package/lib/index.cjs11.js +1 -1
- package/lib/index.cjs2.js +1 -1
- package/lib/index.cjs5.js +1 -1
- package/lib/index.cjs5.js.gz +0 -0
- package/lib/index.cjs6.js +1 -1
- package/lib/index.es11.js +8 -2
- package/lib/index.es11.js.gz +0 -0
- package/lib/index.es2.js +209 -33
- package/lib/index.es2.js.gz +0 -0
- package/lib/index.es5.js +79 -8
- package/lib/index.es5.js.gz +0 -0
- package/lib/index.es6.js +3 -3
- package/lib/index.es6.js.gz +0 -0
- package/lib/utils.cjs.js +1 -1
- package/lib/utils.es.js +9 -1
- package/lib/vendor-axios.cjs.js.gz +0 -0
- package/lib/vendor-axios.es.js.gz +0 -0
- package/lib/vendor-dayjs.es.js.gz +0 -0
- package/lib/vendor-localforage.cjs.js.gz +0 -0
- package/lib/vendor-localforage.es.js.gz +0 -0
- package/lib/vendor-lodash.cjs.js.gz +0 -0
- package/lib/vendor-lodash.es.js.gz +0 -0
- package/lib/vendor-mqtt.cjs.js.gz +0 -0
- package/lib/vendor-mqtt.es.js.gz +0 -0
- package/lib/vendor-sortablejs.cjs.js.gz +0 -0
- package/lib/vendor-sortablejs.es.js.gz +0 -0
- package/lib/version.json +12 -12
- package/lib/yxuse.css +1 -1
- package/lib/yxuse.css.gz +0 -0
- package/package.json +178 -178
- package/types/api/modules/auth/index.d.ts +13 -13
- package/types/components/Common/DynamicComponent/index.vue.d.ts +21 -21
- package/types/components/CommonPage/index.d.ts +3 -3
- package/types/components/CommonPage/page.d.ts +64 -64
- package/types/components/CommonPage/pagination.d.ts +9 -9
- package/types/components/CommonPage/props.d.ts +36 -36
- package/types/components/CommonPage/search.d.ts +4 -4
- package/types/components/CommonPage/table.d.ts +3 -3
- package/types/components/CommonPage/type.d.ts +1 -1
- package/types/components/SearchForm/index.d.ts +3 -3
- package/types/components/SearchForm/index.vue.d.ts +2 -2
- package/types/components/YxForm/form.type.d.ts +183 -183
- package/types/components/YxForm/form.vaildator.d.ts +57 -57
- package/types/components/YxForm/form.vue.d.ts +66 -66
- package/types/components/YxFormV2/index.d.ts +3 -3
- package/types/components/YxFormV2/index.vue.d.ts +46 -46
- package/types/components/YxFormV2/type.d.ts +54 -54
- package/types/components/YxFrom/form.type.d.ts +179 -179
- package/types/components/YxFrom/form.vaildator.d.ts +57 -57
- package/types/components/YxFrom/form.vue.d.ts +66 -66
- package/types/components/YxFrom/index.d.ts +3 -3
- package/types/components/YxIcon/index.vue.d.ts +22 -22
- package/types/components/YxSearchForm/index.d.ts +3 -3
- package/types/components/YxSearchForm/index.vue.d.ts +36 -36
- package/types/components/YxSearchForm/type.d.ts +52 -52
- package/types/components/YxTable3/index.d.ts +1 -1
- package/types/components/YxTable3/src/index.d.ts +31 -31
- package/types/icons/index.d.ts +1 -1
- package/types/icons/src/index.d.ts +4 -4
- package/types/theme/checkVersion.d.ts +1 -0
- package/types/theme/config.d.ts +1 -0
- package/types/theme/type.d.ts +2 -0
- package/types/utils/index.d.ts +1 -0
- package/types/utils/mqtt/index.d.ts +24 -12
- package/types/utils/mqtt/interface.d.ts +6 -2
- package/types/utils/mqtt/singleton.d.ts +50 -0
package/README.md
CHANGED
|
@@ -1,89 +1,89 @@
|
|
|
1
|
-
<!--
|
|
2
|
-
* @Author: WangXin
|
|
3
|
-
* @Date: 2025-04-27 10:42:12
|
|
4
|
-
* @LastEditors: WangXin
|
|
5
|
-
* @LastEditTime: 2025-05-16 15:00:34
|
|
6
|
-
* @FilePath: /yxuse/README.md
|
|
7
|
-
* @Description:
|
|
8
|
-
*
|
|
9
|
-
* Copyright (c) ${2024} by YuXing, All Rights Reserved.
|
|
10
|
-
-->
|
|
11
|
-
|
|
12
|
-
## 更新日志
|
|
13
|
-
|
|
14
|
-
## 2025-05-16
|
|
15
|
-
|
|
16
|
-
### 3.0.51
|
|
17
|
-
|
|
18
|
-
#### Features
|
|
19
|
-
|
|
20
|
-
- Components:[YxForm](/component/yxtable.html)优化部分功能,新增 loadOptions 配置 [详见动态表单](/component/yxform.html#动态表单)
|
|
21
|
-
- Components:[YxTable] 新增 loadOptions 配置[详见](/component/yxtable.html#可编辑表格动态加载数据)
|
|
22
|
-
- utils[useConfirm] 新增 useConfirm 通用方法
|
|
23
|
-
|
|
24
|
-
#### Bug fixes
|
|
25
|
-
|
|
26
|
-
- Components:[YxDialog](/component/yxDialog.html)修复取消的回调不生效的 bug,beforeOpen 新增 Promise 回调的处理
|
|
27
|
-
- Components:[YxDrawer](/component/yxDrawer.html)修复取消的回调不生效的 bug,beforeOpen 新增 Promise 回调的处理
|
|
28
|
-
- Components:[YxUpload](/component/yxUpload.html)修复文件上传的列表和 limit 配置的数量不一致的 bug
|
|
29
|
-
|
|
30
|
-
## 2025-05-12
|
|
31
|
-
|
|
32
|
-
### 3.0.50
|
|
33
|
-
|
|
34
|
-
#### Features
|
|
35
|
-
|
|
36
|
-
- Components:[YxTable](/component/yxtable.html) 操作栏 render,参数新增 index
|
|
37
|
-
|
|
38
|
-
#### Bug fixes
|
|
39
|
-
|
|
40
|
-
- utils:[http]修复请求无法显示错误信息的 bug
|
|
41
|
-
- utils:[bc]修复在主应用下打开两个页面发送路由跳转的消息,子系统会同时进行路由跳转
|
|
42
|
-
|
|
43
|
-
## 2025-05-09
|
|
44
|
-
|
|
45
|
-
### 3.0.47
|
|
46
|
-
|
|
47
|
-
#### Features
|
|
48
|
-
|
|
49
|
-
- Components:[YxTable] 新增系统 title、logo 组件
|
|
50
|
-
|
|
51
|
-
## 2025-05-08
|
|
52
|
-
|
|
53
|
-
### 3.0.46
|
|
54
|
-
|
|
55
|
-
### 2.0.35
|
|
56
|
-
|
|
57
|
-
#### Features
|
|
58
|
-
|
|
59
|
-
- Components:[LogoTitle](/component/logoTitle.html) 新增系统 title、logo 组件
|
|
60
|
-
|
|
61
|
-
#### Bug fixes
|
|
62
|
-
|
|
63
|
-
- utils:[http](/utils/http.html)修复去除国际化逻辑后,请求 401 后无法跳转登录页的 bug
|
|
64
|
-
|
|
65
|
-
## 2025-04-27
|
|
66
|
-
|
|
67
|
-
### 3.0.45
|
|
68
|
-
|
|
69
|
-
#### Features
|
|
70
|
-
|
|
71
|
-
- Components:[YxForm](/component/yxform.html) 新增表单分组样式的自定义
|
|
72
|
-
|
|
73
|
-
### 3.0.44
|
|
74
|
-
|
|
75
|
-
#### Features
|
|
76
|
-
|
|
77
|
-
- Components:[YxTable](/component/yxtable.html) operate 操作栏新增自定义 className 配置
|
|
78
|
-
- utils:[mqtt](/utils/mqtt.html)新增 mqtt 的统一封装
|
|
79
|
-
- utils:[websocket](/utils/socket.html)新增 websocket 的封装
|
|
80
|
-
- utils:[fecth](/utils/fecth.html)新增 fecth 请求的封装
|
|
81
|
-
- docs:更新部分组件的文档
|
|
82
|
-
|
|
83
|
-
#### Bug fixes
|
|
84
|
-
|
|
85
|
-
- Components:[YxForm][YxForm](/component/yxform.html)修复在初始化时传入默认数据不生效的 bug
|
|
86
|
-
- Components:[YxForm]修复类型提示
|
|
87
|
-
- Components:[YxTable]修复类型提示和排序的 bug
|
|
88
|
-
- utils:[translate]修复翻译的 bug
|
|
89
|
-
- auth:[getUserRouter]获取当前系统的动态路由不再需要 viewConfig 配置,统一从权限配置取
|
|
1
|
+
<!--
|
|
2
|
+
* @Author: WangXin
|
|
3
|
+
* @Date: 2025-04-27 10:42:12
|
|
4
|
+
* @LastEditors: WangXin
|
|
5
|
+
* @LastEditTime: 2025-05-16 15:00:34
|
|
6
|
+
* @FilePath: /yxuse/README.md
|
|
7
|
+
* @Description:
|
|
8
|
+
*
|
|
9
|
+
* Copyright (c) ${2024} by YuXing, All Rights Reserved.
|
|
10
|
+
-->
|
|
11
|
+
|
|
12
|
+
## 更新日志
|
|
13
|
+
|
|
14
|
+
## 2025-05-16
|
|
15
|
+
|
|
16
|
+
### 3.0.51
|
|
17
|
+
|
|
18
|
+
#### Features
|
|
19
|
+
|
|
20
|
+
- Components:[YxForm](/component/yxtable.html)优化部分功能,新增 loadOptions 配置 [详见动态表单](/component/yxform.html#动态表单)
|
|
21
|
+
- Components:[YxTable] 新增 loadOptions 配置[详见](/component/yxtable.html#可编辑表格动态加载数据)
|
|
22
|
+
- utils[useConfirm] 新增 useConfirm 通用方法
|
|
23
|
+
|
|
24
|
+
#### Bug fixes
|
|
25
|
+
|
|
26
|
+
- Components:[YxDialog](/component/yxDialog.html)修复取消的回调不生效的 bug,beforeOpen 新增 Promise 回调的处理
|
|
27
|
+
- Components:[YxDrawer](/component/yxDrawer.html)修复取消的回调不生效的 bug,beforeOpen 新增 Promise 回调的处理
|
|
28
|
+
- Components:[YxUpload](/component/yxUpload.html)修复文件上传的列表和 limit 配置的数量不一致的 bug
|
|
29
|
+
|
|
30
|
+
## 2025-05-12
|
|
31
|
+
|
|
32
|
+
### 3.0.50
|
|
33
|
+
|
|
34
|
+
#### Features
|
|
35
|
+
|
|
36
|
+
- Components:[YxTable](/component/yxtable.html) 操作栏 render,参数新增 index
|
|
37
|
+
|
|
38
|
+
#### Bug fixes
|
|
39
|
+
|
|
40
|
+
- utils:[http]修复请求无法显示错误信息的 bug
|
|
41
|
+
- utils:[bc]修复在主应用下打开两个页面发送路由跳转的消息,子系统会同时进行路由跳转
|
|
42
|
+
|
|
43
|
+
## 2025-05-09
|
|
44
|
+
|
|
45
|
+
### 3.0.47
|
|
46
|
+
|
|
47
|
+
#### Features
|
|
48
|
+
|
|
49
|
+
- Components:[YxTable] 新增系统 title、logo 组件
|
|
50
|
+
|
|
51
|
+
## 2025-05-08
|
|
52
|
+
|
|
53
|
+
### 3.0.46
|
|
54
|
+
|
|
55
|
+
### 2.0.35
|
|
56
|
+
|
|
57
|
+
#### Features
|
|
58
|
+
|
|
59
|
+
- Components:[LogoTitle](/component/logoTitle.html) 新增系统 title、logo 组件
|
|
60
|
+
|
|
61
|
+
#### Bug fixes
|
|
62
|
+
|
|
63
|
+
- utils:[http](/utils/http.html)修复去除国际化逻辑后,请求 401 后无法跳转登录页的 bug
|
|
64
|
+
|
|
65
|
+
## 2025-04-27
|
|
66
|
+
|
|
67
|
+
### 3.0.45
|
|
68
|
+
|
|
69
|
+
#### Features
|
|
70
|
+
|
|
71
|
+
- Components:[YxForm](/component/yxform.html) 新增表单分组样式的自定义
|
|
72
|
+
|
|
73
|
+
### 3.0.44
|
|
74
|
+
|
|
75
|
+
#### Features
|
|
76
|
+
|
|
77
|
+
- Components:[YxTable](/component/yxtable.html) operate 操作栏新增自定义 className 配置
|
|
78
|
+
- utils:[mqtt](/utils/mqtt.html)新增 mqtt 的统一封装
|
|
79
|
+
- utils:[websocket](/utils/socket.html)新增 websocket 的封装
|
|
80
|
+
- utils:[fecth](/utils/fecth.html)新增 fecth 请求的封装
|
|
81
|
+
- docs:更新部分组件的文档
|
|
82
|
+
|
|
83
|
+
#### Bug fixes
|
|
84
|
+
|
|
85
|
+
- Components:[YxForm][YxForm](/component/yxform.html)修复在初始化时传入默认数据不生效的 bug
|
|
86
|
+
- Components:[YxForm]修复类型提示
|
|
87
|
+
- Components:[YxTable]修复类型提示和排序的 bug
|
|
88
|
+
- utils:[translate]修复翻译的 bug
|
|
89
|
+
- auth:[getUserRouter]获取当前系统的动态路由不再需要 viewConfig 配置,统一从权限配置取
|
package/lib/index.cjs11.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("./vendor-dayjs.cjs.js"),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 k.post(o,{userName:e,password:t});n.tokenValue&&r.ElMessage.success("登录成功"),p({token:n.tokenValue,userInfo:n})},l=()=>{if(S())n(),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]??"",S=()=>"production"===d("environment"),h=e=>{if(!e)return!1;const t=sessionStorage.getItem("ttcUserBtnList")??"[]";return JSON.parse(t).includes(e)},b=async()=>await k.get(d("userConfigApiUrl"),{},{headers:{noLoading:!0},customResHandler:e=>{if(e.isSuccess)return
|
|
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("./vendor-dayjs.cjs.js"),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 k.post(o,{userName:e,password:t});n.tokenValue&&r.ElMessage.success("登录成功"),p({token:n.tokenValue,userInfo:n})},l=()=>{if(S())n(),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]??"",S=()=>"production"===d("environment"),h=e=>{if(!e)return!1;const t=sessionStorage.getItem("ttcUserBtnList")??"[]";return JSON.parse(t).includes(e)},b=async()=>await k.get(d("userConfigApiUrl"),{},{headers:{noLoading:!0},customResHandler:e=>{if(e.isSuccess)return I(e.data),e}}),f=Object.freeze(Object.defineProperty({__proto__:null,autoLogin:i,changeSystemConfig:m,getHomeUrl:g,getLoginUrl:u,getSystemConfig:d,getToken:a,getUserInfo:(e="ttc")=>{const t=`${e}GlobalState`,s=localStorage.getItem(t)??"{}";return JSON.parse(s)?JSON.parse(s).userInfo:null},getUserIsHaveBtnPower:h,getUserPermissions:async(e,t=!0,s)=>{if(!a()&&t)return l();try{const{data:t}=await((e="ttc")=>k.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")=>k.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},getUserSystemConfig:b,isProduction:S,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"})),R=(e="ttc")=>`${e}GlobalConfig`,E=e=>localStorage.getItem(`${R(e)}`)??"{}",v=(e,t)=>{localStorage.setItem(`${R(e)}`,JSON.stringify(t))},I=(e,t="ttc")=>{const s=E(t),r={...JSON.parse(s),...e};v(t,r),T.publish({type:"globalSystemConfigChange",data:r})},y=(e,t="ttc")=>{const s=JSON.parse(E(t));return e?s[e]??"":s},M=Object.freeze(Object.defineProperty({__proto__:null,changeGlobalSystemConfig:(e,t,s="ttc")=>{const r=E(s),o={...JSON.parse(r),[e]:t};v(s,o)},getGlobalSystemConfig:y,setGlobalSystemConfig:I},Symbol.toStringTag,{value:"Module"}));let w;const O={lock:!0,text:"loading...",fullscreen:!0,background:"rgba(0, 0, 0, 0.6)"};let N=0;const U=()=>{0===N&&(w=r.ElLoading.service(O)),N++},C=()=>{N<=0||(N--,0===N&&w.close())};var G=(e=>(e[e.SUCCESS=200]="SUCCESS",e[e.ERROR=500]="ERROR",e[e.OVERDUE=401]="OVERDUE",e[e.TIMEOUT=3e4]="TIMEOUT",e))(G||{});const x=(e,t)=>{switch(e){case 400:r.ElMessage.error(t||"请求失败!请您稍后重试");break;case 401:r.ElMessage.error(t||"登录失效!请您重新登录"),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 k=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)||U(),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=>{var t;const{config:s}=e;let r=e.data;if((null==(t=null==s?void 0:s.headers)?void 0:t.noLoading)||C(),this.customResponseInterceptors)return this.customResponseInterceptors(e);if(this.customGlobalResHandler){if(!this.customGlobalResHandler(e))return}const o=e.status;return s.url&&this.customResMap[s.url]?this.customResMap[s.url](r,e):(o==G.OVERDUE||r.code===G.OVERDUE?this.handleOverdueResponse(r):r.code!==G.SUCCESS&&this.handleErrorResponse(r),r)}),(e=>{var t;const s=e.response,{config:o}=e;if((null==(t=null==o?void 0:o.headers)?void 0:t.noLoading)||C(),this.customResponseInterceptors)return this.customResponseInterceptors(s);if(this.customGlobalResHandler){if(!this.customGlobalResHandler(s))return}return(null==o?void 0:o.url)&&this.customResMap[o.url]?this.customResMap[o.url](e.response):(e.message.includes("timeout")?r.ElMessage.error("请求超时!请稍后重试"):e.message.includes("Network Error")&&r.ElMessage.error("网络错误!请稍后重试"),s&&x(s.status,this.getResMessage(s.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)):x(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});const T=new class{constructor(){t(this,"subscribers"),this.subscribers={}}subscribe(e,t){this.subscribers[e]||(this.subscribers[e]=[]),this.subscribers[e].push(t)}unsubscribe(e,t){const s=this.subscribers[e];if(!t)return this.subscribers[e]=[];if(s){const e=s.indexOf(t);-1!==e&&s.splice(e,1)}}publish(e){const t=this.subscribers[e.type];t&&t.forEach((t=>{t(e.data)}))}};exports.BC_LANG_NAME="LANG",exports.BC_THEME_NAME="THEME",exports.URL=o,exports.changeSystemConfig=m,exports.checkStatus=x,exports.getGlobalSystemConfig=y,exports.getSystemConfig=d,exports.getToken=a,exports.getUserIsHaveBtnPower=h,exports.getUserSystemConfig=b,exports.hideFullScreenLoading=C,exports.http=k,exports.index=f,exports.index$1=M,exports.jumpToHome=c,exports.setGlobalSystemConfig=I,exports.setSystemConfig=p,exports.showFullScreenLoading=U,exports.yxSubscribe=T;
|
package/lib/index.cjs2.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=Object.defineProperty,t=(t,s,i)=>((t,s,i)=>s in t?e(t,s,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[s]=i)(t,"symbol"!=typeof s?s+"":s,i);const s=require("./index.cjs11.js"),i=require("./index.cjs12.js");require("element-plus"),require("./vendor-dayjs.cjs.js");const n=require("./vendor-mqtt.cjs.js");async function o(e,t,i,n={}){const{headers:o={},responseType:r="json",signal:
|
|
1
|
+
"use strict";var e=Object.defineProperty,t=(t,s,i)=>((t,s,i)=>s in t?e(t,s,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[s]=i)(t,"symbol"!=typeof s?s+"":s,i);const s=require("./index.cjs11.js"),i=require("./index.cjs12.js");require("element-plus"),require("./vendor-dayjs.cjs.js");const n=require("./vendor-mqtt.cjs.js");async function o(e,t,i,n={}){const{headers:o={},responseType:r="json",signal:c,noAuth:a=!1}=n,l="GET"===t?`${e}${function(e){if(!e)return"";const t=new URLSearchParams;return Object.entries(e).forEach((([e,s])=>{null!=s&&t.append(e,String(s))})),`?${t.toString()}`}(i)}`:`${e}`,h=s.getToken();n.noLoading||s.showFullScreenLoading();const u=await fetch(l,{method:t,headers:{"Content-Type":"application/json",...h&&!a?{token:h}:"",...o},body:"GET"!==t&&i?JSON.stringify(i):void 0,signal:c});if(s.hideFullScreenLoading(),!u.ok){let e="";try{const t=await u.json();(null==t?void 0:t.resultMsg)&&(e=t.resultMsg)}catch(g){}throw s.checkStatus(u.status,e),new Error(e)}switch(r){case"text":return u.text();case"blob":return u.blob();default:return u.json()}}const r={get:(e,t,s)=>o(e,"GET",t,s),post:(e,t,s)=>o(e,"POST",t,s),put:(e,t,s)=>o(e,"PUT",t,s),delete:(e,t,s)=>o(e,"DELETE",t,s)},c={mqttVersion:5,clean:!0,connectTimeout:4e3,keepalive:30,reconnectPeriod:6e4},a={qos:1},l={qos:1};class h{constructor(e,s){t(this,"client",null),t(this,"subscribeMap",new Map),t(this,"onConnect"),t(this,"onReconnect"),t(this,"onError"),t(this,"onMessage"),t(this,"destroyed"),t(this,"isManualClose",!1),this.onConnect=e=>{this.resubscribeAll()},this.onReconnect=e=>{},this.onError=e=>{const t=e instanceof Error?e:new Error(String(e));this.analyzeDisconnectReason(t)},this.onMessage=(e,t)=>{var s;const i=this.subscribeMap.get(e);if(!i)return;let n=t;try{const e=null==(s=null==t?void 0:t.toString)?void 0:s.call(t);null!=e&&(n=JSON.parse(e))}catch(o){}i(n,e)},this.destroyed=()=>{var e;this.isManualClose=!0,null==(e=this.client)||e.end(!0)},this.subscribe=this.subscribe.bind(this),this.unsubscribe=this.unsubscribe.bind(this),this.publish=this.publish.bind(this);const i={...c,...s};i.clientId||(i.clientId=`mqttjs_${Date.now()}_${Math.random().toString(16).slice(2,8)}`),this.createClient(e,i)}createClient(e,t){this.client=n.mqtt_minExports.connect(e,t),this.client.on("connect",(e=>this.onConnect(e))),this.client.on("reconnect",(e=>this.onReconnect(e))),this.client.on("error",(e=>this.onError(e))),this.client.on("message",((e,t)=>this.onMessage(e,t))),this.client.on("offline",(()=>{(new Date).toISOString()})),this.client.on("close",((e,t)=>{(new Date).toISOString(),this.isManualClose?this.isManualClose=!1:t&&this.analyzeDisconnectReason(t)})),this.client.on("online",(()=>{}))}publish(e,t,s=l){if(!this.client)return;const i="string"==typeof t?t:JSON.stringify(t);this.client.publish(e,i,s,(e=>{}))}subscribe(e,t,s=a){this.client&&this.client.subscribe(e,s,(s=>{if(s)throw s instanceof Error?s:new Error(String(s));this.subscribeMap.set(e,t)}))}unsubscribe(e){this.client&&this.client.unsubscribe(e,{},(t=>{t||this.subscribeMap.delete(e)}))}resubscribeAll(){this.client&&this.subscribeMap.forEach(((e,t)=>{this.client.subscribe(t,a,(e=>{}))}))}analyzeDisconnectReason(e){var t,s,i;const n=e.code||e.message;return"ECONNREFUSED"===n?"服务器拒绝连接(服务器可能关闭或不可用)":"ETIMEDOUT"===n?"连接超时(网络延迟或服务器无响应)":"ENETUNREACH"===n?"网络不可达(网络中断)":"ECONNRESET"===n?"连接被重置(服务器主动断开连接)":"EPIPE"===n||"ECONNABORTED"===n?"连接异常终止(网络中断或服务器关闭)":(null==(t=e.message)?void 0:t.includes("Not authorized"))||(null==(s=e.message)?void 0:s.includes("unauthorized"))?"服务器主动断开 - 认证失败":(null==(i=e.message)?void 0:i.includes("Connection refused"))?"服务器主动断开 - 连接被拒绝":`其他错误: ${n||e.message}`}}const u=new Map,g=e=>{const t=u.get(e);if(!t)throw new Error(`[mqtt] MQ(${e}) 未初始化,请先调用 initMQSingleton(url, options)`);return t},d=()=>Array.from(u.keys()),b=(e,t,s={})=>{const i=u.get(e);if(i&&!s.force)return i.mq;i&&s.force&&M(e);const n=new h(e,t);return u.set(e,{url:e,mq:n,topicHandlers:new Map,topicDispatcher:new Map}),n},m=e=>{var t;return(null==(t=u.get(e))?void 0:t.mq)??null},p=(e,t,s,i)=>{const{mq:n}=g(e);n.publish(t,s,i)},S=(e,t,s,i)=>{const n=g(e),{mq:o,topicHandlers:r,topicDispatcher:c}=n;let a=r.get(t);const l=!a;if(a||(a=new Set,r.set(t,a)),a.add(s),l){const e=(e,t)=>{const s=r.get(t);s&&0!==s.size&&s.forEach((s=>s(e,t)))};c.set(t,e),o.subscribe(t,e,i)}return()=>w(e,t,s)},w=(e,t,s)=>{const i=u.get(e);if(!i)return;const{mq:n,topicHandlers:o,topicDispatcher:r}=i,c=o.get(t);c&&(s?c.delete(s):c.clear(),c.size>0||(o.delete(t),r.delete(t),n.unsubscribe(t)))},M=e=>{const t=u.get(e);t&&(t.mq.destroyed(),t.topicHandlers.clear(),t.topicDispatcher.clear(),u.delete(e))},E=()=>{Array.from(u.keys()).forEach((e=>M(e)))};class T{constructor(e,s){t(this,"url"),t(this,"protocols"),t(this,"webSocketState"),t(this,"isCustomClose"),t(this,"reconnectTime"),t(this,"heartBeatTime"),t(this,"waitBeatTime"),t(this,"callback"),t(this,"HEART_KEY"),t(this,"HEART_VALUE"),t(this,"ws"),t(this,"isReconnectionLoading"),t(this,"timeId"),t(this,"eventCenter"),t(this,"errorStack"),t(this,"heartMessage"),t(this,"msgDataPreHandler"),this.url=e.url,this.protocols=s,this.webSocketState=!1,this.isCustomClose=!0,this.reconnectTime=e.reconnectTime,this.heartBeatTime=e.heartBeatTime,this.waitBeatTime=e.waitBeatTime,this.callback=e.callback,e.msgDataPreHandler&&(this.msgDataPreHandler=e.msgDataPreHandler),this.onmessage=this.onmessage,this.heartMessage=e.heartMessage,this.HEART_KEY=e.HEART_KEY,this.HEART_VALUE=e.HEART_VALUE,this.ws=null,this.isReconnectionLoading=!1,this.createWs()}createWs(){"WebSocket"in window&&(this.ws=null,this.ws=new WebSocket(this.url,this.protocols),this.onopen(),this.onerror(),this.onclose(),this.onmessage())}onopen(){this.ws.onopen=()=>{this.webSocketState=!0,this.startHeartBeat(this.heartBeatTime)}}startHeartBeat(e){setTimeout((()=>{this.heartMessage&&(this.heartMessage.data=(new Date).getTime()+""),this.send(this.heartMessage?this.heartMessage:this.HEART_KEY),this.waitingServer()}),e)}waitingServer(){this.webSocketState=!1,setTimeout((()=>{if(this.webSocketState)this.startHeartBeat(this.heartBeatTime);else try{this.close(),this.ws&&this.start()}catch(e){}}),this.waitBeatTime)}onerror(){this.ws&&(this.ws.onerror=e=>{this.isCustomClose=!1,this.isReconnectionLoading=!1})}onclose(){this.ws&&(this.ws.onclose=()=>{this.isCustomClose||this.ws&&(this.reconnection(),this.isReconnectionLoading=!1)})}async onmessage(){this.ws&&(this.ws.onmessage=async e=>{try{let t=e.data;if(this.msgDataPreHandler&&await this.msgDataPreHandler(t),t===this.HEART_VALUE)return void(this.webSocketState=!0);const s=JSON.parse(t);this.callback(s)}catch(t){this.callback(e.data)}})}reconnection(){this.isReconnectionLoading||(this.isReconnectionLoading=!0,clearTimeout(this.timeId),this.timeId=null,this.timeId=setTimeout((()=>{this.createWs()}),this.reconnectTime))}send(e){this.webSocketState&&this.ws&&this.ws.send(e)}close(){var e;this.isCustomClose=!0,this.isReconnectionLoading=!1,this.ws&&this.ws.close&&(null==(e=this.ws)||e.close())}start(){this.isCustomClose=!1,this.reconnection()}subscribe(e,t){this.eventCenter.on(e,t)}unsubscribe(e,t){this.eventCenter.off(e,t)}destroy(){clearTimeout(this.timeId),this.close(),this.ws=null,this.errorStack=null,this.eventCenter=null,this.webSocketState=!1}}const y=Object.freeze(Object.defineProperty({__proto__:null,MQ:h,WS:T,areColorsSimilar:i.areColorsSimilar,copyText:i.copyText,deepClone:i.deepClone,destroyAllMQSingleton:E,destroyMQSingleton:M,enumToArray:i.enumToArray,getCownDownTime:i.getCownDownTime,getMQSingleton:m,getMQSingletonUrls:d,getSelectOptions:i.getSelectOptions,http:s.http,initMQSingleton:b,isColorEqual:i.isColorEqual,isDarkColor:i.isDarkColor,notifyMessageToSystems:i.notifyMessageToSystems,publishMQ:p,receiveMessage:i.receiveMessage,subscribeMQ:S,unsubscribeMQ:w,useConfirm:i.useConfirm,yxFecth:r,yxMessage:i.yxMessage,yxSubscribe:s.yxSubscribe},Symbol.toStringTag,{value:"Module"}));exports.MQ=h,exports.Ws=T,exports.destroyAllMQSingleton=E,exports.destroyMQSingleton=M,exports.getMQSingleton=m,exports.getMQSingletonUrls=d,exports.initMQSingleton=b,exports.publishMQ=p,exports.subscribeMQ=S,exports.unsubscribeMQ=w,exports.utils2=y,exports.yxFecth=r;
|