hrp-ui-base 1.3.5 → 1.3.7

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.
@@ -32,7 +32,7 @@ function strToUtf8Bytes(str: string) {
32
32
  utf8.push(
33
33
  0xe0 | (charCode >> 12),
34
34
  0x80 | ((charCode >> 6) & 0x3f),
35
- 0x80 | (charCode & 0x3f)
35
+ 0x80 | (charCode & 0x3f),
36
36
  );
37
37
  } else {
38
38
  ii++;
@@ -45,7 +45,7 @@ function strToUtf8Bytes(str: string) {
45
45
  0xf0 | (charCode >> 18),
46
46
  0x80 | ((charCode >> 12) & 0x3f),
47
47
  0x80 | ((charCode >> 6) & 0x3f),
48
- 0x80 | (charCode & 0x3f)
48
+ 0x80 | (charCode & 0x3f),
49
49
  );
50
50
  }
51
51
  }
@@ -58,16 +58,41 @@ function strToUtf8Bytes(str: string) {
58
58
  }
59
59
  return utf8;
60
60
  }
61
+ // 获取加密的hrp-token
62
+ export const getFinalHrpToken = function () {
63
+ let str1 = localStorage.getItem("TOKEN") + "IhfN5d11Zk1ZC%Po" + Date.now();
64
+ let str2 = "*XeL#J@znVJ#sdSv";
65
+ return encryptSM4(str1, str2);
66
+ };
61
67
 
68
+ // 获取本地token 不加密
69
+ export const getFinalTokenResident = function () {
70
+ return localStorage.getItem("TOKEN");
71
+ };
62
72
 
63
- export const getFinalToken = function () {
64
- let str1 = localStorage.getItem("TOKEN") + "IhfN5d11Zk1ZC%Po" + Date.now()
65
- let str2= "*XeL#J@znVJ#sdSv"
66
- return encryptSM4(str1,str2)
73
+ // 获取pms的加密token
74
+ export const getPMSFinalToken = function (token: string) {
75
+ let str1 = token + "IhfN5d11Zk1ZC%Po" + Date.now();
76
+ let str2 = "*XeL#J@znVJ#sdSv";
77
+ return encryptSM4(str1, str2);
67
78
  };
68
79
 
69
- export const getFinalTokenResident = function () {
70
- let str1 = localStorage.getItem("TOKEN") + "IhfN5d11Zk1ZC%Po" + Date.now()
71
- let str2= "*XeL#J@znVJ#sdSv"
72
- return localStorage.getItem("TOKEN")
73
- };
80
+ // 获取最终的token
81
+ export const getFinalToken = function () {
82
+ // // 从 URL中获取 projectId
83
+ // const hash = window.location.hash;
84
+ // const pathname = window.location.pathname;
85
+ // const projectIdMatch = hash.match(/\/project\/([^\/\?]+)/);
86
+ // const projectId = projectIdMatch ? projectIdMatch[1] : null;
87
+
88
+ // // 如果有 projectId,优先使用项目专属 token
89
+ // if (projectId && pathname.includes("/pms/")) {
90
+ // const projectToken = localStorage.getItem(`TOKEN-${projectId}`);
91
+ // if (projectToken) {
92
+ // return getPMSFinalToken(projectToken);
93
+ // }
94
+ // }
95
+
96
+ // 否则使用通用 TOKEN
97
+ return getFinalHrpToken();
98
+ };
@@ -1 +0,0 @@
1
- "use strict";var E=Object.defineProperty;var D=(t,o,e)=>o in t?E(t,o,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[o]=e;var w=(t,o,e)=>D(t,typeof o!="symbol"?o+"":o,e);const y=require("dingtalk-jsapi"),u=require("element-plus"),R=require("axios"),A=require("qs"),v=require("lodash"),g=require("vant"),J=require("sm-crypto"),L=t=>{if(y.env.platform!=="notInDingTalk")window.open(t+"/?ddtab=true","_blank");else if(window.oaTool&&window.oaTool.isOA){window.oaTool.openNewWindow(t);return}else window.open(t,"_blank")},j=t=>encodeURIComponent(t),K=t=>(t.indexOf("?")>-1&&(t.indexOf("/?")>-1?t=t.split("/?")[0]:t=t.split("?")[0]),t[t.length-1]==="/"&&(t=t.substring(0,t.length-1)),t),M=t=>{if(!(!t||typeof t!="string"))if(y.env.platform!=="notInDingTalk")y.biz.navigation.setTitle({title:t}),document.title=t;else if(window.oaTool&&window.oaTool.isOA){window.oaTool.setTitle(t);return}else document.title=t};function P(t){try{return new URL(t),t}catch{}const o=window.location.origin,e=window.location.pathname;t.startsWith("./")?t=t.substring(2):t.startsWith("/")&&(t=t.substring(1));const n=e.endsWith("/")?e:e.substring(0,e.lastIndexOf("/")+1);return o+n+t}const W=async t=>{let o="";try{o=(sessionStorage.getItem("userConfig")?JSON.parse(sessionStorage.getItem("userConfig")):null).fileUploadType}catch(n){console.log(n)}try{await navigator.clipboard.writeText(P(t.url)),console.log("URL 已复制到剪贴板:",P(t.url)),u.ElMessage.success("文件下载链接已写入剪切板,如遇系统无法下载,自行复制到浏览器打开链接即可下载!")}catch(n){console.error("无法写入剪贴板:",n)}let e=document.createElement("a");e.style="display: none",e.download=t.fileName,e.href=t.url,e.target="_blank",document.body.appendChild(e),e.click(),document.body.removeChild(e)},b=()=>{const t=navigator.userAgent.toLowerCase();return["android","iphone","ipad","ipod","harmonyos","openharmony","huawei","honor","symbianos","windows phone","mobile","webos","blackberry","opera mini","opera mobi","iemobile","wpdesktop"].some(n=>t.includes(n))},q=()=>!b();let m=null;const $=t=>{m=t},x=()=>{var t,o,e;return((o=(t=m==null?void 0:m.currentRoute)==null?void 0:t.value)==null?void 0:o.fullPath)||((e=window.location.hash)==null?void 0:e.replace(/^#/,""))||window.location.pathname+window.location.search},B=v.debounce(()=>{alert("登录失效,请重新登录")},1e3,{leading:!0,trailing:!1});function T(t){const o=localStorage.getItem("TenantHost");localStorage.setItem("preRoute",x()),localStorage.setItem("toRouter",window.location.search),localStorage.getItem("toRouter");let e=localStorage.getItem("currentRouterInfo");if(localStorage.setItem("toRouterObject",e),y.env.platform!=="notInDingTalk")window.location.href=window.location.origin+window.location.pathname+"login/index.html?host="+o;else if(window.oaTool&&window.oaTool.isOA){const n=window.location.origin+(window.location.pathname.endsWith("/")?window.location.pathname:window.location.pathname+"/");let r=x();sessionStorage.setItem("preRoute",r),window.localStorage.removeItem("TOKEN"),window.location.href=`${n}oa-login/index.html?url=${r}`}else if(t&&t===1)window.sessionStorage.clear(),window.localStorage.clear(),window.location.href=window.location.origin+window.location.pathname+"login/index.html";else{localStorage.setItem("toRouter",window.location.search);let n=x();sessionStorage.setItem("preRoute",n),window.localStorage.removeItem("TOKEN"),window.localStorage.removeItem("clientId"),B();const r=window.location.origin+(window.location.pathname.endsWith("/")?window.location.pathname:window.location.pathname+"/");setTimeout(()=>{window.location.href=`${r}login/index.html?host=${o}`},100)}}const H=(t,o)=>J.sm4.encrypt(t,Z(o));function Z(t){const o=[];for(let e=0;e<t.length;e++){let n=t.charCodeAt(e);n<128?o.push(n):n<2048?o.push(192|n>>6,128|n&63):n<55296||n>=57344?o.push(224|n>>12,128|n>>6&63,128|n&63):(e++,n=65536+((n&1023)<<10|t.charCodeAt(e)&1023),o.push(240|n>>18,128|n>>12&63,128|n>>6&63,128|n&63))}for(let e=0;e<o.length;e++){let n=o[e];n>127&&(o[e]=n-256)}return o}const a=function(){let t=localStorage.getItem("TOKEN")+"IhfN5d11Zk1ZC%Po"+Date.now();return H(t,"*XeL#J@znVJ#sdSv")},V=function(){return localStorage.getItem("TOKEN")+""+Date.now(),localStorage.getItem("TOKEN")},U=window.location.origin+window.location.pathname+"api",i=R.create({timeout:18e5,baseURL:U});i.interceptors.request.use(t=>t);i.interceptors.response.use(t=>(b()?t.data.code==501||t.data.code==510?t.data.msg?g.showNotify({type:"danger",message:t.data.msg}):g.showNotify({type:"danger",message:"发生未知错误!"}):t.data.code==500?g.showNotify({type:"danger",message:"服务发生错误!"}):t.data.code==201?g.showNotify({type:"success",message:t.data.msg}):t.data.code===401&&T():t.data.code==501||t.data.code==510?t.data.msg?u.ElMessage({type:"error",dangerouslyUseHTMLString:!0,message:`<span style="word-break: break-all">${t.data.msg}</span>`,duration:5e3}):u.ElMessage.error("发生未知错误!"):t.data.code==500?u.ElMessageBox.alert(t.data.msg?t.data.msg:"服务发生错误","错误提示",{confirmButtonText:"确定",callback:()=>{}}):t.data.code==201?u.ElMessage({type:"success",dangerouslyUseHTMLString:!0,message:`<span style="word-break: break-all">${t.data.msg}</span>`,duration:5e3}):t.data.code===401&&T(),t.data),async t=>(t.response.status===401?T():b()?g.showNotify({type:"danger",message:"网络请求失败"}):u.ElMessage.error("网络请求失败"),Promise.reject(t.response)));class F{static get(o,e){return e&&(e=e||""),i({method:"get",url:o,params:e,headers:{"Content-Type":"application/x-www-form-urlencoded;charset=UTF-8","Authorization-Token":a()}})}static post(o,e){return e&&(e=e||""),i({method:"post",url:o,data:A.stringify(e),headers:{"Content-Type":"application/x-www-form-urlencoded;charset=UTF-8","Authorization-Token":a(),"Authorization-origin-Token":localStorage.getItem("TOKEN")}})}static postJson(o,e,n){return e&&(e=e||""),i({method:"post",url:o,data:JSON.stringify(e),headers:{"Content-Type":"application/json;charset=utf-8","Authorization-Token":a(),"Authorization-origin-Token":localStorage.getItem("TOKEN"),...n}})}static uploadOSS(o,e,n){return e&&(e=e||""),i({method:"post",url:o,data:e,headers:{"Content-Type":"multipart/form-data","Authorization-Token":a(),...n}})}static uploadOSSResident(o,e,n){return e&&(e=e||""),i({method:"post",url:o,data:e,headers:{"Content-Type":"multipart/form-data","Authorization-Token":V(),...n}})}static exportFile(o,e){return e&&(e=e||""),i({method:"post",responseType:"arraybuffer",url:o,data:JSON.stringify(e),headers:{"Content-Type":"application/json;charset=utf-8","Authorization-Token":a()}})}static put(o,e){return e&&(e=e||""),i({method:"put",url:o,data:A.stringify(e),headers:{"Content-Type":"application/x-www-form-urlencoded;charset=UTF-8","Authorization-Token":a()}})}static putJson(o,e){return e&&(e=e||""),i({method:"put",url:o,data:JSON.stringify(e),headers:{"Content-Type":"application/json;charset=utf-8","Authorization-Token":a()}})}static putFile(o,e,n){return e&&(e=e||""),i({method:"put",url:o,data:e,headers:{"Content-Type":"application/x-www-form-urlencoded;charset=UTF-8","Authorization-Token":a(),...n}})}static deleted(o,e){return e&&(e=e||""),i({method:"delete",url:o,data:A.stringify(e),headers:{"Content-Type":"application/x-www-form-urlencoded;charset=UTF-8","Authorization-Token":a()}})}static deletedjson(o,e){return e&&(e=e||""),i({method:"delete",url:o,data:JSON.stringify(e),headers:{"Content-Type":"application/json;charset=utf-8","Authorization-Token":a()}})}static downloadGet(o,e){return e&&(e=e||""),i({method:"get",url:o,responseType:"blob",params:e,headers:{"Content-Type":"application/x-www-form-urlencoded;charset=UTF-8","Authorization-Token":a()}})}static downloadPost(o,e){return e&&(e=e||""),i({method:"post",url:o,responseType:"blob",params:e,headers:{"Content-Type":"application/x-www-form-urlencoded;charset=UTF-8","Authorization-Token":a()}})}static download(o,e){return e&&(e=e||""),i({method:"post",url:o,responseType:"blob",data:JSON.stringify(e),headers:{"Content-Type":"application/json;charset=utf-8","Authorization-Token":a()}})}static downloadPostJson(o,e){return e&&(e=e||""),i({method:"post",url:o,responseType:"blob",data:JSON.stringify(e),headers:{"Content-Type":"application/json;charset=utf-8","Authorization-Token":a()}})}static downloadPut(o,e){return e&&(e=e||""),i({method:"put",url:o,responseType:"blob",params:e,headers:{"Content-Type":"application/x-www-form-urlencoded;charset=UTF-8","Authorization-Token":a()}})}static downloadPutJson(o,e){return e&&(e=e||""),i({method:"put",url:o,responseType:"blob",data:JSON.stringify(e),headers:{"Content-Type":"application/json;charset=utf-8","Authorization-Token":a()}})}static downloadFile(o,e){return e&&(e=e||{}),i({method:"post",url:o,responseType:"blob",params:e,headers:{"Content-Type":"application/x-www-form-urlencoded;charset=UTF-8","Authorization-Token":a()}})}static uploadBase64(o,e,n){let r=new FormData;return r.append("file",e.file),r.append("modulesId",e.modulesId),i({method:"post",url:o,data:r,headers:{"Content-Type":"multipart/form-data","Authorization-Token":a(),...n}})}static postFormData(o,e,n){let r=new FormData;return e.files&&Array.isArray(e.files)&&e.files.forEach(c=>{r.append("files",c)}),e.submitWorkOrderParam&&r.append("submitWorkOrderParam",new Blob([JSON.stringify(e.submitWorkOrderParam)],{type:"application/json;charset=utf-8"})),i({method:"post",url:o,data:r,headers:{"Authorization-Token":a(),"Content-Type":"multipart/form-data",...n}})}}w(F,"baseUrl",U);class _{constructor(){w(this,"havePermission",!1);w(this,"funPointIdList",[])}}const G=(t,o)=>{const e=o.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&"),n=new RegExp(e,"gi");return t.replace(n,c=>`<span style="color:var(--theme-normal-normal)">${c}</span>`)},X=t=>t.split("?")[0].substring(t.lastIndexOf(".")+1).toLowerCase(),Q=(t,o,e=0)=>{let n="";if(e>0)for(let r=0;r<e;r++)n+=".";return t.length>o?t.slice(0,o-e)+n:t};function Y(t){let o=new Array("零","壹","贰","叁","肆","伍","陆","柒","捌","玖"),e=new Array("","拾","佰","仟"),n=new Array("","万","亿","兆"),r=new Array("角","分","毫","厘"),c="元",z=1e15,p="",h="",s="",S=["",""],f,I,d,k,N,C,O;if(t==null)return"";if(t>=z)return"超出最大处理数字";if(t==0)return s=o[0]+c,s;if(t.toString().indexOf(".")==-1?(p=t.toString(),h="",c="元整"):(S=t.toString().split("."),p=S[0],h=S[1].substr(0,2)),parseInt(p,10)>0){f=0,I=p.length;for(let l=0;l<I;l++)d=p.substr(l,1),k=I-l-1,N=k/4,C=k%4,d=="0"?f++:(f>0&&(s+=o[0]),f=0,s+=o[parseInt(d)]+e[C]),C==0&&f<4&&(s+=n[N]);s+=c}if(h!=""){O=h.length;for(let l=0;l<O;l++)d=h.substr(l,1),d!="0"&&(s+=o[Number(d)]+r[l])}return s==""&&(s+=o[0]+c),s}function ee(t){const o=parseFloat(t.toString());if(isNaN(o))return t;const e=o.toString();return(e.split(".")[1]||"").length>11?o.toFixed(11):e}function te(t){const o=parseFloat(t.toString());return isNaN(o)?0:Number(Math.round(o*100)/100)}exports.FunPointVo=_;exports.HttpUtil=F;exports.IsPc=q;exports.IsPhone=b;exports.ddWindowOpen=L;exports.digitUppercase=Y;exports.downloadFile=W;exports.exitLogin=T;exports.formatDecimal=ee;exports.formatTwoDecimal=te;exports.getEllipsis=Q;exports.getFileType=X;exports.getProcessAppIdUrl=K;exports.highlightText=G;exports.openEncodeUrl=j;exports.setDingDingTitle=M;exports.setExitLoginRouter=$;